diff --git a/build.gradle b/build.gradle index f3010e7e..c6d5e888 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ import net.minecraftforge.gradle.common.tasks.ApplyBinPatches import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact import net.minecraftforge.gradle.common.tasks.ExtractInheritance import net.minecraftforge.gradle.common.tasks.SignJar +import net.minecraftforge.gradle.patcher.tasks.GeneratePatches import net.minecraftforge.gradle.userdev.tasks.RenameJar import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.plugins.ide.eclipse.model.SourceFolder @@ -593,12 +594,45 @@ project(':forge') { } dependencies sharedDeps + applyPatches { + if (!patcher.srgPatches) mustRunAfter genPatches + level 'WARNING' + } + + afterEvaluate { + if (!patcher.srgPatches) { + srg2mcpClean { + dependsOn = [] + input = project(':mcp').setupMCP.output + } + userdevJar { + onlyIf = { t -> true } + } + def patches = project.file('build/genPatchesForUserdev/output/') + patches.mkdirs() + def genPatchesForUserdev = tasks.register('genPatchesForUserdev', GeneratePatches){ + base = project(':mcp').setupMCP.output + modified = applyRangeMapBase.output + originalPrefix = genPatches.originalPrefix + modifiedPrefix = genPatches.modifiedPrefix + output = patches + autoHeader true + lineEnding = '\n' + } + bakePatches { + dependsOn = [] + input = genPatchesForUserdev.get().output + } + } + } + + patcher { excs.from file("$rootDir/src/main/resources/forge.exc") parent = project(':clean') patches = file("$rootDir/patches/minecraft") patchedSrc = file('src/main/java') - srgPatches = true + srgPatches = false accessTransformers.from file("$rootDir/src/main/resources/META-INF/accesstransformer.cfg") sideAnnotationStrippers.from file("$rootDir/src/main/resources/forge.sas") diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch index 910e5a4d..52d6b781 100644 --- a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch @@ -1,34 +1,34 @@ --- a/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java @@ -112,7 +_,10 @@ - GlStateManager.m_84331_(3553, 34892, 0); - GlStateManager.m_84331_(3553, 10242, 33071); - GlStateManager.m_84331_(3553, 10243, 33071); + GlStateManager._texParameter(3553, 34892, 0); + GlStateManager._texParameter(3553, 10242, 33071); + GlStateManager._texParameter(3553, 10243, 33071); + if (!stencilEnabled) - GlStateManager.m_84209_(3553, 0, 6402, this.f_83915_, this.f_83916_, 0, 6402, 5126, (IntBuffer)null); + GlStateManager._texImage2D(3553, 0, 6402, this.width, this.height, 0, 6402, 5126, (IntBuffer)null); + else -+ GlStateManager.m_84209_(3553, 0, org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8, this.f_83915_, this.f_83916_, 0, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL, org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV, null); ++ GlStateManager._texImage2D(3553, 0, org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8, this.width, this.height, 0, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL, org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV, null); } - this.m_83936_(9728); + this.setFilterMode(9728); @@ -123,7 +_,14 @@ - GlStateManager.m_84486_(36160, this.f_83920_); - GlStateManager.m_84173_(36160, 36064, 3553, this.f_83923_, 0); - if (this.f_83919_) { + GlStateManager._glBindFramebuffer(36160, this.frameBufferId); + GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, this.colorTextureId, 0); + if (this.useDepth) { + if(!stencilEnabled) - GlStateManager.m_84173_(36160, 36096, 3553, this.f_83924_, 0); + GlStateManager._glFramebufferTexture2D(36160, 36096, 3553, this.depthBufferId, 0); + else if(net.minecraftforge.common.ForgeConfig.CLIENT.useCombinedDepthStencilAttachment.get()) { -+ GlStateManager.m_84173_(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.f_83924_, 0); ++ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); + } else { -+ GlStateManager.m_84173_(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.f_83924_, 0); -+ GlStateManager.m_84173_(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.f_83924_, 0); ++ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.depthBufferId, 0); ++ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); + } } - this.m_83949_(); + this.checkStatus(); @@ -292,4 +_,27 @@ - public int m_83980_() { - return this.f_83924_; + public int getDepthTextureId() { + return this.depthBufferId; } + + /*================================ FORGE START ================================================*/ @@ -42,7 +42,7 @@ + public void enableStencil() { + if(stencilEnabled) return; + stencilEnabled = true; -+ this.m_83941_(f_83917_, f_83918_, net.minecraft.client.Minecraft.f_91002_); ++ this.resize(viewWidth, viewHeight, net.minecraft.client.Minecraft.ON_OSX); + } + + /** diff --git a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch index 778dda74..4d0b0271 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch @@ -1,14 +1,14 @@ --- a/com/mojang/blaze3d/platform/GlStateManager.java +++ b/com/mojang/blaze3d/platform/GlStateManager.java @@ -539,9 +_,16 @@ - f_84077_[f_84076_].f_84800_ = false; + TEXTURES[activeTexture].enable = false; } + /* Stores the last values sent into glMultiTexCoord2f */ + public static float lastBrightnessX = 0.0f; + public static float lastBrightnessY = 0.0f; - public static void m_84160_(int p_84161_, int p_84162_, float p_84163_) { - RenderSystem.m_187555_(); + public static void _texParameter(int p_84161_, int p_84162_, float p_84163_) { + RenderSystem.assertOnRenderThreadOrInit(); GL11.glTexParameterf(p_84161_, p_84162_, p_84163_); + if (p_84161_ == GL13.GL_TEXTURE1) { + lastBrightnessX = p_84162_; @@ -16,4 +16,4 @@ + } } - public static void m_84331_(int p_84332_, int p_84333_, int p_84334_) { + public static void _texParameter(int p_84332_, int p_84333_, int p_84334_) { diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch index 2bdeee44..298b69c8 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch @@ -4,16 +4,16 @@ GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); -- this.f_85349_ = GLFW.glfwCreateWindow(this.f_85359_, this.f_85360_, p_85376_, this.f_85355_ && monitor != null ? monitor.m_84954_() : 0L, 0L); -+ this.f_85349_ = net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.handOffWindow(()->this.f_85359_, ()->this.f_85360_, ()->p_85376_, ()->this.f_85355_ && monitor != null ? monitor.m_84954_() : 0L); +- this.window = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L); ++ this.window = net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.handOffWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L); if (monitor != null) { - VideoMode videomode = monitor.m_84948_(this.f_85355_ ? this.f_85354_ : Optional.empty()); - this.f_85350_ = this.f_85357_ = monitor.m_84951_() + videomode.m_85332_() / 2 - this.f_85359_ / 2; + VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); + this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; @@ -299,6 +_,7 @@ - GLFW.glfwGetFramebufferSize(this.f_85349_, aint, aint1); - this.f_85361_ = aint[0] > 0 ? aint[0] : 1; - this.f_85362_ = aint1[0] > 0 ? aint1[0] : 1; -+ if (this.f_85362_ == 0 || this.f_85361_==0) net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.updateFBSize(w->this.f_85361_=w, h->this.f_85362_=h); + GLFW.glfwGetFramebufferSize(this.window, aint, aint1); + this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; + this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; ++ if (this.framebufferHeight == 0 || this.framebufferWidth==0) net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.updateFBSize(w->this.framebufferWidth=w, h->this.framebufferHeight=h); } - private void m_85427_(long p_85428_, int p_85429_, int p_85430_) { + private void onResize(long p_85428_, int p_85429_, int p_85430_) { diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch index fde4edfb..e5e43915 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch @@ -3,25 +3,25 @@ @@ -332,6 +_,7 @@ } - ByteBuffer bytebuffer = this.f_85648_.slice(); -+ bytebuffer.order(this.f_85648_.order()); // FORGE: Fix incorrect byte order - this.f_85648_.clear(); + ByteBuffer bytebuffer = this.buffer.slice(); ++ bytebuffer.order(this.buffer.order()); // FORGE: Fix incorrect byte order + this.buffer.clear(); return Pair.of(bufferbuilder$drawstate, bytebuffer); } @@ -444,4 +_,16 @@ - this.f_166822_ = p_166829_; + this.sortZ = p_166829_; } } + + // Forge start + public void putBulkData(ByteBuffer buffer) { -+ m_85722_(buffer.limit() + this.f_85658_.m_86020_()); -+ this.f_85648_.position(this.f_85654_ * this.f_85658_.m_86020_()); -+ this.f_85648_.put(buffer); -+ this.f_85654_ += buffer.limit() / this.f_85658_.m_86020_(); -+ this.f_85652_ += buffer.limit(); ++ ensureCapacity(buffer.limit() + this.format.getVertexSize()); ++ this.buffer.position(this.vertices * this.format.getVertexSize()); ++ this.buffer.put(buffer); ++ this.vertices += buffer.limit() / this.format.getVertexSize(); ++ this.nextElementByte += buffer.limit(); + } + + @Override -+ public VertexFormat getVertexFormat() { return this.f_85658_; } ++ public VertexFormat getVertexFormat() { return this.format; } } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch index 139f3854..fa2a61a8 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch @@ -1,11 +1,11 @@ --- a/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java +++ b/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java @@ -91,4 +_,8 @@ - this.f_85878_ = p_85902_; + this.nz = p_85902_; return this; } + + public VertexFormat getVertexFormat() { -+ return this.f_85867_.getVertexFormat(); ++ return this.delegate.getVertexFormat(); + } } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 1f91a101..dc0624d7 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -6,9 +6,9 @@ @OnlyIn(Dist.CLIENT) -public interface VertexConsumer { +public interface VertexConsumer extends net.minecraftforge.client.extensions.IForgeVertexConsumer { - VertexConsumer m_5483_(double p_85945_, double p_85946_, double p_85947_); + VertexConsumer vertex(double p_85945_, double p_85946_, double p_85947_); - VertexConsumer m_6122_(int p_85973_, int p_85974_, int p_85975_, int p_85976_); + VertexConsumer color(int p_85973_, int p_85974_, int p_85975_, int p_85976_); @@ -101,11 +_,12 @@ f5 = afloat[k] * p_86001_; } @@ -18,8 +18,8 @@ float f9 = bytebuffer.getFloat(16); float f10 = bytebuffer.getFloat(20); Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F); - vector4f.m_123607_(matrix4f); -+ applyBakedNormals(vector3f, bytebuffer, p_85996_.m_85864_()); - this.m_5954_(vector4f.m_123601_(), vector4f.m_123615_(), vector4f.m_123616_(), f3, f4, f5, 1.0F, f9, f10, p_86003_, l, vector3f.m_122239_(), vector3f.m_122260_(), vector3f.m_122269_()); + vector4f.transform(matrix4f); ++ applyBakedNormals(vector3f, bytebuffer, p_85996_.normal()); + this.vertex(vector4f.x(), vector4f.y(), vector4f.z(), f3, f4, f5, 1.0F, f9, f10, p_86003_, l, vector3f.x(), vector3f.y(), vector3f.z()); } } catch (Throwable throwable1) { diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch index 2574be5e..04875c68 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -5,10 +5,10 @@ } } + -+ public ImmutableMap getElementMapping() { return f_166905_; } -+ public int getOffset(int index) { return f_86013_.getInt(index); } -+ public boolean hasPosition() { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.POSITION); } -+ public boolean hasNormal() { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.NORMAL); } -+ public boolean hasColor() { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.COLOR); } -+ public boolean hasUV(int which) { return f_86012_.stream().anyMatch(e -> e.m_86048_() == VertexFormatElement.Usage.UV && e.m_86049_() == which); } ++ public ImmutableMap getElementMapping() { return elementMapping; } ++ public int getOffset(int index) { return offsets.getInt(index); } ++ public boolean hasPosition() { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.POSITION); } ++ public boolean hasNormal() { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.NORMAL); } ++ public boolean hasColor() { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.COLOR); } ++ public boolean hasUV(int which) { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.UV && e.getIndex() == which); } } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch index f988836e..cedb5111 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormatElement.java.patch @@ -1,11 +1,11 @@ --- a/com/mojang/blaze3d/vertex/VertexFormatElement.java +++ b/com/mojang/blaze3d/vertex/VertexFormatElement.java @@ -90,6 +_,10 @@ - this.f_86031_.m_166978_(this.f_86032_, p_166964_); + this.usage.clearBufferState(this.index, p_166964_); } + public int getElementCount() { -+ return f_86033_; ++ return count; + } + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexMultiConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexMultiConsumer.java.patch index ca78e972..7e155674 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexMultiConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexMultiConsumer.java.patch @@ -1,26 +1,26 @@ --- a/com/mojang/blaze3d/vertex/VertexMultiConsumer.java +++ b/com/mojang/blaze3d/vertex/VertexMultiConsumer.java @@ -91,6 +_,10 @@ - this.f_86171_.m_141991_(); - this.f_86172_.m_141991_(); + this.first.unsetDefaultColor(); + this.second.unsetDefaultColor(); } + + public VertexFormat getVertexFormat() { -+ return this.f_86171_.getVertexFormat(); ++ return this.first.getVertexFormat(); + } } @OnlyIn(Dist.CLIENT) @@ -176,6 +_,12 @@ - public void m_141991_() { - this.m_167144_(VertexConsumer::m_141991_); + public void unsetDefaultColor() { + this.forEach(VertexConsumer::unsetDefaultColor); + } + + public VertexFormat getVertexFormat() { -+ if(f_167071_.length > 0) -+ return f_167071_[0].getVertexFormat(); -+ return DefaultVertexFormat.f_85811_; ++ if(delegates.length > 0) ++ return delegates[0].getVertexFormat(); ++ return DefaultVertexFormat.BLOCK; } } } diff --git a/patches/minecraft/com/mojang/math/Matrix3f.java.patch b/patches/minecraft/com/mojang/math/Matrix3f.java.patch index cff8694e..2be2ca93 100644 --- a/patches/minecraft/com/mojang/math/Matrix3f.java.patch +++ b/patches/minecraft/com/mojang/math/Matrix3f.java.patch @@ -1,13 +1,13 @@ --- a/com/mojang/math/Matrix3f.java +++ b/com/mojang/math/Matrix3f.java @@ -588,4 +_,10 @@ - public Matrix3f m_8183_() { + public Matrix3f copy() { return new Matrix3f(this); } + + public void multiplyBackward(Matrix3f other) { -+ Matrix3f copy = other.m_8183_(); -+ copy.m_8178_(this); -+ this.m_8169_(copy); ++ Matrix3f copy = other.copy(); ++ copy.mul(this); ++ this.load(copy); + } } diff --git a/patches/minecraft/com/mojang/math/Matrix4f.java.patch b/patches/minecraft/com/mojang/math/Matrix4f.java.patch index 634ccbc3..3bbd8774 100644 --- a/patches/minecraft/com/mojang/math/Matrix4f.java.patch +++ b/patches/minecraft/com/mojang/math/Matrix4f.java.patch @@ -1,43 +1,43 @@ --- a/com/mojang/math/Matrix4f.java +++ b/com/mojang/math/Matrix4f.java @@ -559,4 +_,40 @@ - matrix4f.f_27614_ = p_27656_; + matrix4f.m23 = p_27656_; return matrix4f; } + + // Forge start + public Matrix4f(float[] values) { -+ f_27603_ = values[0]; -+ f_27604_ = values[1]; -+ f_27605_ = values[2]; -+ f_27606_ = values[3]; -+ f_27607_ = values[4]; -+ f_27608_ = values[5]; -+ f_27609_ = values[6]; -+ f_27610_ = values[7]; -+ f_27611_ = values[8]; -+ f_27612_ = values[9]; -+ f_27613_ = values[10]; -+ f_27614_ = values[11]; -+ f_27615_ = values[12]; -+ f_27616_ = values[13]; -+ f_27617_ = values[14]; -+ f_27618_ = values[15]; ++ m00 = values[0]; ++ m01 = values[1]; ++ m02 = values[2]; ++ m03 = values[3]; ++ m10 = values[4]; ++ m11 = values[5]; ++ m12 = values[6]; ++ m13 = values[7]; ++ m20 = values[8]; ++ m21 = values[9]; ++ m22 = values[10]; ++ m23 = values[11]; ++ m30 = values[12]; ++ m31 = values[13]; ++ m32 = values[14]; ++ m33 = values[15]; + } + + public void multiplyBackward(Matrix4f other) { -+ Matrix4f copy = other.m_27658_(); -+ copy.m_27644_(this); -+ this.m_162210_(copy); ++ Matrix4f copy = other.copy(); ++ copy.multiply(this); ++ this.load(copy); + } + + public void setTranslation(float x, float y, float z) { -+ this.f_27603_ = 1.0F; -+ this.f_27608_ = 1.0F; -+ this.f_27613_ = 1.0F; -+ this.f_27618_ = 1.0F; -+ this.f_27606_ = x; -+ this.f_27610_ = y; -+ this.f_27614_ = z; ++ this.m00 = 1.0F; ++ this.m11 = 1.0F; ++ this.m22 = 1.0F; ++ this.m33 = 1.0F; ++ this.m03 = x; ++ this.m13 = y; ++ this.m23 = z; + } } diff --git a/patches/minecraft/com/mojang/math/Transformation.java.patch b/patches/minecraft/com/mojang/math/Transformation.java.patch index 5188bb85..a77b7926 100644 --- a/patches/minecraft/com/mojang/math/Transformation.java.patch +++ b/patches/minecraft/com/mojang/math/Transformation.java.patch @@ -6,12 +6,12 @@ -public final class Transformation { +public final class Transformation implements net.minecraftforge.client.extensions.IForgeTransformation { - private final Matrix4f f_121078_; - private boolean f_121079_; + private final Matrix4f matrix; + private boolean decomposed; @Nullable @@ -145,6 +_,19 @@ public int hashCode() { - return Objects.hash(this.f_121078_); + return Objects.hash(this.matrix); } + + private Matrix3f normalTransform = null; @@ -21,11 +21,11 @@ + } + private void checkNormalTransform() { + if (normalTransform == null) { -+ normalTransform = new Matrix3f(f_121078_); -+ normalTransform.m_8187_(); -+ normalTransform.m_8155_(); ++ normalTransform = new Matrix3f(matrix); ++ normalTransform.invert(); ++ normalTransform.transpose(); + } + } - public Transformation m_175937_(Transformation p_175938_, float p_175939_) { - Vector3f vector3f = this.m_175940_(); + public Transformation slerp(Transformation p_175938_, float p_175939_) { + Vector3f vector3f = this.getTranslation(); diff --git a/patches/minecraft/com/mojang/math/Vector3f.java.patch b/patches/minecraft/com/mojang/math/Vector3f.java.patch index 5fce3b3c..ed652377 100644 --- a/patches/minecraft/com/mojang/math/Vector3f.java.patch +++ b/patches/minecraft/com/mojang/math/Vector3f.java.patch @@ -2,27 +2,27 @@ +++ b/com/mojang/math/Vector3f.java @@ -138,7 +_,7 @@ - public boolean m_122278_() { - float f = this.f_122228_ * this.f_122228_ + this.f_122229_ * this.f_122229_ + this.f_122230_ * this.f_122230_; + public boolean normalize() { + float f = this.x * this.x + this.y * this.y + this.z * this.z; - if ((double)f < 1.0E-5D) { + if (f < Float.MIN_NORMAL) { //Forge: Fix MC-239212 return false; } else { - float f1 = Mth.m_14195_(f); + float f1 = Mth.fastInvSqrt(f); @@ -207,4 +_,16 @@ public String toString() { - return "[" + this.f_122228_ + ", " + this.f_122229_ + ", " + this.f_122230_ + "]"; + return "[" + this.x + ", " + this.y + ", " + this.z + "]"; } + + public Vector3f(float[] values) { + set(values); + } + public void set(float[] values) { -+ this.f_122228_ = values[0]; -+ this.f_122229_ = values[1]; -+ this.f_122230_ = values[2]; ++ this.x = values[0]; ++ this.y = values[1]; ++ this.z = values[2]; + } -+ public void setX(float x) { this.f_122228_ = x; } -+ public void setY(float y) { this.f_122229_ = y; } -+ public void setZ(float z) { this.f_122230_ = z; } ++ public void setX(float x) { this.x = x; } ++ public void setY(float y) { this.y = y; } ++ public void setZ(float z) { this.z = z; } } diff --git a/patches/minecraft/com/mojang/math/Vector4f.java.patch b/patches/minecraft/com/mojang/math/Vector4f.java.patch index 30c3e4df..f450b35f 100644 --- a/patches/minecraft/com/mojang/math/Vector4f.java.patch +++ b/patches/minecraft/com/mojang/math/Vector4f.java.patch @@ -2,17 +2,17 @@ +++ b/com/mojang/math/Vector4f.java @@ -147,4 +_,15 @@ public String toString() { - return "[" + this.f_123589_ + ", " + this.f_123590_ + ", " + this.f_123591_ + ", " + this.f_123592_ + "]"; + return "[" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + "]"; } + + public void set(float[] values) { -+ this.f_123589_ = values[0]; -+ this.f_123590_ = values[1]; -+ this.f_123591_ = values[2]; -+ this.f_123592_ = values[3]; ++ this.x = values[0]; ++ this.y = values[1]; ++ this.z = values[2]; ++ this.w = values[3]; + } -+ public void setX(float x) { this.f_123589_ = x; } -+ public void setY(float y) { this.f_123590_ = y; } -+ public void setZ(float z) { this.f_123591_ = z; } -+ public void setW(float w) { this.f_123592_ = w; } ++ public void setX(float x) { this.x = x; } ++ public void setY(float y) { this.y = y; } ++ public void setZ(float z) { this.z = z; } ++ public void setW(float w) { this.w = w; } } diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch index 11fcabc3..6acb10b5 100644 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -1,18 +1,18 @@ --- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java @@ -67,6 +_,15 @@ - return (new TextComponent("")).m_7220_(this.f_200947_.getFirst()).m_130946_(": ").m_7220_(this.f_200947_.getSecond()); + return (new TextComponent("")).append(this.lines.getFirst()).append(": ").append(this.lines.getSecond()); } + @Override -+ public boolean m_7933_(int key, int scanCode, int modifiers) { ++ public boolean keyPressed(int key, int scanCode, int modifiers) { + if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { -+ f_96541_.m_91152_(this.f_88665_); ++ minecraft.setScreen(this.nextScreen); + return true; + } -+ return super.m_7933_(key, scanCode, modifiers); ++ return super.keyPressed(key, scanCode, modifiers); + } + - public void m_6305_(PoseStack p_88679_, int p_88680_, int p_88681_, float p_88682_) { - this.m_7333_(p_88679_); - m_93215_(p_88679_, this.f_96547_, this.f_200947_.getFirst(), this.f_96543_ / 2, 80, 16777215); + public void render(PoseStack p_88679_, int p_88680_, int p_88681_, float p_88682_) { + this.renderBackground(p_88679_); + drawCenteredString(p_88679_, this.font, this.lines.getFirst(), this.width / 2, 80, 16777215); diff --git a/patches/minecraft/net/minecraft/CrashReport.java.patch b/patches/minecraft/net/minecraft/CrashReport.java.patch index b89c9c5b..698e37af 100644 --- a/patches/minecraft/net/minecraft/CrashReport.java.patch +++ b/patches/minecraft/net/minecraft/CrashReport.java.patch @@ -1,46 +1,46 @@ --- a/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java @@ -29,8 +_,10 @@ - private final SystemReport f_178624_ = new SystemReport(); + private final SystemReport systemReport = new SystemReport(); public CrashReport(String p_127509_, Throwable p_127510_) { + org.magmafoundation.magma.deobf.DeobfRewritePolicy.getDeobfuscator().deobf(p_127510_); - this.f_127500_ = p_127509_; - this.f_127501_ = p_127510_; -+ this.f_178624_.m_143522_("CraftBukkit Information", new org.bukkit.craftbukkit.v1_18_R2.CraftCrashReport()); // CraftBukkit + this.title = p_127509_; + this.exception = p_127510_; ++ this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.v1_18_R2.CraftCrashReport()); // CraftBukkit } - public String m_127511_() { + public String getTitle() { @@ -55,21 +_,18 @@ - if (this.f_127506_ != null && this.f_127506_.length > 0) { + if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) { p_127520_.append("-- Head --\n"); p_127520_.append("Thread: ").append(Thread.currentThread().getName()).append("\n"); - p_127520_.append("Stacktrace:\n"); - -- for(StackTraceElement stacktraceelement : this.f_127506_) { +- for(StackTraceElement stacktraceelement : this.uncategorizedStackTrace) { - p_127520_.append("\t").append("at ").append((Object)stacktraceelement); - p_127520_.append("\n"); - } - - p_127520_.append("\n"); + p_127520_.append("Stacktrace:"); -+ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.f_127506_)); ++ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace)); } - for(CrashReportCategory crashreportcategory : this.f_127503_) { - crashreportcategory.m_128168_(p_127520_); + for(CrashReportCategory crashreportcategory : this.details) { + crashreportcategory.getDetails(p_127520_); - p_127520_.append("\n\n"); -+ p_127520_.append(net.minecraftforge.logging.CrashReportAnalyser.appendSuspectedMods(this.f_127501_, this.f_127506_)); ++ p_127520_.append(net.minecraftforge.logging.CrashReportAnalyser.appendSuspectedMods(this.exception, this.uncategorizedStackTrace)); + p_127520_.append("Stacktrace:"); -+ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.f_127506_)); ++ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace)); } -+ net.minecraftforge.logging.CrashReportExtender.extendSystemReport(f_178624_); - this.f_178624_.m_143525_(p_127520_); ++ net.minecraftforge.logging.CrashReportExtender.extendSystemReport(systemReport); + this.systemReport.appendToCrashReportString(p_127520_); } @@ -89,23 +_,13 @@ - throwable.setStackTrace(this.f_127501_.getStackTrace()); + throwable.setStackTrace(this.exception.getStackTrace()); } - String s; @@ -58,10 +58,10 @@ + return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(throwable); } - public String m_127526_() { + public String getFriendlyReport() { StringBuilder stringbuilder = new StringBuilder(); stringbuilder.append("---- Minecraft Crash Report ----\n"); + net.minecraftforge.logging.CrashReportExtender.addCrashReportHeader(stringbuilder, this); stringbuilder.append("// "); - stringbuilder.append(m_127531_()); + stringbuilder.append(getErrorComment()); stringbuilder.append("\n\n"); diff --git a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch index 85bfc6ef..a1d34170 100644 --- a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch +++ b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch @@ -4,36 +4,36 @@ if (astacktraceelement.length <= 0) { return 0; } else { -- this.f_128139_ = new StackTraceElement[astacktraceelement.length - 3 - p_128149_]; -- System.arraycopy(astacktraceelement, 3 + p_128149_, this.f_128139_, 0, this.f_128139_.length); +- this.stackTrace = new StackTraceElement[astacktraceelement.length - 3 - p_128149_]; +- System.arraycopy(astacktraceelement, 3 + p_128149_, this.stackTrace, 0, this.stackTrace.length); + int len = astacktraceelement.length - 3 - p_128149_; + if (len <= 0) len = astacktraceelement.length; -+ this.f_128139_ = new StackTraceElement[len]; -+ System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.f_128139_, 0, this.f_128139_.length); -+ this.f_128139_ = org.magmafoundation.magma.deobf.DeobfRewritePolicy.getDeobfuscator().deobf(f_128139_); - return this.f_128139_.length; ++ this.stackTrace = new StackTraceElement[len]; ++ System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.stackTrace, 0, this.stackTrace.length); ++ this.stackTrace = org.magmafoundation.magma.deobf.DeobfRewritePolicy.getDeobfuscator().deobf(stackTrace); + return this.stackTrace.length; } } @@ -147,17 +_,17 @@ - if (this.f_128139_ != null && this.f_128139_.length > 0) { + if (this.stackTrace != null && this.stackTrace.length > 0) { p_128169_.append("\nStacktrace:"); - -- for(StackTraceElement stacktraceelement : this.f_128139_) { +- for(StackTraceElement stacktraceelement : this.stackTrace) { - p_128169_.append("\n\tat "); - p_128169_.append((Object)stacktraceelement); - } -+ p_128169_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.f_128139_)); ++ p_128169_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.stackTrace)); } } - public StackTraceElement[] m_128143_() { - return this.f_128139_; + public StackTraceElement[] getStacktrace() { + return this.stackTrace; + } + + public void applyStackTrace(Throwable t) { -+ this.f_128139_ = t.getStackTrace(); ++ this.stackTrace = t.getStackTrace(); } - public static void m_178950_(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, @Nullable BlockState p_178954_) { + public static void populateBlockDetails(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, @Nullable BlockState p_178954_) { diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index 69a6eccc..baa09ce8 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -5,6 +5,6 @@ static { + if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified - ResourceLeakDetector.setLevel(f_136180_); + ResourceLeakDetector.setLevel(NETTY_LEAK_DETECTION); CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = false; CommandSyntaxException.BUILT_IN_EXCEPTIONS = new BrigadierExceptions(); diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch index ddd797ed..850df51d 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -7,25 +7,25 @@ + // We add this inner class to compensate for Mojang's missing inner class and allow us to obf subsequent anon inner classes correctly. + @SuppressWarnings("unused") private static LongSupplier INNER_CLASS_SHIFT = new LongSupplier() { public long getAsLong() { return 0; } }; + - public static ExecutorService m_183988_() { - return f_137443_; + public static ExecutorService bootstrapExecutor() { + return BOOTSTRAP_EXECUTOR; } @@ -233,7 +_,7 @@ try { - type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_183709_().getWorldVersion())).getChoiceType(p_137552_, p_137553_); + type = DataFixers.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getWorldVersion())).getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { -- f_137446_.error("No data fixer registered for {}", (Object)p_137553_); -+ f_137446_.debug("No data fixer registered for {}", (Object)p_137553_); - if (SharedConstants.f_136183_) { +- LOGGER.error("No data fixer registered for {}", (Object)p_137553_); ++ LOGGER.debug("No data fixer registered for {}", (Object)p_137553_); + if (SharedConstants.IS_RUNNING_IN_IDE) { throw illegalargumentexception; } @@ -649,7 +_,8 @@ - public static Function m_143827_(final Function p_143828_) { + public static Function memoize(final Function p_143828_) { return new Function() { -- private final Map f_143852_ = Maps.newHashMap(); +- private final Map cache = Maps.newHashMap(); + // FORGE: Allow using memoized functions from multiple threads. -+ private final Map f_143852_ = Maps.newConcurrentMap(); ++ private final Map cache = Maps.newConcurrentMap(); public R apply(T p_211578_) { - return this.f_143852_.computeIfAbsent(p_211578_, p_143828_); + return this.cache.computeIfAbsent(p_211578_, p_143828_); diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index 7a40e2a0..930ae7ce 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java @@ -38,6 +_,7 @@ - private final String[][] f_138303_; - private final Set f_138304_ = Sets.newLinkedHashSet(); - private final Component f_138305_; + private final String[][] requirements; + private final Set children = Sets.newLinkedHashSet(); + private final Component chatComponent; + public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.v1_18_R2.advancement.CraftAdvancement(this); // CraftBukkit public Advancement(ResourceLocation p_138307_, @Nullable Advancement p_138308_, @Nullable DisplayInfo p_138309_, AdvancementRewards p_138310_, Map p_138311_, String[][] p_138312_) { - this.f_138301_ = p_138307_; + this.id = p_138307_; @@ -129,8 +_,8 @@ - return this.f_138305_; + return this.chatComponent; } - public static class Builder { @Nullable + public static class Builder implements net.minecraftforge.common.extensions.IForgeAdvancementBuilder { - private ResourceLocation f_138332_; + private ResourceLocation parentId; @Nullable - private Advancement f_138333_; + private Advancement parent; @@ -320,7 +_,14 @@ - return "Task Advancement{parentId=" + this.f_138332_ + ", display=" + this.f_138334_ + ", rewards=" + this.f_138335_ + ", criteria=" + this.f_138336_ + ", requirements=" + Arrays.deepToString(this.f_138337_) + "}"; + return "Task Advancement{parentId=" + this.parentId + ", display=" + this.display + ", rewards=" + this.rewards + ", criteria=" + this.criteria + ", requirements=" + Arrays.deepToString(this.requirements) + "}"; } + /** @deprecated Forge: use {@linkplain #fromJson(JsonObject, DeserializationContext, net.minecraftforge.common.crafting.conditions.ICondition.IContext) overload with context}. */ + @Deprecated - public static Advancement.Builder m_138380_(JsonObject p_138381_, DeserializationContext p_138382_) { + public static Advancement.Builder fromJson(JsonObject p_138381_, DeserializationContext p_138382_) { + return fromJson(p_138381_, p_138382_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY); + } + + public static Advancement.Builder fromJson(JsonObject p_138381_, DeserializationContext p_138382_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { + if ((p_138381_ = net.minecraftforge.common.crafting.ConditionalAdvancement.processConditional(p_138381_, context)) == null) return null; - ResourceLocation resourcelocation = p_138381_.has("parent") ? new ResourceLocation(GsonHelper.m_13906_(p_138381_, "parent")) : null; - DisplayInfo displayinfo = p_138381_.has("display") ? DisplayInfo.m_14981_(GsonHelper.m_13930_(p_138381_, "display")) : null; - AdvancementRewards advancementrewards = p_138381_.has("rewards") ? AdvancementRewards.m_9991_(GsonHelper.m_13930_(p_138381_, "rewards")) : AdvancementRewards.f_9978_; + ResourceLocation resourcelocation = p_138381_.has("parent") ? new ResourceLocation(GsonHelper.getAsString(p_138381_, "parent")) : null; + DisplayInfo displayinfo = p_138381_.has("display") ? DisplayInfo.fromJson(GsonHelper.getAsJsonObject(p_138381_, "display")) : null; + AdvancementRewards advancementrewards = p_138381_.has("rewards") ? AdvancementRewards.deserialize(GsonHelper.getAsJsonObject(p_138381_, "rewards")) : AdvancementRewards.EMPTY; diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch index 4db23630..ddd01b37 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch @@ -4,9 +4,9 @@ } } -- f_139325_.info("Loaded {} advancements", (int)this.f_139326_.size()); -+ net.minecraftforge.common.AdvancementLoadFix.buildSortedTrees(this.f_139327_); +- LOGGER.info("Loaded {} advancements", (int)this.advancements.size()); ++ net.minecraftforge.common.AdvancementLoadFix.buildSortedTrees(this.roots); + // LOGGER.info("Loaded {} advancements", (int)this.advancements.size()); // CraftBukkit } - public void m_139332_() { + public void clear() { diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch index f828d224..fdb56906 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/advancements/AdvancementRewards.java @@ -43,7 +_,7 @@ - public void m_9989_(ServerPlayer p_9990_) { - p_9990_.m_6756_(this.f_9979_); -- LootContext lootcontext = (new LootContext.Builder(p_9990_.m_183503_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78975_(LootContextParamSets.f_81418_); -+ LootContext lootcontext = (new LootContext.Builder(p_9990_.m_183503_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78963_(p_9990_.m_36336_()).m_78975_(LootContextParamSets.f_81418_); // FORGE: luck to LootContext + public void grant(ServerPlayer p_9990_) { + p_9990_.giveExperiencePoints(this.experience); +- LootContext lootcontext = (new LootContext.Builder(p_9990_.getLevel())).withParameter(LootContextParams.THIS_ENTITY, p_9990_).withParameter(LootContextParams.ORIGIN, p_9990_.position()).withRandom(p_9990_.getRandom()).create(LootContextParamSets.ADVANCEMENT_REWARD); ++ LootContext lootcontext = (new LootContext.Builder(p_9990_.getLevel())).withParameter(LootContextParams.THIS_ENTITY, p_9990_).withParameter(LootContextParams.ORIGIN, p_9990_.position()).withRandom(p_9990_.getRandom()).withLuck(p_9990_.getLuck()).create(LootContextParamSets.ADVANCEMENT_REWARD); // FORGE: luck to LootContext boolean flag = false; - for(ResourceLocation resourcelocation : this.f_9980_) { + for(ResourceLocation resourcelocation : this.loot) { diff --git a/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch index 88d98aaa..fd0f728a 100644 --- a/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch +++ b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch @@ -6,20 +6,20 @@ public class ItemPredicate { + private static final Map> custom_predicates = new java.util.HashMap<>(); + private static final Map> unmod_predicates = java.util.Collections.unmodifiableMap(custom_predicates); - public static final ItemPredicate f_45028_ = new ItemPredicate(); + public static final ItemPredicate ANY = new ItemPredicate(); @Nullable - private final TagKey f_45029_; + private final TagKey tag; @@ -107,6 +_,11 @@ - public static ItemPredicate m_45051_(@Nullable JsonElement p_45052_) { + public static ItemPredicate fromJson(@Nullable JsonElement p_45052_) { if (p_45052_ != null && !p_45052_.isJsonNull()) { - JsonObject jsonobject = GsonHelper.m_13918_(p_45052_, "item"); + JsonObject jsonobject = GsonHelper.convertToJsonObject(p_45052_, "item"); + if (jsonobject.has("type")) { -+ final ResourceLocation rl = new ResourceLocation(GsonHelper.m_13906_(jsonobject, "type")); ++ final ResourceLocation rl = new ResourceLocation(GsonHelper.getAsString(jsonobject, "type")); + if (custom_predicates.containsKey(rl)) return custom_predicates.get(rl).apply(jsonobject); + else throw new JsonSyntaxException("There is no ItemPredicate of type "+rl); + } - MinMaxBounds.Ints minmaxbounds$ints = MinMaxBounds.Ints.m_55373_(jsonobject.get("count")); - MinMaxBounds.Ints minmaxbounds$ints1 = MinMaxBounds.Ints.m_55373_(jsonobject.get("durability")); + MinMaxBounds.Ints minmaxbounds$ints = MinMaxBounds.Ints.fromJson(jsonobject.get("count")); + MinMaxBounds.Ints minmaxbounds$ints1 = MinMaxBounds.Ints.fromJson(jsonobject.get("durability")); if (jsonobject.has("data")) { @@ -214,6 +_,14 @@ } else { diff --git a/patches/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch index 3e2fdda5..feeb14e6 100644 --- a/patches/minecraft/net/minecraft/client/Camera.java.patch +++ b/patches/minecraft/net/minecraft/client/Camera.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java @@ -211,6 +_,18 @@ - this.f_90549_ = false; + this.initialized = false; } + public void setAnglesInternal(float yaw, float pitch) { -+ this.f_90558_ = yaw; -+ this.f_90557_ = pitch; ++ this.yRot = yaw; ++ this.xRot = pitch; + } + + public net.minecraft.world.level.block.state.BlockState getBlockAtCamera() { -+ if (!this.f_90549_) -+ return net.minecraft.world.level.block.Blocks.f_50016_.m_49966_(); ++ if (!this.initialized) ++ return net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); + else -+ return this.f_90550_.m_8055_(this.f_90553_).getStateAtViewpoint(this.f_90550_, this.f_90553_, this.f_90552_); ++ return this.level.getBlockState(this.blockPosition).getStateAtViewpoint(this.level, this.blockPosition, this.position); + } + @OnlyIn(Dist.CLIENT) public static class NearPlane { - final Vec3 f_167687_; + final Vec3 forward; diff --git a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch index a2336600..f455031d 100644 --- a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch +++ b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch @@ -3,7 +3,7 @@ @@ -10,6 +_,6 @@ @DontObfuscate - public static String m_129629_() { + public static String getClientModName() { - return "vanilla"; + return net.minecraftforge.internal.BrandingControl.getClientBranding(); } diff --git a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch index f3265485..2265e17a 100644 --- a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch +++ b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch @@ -2,19 +2,19 @@ +++ b/net/minecraft/client/ClientRecipeBook.java @@ -52,7 +_,7 @@ for(Recipe recipe : p_90643_) { - if (!recipe.m_5598_() && !recipe.m_142505_()) { - RecipeBookCategories recipebookcategories = m_90646_(recipe); -- String s = recipe.m_6076_(); -+ String s = recipe.m_6076_().isEmpty() ? recipe.m_6423_().toString() : recipe.m_6076_(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty. + if (!recipe.isSpecial() && !recipe.isIncomplete()) { + RecipeBookCategories recipebookcategories = getCategory(recipe); +- String s = recipe.getGroup(); ++ String s = recipe.getGroup().isEmpty() ? recipe.getId().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_) -> { return Lists.newArrayList(); @@ -104,6 +_,8 @@ - } else if (recipetype == RecipeType.f_44113_) { + } else if (recipetype == RecipeType.SMITHING) { return RecipeBookCategories.SMITHING; } else { + RecipeBookCategories categories = net.minecraftforge.client.RecipeBookRegistry.findCategories(recipetype, p_90647_); + if (categories != null) return categories; - f_90618_.warn("Unknown recipe category: {}/{}", LogUtils.defer(() -> { - return Registry.f_122864_.m_7981_(p_90647_.m_6671_()); - }), LogUtils.defer(p_90647_::m_6423_)); + LOGGER.warn("Unknown recipe category: {}/{}", LogUtils.defer(() -> { + return Registry.RECIPE_TYPE.getKey(p_90647_.getType()); + }), LogUtils.defer(p_90647_::getId)); diff --git a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch index 3237bef3..3c70294c 100644 --- a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch @@ -6,77 +6,77 @@ @OnlyIn(Dist.CLIENT) -public class KeyMapping implements Comparable { +public class KeyMapping implements Comparable, net.minecraftforge.client.extensions.IForgeKeyMapping { - private static final Map f_90809_ = Maps.newHashMap(); -- private static final Map f_90810_ = Maps.newHashMap(); -+ private static final net.minecraftforge.client.settings.KeyBindingMap f_90810_ = new net.minecraftforge.client.settings.KeyBindingMap(); - private static final Set f_90811_ = Sets.newHashSet(); - public static final String f_167805_ = "key.categories.movement"; - public static final String f_167806_ = "key.categories.misc"; + private static final Map ALL = Maps.newHashMap(); +- private static final Map MAP = Maps.newHashMap(); ++ private static final net.minecraftforge.client.settings.KeyBindingMap MAP = new net.minecraftforge.client.settings.KeyBindingMap(); + private static final Set CATEGORIES = Sets.newHashSet(); + public static final String CATEGORY_MOVEMENT = "key.categories.movement"; + public static final String CATEGORY_MISC = "key.categories.misc"; @@ -42,7 +_,7 @@ - private int f_90818_; + private int clickCount; - public static void m_90835_(InputConstants.Key p_90836_) { -- KeyMapping keymapping = f_90810_.get(p_90836_); -+ KeyMapping keymapping = f_90810_.lookupActive(p_90836_); + public static void click(InputConstants.Key p_90836_) { +- KeyMapping keymapping = MAP.get(p_90836_); ++ KeyMapping keymapping = MAP.lookupActive(p_90836_); if (keymapping != null) { - ++keymapping.f_90818_; + ++keymapping.clickCount; } @@ -50,7 +_,7 @@ } - public static void m_90837_(InputConstants.Key p_90838_, boolean p_90839_) { -- KeyMapping keymapping = f_90810_.get(p_90838_); -+ for (KeyMapping keymapping : f_90810_.lookupAll(p_90838_)) + public static void set(InputConstants.Key p_90838_, boolean p_90839_) { +- KeyMapping keymapping = MAP.get(p_90838_); ++ for (KeyMapping keymapping : MAP.lookupAll(p_90838_)) if (keymapping != null) { - keymapping.m_7249_(p_90839_); + keymapping.setDown(p_90839_); } @@ -74,10 +_,10 @@ } - public static void m_90854_() { -- f_90810_.clear(); -+ f_90810_.clearMap(); + public static void resetMapping() { +- MAP.clear(); ++ MAP.clearMap(); - for(KeyMapping keymapping : f_90809_.values()) { -- f_90810_.put(keymapping.f_90816_, keymapping); -+ f_90810_.addKey(keymapping.f_90816_, keymapping); + for(KeyMapping keymapping : ALL.values()) { +- MAP.put(keymapping.key, keymapping); ++ MAP.addKey(keymapping.key, keymapping); } } @@ -92,12 +_,12 @@ - this.f_90814_ = this.f_90816_; - this.f_90815_ = p_90828_; - f_90809_.put(p_90825_, this); -- f_90810_.put(this.f_90816_, this); -+ f_90810_.addKey(this.f_90816_, this); - f_90811_.add(p_90828_); + this.defaultKey = this.key; + this.category = p_90828_; + ALL.put(p_90825_, this); +- MAP.put(this.key, this); ++ MAP.addKey(this.key, this); + CATEGORIES.add(p_90828_); } - public boolean m_90857_() { -- return this.f_90817_; -+ return this.f_90817_ && isConflictContextAndModifierActive(); + public boolean isDown() { +- return this.isDown; ++ return this.isDown && isConflictContextAndModifierActive(); } - public String m_90858_() { + public String getCategory() { @@ -131,7 +_,13 @@ } public int compareTo(KeyMapping p_90841_) { -- return this.f_90815_.equals(p_90841_.f_90815_) ? I18n.m_118938_(this.f_90813_).compareTo(I18n.m_118938_(p_90841_.f_90813_)) : f_90812_.get(this.f_90815_).compareTo(f_90812_.get(p_90841_.f_90815_)); -+ if (this.f_90815_.equals(p_90841_.f_90815_)) return I18n.m_118938_(this.f_90813_).compareTo(I18n.m_118938_(p_90841_.f_90813_)); -+ Integer tCat = f_90812_.get(this.f_90815_); -+ Integer oCat = f_90812_.get(p_90841_.f_90815_); +- return this.category.equals(p_90841_.category) ? I18n.get(this.name).compareTo(I18n.get(p_90841_.name)) : CATEGORY_SORT_ORDER.get(this.category).compareTo(CATEGORY_SORT_ORDER.get(p_90841_.category)); ++ if (this.category.equals(p_90841_.category)) return I18n.get(this.name).compareTo(I18n.get(p_90841_.name)); ++ Integer tCat = CATEGORY_SORT_ORDER.get(this.category); ++ Integer oCat = CATEGORY_SORT_ORDER.get(p_90841_.category); + if (tCat == null && oCat != null) return 1; + if (tCat != null && oCat == null) return -1; -+ if (tCat == null && oCat == null) return I18n.m_118938_(this.f_90815_).compareTo(I18n.m_118938_(p_90841_.f_90815_)); ++ if (tCat == null && oCat == null) return I18n.get(this.category).compareTo(I18n.get(p_90841_.category)); + return tCat.compareTo(oCat); } - public static Supplier m_90842_(String p_90843_) { + public static Supplier createNameSupplier(String p_90843_) { @@ -142,6 +_,20 @@ } - public boolean m_90850_(KeyMapping p_90851_) { + public boolean same(KeyMapping p_90851_) { + if (getKeyConflictContext().conflicts(p_90851_.getKeyConflictContext()) || p_90851_.getKeyConflictContext().conflicts(getKeyConflictContext())) { + net.minecraftforge.client.settings.KeyModifier keyModifier = getKeyModifier(); + net.minecraftforge.client.settings.KeyModifier otherKeyModifier = p_90851_.getKeyModifier(); @@ -91,27 +91,27 @@ + (keyModifier == net.minecraftforge.client.settings.KeyModifier.NONE || otherKeyModifier == net.minecraftforge.client.settings.KeyModifier.NONE)); + } + } - return this.f_90816_.equals(p_90851_.f_90816_); + return this.key.equals(p_90851_.key); } @@ -162,11 +_,13 @@ } - public Component m_90863_() { -+ return getKeyModifier().getCombinedName(f_90816_, () -> { - return this.f_90816_.m_84875_(); + public Component getTranslatedKeyMessage() { ++ return getKeyModifier().getCombinedName(key, () -> { + return this.key.getDisplayName(); + }); } - public boolean m_90864_() { -- return this.f_90816_.equals(this.f_90814_); -+ return this.f_90816_.equals(this.f_90814_) && getKeyModifier() == getDefaultKeyModifier(); + public boolean isDefault() { +- return this.key.equals(this.defaultKey); ++ return this.key.equals(this.defaultKey) && getKeyModifier() == getDefaultKeyModifier(); } - public String m_90865_() { + public String saveString() { @@ -176,4 +_,84 @@ - public void m_7249_(boolean p_90846_) { - this.f_90817_ = p_90846_; + public void setDown(boolean p_90846_) { + this.isDown = p_90846_; } + + /****************** Forge Start *****************************/ @@ -123,7 +123,7 @@ + * Convenience constructor for creating KeyBindings with keyConflictContext set. + */ + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, String category) { -+ this(description, keyConflictContext, inputType.m_84895_(keyCode), category); ++ this(description, keyConflictContext, inputType.getOrCreate(keyCode), category); + } + + /** @@ -137,30 +137,30 @@ + * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. + */ + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, String category) { -+ this(description, keyConflictContext, keyModifier, inputType.m_84895_(keyCode), category); ++ this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), category); + } + + /** + * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. + */ + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, String category) { -+ this.f_90813_ = description; -+ this.f_90816_ = keyCode; -+ this.f_90814_ = keyCode; -+ this.f_90815_ = category; ++ this.name = description; ++ this.key = keyCode; ++ this.defaultKey = keyCode; ++ this.category = category; + this.keyConflictContext = keyConflictContext; + this.keyModifier = keyModifier; + this.keyModifierDefault = keyModifier; + if (this.keyModifier.matches(keyCode)) + this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; -+ f_90809_.put(description, this); -+ f_90810_.addKey(keyCode, this); -+ f_90811_.add(category); ++ ALL.put(description, this); ++ MAP.addKey(keyCode, this); ++ CATEGORIES.add(category); + } + + @Override + public InputConstants.Key getKey() { -+ return this.f_90816_; ++ return this.key; + } + + @Override @@ -185,12 +185,12 @@ + + @Override + public void setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode) { -+ this.f_90816_ = keyCode; ++ this.key = keyCode; + if (keyModifier.matches(keyCode)) + keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; -+ f_90810_.removeKey(this); ++ MAP.removeKey(this); + this.keyModifier = keyModifier; -+ f_90810_.addKey(keyCode, this); ++ MAP.addKey(keyCode, this); + } + /****************** Forge End *****************************/ } diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index c91cbc27..13cd0b32 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -3,37 +3,37 @@ @@ -307,7 +_,9 @@ } - Screen screen = this.f_90867_.f_91080_; -- if (p_90897_ == 1 && (!(this.f_90867_.f_91080_ instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).f_193976_ <= Util.m_137550_() - 20L)) { + Screen screen = this.minecraft.screen; +- if (p_90897_ == 1 && (!(this.minecraft.screen instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).lastKeySelection <= Util.getMillis() - 20L)) { + -+ if ((!(this.f_90867_.f_91080_ instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).f_193976_ <= Util.m_137550_() - 20L)) { ++ if ((!(this.minecraft.screen instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).lastKeySelection <= Util.getMillis() - 20L)) { + if (p_90897_ == 1) { - if (this.f_90867_.f_91066_.f_92105_.m_90832_(p_90895_, p_90896_)) { - this.f_90867_.m_91268_().m_85438_(); - this.f_90867_.f_91066_.f_92052_ = this.f_90867_.m_91268_().m_85440_(); + if (this.minecraft.options.keyFullscreen.matches(p_90895_, p_90896_)) { + this.minecraft.getWindow().toggleFullScreen(); + this.minecraft.options.fullscreen = this.minecraft.getWindow().isFullscreen(); @@ -326,6 +_,8 @@ }); return; } -+ } else if (p_90897_ == 0 /*GLFW_RELEASE*/ && this.f_90867_.f_91080_ instanceof KeyBindsScreen) -+ ((KeyBindsScreen)this.f_90867_.f_91080_).f_193975_ = null; //Forge: Unset pure modifiers. ++ } else if (p_90897_ == 0 /*GLFW_RELEASE*/ && this.minecraft.screen instanceof KeyBindsScreen) ++ ((KeyBindsScreen)this.minecraft.screen).selectedKey = null; //Forge: Unset pure modifiers. } - if (NarratorChatListener.f_93311_.m_93316_()) { + if (NarratorChatListener.INSTANCE.isActive()) { @@ -349,11 +_,15 @@ - Screen.m_96579_(() -> { - if (p_90897_ != 1 && (p_90897_ != 2 || !this.f_90868_)) { + Screen.wrapScreenError(() -> { + if (p_90897_ != 1 && (p_90897_ != 2 || !this.sendRepeatsToGui)) { if (p_90897_ == 0) { -- aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); +- aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleasedPre(screen, p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); + if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleasedPost(screen, p_90895_, p_90896_, p_90898_); } } else { - screen.m_169416_(); -- aboolean[0] = screen.m_7933_(p_90895_, p_90896_, p_90898_); + screen.afterKeyboardAction(); +- aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressedPre(screen, p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = screen.m_7933_(p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); + if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressedPost(screen, p_90895_, p_90896_, p_90898_); } @@ -47,24 +47,24 @@ } } - private void m_90889_(long p_90890_, int p_90891_, int p_90892_) { - if (p_90890_ == this.f_90867_.m_91268_().m_85439_()) { -- GuiEventListener guieventlistener = this.f_90867_.f_91080_; -+ Screen guieventlistener = this.f_90867_.f_91080_; - if (guieventlistener != null && this.f_90867_.m_91265_() == null) { + 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.m_96579_(() -> { -- guieventlistener.m_5534_((char)p_90891_, p_90892_); + Screen.wrapScreenError(() -> { +- guieventlistener.charTyped((char)p_90891_, p_90892_); + if (net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPre(guieventlistener, (char)p_90891_, p_90892_)) return; -+ if (guieventlistener.m_5534_((char)p_90891_, p_90892_)) return; ++ if (guieventlistener.charTyped((char)p_90891_, p_90892_)) return; + net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPost(guieventlistener, (char)p_90891_, p_90892_); }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); } else { for(char c0 : Character.toChars(p_90891_)) { - Screen.m_96579_(() -> { -- guieventlistener.m_5534_(c0, p_90892_); + Screen.wrapScreenError(() -> { +- guieventlistener.charTyped(c0, p_90892_); + if (net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPre(guieventlistener, c0, p_90892_)) return; -+ if (guieventlistener.m_5534_(c0, p_90892_)) return; ++ if (guieventlistener.charTyped(c0, p_90892_)) return; + net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPost(guieventlistener, c0, p_90892_); }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 93b78f07..3a4c0a7f 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -6,216 +6,208 @@ @OnlyIn(Dist.CLIENT) -public class Minecraft extends ReentrantBlockableEventLoop implements WindowEventHandler { +public class Minecraft extends ReentrantBlockableEventLoop implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft { - private static Minecraft f_90981_; - private static final Logger f_90982_ = LogUtils.getLogger(); - public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX; -@@ -394,14 +_,13 @@ - this.f_91029_ = p_91084_.f_101908_.f_101928_; - this.f_90986_ = p_91084_.f_101905_.f_101944_; - this.f_91037_ = new ClientPackSource(new File(this.f_91069_, "server-resource-packs"), p_91084_.f_101907_.m_101925_()); -- this.f_91038_ = new PackRepository(Minecraft::m_167933_, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); -+ this.f_91038_ = new PackRepository(Minecraft::createClientPackAdapter, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); - this.f_91030_ = p_91084_.f_101905_.f_101945_; - YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); - this.f_91048_ = yggdrasilauthenticationservice.createMinecraftSessionService(); - this.f_193584_ = this.m_193585_(yggdrasilauthenticationservice, p_91084_); - this.f_90998_ = p_91084_.f_101905_.f_101942_; - f_90982_.info("Setting user: {}", (Object)this.f_90998_.m_92546_()); -- f_90982_.debug("(Session ID is {})", (Object)this.f_90998_.m_92544_()); - this.f_91033_ = p_91084_.f_101908_.f_101926_; - this.f_91034_ = !p_91084_.f_101908_.f_101929_; - this.f_91035_ = !p_91084_.f_101908_.f_101930_; + private static Minecraft instance; + private static final Logger LOGGER = LogUtils.getLogger(); + public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX; +@@ -401,7 +_,6 @@ + this.userApiService = this.createUserApiService(yggdrasilauthenticationservice, p_91084_); + this.user = p_91084_.user.user; + LOGGER.info("Setting user: {}", (Object)this.user.getName()); +- LOGGER.debug("(Session ID is {})", (Object)this.user.getSessionId()); + this.demo = p_91084_.game.demo; + this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; + this.allowsChat = !p_91084_.game.disableChat; @@ -433,6 +_,7 @@ } - Util.f_137440_ = RenderSystem.m_69576_(); -+ if (net.minecraftforge.common.ForgeConfig.CLIENT.forceSystemNanoTime.get()) Util.f_137440_ = System::nanoTime; - this.f_90989_ = new VirtualScreen(this); - this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_()); - this.m_7440_(true); + Util.timeSource = RenderSystem.initBackendSystem(); ++ if (net.minecraftforge.common.ForgeConfig.CLIENT.forceSystemNanoTime.get()) Util.timeSource = System::nanoTime; + this.virtualScreen = new VirtualScreen(this); + this.window = this.virtualScreen.newWindow(displaydata, this.options.fullscreenVideoModeString, this.createTitle()); + this.setWindowActive(true); @@ -448,7 +_,6 @@ - this.f_90990_.m_85380_(this.f_91066_.f_92113_); - this.f_91067_ = new MouseHandler(this); -- this.f_91067_.m_91524_(this.f_90990_.m_85439_()); - this.f_91068_ = new KeyboardHandler(this); - this.f_91068_.m_90887_(this.f_90990_.m_85439_()); - RenderSystem.m_69580_(this.f_91066_.f_92035_, false); + this.window.setFramerateLimit(this.options.framerateLimit); + this.mouseHandler = new MouseHandler(this); +- this.mouseHandler.setup(this.window.getWindow()); + this.keyboardHandler = new KeyboardHandler(this); + this.keyboardHandler.setup(this.window.getWindow()); + RenderSystem.initRenderer(this.options.glDebugVerbosity, false); @@ -456,6 +_,8 @@ - this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); - this.f_91042_.m_83954_(f_91002_); - this.f_91036_ = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); + this.mainRenderTarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); + this.mainRenderTarget.clear(ON_OSX); + this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); + net.minecraftforge.client.RecipeBookRegistry.initDefaultValues(); -+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_); - this.f_91038_.m_10506_(); - this.f_91066_.m_92145_(this.f_91038_); - this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_); ++ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager, this.clientPackSource); + this.resourcePackRepository.reload(); + this.options.loadSelectedResourcePacks(this.resourcePackRepository); + this.languageManager = new LanguageManager(this.options.languageCode); @@ -500,10 +_,12 @@ - this.f_91052_ = new BlockRenderDispatcher(this.f_91051_.m_119430_(), blockentitywithoutlevelrenderer, this.f_91040_); - this.f_91036_.m_7217_(this.f_91052_); - this.f_91060_ = new LevelRenderer(this, this.f_90993_); + this.blockRenderer = new BlockRenderDispatcher(this.modelManager.getBlockModelShaper(), blockentitywithoutlevelrenderer, this.blockColors); + this.resourceManager.registerReloadListener(this.blockRenderer); + this.levelRenderer = new LevelRenderer(this, this.renderBuffers); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RenderLevelStageEvent.RegisterStageEvent()); - this.f_91036_.m_7217_(this.f_91060_); - this.m_91271_(); - this.f_91036_.m_7217_(this.f_90997_); - this.f_91061_ = new ParticleEngine(this.f_91073_, this.f_90987_); + this.resourceManager.registerReloadListener(this.levelRenderer); + this.createSearchTrees(); + this.resourceManager.registerReloadListener(this.searchRegistry); + this.particleEngine = new ParticleEngine(this.level, this.textureManager); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.ParticleFactoryRegisterEvent()); - this.f_91036_.m_7217_(this.f_91061_); - this.f_91053_ = new PaintingTextureManager(this.f_90987_); - this.f_91036_.m_7217_(this.f_91053_); + this.resourceManager.registerReloadListener(this.particleEngine); + this.paintingTextures = new PaintingTextureManager(this.textureManager); + this.resourceManager.registerReloadListener(this.paintingTextures); @@ -512,7 +_,8 @@ - this.f_91047_ = new GpuWarnlistManager(); - this.f_91036_.m_7217_(this.f_91047_); - this.f_91036_.m_7217_(this.f_205120_); -- this.f_91065_ = new Gui(this); -+ this.f_91065_ = new net.minecraftforge.client.gui.ForgeIngameGui(this); -+ this.f_91067_.m_91524_(this.f_90990_.m_85439_()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler. - this.f_91064_ = new DebugRenderer(this); - RenderSystem.m_69900_(this::m_91113_); - if (this.f_91042_.f_83915_ == this.f_90990_.m_85441_() && this.f_91042_.f_83916_ == this.f_90990_.m_85442_()) { + this.gpuWarnlistManager = new GpuWarnlistManager(); + this.resourceManager.registerReloadListener(this.gpuWarnlistManager); + this.resourceManager.registerReloadListener(this.regionalCompliancies); +- this.gui = new Gui(this); ++ this.gui = new net.minecraftforge.client.gui.ForgeIngameGui(this); ++ this.mouseHandler.setup(this.window.getWindow()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler. + this.debugRenderer = new DebugRenderer(this); + RenderSystem.setErrorCallback(this::onFullscreenError); + if (this.mainRenderTarget.width == this.window.getWidth() && this.mainRenderTarget.height == this.window.getHeight()) { @@ -530,6 +_,11 @@ TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false); } + net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests(); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterClientReloadListenersEvent(this.f_91036_)); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterClientReloadListenersEvent(this.resourceManager)); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterLayerDefinitions()); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers()); + - this.f_90990_.m_85409_(this.f_91066_.f_92041_); - this.f_90990_.m_85424_(this.f_91066_.f_92034_); - this.f_90990_.m_85426_(); + this.window.updateVsync(this.options.enableVsync); + this.window.updateRawMouseInput(this.options.rawMouseInput); + this.window.setDefaultErrorCallback(); @@ -545,13 +_,16 @@ } - this.f_167847_.m_168556_(); + this.reloadStateTracker.finishReload(); + if (net.minecraftforge.client.loading.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen + // FORGE: Move opening initial screen to after startup and events are enabled. + // Also Fixes MC-145102 + if (s != null) { -+ ConnectScreen.m_169267_(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); ++ ConnectScreen.startConnecting(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); + } else { -+ this.m_91152_(new TitleScreen(true)); ++ this.setScreen(new TitleScreen(true)); + } }); }, false)); - if (s != null) { -- ConnectScreen.m_169267_(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); +- ConnectScreen.startConnecting(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); - } else { -- this.m_91152_(new TitleScreen(true)); +- this.setScreen(new TitleScreen(true)); - } } @@ -594,6 +_,8 @@ - private UserApiService m_193585_(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { + private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { try { -+ if ("0".equals(p_193587_.f_101905_.f_101942_.m_92547_())) // Forge: We use "0" in dev. Short circuit to stop exception spam. ++ if ("0".equals(p_193587_.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam. + return UserApiService.OFFLINE; - return p_193586_.createUserApiService(p_193587_.f_101905_.f_101942_.m_92547_()); + return p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); } catch (AuthenticationException authenticationexception) { - f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception); + LOGGER.error("Failed to verify authentication", (Throwable)authenticationexception); @@ -606,7 +_,7 @@ } - private void m_91239_(Throwable p_91240_) { -- if (this.f_91038_.m_10523_().size() > 1) { -+ if (this.f_91038_.m_10524_().stream().anyMatch(e -> !e.m_10449_())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any. - this.m_91241_(p_91240_, (Component)null); + private void rollbackResourcePacks(Throwable p_91240_) { +- if (this.resourcePackRepository.getSelectedIds().size() > 1) { ++ if (this.resourcePackRepository.getSelectedPacks().stream().anyMatch(e -> !e.isRequired())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any. + this.clearResourcePacksOnError(p_91240_, (Component)null); } else { - Util.m_137559_(p_91240_); + Util.throwAsRuntime(p_91240_); @@ -763,13 +_,13 @@ - Bootstrap.m_135875_(p_91333_.m_127526_()); - if (p_91333_.m_127527_() != null) { - Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.m_127527_()); + Bootstrap.realStdoutPrintln(p_91333_.getFriendlyReport()); + if (p_91333_.getSaveFile() != null) { + Bootstrap.realStdoutPrintln("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.getSaveFile()); - System.exit(-1); + net.minecraftforge.server.ServerLifecycleHooks.handleExit(-1); - } else if (p_91333_.m_127512_(file2)) { - Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); + } else if (p_91333_.saveToFile(file2)) { + Bootstrap.realStdoutPrintln("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); - System.exit(-1); + net.minecraftforge.server.ServerLifecycleHooks.handleExit(-1); } else { - Bootstrap.m_135875_("#@?@# Game crashed! Crash report could not be saved. #@?@#"); + Bootstrap.realStdoutPrintln("#@?@# Game crashed! Crash report could not be saved. #@?@#"); - System.exit(-2); + net.minecraftforge.server.ServerLifecycleHooks.handleExit(-2); } } @@ -879,10 +_,6 @@ - f_90982_.error("setScreen called from non-game thread"); + LOGGER.error("setScreen called from non-game thread"); } -- if (this.f_91080_ != null) { -- this.f_91080_.m_7861_(); +- if (this.screen != null) { +- this.screen.removed(); - } - - if (p_91153_ == null && this.f_91073_ == null) { + if (p_91153_ == null && this.level == null) { p_91153_ = new TitleScreen(); - } else if (p_91153_ == null && this.f_91074_.m_21224_()) { + } else if (p_91153_ == null && this.player.isDeadOrDying()) { @@ -893,6 +_,15 @@ } } + net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this); -+ Screen old = this.f_91080_; ++ Screen old = this.screen; + net.minecraftforge.client.event.ScreenOpenEvent event = new net.minecraftforge.client.event.ScreenOpenEvent(p_91153_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; + + p_91153_ = event.getScreen(); + if (old != null && p_91153_ != old) -+ old.m_7861_(); ++ old.removed(); + - this.f_91080_ = p_91153_; - BufferUploader.m_166835_(); + this.screen = p_91153_; + BufferUploader.reset(); if (p_91153_ != null) { @@ -1022,11 +_,13 @@ - RenderSystem.m_69481_(); - this.f_91026_.m_7238_(); - if (!this.f_91079_) { -+ net.minecraftforge.event.ForgeEventFactory.onRenderTickStart(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); - this.f_91026_.m_6182_("gameRenderer"); - this.f_91063_.m_109093_(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_, i, p_91384_); - this.f_91026_.m_6182_("toasts"); - this.f_91003_.m_94920_(new PoseStack()); - this.f_91026_.m_7238_(); -+ net.minecraftforge.event.ForgeEventFactory.onRenderTickEnd(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); + RenderSystem.enableCull(); + this.profiler.pop(); + if (!this.noRender) { ++ net.minecraftforge.event.ForgeEventFactory.onRenderTickStart(this.pause ? this.pausePartialTick : this.timer.partialTick); + this.profiler.popPush("gameRenderer"); + this.gameRenderer.render(this.pause ? this.pausePartialTick : this.timer.partialTick, i, p_91384_); + this.profiler.popPush("toasts"); + this.toast.render(new PoseStack()); + this.profiler.pop(); ++ net.minecraftforge.event.ForgeEventFactory.onRenderTickEnd(this.pause ? this.pausePartialTick : this.timer.partialTick); } - if (this.f_91056_ != null) { + if (this.fpsPieResults != null) { @@ -1132,10 +_,12 @@ - this.f_90990_.m_85378_((double)i); - if (this.f_91080_ != null) { - this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_()); -+ net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_()); + this.window.setGuiScale((double)i); + if (this.screen != null) { + this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); ++ net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); } - RenderTarget rendertarget = this.m_91385_(); - rendertarget.m_83941_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_(), f_91002_); -+ if (this.f_91063_ != null) - this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_()); - this.f_91067_.m_91599_(); + RenderTarget rendertarget = this.getMainRenderTarget(); + rendertarget.resize(this.window.getWidth(), this.window.getHeight(), ON_OSX); ++ if (this.gameRenderer != null) + this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); + this.mouseHandler.setIgnoreFirstMove(); } @@ -1432,11 +_,21 @@ - if (p_91387_ && this.f_91077_ != null && this.f_91077_.m_6662_() == HitResult.Type.BLOCK) { - BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; - BlockPos blockpos = blockhitresult.m_82425_(); -- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { -+ if (!this.f_91073_.m_46859_(blockpos)) { -+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND); + if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { + BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; + BlockPos blockpos = blockhitresult.getBlockPos(); +- if (!this.level.getBlockState(blockpos).isAir()) { ++ if (!this.level.isEmptyBlock(blockpos)) { ++ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.options.keyAttack, InteractionHand.MAIN_HAND); + if (inputEvent.isCanceled()) { + if (inputEvent.shouldSwingHand()) { -+ this.f_91061_.addBlockHitEffects(blockpos, blockhitresult); -+ this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); ++ this.particleEngine.addBlockHitEffects(blockpos, blockhitresult); ++ this.player.swing(InteractionHand.MAIN_HAND); + } + return; + } - Direction direction = blockhitresult.m_82434_(); - if (this.f_91072_.m_105283_(blockpos, direction)) { -- this.f_91061_.m_107367_(blockpos, direction); + Direction direction = blockhitresult.getDirection(); + if (this.gameMode.continueDestroyBlock(blockpos, direction)) { +- this.particleEngine.crack(blockpos, direction); + if (inputEvent.shouldSwingHand()) { -+ this.f_91061_.addBlockHitEffects(blockpos, blockhitresult); - this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); ++ this.particleEngine.addBlockHitEffects(blockpos, blockhitresult); + this.player.swing(InteractionHand.MAIN_HAND); + } } } @@ -224,191 +216,186 @@ return false; } else { boolean flag = false; -- switch(this.f_91077_.m_6662_()) { -+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND); -+ HitResult.Type hitType = this.f_91077_.m_6662_(); -+ if(this.f_91077_ instanceof EntityHitResult entityHit) { // Forge: Perform attack range checks here, instead of in GameRenderer#pick, so extended-reach interactions work. -+ if(!f_91074_.canHit(entityHit.m_82443_(), 0)) hitType = HitResult.Type.MISS; // No padding in client code. +- switch(this.hitResult.getType()) { ++ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.options.keyAttack, InteractionHand.MAIN_HAND); ++ HitResult.Type hitType = this.hitResult.getType(); ++ if(this.hitResult instanceof EntityHitResult entityHit) { // Forge: Perform attack range checks here, instead of in GameRenderer#pick, so extended-reach interactions work. ++ if(!player.canHit(entityHit.getEntity(), 0)) hitType = HitResult.Type.MISS; // No padding in client code. + } + if (!inputEvent.isCanceled()) + switch(hitType) { case ENTITY: - this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_()); + this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); break; case BLOCK: - BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; - BlockPos blockpos = blockhitresult.m_82425_(); -- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { -+ if (!this.f_91073_.m_46859_(blockpos)) { - this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); - if (this.f_91073_.m_8055_(blockpos).m_60795_()) { + BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; + BlockPos blockpos = blockhitresult.getBlockPos(); +- if (!this.level.getBlockState(blockpos).isAir()) { ++ if (!this.level.isEmptyBlock(blockpos)) { + this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); + if (this.level.getBlockState(blockpos).isAir()) { flag = true; @@ -1480,8 +_,10 @@ } - this.f_91074_.m_36334_(); -+ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.f_91074_); + this.player.resetAttackStrengthTicker(); ++ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.player); } + if (inputEvent.shouldSwingHand()) - this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); + this.player.swing(InteractionHand.MAIN_HAND); return flag; } @@ -1496,6 +_,11 @@ } for(InteractionHand interactionhand : InteractionHand.values()) { -+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(1, this.f_91066_.f_92095_, interactionhand); ++ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(1, this.options.keyUse, interactionhand); + if (inputEvent.isCanceled()) { -+ if (inputEvent.shouldSwingHand()) this.f_91074_.m_6674_(interactionhand); ++ if (inputEvent.shouldSwingHand()) this.player.swing(interactionhand); + return; + } - ItemStack itemstack = this.f_91074_.m_21120_(interactionhand); - if (this.f_91077_ != null) { - switch(this.f_91077_.m_6662_()) { + ItemStack itemstack = this.player.getItemInHand(interactionhand); + if (this.hitResult != null) { + switch(this.hitResult.getType()) { @@ -1506,6 +_,7 @@ return; } -+ if(!this.f_91074_.canInteractWith(entityhitresult.m_82443_(), 0)) break; //Forge: Entity may be traced via attack range, but the player may not have sufficient reach. No padding in client code. - InteractionResult interactionresult = this.f_91072_.m_105230_(this.f_91074_, entity, entityhitresult, interactionhand); - if (!interactionresult.m_19077_()) { - interactionresult = this.f_91072_.m_105226_(this.f_91074_, entity, interactionhand); ++ if(!this.player.canInteractWith(entityhitresult.getEntity(), 0)) break; //Forge: Entity may be traced via attack range, but the player may not have sufficient reach. No padding in client code. + InteractionResult interactionresult = this.gameMode.interactAt(this.player, entity, entityhitresult, interactionhand); + if (!interactionresult.consumesAction()) { + interactionresult = this.gameMode.interact(this.player, entity, interactionhand); @@ -1513,6 +_,7 @@ - if (interactionresult.m_19077_()) { - if (interactionresult.m_19080_()) { + if (interactionresult.consumesAction()) { + if (interactionresult.shouldSwing()) { + if (inputEvent.shouldSwingHand()) - this.f_91074_.m_6674_(interactionhand); + this.player.swing(interactionhand); } @@ -1525,6 +_,7 @@ - InteractionResult interactionresult1 = this.f_91072_.m_105262_(this.f_91074_, this.f_91073_, interactionhand, blockhitresult); - if (interactionresult1.m_19077_()) { - if (interactionresult1.m_19080_()) { + InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, this.level, interactionhand, blockhitresult); + if (interactionresult1.consumesAction()) { + if (interactionresult1.shouldSwing()) { + if (inputEvent.shouldSwingHand()) - this.f_91074_.m_6674_(interactionhand); - if (!itemstack.m_41619_() && (itemstack.m_41613_() != i || this.f_91072_.m_105290_())) { - this.f_91063_.f_109055_.m_109320_(interactionhand); + this.player.swing(interactionhand); + if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.gameMode.hasInfiniteItems())) { + this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); @@ -1540,6 +_,9 @@ } } -+ if (itemstack.m_41619_() && (this.f_91077_ == null || this.f_91077_.m_6662_() == HitResult.Type.MISS)) -+ net.minecraftforge.common.ForgeHooks.onEmptyClick(this.f_91074_, interactionhand); ++ if (itemstack.isEmpty() && (this.hitResult == null || this.hitResult.getType() == HitResult.Type.MISS)) ++ net.minecraftforge.common.ForgeHooks.onEmptyClick(this.player, interactionhand); + - if (!itemstack.m_41619_()) { - InteractionResult interactionresult2 = this.f_91072_.m_105235_(this.f_91074_, this.f_91073_, interactionhand); - if (interactionresult2.m_19077_()) { + if (!itemstack.isEmpty()) { + InteractionResult interactionresult2 = this.gameMode.useItem(this.player, this.level, interactionhand); + if (interactionresult2.consumesAction()) { @@ -1566,6 +_,8 @@ - --this.f_91011_; + --this.rightClickDelay; } + net.minecraftforge.event.ForgeEventFactory.onPreClientTick(); + - this.f_91026_.m_6180_("gui"); - this.f_91065_.m_193832_(this.f_91012_); - this.f_91026_.m_7238_(); + this.profiler.push("gui"); + this.gui.tick(this.pause); + this.profiler.pop(); @@ -1694,6 +_,8 @@ - this.f_91026_.m_6182_("keyboard"); - this.f_91068_.m_90931_(); - this.f_91026_.m_7238_(); + this.profiler.popPush("keyboard"); + this.keyboardHandler.tick(); + this.profiler.pop(); + + net.minecraftforge.event.ForgeEventFactory.onPostClientTick(); } - private boolean m_91278_() { -@@ -1814,11 +_,11 @@ + private boolean isMultiplayerServer() { +@@ -1814,7 +_,7 @@ } - public void m_91200_(String p_91201_) { -- this.m_205205_(p_91201_, WorldStem.DataPackConfigSupplier::m_206928_, WorldStem.WorldDataSupplier::m_206954_, false, Minecraft.ExperimentalDialogType.BACKUP); -+ this.doLoadLevel(p_91201_, WorldStem.DataPackConfigSupplier::m_206928_, WorldStem.WorldDataSupplier::m_206954_, false, Minecraft.ExperimentalDialogType.BACKUP, false); + public void loadLevel(String p_91201_) { +- this.doLoadLevel(p_91201_, WorldStem.DataPackConfigSupplier::loadFromWorld, WorldStem.WorldDataSupplier::loadFromWorld, false, Minecraft.ExperimentalDialogType.BACKUP); ++ this.doLoadLevel(p_91201_, WorldStem.DataPackConfigSupplier::loadFromWorld, WorldStem.WorldDataSupplier::loadFromWorld, false, Minecraft.ExperimentalDialogType.BACKUP, false); } - public void m_205185_(String p_205186_, LevelSettings p_205187_, RegistryAccess p_205188_, WorldGenSettings p_205189_) { -- this.m_205205_(p_205186_, (p_210684_) -> { -+ this.doLoadLevel(p_205186_, (p_210684_) -> { - return p_205187_::m_46934_; - }, (p_210718_) -> { - return (p_210712_, p_210713_) -> { + public void createLevel(String p_205186_, LevelSettings p_205187_, RegistryAccess p_205188_, WorldGenSettings p_205189_) { @@ -1831,10 +_,10 @@ - WorldGenSettings worldgensettings = dataresult.getOrThrow(false, Util.m_137489_("Error reading worldgen settings after loading data packs: ", f_90982_::error)); - return Pair.of(new PrimaryLevelData(p_205187_, worldgensettings, dataresult.lifecycle()), registryaccess$writable.m_203557_()); + WorldGenSettings worldgensettings = dataresult.getOrThrow(false, Util.prefix("Error reading worldgen settings after loading data packs: ", LOGGER::error)); + return Pair.of(new PrimaryLevelData(p_205187_, worldgensettings, dataresult.lifecycle()), registryaccess$writable.freeze()); }; - }, false, Minecraft.ExperimentalDialogType.CREATE); + }, false, Minecraft.ExperimentalDialogType.CREATE, true); } -- private void m_205205_(String p_205206_, Function p_205207_, Function p_205208_, boolean p_205209_, Minecraft.ExperimentalDialogType p_205210_) { +- private void doLoadLevel(String p_205206_, Function p_205207_, Function p_205208_, boolean p_205209_, Minecraft.ExperimentalDialogType p_205210_) { + private void doLoadLevel(String p_205206_, Function p_205207_, Function p_205208_, boolean p_205209_, Minecraft.ExperimentalDialogType p_205210_, boolean creating) { LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess; try { - levelstoragesource$levelstorageaccess = this.f_91031_.m_78260_(p_205206_); + levelstoragesource$levelstorageaccess = this.levelSource.createAccess(p_205206_); @@ -1849,11 +_,12 @@ WorldStem worldstem; try { + if (!creating) levelstoragesource$levelstorageaccess.readAdditionalLevelSaveData(); - worldstem = this.m_205125_(packrepository, p_205209_, p_205207_.apply(levelstoragesource$levelstorageaccess), p_205208_.apply(levelstoragesource$levelstorageaccess)); + worldstem = this.makeWorldStem(packrepository, p_205209_, p_205207_.apply(levelstoragesource$levelstorageaccess), p_205208_.apply(levelstoragesource$levelstorageaccess)); } catch (Exception exception) { - f_90982_.warn("Failed to load datapacks, can't proceed with server load", (Throwable)exception); - this.m_91152_(new DatapackLoadFailureScreen(() -> { -- this.m_205205_(p_205206_, p_205207_, p_205208_, true, p_205210_); + LOGGER.warn("Failed to load datapacks, can't proceed with server load", (Throwable)exception); + this.setScreen(new DatapackLoadFailureScreen(() -> { +- this.doLoadLevel(p_205206_, p_205207_, p_205208_, true, p_205210_); + this.doLoadLevel(p_205206_, p_205207_, p_205208_, true, p_205210_, creating); })); try { @@ -1869,13 +_,15 @@ - WorldData worlddata = worldstem.f_206895_(); - boolean flag = worlddata.m_5961_().m_64670_(); - boolean flag1 = worlddata.m_5754_() != Lifecycle.stable(); + WorldData worlddata = worldstem.worldData(); + boolean flag = worlddata.worldGenSettings().isOldCustomizedWorld(); + boolean flag1 = worlddata.worldGenSettingsLifecycle() != Lifecycle.stable(); - if (p_205210_ == Minecraft.ExperimentalDialogType.NONE || !flag && !flag1) { + //Skip confirmation if it has been done already for this world + boolean skipConfirmation = worlddata instanceof PrimaryLevelData pld && pld.hasConfirmedExperimentalWarning(); + if (skipConfirmation || p_205210_ == Minecraft.ExperimentalDialogType.NONE || !flag && !flag1) { - this.m_91399_(); - this.f_90999_.set((StoringChunkProgressListener)null); + this.clearLevel(); + this.progressListener.set((StoringChunkProgressListener)null); try { - RegistryAccess.Frozen registryaccess$frozen = worldstem.f_206894_(); -- levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); -+ levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); //TODO-PATCHING: Figure out what registry access needs to be passed in here. - worldstem.m_206901_(); - YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); + RegistryAccess.Frozen registryaccess$frozen = worldstem.registryAccess(); +- levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); ++ levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); //TODO-PATCHING: Figure out what registry access needs to be passed in here. + worldstem.updateGlobals(); + YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.proxy); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); @@ -1885,7 +_,8 @@ - SkullBlockEntity.m_196700_(gameprofilecache, minecraftsessionservice, this); - GameProfileCache.m_11004_(false); - this.f_91007_ = MinecraftServer.m_129872_((p_210695_) -> { + SkullBlockEntity.setup(gameprofilecache, minecraftsessionservice, this); + GameProfileCache.setUsesAuthentication(false); + this.singleplayerServer = MinecraftServer.spin((p_210695_) -> { - return new IntegratedServer(p_210695_, this, levelstoragesource$levelstorageaccess, packrepository, worldstem, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_210795_) -> { + org.magmafoundation.magma.helpers.ServerInitHelper.init(null, null, null); + return new IntegratedServer(p_210695_, this, levelstoragesource$levelstorageaccess, packrepository, worldstem, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_210795_) -> { //TODO-PATCHING: Handle the registry freeze delay again. StoringChunkProgressListener storingchunkprogresslistener = new StoringChunkProgressListener(p_210795_ + 0); - this.f_90999_.set(storingchunkprogresslistener); - return ProcessorChunkProgressListener.m_143583_(storingchunkprogresslistener, this.f_91023_::add); + this.progressListener.set(storingchunkprogresslistener); + return ProcessorChunkProgressListener.createStarted(storingchunkprogresslistener, this.progressTasks::add); @@ -1929,13 +_,20 @@ - connection.m_129505_(new ClientHandshakePacketListenerImpl(connection, this, (Screen)null, (p_210793_) -> { + connection.setListener(new ClientHandshakePacketListenerImpl(connection, this, (Screen)null, (p_210793_) -> { })); - connection.m_129512_(new ClientIntentionPacket(socketaddress.toString(), 0, ConnectionProtocol.LOGIN)); -- connection.m_129512_(new ServerboundHelloPacket(this.m_91094_().m_92548_())); -+ com.mojang.authlib.GameProfile gameProfile = this.m_91094_().m_92548_(); -+ if (!this.m_91094_().hasCachedProperties()) { -+ gameProfile = f_91048_.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974. -+ this.m_91094_().setProperties(gameProfile.getProperties()); + connection.send(new ClientIntentionPacket(socketaddress.toString(), 0, ConnectionProtocol.LOGIN)); +- connection.send(new ServerboundHelloPacket(this.getUser().getGameProfile())); ++ com.mojang.authlib.GameProfile gameProfile = this.getUser().getGameProfile(); ++ if (!this.getUser().hasCachedProperties()) { ++ gameProfile = minecraftSessionService.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974. ++ this.getUser().setProperties(gameProfile.getProperties()); + } -+ connection.m_129512_(new ServerboundHelloPacket(gameProfile)); - this.f_91009_ = connection; ++ connection.send(new ServerboundHelloPacket(gameProfile)); + this.pendingConnection = connection; } else { -- this.m_91143_(p_205210_, p_205206_, flag, () -> { -- this.m_205205_(p_205206_, p_205207_, p_205208_, p_205209_, Minecraft.ExperimentalDialogType.NONE); +- this.displayExperimentalConfirmationDialog(p_205210_, p_205206_, flag, () -> { +- this.doLoadLevel(p_205206_, p_205207_, p_205208_, p_205209_, Minecraft.ExperimentalDialogType.NONE); - }); - worldstem.close(); + if (flag) //FORGE: For legacy world options, let vanilla handle it. -+ this.m_91143_(p_205210_, p_205206_, flag, () -> { ++ this.displayExperimentalConfirmationDialog(p_205210_, p_205206_, flag, () -> { + this.doLoadLevel(p_205206_, p_205207_, p_205208_, p_205209_, Minecraft.ExperimentalDialogType.NONE, creating); + }); -+ else net.minecraftforge.client.ForgeHooksClient.createWorldConfirmationScreen(f_91031_, p_205206_, creating, p_205208_, wds -> () -> this.doLoadLevel(p_205206_, p_205207_, wds, p_205209_, ExperimentalDialogType.NONE, creating)); ++ else net.minecraftforge.client.ForgeHooksClient.createWorldConfirmationScreen(levelSource, p_205206_, creating, p_205208_, wds -> () -> this.doLoadLevel(p_205206_, p_205207_, wds, p_205209_, ExperimentalDialogType.NONE, creating)); + worldstem.close(); try { @@ -416,134 +403,134 @@ @@ -2026,6 +_,7 @@ } - public void m_91156_(ClientLevel p_91157_) { -+ if (f_91073_ != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(f_91073_)); + public void setLevel(ClientLevel p_91157_) { ++ if (level != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(level)); ProgressScreen progressscreen = new ProgressScreen(true); - progressscreen.m_6309_(new TranslatableComponent("connect.joining")); - this.m_91362_(progressscreen); + progressscreen.progressStartNoAbort(new TranslatableComponent("connect.joining")); + this.updateScreenAndTick(progressscreen); @@ -2058,10 +_,12 @@ - IntegratedServer integratedserver = this.f_91007_; - this.f_91007_ = null; - this.f_91063_.m_109150_(); -+ net.minecraftforge.client.ForgeHooksClient.firePlayerLogout(this.f_91072_, this.f_91074_); - this.f_91072_ = null; - NarratorChatListener.f_93311_.m_93328_(); - this.m_91362_(p_91321_); - if (this.f_91073_ != null) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(f_91073_)); + IntegratedServer integratedserver = this.singleplayerServer; + this.singleplayerServer = null; + this.gameRenderer.resetData(); ++ net.minecraftforge.client.ForgeHooksClient.firePlayerLogout(this.gameMode, this.player); + this.gameMode = null; + NarratorChatListener.INSTANCE.clear(); + this.updateScreenAndTick(p_91321_); + if (this.level != null) { ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(level)); if (integratedserver != null) { - this.f_91026_.m_6180_("waitForServer"); + this.profiler.push("waitForServer"); @@ -2076,6 +_,7 @@ - this.f_91065_.m_93089_(); - this.f_91008_ = null; - this.f_91010_ = false; -+ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(f_91073_); - this.f_91004_.m_90740_(); + this.gui.onDisconnected(); + this.currentServer = null; + this.isLocalServer = false; ++ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(level); + this.game.onLeaveGameSession(); } @@ -2162,66 +_,9 @@ - private void m_91280_() { - if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) { -- boolean flag = this.f_91074_.m_150110_().f_35937_; + private void pickBlock() { + if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { +- boolean flag = this.player.getAbilities().instabuild; - BlockEntity blockentity = null; -- HitResult.Type hitresult$type = this.f_91077_.m_6662_(); +- HitResult.Type hitresult$type = this.hitResult.getType(); - ItemStack itemstack; - if (hitresult$type == HitResult.Type.BLOCK) { -- BlockPos blockpos = ((BlockHitResult)this.f_91077_).m_82425_(); -- BlockState blockstate = this.f_91073_.m_8055_(blockpos); -- if (blockstate.m_60795_()) { +- BlockPos blockpos = ((BlockHitResult)this.hitResult).getBlockPos(); +- BlockState blockstate = this.level.getBlockState(blockpos); +- if (blockstate.isAir()) { - return; - } - -- Block block = blockstate.m_60734_(); -- itemstack = block.m_7397_(this.f_91073_, blockpos, blockstate); -- if (itemstack.m_41619_()) { +- Block block = blockstate.getBlock(); +- itemstack = block.getCloneItemStack(this.level, blockpos, blockstate); +- if (itemstack.isEmpty()) { - return; - } - -- if (flag && Screen.m_96637_() && blockstate.m_155947_()) { -- blockentity = this.f_91073_.m_7702_(blockpos); +- if (flag && Screen.hasControlDown() && blockstate.hasBlockEntity()) { +- blockentity = this.level.getBlockEntity(blockpos); - } - } else { - if (hitresult$type != HitResult.Type.ENTITY || !flag) { - return; - } - -- Entity entity = ((EntityHitResult)this.f_91077_).m_82443_(); -- itemstack = entity.m_142340_(); +- Entity entity = ((EntityHitResult)this.hitResult).getEntity(); +- itemstack = entity.getPickResult(); - if (itemstack == null) { - return; - } - } - -- if (itemstack.m_41619_()) { +- if (itemstack.isEmpty()) { - String s = ""; - if (hitresult$type == HitResult.Type.BLOCK) { -- s = Registry.f_122824_.m_7981_(this.f_91073_.m_8055_(((BlockHitResult)this.f_91077_).m_82425_()).m_60734_()).toString(); +- s = Registry.BLOCK.getKey(this.level.getBlockState(((BlockHitResult)this.hitResult).getBlockPos()).getBlock()).toString(); - } else if (hitresult$type == HitResult.Type.ENTITY) { -- s = Registry.f_122826_.m_7981_(((EntityHitResult)this.f_91077_).m_82443_().m_6095_()).toString(); +- s = Registry.ENTITY_TYPE.getKey(((EntityHitResult)this.hitResult).getEntity().getType()).toString(); - } - -- f_90982_.warn("Picking on: [{}] {} gave null item", hitresult$type, s); +- LOGGER.warn("Picking on: [{}] {} gave null item", hitresult$type, s); - } else { -- Inventory inventory = this.f_91074_.m_150109_(); +- Inventory inventory = this.player.getInventory(); - if (blockentity != null) { -- this.m_91122_(itemstack, blockentity); +- this.addCustomNbtData(itemstack, blockentity); - } - -- int i = inventory.m_36030_(itemstack); +- int i = inventory.findSlotMatchingItem(itemstack); - if (flag) { -- inventory.m_36012_(itemstack); -- this.f_91072_.m_105241_(this.f_91074_.m_21120_(InteractionHand.MAIN_HAND), 36 + inventory.f_35977_); +- inventory.setPickedItem(itemstack); +- this.gameMode.handleCreativeModeItemAdd(this.player.getItemInHand(InteractionHand.MAIN_HAND), 36 + inventory.selected); - } else if (i != -1) { -- if (Inventory.m_36045_(i)) { -- inventory.f_35977_ = i; +- if (Inventory.isHotbarSlot(i)) { +- inventory.selected = i; - } else { -- this.f_91072_.m_105206_(i); +- this.gameMode.handlePickItem(i); - } - } - - } -+ if (!net.minecraftforge.client.ForgeHooksClient.onClickInput(2, this.f_91066_.f_92097_, InteractionHand.MAIN_HAND).isCanceled()) -+ net.minecraftforge.common.ForgeHooks.onPickBlock(this.f_91077_, this.f_91074_, this.f_91073_); ++ if (!net.minecraftforge.client.ForgeHooksClient.onClickInput(2, this.options.keyPickItem, InteractionHand.MAIN_HAND).isCanceled()) ++ net.minecraftforge.common.ForgeHooks.onPickBlock(this.hitResult, this.player, this.level); + // We delete this code wholly instead of commenting it out, to make sure we detect changes in it between MC versions } } @@ -2713,8 +_,8 @@ - return this.f_90993_; + return this.renderBuffers; } -- private static Pack m_167933_(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_) { -- int i = p_167938_.m_10374_(); +- private static Pack createClientPackAdapter(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_) { +- int i = p_167938_.getPackFormat(); + private static Pack createClientPackAdapter(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_, boolean hidden) { + int i = p_167938_.getPackFormat(PackType.CLIENT_RESOURCES); Supplier supplier = p_167937_; if (i <= 3) { - supplier = m_91330_(p_167937_); + supplier = adaptV3(p_167937_); @@ -2724,7 +_,7 @@ - supplier = m_91352_(supplier); + supplier = adaptV4(supplier); } - return new Pack(p_167934_, p_167935_, p_167936_, supplier, p_167938_, PackType.CLIENT_RESOURCES, p_167939_, p_167940_); + return new Pack(p_167934_, p_167935_, p_167936_, supplier, p_167938_, PackType.CLIENT_RESOURCES, p_167939_, p_167940_, hidden); } - private static Supplier m_91330_(Supplier p_91331_) { + private static Supplier adaptV3(Supplier p_91331_) { @@ -2741,6 +_,14 @@ - public void m_91312_(int p_91313_) { - this.f_91051_.m_119410_(p_91313_); + public void updateMaxMipLevel(int p_91313_) { + this.modelManager.updateMaxMipLevel(p_91313_); + } + + public ItemColors getItemColors() { -+ return this.f_91041_; ++ return this.itemColors; + } + + public SearchRegistry getSearchTreeManager() { -+ return this.f_90997_; ++ return this.searchRegistry; } - public EntityModelSet m_167973_() { + public EntityModelSet getEntityModels() { diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index c3534811..9147f1f3 100644 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java @@ -69,6 +_,7 @@ - this.f_91510_ = -1; + this.activeButton = -1; } + if (net.minecraftforge.client.ForgeHooksClient.onRawMouseClicked(p_91532_, p_91533_, p_91534_)) return; boolean[] aboolean = new boolean[]{false}; - if (this.f_91503_.m_91265_() == null) { - if (this.f_91503_.f_91080_ == null) { + if (this.minecraft.getOverlay() == null) { + if (this.minecraft.screen == null) { @@ -82,11 +_,19 @@ if (flag) { - screen.m_169415_(); - Screen.m_96579_(() -> { -- aboolean[0] = screen.m_6375_(d0, d1, i); + screen.afterMouseAction(); + Screen.wrapScreenError(() -> { +- aboolean[0] = screen.mouseClicked(d0, d1, i); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPre(screen, d0, d1, i); + if (!aboolean[0]) { -+ aboolean[0] = this.f_91503_.f_91080_.m_6375_(d0, d1, i); ++ aboolean[0] = this.minecraft.screen.mouseClicked(d0, d1, i); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPost(screen, d0, d1, i, aboolean[0]); + } }, "mouseClicked event handler", screen.getClass().getCanonicalName()); } else { - Screen.m_96579_(() -> { -- aboolean[0] = screen.m_6348_(d0, d1, i); + Screen.wrapScreenError(() -> { +- aboolean[0] = screen.mouseReleased(d0, d1, i); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPre(screen, d0, d1, i); + if (!aboolean[0]) { -+ aboolean[0] = this.f_91503_.f_91080_.m_6348_(d0, d1, i); ++ aboolean[0] = this.minecraft.screen.mouseReleased(d0, d1, i); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPost(screen, d0, d1, i, aboolean[0]); + } }, "mouseReleased event handler", screen.getClass().getCanonicalName()); @@ -39,58 +39,58 @@ } } - private void m_91526_(long p_91527_, double p_91528_, double p_91529_) { - if (p_91527_ == Minecraft.m_91087_().m_91268_().m_85439_()) { -- double d0 = (this.f_91503_.f_91066_.f_92045_ ? Math.signum(p_91529_) : p_91529_) * this.f_91503_.f_91066_.f_92033_; + private void onScroll(long p_91527_, double p_91528_, double p_91529_) { + if (p_91527_ == Minecraft.getInstance().getWindow().getWindow()) { +- double d0 = (this.minecraft.options.discreteMouseScroll ? Math.signum(p_91529_) : p_91529_) * this.minecraft.options.mouseWheelSensitivity; + // FORGE: Allows for Horizontal Scroll to be recognized as Vertical Scroll - Fixes MC-121772 + double offset = p_91529_; -+ if (Minecraft.f_91002_ && p_91529_ == 0) { ++ if (Minecraft.ON_OSX && p_91529_ == 0) { + offset = p_91528_; + } -+ double d0 = (this.f_91503_.f_91066_.f_92045_ ? Math.signum(offset) : offset) * this.f_91503_.f_91066_.f_92033_; - if (this.f_91503_.m_91265_() == null) { - if (this.f_91503_.f_91080_ != null) { - double d1 = this.f_91507_ * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); - double d2 = this.f_91508_ * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); -- this.f_91503_.f_91080_.m_6050_(d1, d2, d0); - this.f_91503_.f_91080_.m_169415_(); -+ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPre(this, this.f_91503_.f_91080_, d0)) return; -+ if (this.f_91503_.f_91080_.m_6050_(d1, d2, d0)) return; -+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPost(this, this.f_91503_.f_91080_, d0); - } else if (this.f_91503_.f_91074_ != null) { - if (this.f_91518_ != 0.0D && Math.signum(d0) != Math.signum(this.f_91518_)) { - this.f_91518_ = 0.0D; ++ double d0 = (this.minecraft.options.discreteMouseScroll ? Math.signum(offset) : offset) * this.minecraft.options.mouseWheelSensitivity; + if (this.minecraft.getOverlay() == null) { + if (this.minecraft.screen != null) { + double d1 = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth(); + double d2 = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); +- this.minecraft.screen.mouseScrolled(d1, d2, d0); + this.minecraft.screen.afterMouseAction(); ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPre(this, this.minecraft.screen, d0)) return; ++ if (this.minecraft.screen.mouseScrolled(d1, d2, d0)) return; ++ net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPost(this, this.minecraft.screen, d0); + } else if (this.minecraft.player != null) { + if (this.accumulatedScroll != 0.0D && Math.signum(d0) != Math.signum(this.accumulatedScroll)) { + this.accumulatedScroll = 0.0D; @@ -135,6 +_,7 @@ } - this.f_91518_ -= (double)i; + this.accumulatedScroll -= (double)i; + if (net.minecraftforge.client.ForgeHooksClient.onMouseScroll(this, d0)) return; - if (this.f_91503_.f_91074_.m_5833_()) { - if (this.f_91503_.f_91065_.m_93085_().m_94768_()) { - this.f_91503_.f_91065_.m_93085_().m_205380_(-i); + if (this.minecraft.player.isSpectator()) { + if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { + this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); @@ -203,7 +_,9 @@ - double d2 = (p_91563_ - this.f_91507_) * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); - double d3 = (p_91564_ - this.f_91508_) * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); - Screen.m_96579_(() -> { -- screen.m_7979_(d0, d1, this.f_91510_, d2, d3); -+ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPre(screen, d0, d1, this.f_91510_, d2, d3)) return; -+ if (screen.m_7979_(d0, d1, this.f_91510_, d2, d3)) return; -+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPost(screen, d0, d1, this.f_91510_, d2, d3); + double d2 = (p_91563_ - this.xpos) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth(); + double d3 = (p_91564_ - this.ypos) * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); + Screen.wrapScreenError(() -> { +- screen.mouseDragged(d0, d1, this.activeButton, d2, d3); ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPre(screen, d0, d1, this.activeButton, d2, d3)) return; ++ if (screen.mouseDragged(d0, d1, this.activeButton, d2, d3)) return; ++ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPost(screen, d0, d1, this.activeButton, d2, d3); }, "mouseDragged event handler", screen.getClass().getCanonicalName()); } @@ -286,6 +_,14 @@ - public double m_91594_() { - return this.f_91508_; + public double ypos() { + return this.ypos; + } + + public double getXVelocity() { -+ return this.f_91516_; ++ return this.accumulatedDX; + } + + public double getYVelocity() { -+ return this.f_91517_; ++ return this.accumulatedDY; } - public void m_91599_() { + public void setIgnoreFirstMove() { diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index 826b04f9..6de29bb7 100644 --- a/patches/minecraft/net/minecraft/client/Options.java.patch +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -1,59 +1,59 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java @@ -188,6 +_,7 @@ - public boolean f_92076_; + public boolean syncWrites; public Options(Minecraft p_92138_, File p_92139_) { + setForgeKeybindProperties(); - this.f_92060_ = p_92138_; - this.f_92110_ = new File(p_92139_, "options.txt"); - if (p_92138_.m_91103_() && Runtime.getRuntime().maxMemory() >= 1000000000L) { + this.minecraft = p_92138_; + this.optionsFile = new File(p_92139_, "options.txt"); + if (p_92138_.is64Bit() && Runtime.getRuntime().maxMemory() >= 1000000000L) { @@ -302,10 +_,14 @@ - this.f_193762_ = p_168428_.m_142682_("allowServerListing", this.f_193762_); + this.allowServerListing = p_168428_.process("allowServerListing", this.allowServerListing); - for(KeyMapping keymapping : this.f_92059_) { -- String s = keymapping.m_90865_(); -+ String s = keymapping.m_90865_() + (keymapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keymapping.getKeyModifier() : ""); - String s1 = p_168428_.m_141943_("key_" + keymapping.m_90860_(), s); + for(KeyMapping keymapping : this.keyMappings) { +- String s = keymapping.saveString(); ++ String s = keymapping.saveString() + (keymapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keymapping.getKeyModifier() : ""); + String s1 = p_168428_.process("key_" + keymapping.getName(), s); if (!s.equals(s1)) { -- keymapping.m_90848_(InputConstants.m_84851_(s1)); +- keymapping.setKey(InputConstants.getKey(s1)); + if (s1.indexOf(':') != -1) { + String[] pts = s1.split(":"); -+ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.m_84851_(pts[0])); ++ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.getKey(pts[0])); + } else -+ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.m_84851_(s1)); ++ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.getKey(s1)); } } @@ -493,6 +_,7 @@ } - public void m_92169_() { + public void save() { + if (net.minecraftforge.client.loading.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. try { - final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.f_92110_), StandardCharsets.UTF_8)); + final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8)); @@ -641,6 +_,23 @@ } - p_92146_.m_10509_(set); + p_92146_.setSelected(set); + } + + private void setForgeKeybindProperties() { + net.minecraftforge.client.settings.KeyConflictContext inGame = net.minecraftforge.client.settings.KeyConflictContext.IN_GAME; -+ f_92085_.setKeyConflictContext(inGame); -+ f_92086_.setKeyConflictContext(inGame); -+ f_92087_.setKeyConflictContext(inGame); -+ f_92088_.setKeyConflictContext(inGame); -+ f_92089_.setKeyConflictContext(inGame); -+ f_92090_.setKeyConflictContext(inGame); -+ f_92091_.setKeyConflictContext(inGame); -+ f_92096_.setKeyConflictContext(inGame); -+ f_92098_.setKeyConflictContext(inGame); -+ f_92099_.setKeyConflictContext(inGame); -+ f_92100_.setKeyConflictContext(inGame); -+ f_92103_.setKeyConflictContext(inGame); -+ f_92104_.setKeyConflictContext(inGame); ++ keyUp.setKeyConflictContext(inGame); ++ keyLeft.setKeyConflictContext(inGame); ++ keyDown.setKeyConflictContext(inGame); ++ keyRight.setKeyConflictContext(inGame); ++ keyJump.setKeyConflictContext(inGame); ++ keyShift.setKeyConflictContext(inGame); ++ keySprint.setKeyConflictContext(inGame); ++ keyAttack.setKeyConflictContext(inGame); ++ keyChat.setKeyConflictContext(inGame); ++ keyPlayerList.setKeyConflictContext(inGame); ++ keyCommand.setKeyConflictContext(inGame); ++ keyTogglePerspective.setKeyConflictContext(inGame); ++ keySmoothCamera.setKeyConflictContext(inGame); } - public CameraType m_92176_() { + public CameraType getCameraType() { diff --git a/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch b/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch index 3ee67a58..9998d426 100644 --- a/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch +++ b/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch @@ -6,21 +6,21 @@ @OnlyIn(Dist.CLIENT) -public enum RecipeBookCategories { +public enum RecipeBookCategories implements net.minecraftforge.common.IExtensibleEnum { - CRAFTING_SEARCH(new ItemStack(Items.f_42522_)), - CRAFTING_BUILDING_BLOCKS(new ItemStack(Blocks.f_50076_)), - CRAFTING_REDSTONE(new ItemStack(Items.f_42451_)), + CRAFTING_SEARCH(new ItemStack(Items.COMPASS)), + CRAFTING_BUILDING_BLOCKS(new ItemStack(Blocks.BRICKS)), + CRAFTING_REDSTONE(new ItemStack(Items.REDSTONE)), @@ -36,7 +_,7 @@ - public static final List f_92257_ = ImmutableList.of(BLAST_FURNACE_SEARCH, BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC); - public static final List f_92258_ = ImmutableList.of(FURNACE_SEARCH, FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC); - public static final List f_92259_ = ImmutableList.of(CRAFTING_SEARCH, CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE); -- public static final Map> f_92260_ = ImmutableMap.of(CRAFTING_SEARCH, ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), FURNACE_SEARCH, ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), BLAST_FURNACE_SEARCH, ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), SMOKER_SEARCH, ImmutableList.of(SMOKER_FOOD)); -+ public static final Map> f_92260_ = net.minecraftforge.client.RecipeBookRegistry.AGGREGATE_CATEGORIES_VIEW; - private final List f_92261_; + public static final List BLAST_FURNACE_CATEGORIES = ImmutableList.of(BLAST_FURNACE_SEARCH, BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC); + public static final List FURNACE_CATEGORIES = ImmutableList.of(FURNACE_SEARCH, FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC); + 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(CRAFTING_SEARCH, ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), FURNACE_SEARCH, ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), BLAST_FURNACE_SEARCH, ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), SMOKER_SEARCH, ImmutableList.of(SMOKER_FOOD)); ++ public static final Map> AGGREGATE_CATEGORIES = net.minecraftforge.client.RecipeBookRegistry.AGGREGATE_CATEGORIES_VIEW; + private final List itemIcons; private RecipeBookCategories(ItemStack... p_92267_) { @@ -54,11 +_,17 @@ case SMOKER: - return f_92256_; + return SMOKER_CATEGORIES; default: + if (net.minecraftforge.client.RecipeBookRegistry.TYPE_TO_CATEGORIES_VIEW.containsKey(p_92270_)) + return net.minecraftforge.client.RecipeBookRegistry.TYPE_TO_CATEGORIES_VIEW.get(p_92270_); @@ -28,8 +28,8 @@ } } - public List m_92268_() { - return this.f_92261_; + public List getIconItems() { + return this.itemIcons; + } + + public static RecipeBookCategories create(String name, ItemStack... icons) { diff --git a/patches/minecraft/net/minecraft/client/Screenshot.java.patch b/patches/minecraft/net/minecraft/client/Screenshot.java.patch index e60f21fc..e76cd72a 100644 --- a/patches/minecraft/net/minecraft/client/Screenshot.java.patch +++ b/patches/minecraft/net/minecraft/client/Screenshot.java.patch @@ -11,13 +11,13 @@ + } + final File target = event.getScreenshotFile(); + - Util.m_183992_().execute(() -> { + Util.ioPool().execute(() -> { try { -- nativeimage.m_85056_(file2); -+ nativeimage.m_85056_(target); - Component component = (new TextComponent(file2.getName())).m_130940_(ChatFormatting.UNDERLINE).m_130938_((p_168608_) -> { -- return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())); -+ return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath())); +- nativeimage.writeToFile(file2); ++ nativeimage.writeToFile(target); + Component component = (new TextComponent(file2.getName())).withStyle(ChatFormatting.UNDERLINE).withStyle((p_168608_) -> { +- return p_168608_.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())); ++ return p_168608_.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath())); }); - p_92311_.accept(new TranslatableComponent("screenshot.success", component)); + if (event.getResultMessage() != null) @@ -25,5 +25,5 @@ + else + p_92311_.accept(new TranslatableComponent("screenshot.success", component)); } catch (Exception exception) { - f_92276_.warn("Couldn't save screenshot", (Throwable)exception); + LOGGER.warn("Couldn't save screenshot", (Throwable)exception); p_92311_.accept(new TranslatableComponent("screenshot.failure", exception.getMessage())); diff --git a/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch b/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch index 89dd794f..0fdd0c5a 100644 --- a/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch +++ b/patches/minecraft/net/minecraft/client/ToggleKeyMapping.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/client/ToggleKeyMapping.java @@ -16,7 +_,7 @@ - public void m_7249_(boolean p_92534_) { - if (this.f_92527_.getAsBoolean()) { + public void setDown(boolean p_92534_) { + if (this.needsToggle.getAsBoolean()) { - if (p_92534_) { + if (p_92534_ && isConflictContextAndModifierActive()) { - super.m_7249_(!this.m_90857_()); + super.setDown(!this.isDown()); } } else { @@ -24,4 +_,5 @@ } } -+ @Override public boolean m_90857_() { return this.f_90817_ && (isConflictContextAndModifierActive() || f_92527_.getAsBoolean()); } ++ @Override public boolean isDown() { return this.isDown && (isConflictContextAndModifierActive() || needsToggle.getAsBoolean()); } } diff --git a/patches/minecraft/net/minecraft/client/User.java.patch b/patches/minecraft/net/minecraft/client/User.java.patch index c0856fca..80d4ef43 100644 --- a/patches/minecraft/net/minecraft/client/User.java.patch +++ b/patches/minecraft/net/minecraft/client/User.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/User.java +++ b/net/minecraft/client/User.java @@ -21,8 +_,22 @@ - private final Optional f_193796_; - private final Optional f_193797_; - private final User.Type f_92538_; + private final Optional xuid; + private final Optional clientId; + private final User.Type type; + /** Forge: Cache of the local session's GameProfile properties. */ + private com.mojang.authlib.properties.PropertyMap properties; @@ -20,19 +20,19 @@ + logger.warn("when asking for help!"); + logger.warn("========================================================="); + } - this.f_92535_ = p_193799_; - this.f_92536_ = p_193800_; - this.f_92537_ = p_193801_; + this.name = p_193799_; + this.uuid = p_193800_; + this.accessToken = p_193801_; @@ -58,10 +_,22 @@ - public GameProfile m_92548_() { + public GameProfile getGameProfile() { try { - UUID uuid = UUIDTypeAdapter.fromString(this.m_92545_()); -- return new GameProfile(uuid, this.m_92546_()); -+ GameProfile ret = new GameProfile(uuid, this.m_92546_()); //Forge: Adds cached GameProfile properties to returned GameProfile. + UUID uuid = UUIDTypeAdapter.fromString(this.getUuid()); +- return new GameProfile(uuid, this.getName()); ++ GameProfile ret = new GameProfile(uuid, this.getName()); //Forge: Adds cached GameProfile properties to returned GameProfile. + if (properties != null) ret.getProperties().putAll(properties); // Helps to cut down on calls to the session service, + return ret; // which helps to fix MC-52974. } catch (IllegalArgumentException illegalargumentexception) { - return new GameProfile((UUID)null, this.m_92546_()); + return new GameProfile((UUID)null, this.getName()); } + } + @@ -46,4 +46,4 @@ + return properties != null; } - public User.Type m_168638_() { + public User.Type getType() { diff --git a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch index 531cd100..d8f4a9b3 100644 --- a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch +++ b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch @@ -3,40 +3,40 @@ @@ -28,7 +_,8 @@ @OnlyIn(Dist.CLIENT) public class BlockColors { - private static final int f_168640_ = -1; -- private final IdMapper f_92571_ = new IdMapper<>(32); + private static final int DEFAULT = -1; +- private final IdMapper blockColors = new IdMapper<>(32); + // FORGE: Use RegistryDelegates as non-Vanilla block ids are not constant -+ private final java.util.Map, BlockColor> f_92571_ = new java.util.HashMap<>(); - private final Map>> f_92572_ = Maps.newHashMap(); ++ private final java.util.Map, BlockColor> blockColors = new java.util.HashMap<>(); + private final Map>> coloringStates = Maps.newHashMap(); - public static BlockColors m_92574_() { + public static BlockColors createDefault() { @@ -73,11 +_,12 @@ - blockcolors.m_92589_((p_92596_, p_92597_, p_92598_, p_92599_) -> { + blockcolors.register((p_92596_, p_92597_, p_92598_, p_92599_) -> { return p_92597_ != null && p_92598_ != null ? 2129968 : 7455580; - }, Blocks.f_50196_); + }, Blocks.LILY_PAD); + net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors); return blockcolors; } - public int m_92582_(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) { -- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92583_.m_60734_())); -+ BlockColor blockcolor = this.f_92571_.get(p_92583_.m_60734_().delegate); + public int getColor(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) { +- BlockColor blockcolor = this.blockColors.byId(Registry.BLOCK.getId(p_92583_.getBlock())); ++ BlockColor blockcolor = this.blockColors.get(p_92583_.getBlock().delegate); if (blockcolor != null) { - return blockcolor.m_92566_(p_92583_, (BlockAndTintGetter)null, (BlockPos)null, 0); + return blockcolor.getColor(p_92583_, (BlockAndTintGetter)null, (BlockPos)null, 0); } else { @@ -87,13 +_,13 @@ } - public int m_92577_(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) { -- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92578_.m_60734_())); -+ BlockColor blockcolor = this.f_92571_.get(p_92578_.m_60734_().delegate); - return blockcolor == null ? -1 : blockcolor.m_92566_(p_92578_, p_92579_, p_92580_, p_92581_); + public int getColor(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) { +- BlockColor blockcolor = this.blockColors.byId(Registry.BLOCK.getId(p_92578_.getBlock())); ++ BlockColor blockcolor = this.blockColors.get(p_92578_.getBlock().delegate); + return blockcolor == null ? -1 : blockcolor.getColor(p_92578_, p_92579_, p_92580_, p_92581_); } - public void m_92589_(BlockColor p_92590_, Block... p_92591_) { + public void register(BlockColor p_92590_, Block... p_92591_) { for(Block block : p_92591_) { -- this.f_92571_.m_122664_(p_92590_, Registry.f_122824_.m_7447_(block)); -+ this.f_92571_.put(block.delegate, p_92590_); +- this.blockColors.addMapping(p_92590_, Registry.BLOCK.getId(block)); ++ this.blockColors.put(block.delegate, p_92590_); } } diff --git a/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch index 1ab1c1de..1c200175 100644 --- a/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch +++ b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch @@ -3,31 +3,31 @@ @@ -24,7 +_,8 @@ @OnlyIn(Dist.CLIENT) public class ItemColors { - private static final int f_168642_ = -1; -- private final IdMapper f_92674_ = new IdMapper<>(32); + private static final int DEFAULT = -1; +- private final IdMapper itemColors = new IdMapper<>(32); + // FORGE: Use RegistryDelegates as non-Vanilla item ids are not constant -+ private final java.util.Map, ItemColor> f_92674_ = new java.util.HashMap<>(); ++ private final java.util.Map, ItemColor> itemColors = new java.util.HashMap<>(); - public static ItemColors m_92683_(BlockColors p_92684_) { + public static ItemColors createDefault(BlockColors p_92684_) { ItemColors itemcolors = new ItemColors(); @@ -84,17 +_,18 @@ - itemcolors.m_92689_((p_92693_, p_92694_) -> { - return p_92694_ == 0 ? -1 : MapItem.m_42918_(p_92693_); - }, Items.f_42573_); + itemcolors.register((p_92693_, p_92694_) -> { + return p_92694_ == 0 ? -1 : MapItem.getColor(p_92693_); + }, Items.FILLED_MAP); + net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_92684_); return itemcolors; } - public int m_92676_(ItemStack p_92677_, int p_92678_) { -- ItemColor itemcolor = this.f_92674_.m_7942_(Registry.f_122827_.m_7447_(p_92677_.m_41720_())); -+ ItemColor itemcolor = this.f_92674_.get(p_92677_.m_41720_().delegate); - return itemcolor == null ? -1 : itemcolor.m_92671_(p_92677_, p_92678_); + public int getColor(ItemStack p_92677_, int p_92678_) { +- ItemColor itemcolor = this.itemColors.byId(Registry.ITEM.getId(p_92677_.getItem())); ++ ItemColor itemcolor = this.itemColors.get(p_92677_.getItem().delegate); + return itemcolor == null ? -1 : itemcolor.getColor(p_92677_, p_92678_); } - public void m_92689_(ItemColor p_92690_, ItemLike... p_92691_) { + public void register(ItemColor p_92690_, ItemLike... p_92691_) { for(ItemLike itemlike : p_92691_) { -- this.f_92674_.m_122664_(p_92690_, Item.m_41393_(itemlike.m_5456_())); -+ this.f_92674_.put(itemlike.m_5456_().delegate, p_92690_); +- this.itemColors.addMapping(p_92690_, Item.getId(itemlike.asItem())); ++ this.itemColors.put(itemlike.asItem().delegate, p_92690_); } } diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index 72682e4e..6ccb511a 100644 --- a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch @@ -1,69 +1,69 @@ --- a/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java @@ -411,6 +_,7 @@ - if (this.f_92986_.f_91076_ != null && this.f_92986_.f_91076_ instanceof LivingEntity && f >= 1.0F) { - flag = this.f_92986_.f_91074_.m_36333_() > 5.0F; - flag &= this.f_92986_.f_91076_.m_6084_(); -+ flag &= this.f_92986_.f_91074_.canHit(this.f_92986_.f_91076_, 0); + if (this.minecraft.crosshairPickEntity != null && this.minecraft.crosshairPickEntity instanceof LivingEntity && f >= 1.0F) { + flag = this.minecraft.player.getCurrentItemAttackStrengthDelay() > 5.0F; + flag &= this.minecraft.crosshairPickEntity.isAlive(); ++ flag &= this.minecraft.player.canHit(this.minecraft.crosshairPickEntity, 0); } - int j = this.f_92978_ / 2 - 7 + 16; + int j = this.screenHeight / 2 - 7 + 16; @@ -463,6 +_,10 @@ for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { - MobEffect mobeffect = mobeffectinstance.m_19544_(); + MobEffect mobeffect = mobeffectinstance.getEffect(); + net.minecraftforge.client.EffectRenderer renderer = net.minecraftforge.client.RenderProperties.getEffectRenderer(mobeffectinstance); + if (!renderer.shouldRenderHUD(mobeffectinstance)) continue; + // Rebind in case previous renderHUDEffect changed texture -+ RenderSystem.m_157456_(0, AbstractContainerScreen.f_97725_); - if (mobeffectinstance.m_19575_()) { - int i = this.f_92977_; ++ RenderSystem.setShaderTexture(0, AbstractContainerScreen.INVENTORY_LOCATION); + if (mobeffectinstance.showIcon()) { + int i = this.screenWidth; int j = 1; @@ -500,6 +_,7 @@ - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, f1); - m_93200_(p_93029_, l + 3, i1 + 3, this.m_93252_(), 18, 18, textureatlassprite); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, f1); + blit(p_93029_, l + 3, i1 + 3, this.getBlitOffset(), 18, 18, textureatlassprite); }); -+ renderer.renderHUDEffect(mobeffectinstance,this, p_93029_, i, j, this.m_93252_(), f); ++ renderer.renderHUDEffect(mobeffectinstance,this, p_93029_, i, j, this.getBlitOffset(), f); } } @@ -620,12 +_,13 @@ - public void m_93069_(PoseStack p_93070_) { - this.f_92986_.m_91307_().m_6180_("selectedItemName"); - if (this.f_92993_ > 0 && !this.f_92994_.m_41619_()) { -- MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.f_92994_.m_41786_()).m_130940_(this.f_92994_.m_41791_().f_43022_); -+ MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.f_92994_.m_41786_()).m_130938_(this.f_92994_.m_41791_().getStyleModifier()); - if (this.f_92994_.m_41788_()) { - mutablecomponent.m_130940_(ChatFormatting.ITALIC); + public void renderSelectedItemName(PoseStack p_93070_) { + this.minecraft.getProfiler().push("selectedItemName"); + if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { +- MutableComponent mutablecomponent = (new TextComponent("")).append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color); ++ MutableComponent mutablecomponent = (new TextComponent("")).append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().getStyleModifier()); + if (this.lastToolHighlight.hasCustomHoverName()) { + mutablecomponent.withStyle(ChatFormatting.ITALIC); } -- int i = this.m_93082_().m_92852_(mutablecomponent); -+ Component highlightTip = this.f_92994_.getHighlightTip(mutablecomponent); -+ int i = this.m_93082_().m_92852_(highlightTip); - int j = (this.f_92977_ - i) / 2; - int k = this.f_92978_ - 59; - if (!this.f_92986_.f_91072_.m_105205_()) { +- int i = this.getFont().width(mutablecomponent); ++ Component highlightTip = this.lastToolHighlight.getHighlightTip(mutablecomponent); ++ int i = this.getFont().width(highlightTip); + int j = (this.screenWidth - i) / 2; + int k = this.screenHeight - 59; + if (!this.minecraft.gameMode.canHurtPlayer()) { @@ -641,7 +_,13 @@ - RenderSystem.m_69478_(); - RenderSystem.m_69453_(); - m_93172_(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0)); -- this.m_93082_().m_92763_(p_93070_, mutablecomponent, (float)j, (float)k, 16777215 + (l << 24)); -+ Font font = net.minecraftforge.client.RenderProperties.get(f_92994_).getFont(f_92994_); + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + fill(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.minecraft.options.getBackgroundColor(0)); +- this.getFont().drawShadow(p_93070_, mutablecomponent, (float)j, (float)k, 16777215 + (l << 24)); ++ Font font = net.minecraftforge.client.RenderProperties.get(lastToolHighlight).getFont(lastToolHighlight); + if (font == null) { -+ this.m_93082_().m_92763_(p_93070_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); ++ this.getFont().drawShadow(p_93070_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); + } else { -+ j = (this.f_92977_ - font.m_92852_(highlightTip)) / 2; -+ font.m_92763_(p_93070_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); ++ j = (this.screenWidth - font.width(highlightTip)) / 2; ++ font.drawShadow(p_93070_, highlightTip, (float)j, (float)k, 16777215 + (l << 24)); + } - RenderSystem.m_69461_(); + RenderSystem.disableBlend(); } } @@ -1153,7 +_,7 @@ - ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_(); - if (itemstack.m_41619_()) { - this.f_92993_ = 0; -- } else if (!this.f_92994_.m_41619_() && itemstack.m_150930_(this.f_92994_.m_41720_()) && itemstack.m_41786_().equals(this.f_92994_.m_41786_())) { -+ } else if (!this.f_92994_.m_41619_() && itemstack.m_41720_() == this.f_92994_.m_41720_() && (itemstack.m_41786_().equals(this.f_92994_.m_41786_()) && itemstack.getHighlightTip(itemstack.m_41786_()).equals(f_92994_.getHighlightTip(f_92994_.m_41786_())))) { - if (this.f_92993_ > 0) { - --this.f_92993_; + ItemStack itemstack = this.minecraft.player.getInventory().getSelected(); + if (itemstack.isEmpty()) { + this.toolHighlightTimer = 0; +- } else if (!this.lastToolHighlight.isEmpty() && itemstack.is(this.lastToolHighlight.getItem()) && itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName())) { ++ } else if (!this.lastToolHighlight.isEmpty() && itemstack.getItem() == this.lastToolHighlight.getItem() && (itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName()) && itemstack.getHighlightTip(itemstack.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName())))) { + if (this.toolHighlightTimer > 0) { + --this.toolHighlightTimer; } diff --git a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch index 2c2122cc..ba02b919 100644 --- a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/client/gui/MapRenderer.java @@ -118,6 +_,7 @@ - for(MapDecoration mapdecoration : this.f_93280_.m_164811_()) { - if (!p_93294_ || mapdecoration.m_77809_()) { + for(MapDecoration mapdecoration : this.data.getDecorations()) { + if (!p_93294_ || mapdecoration.renderOnFrame()) { + if (mapdecoration.render(k)) { k++; continue; } - p_93292_.m_85836_(); - p_93292_.m_85837_((double)(0.0F + (float)mapdecoration.m_77804_() / 2.0F + 64.0F), (double)(0.0F + (float)mapdecoration.m_77805_() / 2.0F + 64.0F), (double)-0.02F); - p_93292_.m_85845_(Vector3f.f_122227_.m_122240_((float)(mapdecoration.m_77806_() * 360) / 16.0F)); + p_93292_.pushPose(); + p_93292_.translate((double)(0.0F + (float)mapdecoration.getX() / 2.0F + 64.0F), (double)(0.0F + (float)mapdecoration.getY() / 2.0F + 64.0F), (double)-0.02F); + p_93292_.mulPose(Vector3f.ZP.rotationDegrees((float)(mapdecoration.getRot() * 360) / 16.0F)); diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch index 2f20e136..e09d1066 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch @@ -4,12 +4,12 @@ } -+ public int getWidth() { return this.f_93388_; } -+ public int getHeight() { return this.f_93389_; } -+ public int getTop() { return this.f_93390_; } -+ public int getBottom() { return this.f_93391_; } -+ public int getLeft() { return this.f_93393_; } -+ public int getRight() { return this.f_93392_; } ++ public int getWidth() { return this.width; } ++ public int getHeight() { return this.height; } ++ public int getTop() { return this.y0; } ++ public int getBottom() { return this.y1; } ++ public int getLeft() { return this.x0; } ++ public int getRight() { return this.x1; } + @OnlyIn(Dist.CLIENT) public abstract static class Entry> implements GuiEventListener { 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 130f63de..573b12b5 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java @@ -86,7 +_,7 @@ - this.m_93228_(p_93676_, this.f_93620_, this.f_93621_, 0, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); - this.m_93228_(p_93676_, this.f_93620_ + this.f_93618_ / 2, this.f_93621_, 200 - this.f_93618_ / 2, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); - this.m_7906_(p_93676_, minecraft, p_93677_, p_93678_); -- int j = this.f_93623_ ? 16777215 : 10526880; + this.blit(p_93676_, this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height); + this.blit(p_93676_, this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + this.renderBg(p_93676_, minecraft, p_93677_, p_93678_); +- int j = this.active ? 16777215 : 10526880; + int j = getFGColor(); - m_93215_(p_93676_, font, this.m_6035_(), this.f_93620_ + this.f_93618_ / 2, this.f_93621_ + (this.f_93619_ - 8) / 2, j | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); + drawCenteredString(p_93676_, font, this.getMessage(), this.x + this.width / 2, this.y + (this.height - 8) / 2, j | Mth.ceil(this.alpha * 255.0F) << 24); } @@ -181,6 +_,10 @@ - this.f_93618_ = p_93675_; + this.width = p_93675_; } + public void setHeight(int value) { -+ this.f_93619_ = value; ++ this.height = value; + } + - public void m_93650_(float p_93651_) { - this.f_93625_ = p_93651_; + public void setAlpha(float p_93651_) { + this.alpha = p_93651_; } @@ -203,6 +_,19 @@ - protected void m_93692_(boolean p_93693_) { - this.f_93616_ = p_93693_; + protected void setFocused(boolean p_93693_) { + this.focused = p_93693_; + } + + public static final int UNSET_FG_COLOR = -1; + protected int packedFGColor = UNSET_FG_COLOR; + public int getFGColor() { + if (packedFGColor != UNSET_FG_COLOR) return packedFGColor; -+ return this.f_93623_ ? 16777215 : 10526880; // White : Light Grey ++ return this.active ? 16777215 : 10526880; // White : Light Grey + } + public void setFGColor(int color) { + this.packedFGColor = color; @@ -39,4 +39,4 @@ + this.packedFGColor = UNSET_FG_COLOR; } - public NarratableEntry.NarrationPriority m_142684_() { + public NarratableEntry.NarrationPriority narrationPriority() { 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 f8aa36b2..3d55b3a6 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -2,22 +2,22 @@ +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java @@ -34,6 +_,9 @@ - for(LerpingBossEvent lerpingbossevent : this.f_93699_.values()) { + for(LerpingBossEvent lerpingbossevent : this.events.values()) { int k = i / 2 - 91; + net.minecraftforge.client.event.RenderGameOverlayEvent.BossInfo event = -+ net.minecraftforge.client.ForgeHooksClient.renderBossEventPre(p_93705_, this.f_93698_.m_91268_(), lerpingbossevent, k, j, 10 + this.f_93698_.f_91062_.f_92710_); ++ net.minecraftforge.client.ForgeHooksClient.renderBossEventPre(p_93705_, this.minecraft.getWindow(), lerpingbossevent, k, j, 10 + this.minecraft.font.lineHeight); + if (!event.isCanceled()) { - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.m_157456_(0, f_93697_); - this.m_93706_(p_93705_, k, j, lerpingbossevent); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, GUI_BARS_LOCATION); + this.drawBar(p_93705_, k, j, lerpingbossevent); @@ -42,7 +_,9 @@ int i1 = i / 2 - l / 2; int j1 = j - 9; - this.f_93698_.f_91062_.m_92763_(p_93705_, component, (float)i1, (float)j1, 16777215); + this.minecraft.font.drawShadow(p_93705_, component, (float)i1, (float)j1, 16777215); - j += 10 + 9; + } + j += event.getIncrement(); -+ net.minecraftforge.client.ForgeHooksClient.renderBossEventPost(p_93705_, this.f_93698_.m_91268_()); - if (j >= this.f_93698_.m_91268_().m_85446_() / 3) { ++ net.minecraftforge.client.ForgeHooksClient.renderBossEventPost(p_93705_, this.minecraft.getWindow()); + if (j >= this.minecraft.getWindow().getGuiScaledHeight() / 3) { break; } 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 548584b7..50d41e63 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -3,8 +3,8 @@ @@ -399,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); - list.add(String.valueOf((Object)Registry.f_122826_.m_7981_(entity.m_6095_()))); -+ entity.m_6095_().m_204041_().m_203616_().forEach(t -> list.add("#" + t.f_203868_())); + list.add(String.valueOf((Object)Registry.ENTITY_TYPE.getKey(entity.getType()))); ++ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location())); } return list; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch index 438b09e4..89e9dbbd 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/client/gui/screens/DeathScreen.java @@ -37,6 +_,7 @@ }))); - this.f_169295_.add(this.m_142416_(new Button(this.f_96543_ / 2 - 100, this.f_96544_ / 4 + 96, 200, 20, new TranslatableComponent("deathScreen.titleScreen"), (p_95925_) -> { - if (this.f_95908_) { -+ m_95931_(true); - this.m_95934_(); + this.exitButtons.add(this.addRenderableWidget(new Button(this.width / 2 - 100, this.height / 4 + 96, 200, 20, new TranslatableComponent("deathScreen.titleScreen"), (p_95925_) -> { + if (this.hardcore) { ++ confirmResult(true); + this.exitToTitleScreen(); } else { - ConfirmScreen confirmscreen = new ConfirmScreen(this::m_95931_, new TranslatableComponent("deathScreen.quit.confirm"), TextComponent.f_131282_, new TranslatableComponent("deathScreen.titleScreen"), new TranslatableComponent("deathScreen.respawn")); + ConfirmScreen confirmscreen = new ConfirmScreen(this::confirmResult, new TranslatableComponent("deathScreen.quit.confirm"), TextComponent.EMPTY, new TranslatableComponent("deathScreen.titleScreen"), new TranslatableComponent("deathScreen.respawn")); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index 3fd6dfdd..fd2b93c8 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java @@ -119,6 +_,7 @@ - int k1 = (int)((double)this.f_96163_.m_91268_().m_85446_() * 0.8325D); - float f6 = this.f_96164_.m_7750_(); - this.f_96167_ = Mth.m_14036_(this.f_96167_ * 0.95F + f6 * 0.050000012F, 0.0F, 1.0F); + int k1 = (int)((double)this.minecraft.getWindow().getGuiScaledHeight() * 0.8325D); + float f6 = this.reload.getActualProgress(); + this.currentProgress = Mth.clamp(this.currentProgress * 0.95F + f6 * 0.050000012F, 0.0F, 1.0F); + net.minecraftforge.client.loading.ClientModLoader.renderProgressText(); if (f < 1.0F) { - this.m_96182_(p_96178_, i / 2 - j1, k1 - 5, i / 2 + j1, k1 + 5, 1.0F - Mth.m_14036_(f, 0.0F, 1.0F)); + this.drawProgressBar(p_96178_, i / 2 - j1, k1 - 5, i / 2 + j1, k1 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); } @@ -128,6 +_,7 @@ } - if (this.f_96168_ == -1L && this.f_96164_.m_7746_() && (!this.f_96166_ || f1 >= 2.0F)) { -+ this.f_96168_ = Util.m_137550_(); // Moved up to guard against inf loops caused by callback + if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) { ++ this.fadeOutStart = Util.getMillis(); // Moved up to guard against inf loops caused by callback try { - this.f_96164_.m_7748_(); - this.f_96165_.accept(Optional.empty()); + this.reload.checkExceptions(); + this.onFinish.accept(Optional.empty()); @@ -135,7 +_,6 @@ - this.f_96165_.accept(Optional.of(throwable)); + this.onFinish.accept(Optional.of(throwable)); } -- this.f_96168_ = Util.m_137550_(); - if (this.f_96163_.f_91080_ != null) { - this.f_96163_.f_91080_.m_6575_(this.f_96163_, this.f_96163_.m_91268_().m_85445_(), this.f_96163_.m_91268_().m_85446_()); +- this.fadeOutStart = Util.getMillis(); + if (this.minecraft.screen != null) { + this.minecraft.screen.init(this.minecraft, this.minecraft.getWindow().getGuiScaledWidth(), this.minecraft.getWindow().getGuiScaledHeight()); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch index beff574d..3df9b2b4 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/client/gui/screens/MenuScreens.java +++ b/net/minecraft/client/gui/screens/MenuScreens.java @@ -40,6 +_,10 @@ - private static final Map, MenuScreens.ScreenConstructor> f_96196_ = Maps.newHashMap(); + private static final Map, MenuScreens.ScreenConstructor> SCREENS = Maps.newHashMap(); - public static void m_96201_(@Nullable MenuType p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) { -+ getScreenFactory(p_96202_, p_96203_, p_96204_, p_96205_).ifPresent(f -> f.m_96209_(p_96205_, p_96202_, p_96203_, p_96204_)); + public static void create(@Nullable MenuType p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) { ++ getScreenFactory(p_96202_, p_96203_, p_96204_, p_96205_).ifPresent(f -> f.fromPacket(p_96205_, p_96202_, p_96203_, p_96204_)); + } + + public static java.util.Optional> getScreenFactory(@Nullable MenuType p_96202_, Minecraft p_96203_, int p_96204_, Component p_96205_) { if (p_96202_ == null) { - f_96195_.warn("Trying to open invalid screen with name: {}", (Object)p_96205_.getString()); + LOGGER.warn("Trying to open invalid screen with name: {}", (Object)p_96205_.getString()); } else { @@ -47,9 +_,10 @@ if (screenconstructor == null) { - f_96195_.warn("Failed to create screen for menu type: {}", (Object)Registry.f_122863_.m_7981_(p_96202_)); + LOGGER.warn("Failed to create screen for menu type: {}", (Object)Registry.MENU.getKey(p_96202_)); } else { -- screenconstructor.m_96209_(p_96205_, p_96202_, p_96203_, p_96204_); +- screenconstructor.fromPacket(p_96205_, p_96202_, p_96203_, p_96204_); + return java.util.Optional.of(screenconstructor); } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch index bbb6bf4c..7eee0655 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/gui/screens/OptionsScreen.java +++ b/net/minecraft/client/gui/screens/OptionsScreen.java @@ -141,4 +_,12 @@ - m_93215_(p_96249_, this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215); - super.m_6305_(p_96249_, p_96250_, p_96251_, p_96252_); + drawCenteredString(p_96249_, this.font, this.title, this.width / 2, 15, 16777215); + super.render(p_96249_, p_96250_, p_96251_, p_96252_); } + + @Override -+ public void m_7379_() { ++ public void onClose() { + // We need to consider 2 potential parent screens here: + // 1. From the main menu, in which case display the main menu + // 2. From the pause menu, in which case exit back to game -+ this.f_96541_.m_91152_(this.f_96235_ instanceof PauseScreen ? null : this.f_96235_); ++ this.minecraft.setScreen(this.lastScreen instanceof PauseScreen ? null : this.lastScreen); + } } 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 4ee57876..e440d780 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -3,207 +3,207 @@ @@ -127,7 +_,7 @@ } - public void m_7379_() { -- this.f_96541_.m_91152_((Screen)null); -+ this.f_96541_.popGuiLayer(); + public void onClose() { +- this.minecraft.setScreen((Screen)null); ++ this.minecraft.popGuiLayer(); } - protected T m_142416_(T p_169406_) { + protected T addRenderableWidget(T p_169406_) { @@ -164,15 +_,29 @@ - this.f_169368_.clear(); + this.narratables.clear(); } + private Font tooltipFont = null; -+ private ItemStack tooltipStack = ItemStack.f_41583_; - protected void m_6057_(PoseStack p_96566_, ItemStack p_96567_, int p_96568_, int p_96569_) { ++ private ItemStack tooltipStack = ItemStack.EMPTY; + protected void renderTooltip(PoseStack p_96566_, ItemStack p_96567_, int p_96568_, int p_96569_) { + tooltipStack = p_96567_; - this.m_169388_(p_96566_, this.m_96555_(p_96567_), p_96567_.m_150921_(), p_96568_, p_96569_); -+ tooltipStack = ItemStack.f_41583_; + this.renderTooltip(p_96566_, this.getTooltipFromItem(p_96567_), p_96567_.getTooltipImage(), p_96568_, p_96569_); ++ tooltipStack = ItemStack.EMPTY; } + public void renderTooltip(PoseStack poseStack, List textComponents, Optional tooltipComponent, int x, int y, ItemStack stack) { + this.renderTooltip(poseStack, textComponents, tooltipComponent, x, y, null, stack); + } + public void renderTooltip(PoseStack poseStack, List textComponents, Optional tooltipComponent, int x, int y, @Nullable Font font) { -+ this.renderTooltip(poseStack, textComponents, tooltipComponent, x, y, font, ItemStack.f_41583_); ++ this.renderTooltip(poseStack, textComponents, tooltipComponent, x, y, font, ItemStack.EMPTY); + } + public void renderTooltip(PoseStack poseStack, List textComponents, Optional tooltipComponent, int x, int y, @Nullable Font font, ItemStack stack) { + this.tooltipFont = font; + this.tooltipStack = stack; -+ this.m_169388_(poseStack, textComponents, tooltipComponent, x, y); ++ this.renderTooltip(poseStack, textComponents, tooltipComponent, x, y); + this.tooltipFont = null; -+ this.tooltipStack = ItemStack.f_41583_; ++ this.tooltipStack = ItemStack.EMPTY; + } - public void m_169388_(PoseStack p_169389_, List p_169390_, Optional p_169391_, int p_169392_, int p_169393_) { -- List list = p_169390_.stream().map(Component::m_7532_).map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()); + public void renderTooltip(PoseStack p_169389_, List p_169390_, Optional p_169391_, int p_169392_, int p_169393_) { +- List list = p_169390_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Collectors.toList()); - p_169391_.ifPresent((p_169399_) -> { -- list.add(1, ClientTooltipComponent.m_169950_(p_169399_)); +- list.add(1, ClientTooltipComponent.create(p_169399_)); - }); -+ List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_169390_, p_169391_, p_169392_, f_96543_, f_96544_, this.tooltipFont, this.f_96547_); - this.m_169383_(p_169389_, list, p_169392_, p_169393_); ++ List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_169390_, p_169391_, p_169392_, width, height, this.tooltipFont, this.font); + this.renderTooltipInternal(p_169389_, list, p_169392_, p_169393_); } @@ -185,20 +_,44 @@ } - public void m_96597_(PoseStack p_96598_, List p_96599_, int p_96600_, int p_96601_) { -- this.m_96617_(p_96598_, Lists.transform(p_96599_, Component::m_7532_), p_96600_, p_96601_); -+ List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_96599_, p_96600_, f_96543_, f_96544_, this.tooltipFont, this.f_96547_); -+ this.m_169383_(p_96598_, components, p_96600_, p_96601_); + public void renderComponentTooltip(PoseStack p_96598_, List p_96599_, int p_96600_, int p_96601_) { +- this.renderTooltip(p_96598_, Lists.transform(p_96599_, Component::getVisualOrderText), p_96600_, p_96601_); ++ List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_96599_, p_96600_, width, height, this.tooltipFont, this.font); ++ this.renderTooltipInternal(p_96598_, components, p_96600_, p_96601_); + } + public void renderComponentTooltip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, ItemStack stack) { + this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, null, stack); + } + public void renderComponentTooltip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, @Nullable Font font) { -+ this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, font, ItemStack.f_41583_); ++ this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, font, ItemStack.EMPTY); + } + + public void renderComponentTooltip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, @Nullable Font font, ItemStack stack) { + this.tooltipFont = font; + this.tooltipStack = stack; -+ List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, f_96543_, f_96544_, this.tooltipFont, this.f_96547_); -+ this.m_169383_(poseStack, components, mouseX, mouseY); ++ List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, width, height, this.tooltipFont, this.font); ++ this.renderTooltipInternal(poseStack, components, mouseX, mouseY); + this.tooltipFont = null; -+ this.tooltipStack = ItemStack.f_41583_; ++ this.tooltipStack = ItemStack.EMPTY; } - public void m_96617_(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_) { - this.m_169383_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_); + public void renderTooltip(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_) { + this.renderTooltipInternal(p_96618_, p_96619_.stream().map(ClientTooltipComponent::create).collect(Collectors.toList()), p_96620_, p_96621_); } + public void renderTooltip(PoseStack poseStack, List lines, int x, int y, Font font) { + this.tooltipFont = font; -+ this.m_96617_(poseStack, lines, x, y); ++ this.renderTooltip(poseStack, lines, x, y); + this.tooltipFont = null; + } + - private void m_169383_(PoseStack p_169384_, List p_169385_, int p_169386_, int p_169387_) { + private void renderTooltipInternal(PoseStack p_169384_, List p_169385_, int p_169386_, int p_169387_) { if (!p_169385_.isEmpty()) { -+ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, p_169384_, p_169386_, p_169387_, f_96543_, f_96544_, p_169385_, this.tooltipFont, this.f_96547_); ++ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, p_169384_, p_169386_, p_169387_, width, height, p_169385_, this.tooltipFont, this.font); + if (preEvent.isCanceled()) return; int i = 0; int j = p_169385_.size() == 1 ? -2 : 0; for(ClientTooltipComponent clienttooltipcomponent : p_169385_) { -- int k = clienttooltipcomponent.m_142069_(this.f_96547_); -+ int k = clienttooltipcomponent.m_142069_(preEvent.getFont()); +- int k = clienttooltipcomponent.getWidth(this.font); ++ int k = clienttooltipcomponent.getWidth(preEvent.getFont()); if (k > i) { i = k; } @@ -206,8 +_,8 @@ - j += clienttooltipcomponent.m_142103_(); + j += clienttooltipcomponent.getHeight(); } - int j2 = p_169386_ + 12; - int k2 = p_169387_ - 12; + int j2 = preEvent.getX() + 12; + int k2 = preEvent.getY() - 12; - if (j2 + i > this.f_96543_) { + if (j2 + i > this.width) { j2 -= 28 + i; } @@ -228,15 +_,16 @@ - RenderSystem.m_157427_(GameRenderer::m_172811_); - bufferbuilder.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85815_); - Matrix4f matrix4f = p_169384_.m_85850_().m_85861_(); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, 1347420415, 1344798847); -- m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, 1347420415, 1344798847); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, 1347420415, 1347420415); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, 1344798847, 1344798847); + RenderSystem.setShader(GameRenderer::getPositionColorShader); + bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + Matrix4f matrix4f = p_169384_.last().pose(); +- fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, -267386864, -267386864); +- fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, -267386864, -267386864); +- fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, -267386864, -267386864); +- fillGradient(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, -267386864, -267386864); +- fillGradient(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, -267386864, -267386864); +- fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, 1347420415, 1344798847); +- fillGradient(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, 1347420415, 1344798847); +- fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, 1347420415, 1347420415); +- fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, 1344798847, 1344798847); + net.minecraftforge.client.event.RenderTooltipEvent.Color colorEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipColor(this.tooltipStack, p_169384_, j2, k2, preEvent.getFont(), p_169385_); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundStart()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, colorEvent.getBackgroundEnd(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderStart()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBorderEnd(), colorEvent.getBorderEnd()); - RenderSystem.m_69482_(); - RenderSystem.m_69472_(); - RenderSystem.m_69478_(); ++ fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundStart()); ++ fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, colorEvent.getBackgroundEnd(), colorEvent.getBackgroundEnd()); ++ fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); ++ fillGradient(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); ++ fillGradient(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); ++ fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd()); ++ fillGradient(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd()); ++ fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderStart()); ++ fillGradient(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBorderEnd(), colorEvent.getBorderEnd()); + RenderSystem.enableDepthTest(); + RenderSystem.disableTexture(); + RenderSystem.enableBlend(); @@ -251,7 +_,7 @@ for(int i2 = 0; i2 < p_169385_.size(); ++i2) { ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2); -- clienttooltipcomponent1.m_142440_(this.f_96547_, j2, l1, matrix4f, multibuffersource$buffersource); -+ clienttooltipcomponent1.m_142440_(preEvent.getFont(), j2, l1, matrix4f, multibuffersource$buffersource); - l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0); +- clienttooltipcomponent1.renderText(this.font, j2, l1, matrix4f, multibuffersource$buffersource); ++ clienttooltipcomponent1.renderText(preEvent.getFont(), j2, l1, matrix4f, multibuffersource$buffersource); + l1 += clienttooltipcomponent1.getHeight() + (i2 == 0 ? 2 : 0); } @@ -261,7 +_,7 @@ for(int l2 = 0; l2 < p_169385_.size(); ++l2) { ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2); -- clienttooltipcomponent2.m_183452_(this.f_96547_, j2, l1, p_169384_, this.f_96542_, 400); -+ clienttooltipcomponent2.m_183452_(preEvent.getFont(), j2, l1, p_169384_, this.f_96542_, 400); - l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0); +- clienttooltipcomponent2.renderImage(this.font, j2, l1, p_169384_, this.itemRenderer, 400); ++ clienttooltipcomponent2.renderImage(preEvent.getFont(), j2, l1, p_169384_, this.itemRenderer, 400); + l1 += clienttooltipcomponent2.getHeight() + (l2 == 0 ? 2 : 0); } @@ -355,9 +_,12 @@ } - public void m_96612_(String p_96613_, boolean p_96614_) { + public void sendMessage(String p_96613_, boolean p_96614_) { + p_96613_ = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(p_96613_); + if (p_96613_.isEmpty()) return; if (p_96614_) { - this.f_96541_.f_91065_.m_93076_().m_93783_(p_96613_); + this.minecraft.gui.getChat().addRecentChat(p_96613_); } + if (net.minecraftforge.client.ClientCommandHandler.sendMessage(p_96613_)) return; - this.f_96541_.f_91074_.m_108739_(p_96613_); + this.minecraft.player.chat(p_96613_); } @@ -368,11 +_,21 @@ - this.f_96547_ = p_96607_.f_91062_; - this.f_96543_ = p_96608_; - this.f_96544_ = p_96609_; + this.font = p_96607_.font; + this.width = p_96608_; + this.height = p_96609_; + java.util.function.Consumer add = (b) -> { + if (b instanceof Widget w) -+ this.f_169369_.add(w); ++ this.renderables.add(w); + if (b instanceof NarratableEntry ne) -+ this.f_169368_.add(ne); -+ f_96540_.add(b); ++ this.narratables.add(ne); ++ children.add(b); + }; -+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Pre(this, this.f_96540_, add, this::m_169411_))) { - this.m_169413_(); - this.m_7522_((GuiEventListener)null); - this.m_7856_(); - this.m_169407_(false); - this.m_169378_(f_169370_); ++ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Pre(this, this.children, add, this::removeWidget))) { + this.clearWidgets(); + this.setFocused((GuiEventListener)null); + this.init(); + this.triggerImmediateNarration(false); + this.suppressNarration(NARRATE_SUPPRESS_AFTER_INIT_TIME); + } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Post(this, this.f_96540_, add, this::m_169411_)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Post(this, this.children, add, this::removeWidget)); } - public List m_6702_() { + public List children() { @@ -395,6 +_,7 @@ - public void m_96558_(PoseStack p_96559_, int p_96560_) { - if (this.f_96541_.f_91073_ != null) { - this.m_93179_(p_96559_, 0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680); + public void renderBackground(PoseStack p_96559_, int p_96560_) { + if (this.minecraft.level != null) { + this.fillGradient(p_96559_, 0, 0, this.width, this.height, -1072689136, -804253680); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.BackgroundDrawnEvent(this, p_96559_)); } else { - this.m_96626_(p_96560_); + this.renderDirtBackground(p_96560_); } @@ -414,6 +_,7 @@ - bufferbuilder.m_5483_((double)this.f_96543_, 0.0D, 0.0D).m_7421_((float)this.f_96543_ / 32.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); - bufferbuilder.m_5483_(0.0D, 0.0D, 0.0D).m_7421_(0.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); - tesselator.m_85914_(); + bufferbuilder.vertex((double)this.width, 0.0D, 0.0D).uv((float)this.width / 32.0F, (float)p_96627_).color(64, 64, 64, 255).endVertex(); + bufferbuilder.vertex(0.0D, 0.0D, 0.0D).uv(0.0F, (float)p_96627_).color(64, 64, 64, 255).endVertex(); + tesselator.end(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.BackgroundDrawnEvent(this, new PoseStack())); } - public boolean m_7043_() { + public boolean isPauseScreen() { @@ -499,6 +_,10 @@ } - public void m_7400_(List p_96591_) { + public void onFilesDrop(List p_96591_) { + } + + public Minecraft getMinecraft() { -+ return this.f_96541_; ++ return this.minecraft; } - private void m_169380_(long p_169381_, boolean p_169382_) { + private void scheduleNarration(long p_169381_, boolean p_169382_) { 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 acd4dcb6..4f02bc44 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -1,68 +1,68 @@ --- a/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java @@ -73,6 +_,7 @@ - private TitleScreen.Warning32Bit f_210857_; - private RealmsClient f_210858_; - private boolean f_210859_ = false; + private TitleScreen.Warning32Bit warning32Bit; + private RealmsClient realmsClient; + private boolean realms32bitWarningShown = false; + private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification; public TitleScreen() { this(false); @@ -131,11 +_,16 @@ - int j = this.f_96543_ - i - 2; + int j = this.width - i - 2; int k = 24; - int l = this.f_96544_ / 4 + 48; + int l = this.height / 4 + 48; + Button modButton = null; - if (this.f_96541_.m_91402_()) { - this.m_96772_(l, 24); + if (this.minecraft.isDemo()) { + this.createDemoMenuOptions(l, 24); } else { - this.m_96763_(l, 24); -+ modButton = this.m_142416_(new Button(this.f_96543_ / 2 - 100, l + 24 * 2, 98, 20, new TranslatableComponent("fml.menu.mods"), button -> { -+ this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this)); + this.createNormalMenuOptions(l, 24); ++ modButton = this.addRenderableWidget(new Button(this.width / 2 - 100, l + 24 * 2, 98, 20, new TranslatableComponent("fml.menu.mods"), button -> { ++ this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this)); + })); } + modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton); - this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, l + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_96791_) -> { - this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_())); + this.addRenderableWidget(new ImageButton(this.width / 2 - 124, l + 72 + 12, 20, 20, 0, 106, 20, Button.WIDGETS_LOCATION, 256, 256, (p_96791_) -> { + this.minecraft.setScreen(new LanguageSelectScreen(this, this.minecraft.options, this.minecraft.getLanguageManager())); @@ -201,7 +_,7 @@ - Screen screen = (Screen)(this.f_96541_.f_91066_.f_92083_ ? new JoinMultiplayerScreen(this) : new SafetyScreen(this)); - this.f_96541_.m_91152_(screen); - }, button$ontooltip))).f_93623_ = flag; -- (this.m_142416_(new Button(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20, new TranslatableComponent("menu.online"), (p_211788_) -> { -+ (this.m_142416_(new Button(this.f_96543_ / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20, new TranslatableComponent("menu.online"), (p_96771_) -> { - this.m_96793_(); - }, button$ontooltip))).f_93623_ = flag; + Screen screen = (Screen)(this.minecraft.options.skipMultiplayerWarning ? new JoinMultiplayerScreen(this) : new SafetyScreen(this)); + this.minecraft.setScreen(screen); + }, button$ontooltip))).active = flag; +- (this.addRenderableWidget(new Button(this.width / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20, new TranslatableComponent("menu.online"), (p_211788_) -> { ++ (this.addRenderableWidget(new Button(this.width / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20, new TranslatableComponent("menu.online"), (p_96771_) -> { + this.realmsButtonClicked(); + }, button$ontooltip))).active = flag; } @@ -331,6 +_,7 @@ - this.f_210857_.f_210875_.m_6514_(p_96739_, this.f_210857_.f_210876_, this.f_210857_.f_210877_, 9, 16777215 | l); + this.warning32Bit.label.renderCentered(p_96739_, this.warning32Bit.x, this.warning32Bit.y, 9, 16777215 | l); } -+ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_96739_, this.f_96547_, this.f_96543_, this.f_96544_, l); - if (this.f_96721_ != null) { - p_96739_.m_85836_(); - p_96739_.m_85837_((double)(this.f_96543_ / 2 + 90), 70.0D, 0.0D); ++ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_96739_, this.font, this.width, this.height, l); + if (this.splash != null) { + p_96739_.pushPose(); + p_96739_.translate((double)(this.width / 2 + 90), 70.0D, 0.0D); @@ -353,7 +_,14 @@ - s = s + I18n.m_118938_("menu.modded"); + s = s + I18n.get("menu.modded"); } -- m_93236_(p_96739_, this.f_96547_, s, 2, this.f_96544_ - 10, 16777215 | l); +- drawString(p_96739_, this.font, s, 2, this.height - 10, 16777215 | l); + net.minecraftforge.internal.BrandingControl.forEachLine(true, true, (brdline, brd) -> -+ m_93236_(p_96739_, this.f_96547_, brd, 2, this.f_96544_ - ( 10 + brdline * (this.f_96547_.f_92710_ + 1)), 16777215 | l) ++ drawString(p_96739_, this.font, brd, 2, this.height - ( 10 + brdline * (this.font.lineHeight + 1)), 16777215 | l) + ); + + net.minecraftforge.internal.BrandingControl.forEachAboveCopyrightLine((brdline, brd) -> -+ m_93236_(p_96739_, this.f_96547_, brd, this.f_96543_ - f_96547_.m_92895_(brd), this.f_96544_ - (10 + (brdline + 1) * ( this.f_96547_.f_92710_ + 1)), 16777215 | l) ++ drawString(p_96739_, this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * ( this.font.lineHeight + 1)), 16777215 | l) + ); + - for(GuiEventListener guieventlistener : this.m_6702_()) { + for(GuiEventListener guieventlistener : this.children()) { if (guieventlistener instanceof AbstractWidget) { @@ -365,6 +_,7 @@ - if (this.m_96789_() && f1 >= 1.0F) { - this.f_96726_.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); + if (this.realmsNotificationsEnabled() && f1 >= 1.0F) { + this.realmsNotificationsScreen.render(p_96739_, p_96740_, p_96741_, p_96742_); } -+ if (f1 >= 1.0f) modUpdateNotification.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); ++ if (f1 >= 1.0f) modUpdateNotification.render(p_96739_, p_96740_, p_96741_, p_96742_); } } 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 c00f842b..295ed1e7 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,15 +1,15 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java @@ -39,6 +_,7 @@ - private int f_97141_ = Integer.MIN_VALUE; - private float f_97142_; - private boolean f_97143_; + private int maxY = Integer.MIN_VALUE; + private float fade; + private boolean centered; + private int page; public AdvancementTab(Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, Advancement p_97149_, DisplayInfo p_97150_) { - this.f_97126_ = p_97145_; + this.minecraft = p_97145_; @@ -53,6 +_,15 @@ - this.m_97175_(this.f_97134_, p_97149_); + this.addWidget(this.root, p_97149_); } + public AdvancementTab(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, Advancement adv, DisplayInfo info) { @@ -21,17 +21,17 @@ + return page; + } + - public AdvancementTabType m_169538_() { - return this.f_97128_; + public AdvancementTabType getType() { + return this.type; } @@ -165,8 +_,8 @@ return null; } else { for(AdvancementTabType advancementtabtype : AdvancementTabType.values()) { -- if (p_97173_ < advancementtabtype.m_97210_()) { -- return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_, p_97174_, p_97174_.m_138320_()); -+ if ((p_97173_ % AdvancementTabType.MAX_TABS) < advancementtabtype.m_97210_()) { -+ return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_ % AdvancementTabType.MAX_TABS, p_97173_ / AdvancementTabType.MAX_TABS, p_97174_, p_97174_.m_138320_()); +- if (p_97173_ < advancementtabtype.getMax()) { +- return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_, p_97174_, p_97174_.getDisplay()); ++ if ((p_97173_ % AdvancementTabType.MAX_TABS) < advancementtabtype.getMax()) { ++ return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_ % AdvancementTabType.MAX_TABS, p_97173_ / AdvancementTabType.MAX_TABS, p_97174_, p_97174_.getDisplay()); } - p_97173_ -= advancementtabtype.m_97210_(); + p_97173_ -= advancementtabtype.getMax(); 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 95042774..eb412fe1 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 @@ -4,7 +4,7 @@ LEFT(0, 64, 32, 28, 5), RIGHT(96, 64, 32, 28, 5); -+ public static final int MAX_TABS = java.util.Arrays.stream(values()).mapToInt(e -> e.f_97199_).sum(); - private final int f_97195_; - private final int f_97196_; - private final int f_97197_; ++ public static final int MAX_TABS = java.util.Arrays.stream(values()).mapToInt(e -> e.max).sum(); + private final int textureX; + private final int textureY; + private final int width; 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 e69bb8ba..c1a43780 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 @@ -2,69 +2,69 @@ +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java @@ -43,6 +_,7 @@ @Nullable - private AdvancementTab f_97336_; - private boolean f_97337_; + private AdvancementTab selectedTab; + private boolean isScrolling; + private static int tabPage, maxPages; public AdvancementsScreen(ClientAdvancements p_97340_) { - super(NarratorChatListener.f_93310_); + super(NarratorChatListener.NO_TITLE); @@ -58,7 +_,13 @@ } else { - this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true); + this.advancements.setSelectedTab(this.selectedTab == null ? null : this.selectedTab.getAdvancement(), true); } - -+ if (this.f_97335_.size() > AdvancementTabType.MAX_TABS) { -+ int guiLeft = (this.f_96543_ - 252) / 2; -+ int guiTop = (this.f_96544_ - 140) / 2; -+ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); -+ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); -+ maxPages = this.f_97335_.size() / AdvancementTabType.MAX_TABS; ++ if (this.tabs.size() > AdvancementTabType.MAX_TABS) { ++ int guiLeft = (this.width - 252) / 2; ++ int guiTop = (this.height - 140) / 2; ++ addRenderableWidget(new net.minecraft.client.gui.components.Button(guiLeft, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); ++ addRenderableWidget(new net.minecraft.client.gui.components.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); ++ maxPages = this.tabs.size() / AdvancementTabType.MAX_TABS; + } } - public void m_7861_() { + public void removed() { @@ -76,7 +_,7 @@ - int j = (this.f_96544_ - 140) / 2; + int j = (this.height - 140) / 2; - for(AdvancementTab advancementtab : this.f_97335_.values()) { -- if (advancementtab.m_97154_(i, j, p_97343_, p_97344_)) { -+ if (advancementtab.getPage() == tabPage && advancementtab.m_97154_(i, j, p_97343_, p_97344_)) { - this.f_97334_.m_104401_(advancementtab.m_97182_(), true); + for(AdvancementTab advancementtab : this.tabs.values()) { +- if (advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) { ++ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) { + this.advancements.setSelectedTab(advancementtab.getAdvancement(), true); break; } @@ -100,6 +_,11 @@ - int i = (this.f_96543_ - 252) / 2; - int j = (this.f_96544_ - 140) / 2; - this.m_7333_(p_97361_); + int i = (this.width - 252) / 2; + int j = (this.height - 140) / 2; + this.renderBackground(p_97361_); + if (maxPages != 0) { + net.minecraft.network.chat.Component page = new net.minecraft.network.chat.TextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); -+ int width = this.f_96547_.m_92852_(page); -+ this.f_96547_.m_92744_(p_97361_, page.m_7532_(), i + (252 / 2) - (width / 2), j - 44, -1); ++ int width = this.font.width(page); ++ this.font.drawShadow(p_97361_, page.getVisualOrderText(), i + (252 / 2) - (width / 2), j - 44, -1); + } - this.m_97373_(p_97361_, p_97362_, p_97363_, i, j); - this.m_97356_(p_97361_, i, j); - this.m_97381_(p_97361_, p_97362_, p_97363_, i, j); + this.renderInside(p_97361_, p_97362_, p_97363_, i, j); + this.renderWindow(p_97361_, i, j); + this.renderTooltips(p_97361_, p_97362_, p_97363_, i, j); @@ -150,12 +_,14 @@ - RenderSystem.m_157456_(0, f_97330_); + RenderSystem.setShaderTexture(0, TABS_LOCATION); - for(AdvancementTab advancementtab : this.f_97335_.values()) { + for(AdvancementTab advancementtab : this.tabs.values()) { + if (advancementtab.getPage() == tabPage) - advancementtab.m_97165_(p_97357_, p_97358_, p_97359_, advancementtab == this.f_97336_); + advancementtab.drawTab(p_97357_, p_97358_, p_97359_, advancementtab == this.selectedTab); } - RenderSystem.m_69453_(); + RenderSystem.defaultBlendFunc(); - for(AdvancementTab advancementtab1 : this.f_97335_.values()) { + for(AdvancementTab advancementtab1 : this.tabs.values()) { + if (advancementtab1.getPage() == tabPage) - advancementtab1.m_97159_(p_97358_, p_97359_, this.f_96542_); + advancementtab1.drawIcon(p_97358_, p_97359_, this.itemRenderer); } @@ -181,7 +_,7 @@ - if (this.f_97335_.size() > 1) { - for(AdvancementTab advancementtab : this.f_97335_.values()) { -- if (advancementtab.m_97154_(p_97385_, p_97386_, (double)p_97383_, (double)p_97384_)) { -+ if (advancementtab.getPage() == tabPage && advancementtab.m_97154_(p_97385_, p_97386_, (double)p_97383_, (double)p_97384_)) { - this.m_96602_(p_97382_, advancementtab.m_97189_(), p_97383_, p_97384_); + if (this.tabs.size() > 1) { + for(AdvancementTab advancementtab : this.tabs.values()) { +- if (advancementtab.isMouseOver(p_97385_, p_97386_, (double)p_97383_, (double)p_97384_)) { ++ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(p_97385_, p_97386_, (double)p_97383_, (double)p_97384_)) { + this.renderTooltip(p_97382_, advancementtab.getTitle(), p_97383_, p_97384_); } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch index 6343977b..21e1db92 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch @@ -3,58 +3,58 @@ @@ -53,7 +_,7 @@ } - protected int m_5756_() { -- return super.m_5756_() + 15; -+ return super.m_5756_() + 15 + 20; + protected int getScrollbarPosition() { +- return super.getScrollbarPosition() + 15; ++ return super.getScrollbarPosition() + 15 + 20; } - public int m_5759_() { + public int getRowWidth() { @@ -109,7 +_,7 @@ KeyEntry(final KeyMapping p_193916_, final Component p_193917_) { - this.f_193910_ = p_193916_; - this.f_193911_ = p_193917_; -- this.f_193912_ = new Button(0, 0, 75, 20, p_193917_, (p_193939_) -> { -+ this.f_193912_ = new Button(0, 0, 75 + 20 /* Forge: Add space */, 20, p_193917_, (p_193939_) -> { - KeyBindsList.this.f_193858_.f_193975_ = p_193916_; + this.key = p_193916_; + this.name = p_193917_; +- this.changeButton = new Button(0, 0, 75, 20, p_193917_, (p_193939_) -> { ++ this.changeButton = new Button(0, 0, 75 + 20 /* Forge: Add space */, 20, p_193917_, (p_193939_) -> { + KeyBindsList.this.keyBindsScreen.selectedKey = p_193916_; }) { - protected MutableComponent m_5646_() { + protected MutableComponent createNarrationMessage() { @@ -117,6 +_,7 @@ } }; - this.f_193913_ = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_193935_) -> { -+ this.f_193910_.setToDefault(); - KeyBindsList.this.f_93386_.f_91066_.m_92159_(p_193916_, p_193916_.m_90861_()); - KeyMapping.m_90854_(); + this.resetButton = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_193935_) -> { ++ this.key.setToDefault(); + KeyBindsList.this.minecraft.options.setKey(p_193916_, p_193916_.getDefaultKey()); + KeyMapping.resetMapping(); }) { @@ -130,7 +_,7 @@ - boolean flag = KeyBindsList.this.f_193858_.f_193975_ == this.f_193910_; - float f = (float)(p_193926_ + 90 - KeyBindsList.this.f_193859_); - KeyBindsList.this.f_93386_.f_91062_.m_92889_(p_193923_, this.f_193911_, f, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215); -- this.f_193913_.f_93620_ = p_193926_ + 190; -+ this.f_193913_.f_93620_ = p_193926_ + 190 + 20; - this.f_193913_.f_93621_ = p_193925_; - this.f_193913_.f_93623_ = !this.f_193910_.m_90864_(); - this.f_193913_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); + boolean flag = KeyBindsList.this.keyBindsScreen.selectedKey == this.key; + float f = (float)(p_193926_ + 90 - KeyBindsList.this.maxNameWidth); + KeyBindsList.this.minecraft.font.draw(p_193923_, this.name, f, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215); +- this.resetButton.x = p_193926_ + 190; ++ this.resetButton.x = p_193926_ + 190 + 20; + this.resetButton.y = p_193925_; + this.resetButton.active = !this.key.isDefault(); + this.resetButton.render(p_193923_, p_193929_, p_193930_, p_193932_); @@ -138,11 +_,12 @@ - this.f_193912_.f_93621_ = p_193925_; - this.f_193912_.m_93666_(this.f_193910_.m_90863_()); + this.changeButton.y = p_193925_; + this.changeButton.setMessage(this.key.getTranslatedKeyMessage()); boolean flag1 = false; + boolean keyCodeModifierConflict = true; // gracefully handle conflicts like SHIFT vs SHIFT+G - if (!this.f_193910_.m_90862_()) { - for(KeyMapping keymapping : KeyBindsList.this.f_93386_.f_91066_.f_92059_) { - if (keymapping != this.f_193910_ && this.f_193910_.m_90850_(keymapping)) { + if (!this.key.isUnbound()) { + for(KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) { + if (keymapping != this.key && this.key.same(keymapping)) { flag1 = true; - break; -+ keyCodeModifierConflict &= keymapping.hasKeyModifierConflict(this.f_193910_); ++ keyCodeModifierConflict &= keymapping.hasKeyModifierConflict(this.key); } } } @@ -150,7 +_,7 @@ if (flag) { - this.f_193912_.m_93666_((new TextComponent("> ")).m_7220_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW)); + this.changeButton.setMessage((new TextComponent("> ")).append(this.changeButton.getMessage().copy().withStyle(ChatFormatting.YELLOW)).append(" <").withStyle(ChatFormatting.YELLOW)); } else if (flag1) { -- this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.RED)); -+ this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); +- this.changeButton.setMessage(this.changeButton.getMessage().copy().withStyle(ChatFormatting.RED)); ++ this.changeButton.setMessage(this.changeButton.getMessage().copy().withStyle(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); } - this.f_193912_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); + this.changeButton.render(p_193923_, p_193929_, p_193930_, p_193932_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch index 7891326e..39dc1fe4 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java +++ b/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java @@ -31,7 +_,7 @@ - this.m_7787_(this.f_193977_); - this.f_193978_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, new TranslatableComponent("controls.resetAll"), (p_193999_) -> { - for(KeyMapping keymapping : this.f_96282_.f_92059_) { -- keymapping.m_90848_(keymapping.m_90861_()); + this.addWidget(this.keyBindsList); + this.resetButton = this.addRenderableWidget(new Button(this.width / 2 - 155, this.height - 29, 150, 20, new TranslatableComponent("controls.resetAll"), (p_193999_) -> { + for(KeyMapping keymapping : this.options.keyMappings) { +- keymapping.setKey(keymapping.getDefaultKey()); + keymapping.setToDefault(); } - KeyMapping.m_90854_(); + KeyMapping.resetMapping(); @@ -55,11 +_,14 @@ - public boolean m_7933_(int p_193987_, int p_193988_, int p_193989_) { - if (this.f_193975_ != null) { + public boolean keyPressed(int p_193987_, int p_193988_, int p_193989_) { + if (this.selectedKey != null) { if (p_193987_ == 256) { -+ this.f_193975_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.f_84822_); - this.f_96282_.m_92159_(this.f_193975_, InputConstants.f_84822_); ++ this.selectedKey.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.UNKNOWN); + this.options.setKey(this.selectedKey, InputConstants.UNKNOWN); } else { -+ this.f_193975_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.m_84827_(p_193987_, p_193988_)); - this.f_96282_.m_92159_(this.f_193975_, InputConstants.m_84827_(p_193987_, p_193988_)); ++ this.selectedKey.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.getKey(p_193987_, p_193988_)); + this.options.setKey(this.selectedKey, InputConstants.getKey(p_193987_, p_193988_)); } -+ if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.f_193975_.getKey())) - this.f_193975_ = null; - this.f_193976_ = Util.m_137550_(); - KeyMapping.m_90854_(); ++ if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey())) + this.selectedKey = null; + this.lastKeySelection = Util.getMillis(); + KeyMapping.resetMapping(); 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 8e2cd08a..d979d68c 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,147 +1,147 @@ --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java @@ -90,6 +_,7 @@ - int i = this.f_97735_; - int j = this.f_97736_; - this.m_7286_(p_97795_, p_97798_, p_97796_, p_97797_); + int i = this.leftPos; + int j = this.topPos; + this.renderBg(p_97795_, p_97798_, p_97796_, p_97797_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ContainerScreenEvent.DrawBackground(this, p_97795_, p_97796_, p_97797_)); - RenderSystem.m_69465_(); - super.m_6305_(p_97795_, p_97796_, p_97797_, p_97798_); - PoseStack posestack = RenderSystem.m_157191_(); + RenderSystem.disableDepthTest(); + super.render(p_97795_, p_97796_, p_97797_, p_97798_); + PoseStack posestack = RenderSystem.getModelViewStack(); @@ -111,11 +_,12 @@ - this.f_97734_ = slot; - int l = slot.f_40220_; - int i1 = slot.f_40221_; -- m_169606_(p_97795_, l, i1, this.m_93252_()); -+ renderSlotHighlight(p_97795_, l, i1, this.m_93252_(), this.getSlotColor(k)); + this.hoveredSlot = slot; + int l = slot.x; + int i1 = slot.y; +- renderSlotHighlight(p_97795_, l, i1, this.getBlitOffset()); ++ renderSlotHighlight(p_97795_, l, i1, this.getBlitOffset(), this.getSlotColor(k)); } } - this.m_7027_(p_97795_, p_97796_, p_97797_); + this.renderLabels(p_97795_, p_97796_, p_97797_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ContainerScreenEvent.DrawForeground(this, p_97795_, p_97796_, p_97797_)); - ItemStack itemstack = this.f_97711_.m_41619_() ? this.f_97732_.m_142621_() : this.f_97711_; - if (!itemstack.m_41619_()) { + ItemStack itemstack = this.draggingItem.isEmpty() ? this.menu.getCarried() : this.draggingItem; + if (!itemstack.isEmpty()) { int l1 = 8; @@ -155,9 +_,13 @@ } - public static void m_169606_(PoseStack p_169607_, int p_169608_, int p_169609_, int p_169610_) { + public static void renderSlotHighlight(PoseStack p_169607_, int p_169608_, int p_169609_, int p_169610_) { + renderSlotHighlight(p_169607_, p_169608_, p_169609_, p_169610_, -2130706433); + } + + public static void renderSlotHighlight(PoseStack p_169607_, int p_169608_, int p_169609_, int p_169610_, int slotColor) { - RenderSystem.m_69465_(); - RenderSystem.m_69444_(true, true, true, false); -- m_168740_(p_169607_, p_169608_, p_169609_, p_169608_ + 16, p_169609_ + 16, -2130706433, -2130706433, p_169610_); -+ m_168740_(p_169607_, p_169608_, p_169609_, p_169608_ + 16, p_169609_ + 16, slotColor, slotColor, p_169610_); - RenderSystem.m_69444_(true, true, true, true); - RenderSystem.m_69482_(); + RenderSystem.disableDepthTest(); + RenderSystem.colorMask(true, true, true, false); +- fillGradient(p_169607_, p_169608_, p_169609_, p_169608_ + 16, p_169609_ + 16, -2130706433, -2130706433, p_169610_); ++ fillGradient(p_169607_, p_169608_, p_169609_, p_169608_ + 16, p_169609_ + 16, slotColor, slotColor, p_169610_); + RenderSystem.colorMask(true, true, true, true); + RenderSystem.enableDepthTest(); } @@ -175,8 +_,10 @@ - RenderSystem.m_157182_(); - this.m_93250_(200); - this.f_96542_.f_115093_ = 200.0F; + RenderSystem.applyModelViewMatrix(); + this.setBlitOffset(200); + this.itemRenderer.blitOffset = 200.0F; + net.minecraft.client.gui.Font font = net.minecraftforge.client.RenderProperties.get(p_97783_).getFont(p_97783_); -+ if (font == null) font = this.f_96547_; - this.f_96542_.m_115203_(p_97783_, p_97784_, p_97785_); -- this.f_96542_.m_115174_(this.f_96547_, p_97783_, p_97784_, p_97785_ - (this.f_97711_.m_41619_() ? 0 : 8), p_97786_); -+ this.f_96542_.m_115174_(font, p_97783_, p_97784_, p_97785_ - (this.f_97711_.m_41619_() ? 0 : 8), p_97786_); - this.m_93250_(0); - this.f_96542_.f_115093_ = 0.0F; ++ if (font == null) font = this.font; + this.itemRenderer.renderAndDecorateItem(p_97783_, p_97784_, p_97785_); +- this.itemRenderer.renderGuiItemDecorations(this.font, p_97783_, p_97784_, p_97785_ - (this.draggingItem.isEmpty() ? 0 : 8), p_97786_); ++ this.itemRenderer.renderGuiItemDecorations(font, p_97783_, p_97784_, p_97785_ - (this.draggingItem.isEmpty() ? 0 : 8), p_97786_); + this.setBlitOffset(0); + this.itemRenderer.blitOffset = 0.0F; } @@ -286,7 +_,8 @@ - if (super.m_6375_(p_97748_, p_97749_, p_97750_)) { + if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) { return true; } else { -- boolean flag = this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_) && this.f_96541_.f_91072_.m_105290_(); -+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.m_84895_(p_97750_); -+ boolean flag = this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey); - Slot slot = this.m_97744_(p_97748_, p_97749_); - long i = Util.m_137550_(); - this.f_97723_ = this.f_97709_ == slot && i - this.f_97721_ < 250L && this.f_97722_ == p_97750_; +- 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_); + long i = Util.getMillis(); + this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_; @@ -297,6 +_,7 @@ - int j = this.f_97735_; - int k = this.f_97736_; - boolean flag1 = this.m_7467_(p_97748_, p_97749_, j, k, p_97750_); + int j = this.leftPos; + int k = this.topPos; + boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_); + if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries int l = -1; if (slot != null) { - l = slot.f_40219_; + l = slot.index; @@ -322,7 +_,7 @@ } - } else if (!this.f_97738_) { - if (this.f_97732_.m_142621_().m_41619_()) { + } else if (!this.isQuickCrafting) { + if (this.menu.getCarried().isEmpty()) { - if (flag) { -+ if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { - this.m_6597_(slot, l, p_97750_, ClickType.CLONE); ++ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + this.slotClicked(slot, l, p_97750_, ClickType.CLONE); } else { - boolean flag2 = l != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); + boolean flag2 = l != -999 && (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 340) || InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 344)); @@ -346,7 +_,7 @@ - this.f_97717_ = 0; + this.quickCraftingType = 0; } else if (p_97750_ == 1) { - this.f_97717_ = 1; + this.quickCraftingType = 1; - } else if (flag) { -+ } else if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { - this.f_97717_ = 2; ++ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + this.quickCraftingType = 2; } } @@ -415,10 +_,13 @@ } - public boolean m_6348_(double p_97812_, double p_97813_, int p_97814_) { -+ super.m_6348_(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons - Slot slot = this.m_97744_(p_97812_, p_97813_); - int i = this.f_97735_; - int j = this.f_97736_; - boolean flag = this.m_7467_(p_97812_, p_97813_, i, j, p_97814_); + 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_); + int i = this.leftPos; + int j = this.topPos; + boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_); + if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries -+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.m_84895_(p_97814_); ++ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97814_); int k = -1; if (slot != null) { - k = slot.f_40219_; + k = slot.index; @@ -432,7 +_,7 @@ - if (m_96638_()) { - if (!this.f_97724_.m_41619_()) { - for(Slot slot2 : this.f_97732_.f_38839_) { -- if (slot2 != null && slot2.m_8010_(this.f_96541_.f_91074_) && slot2.m_6657_() && slot2.f_40218_ == slot.f_40218_ && AbstractContainerMenu.m_38899_(slot2, this.f_97724_, true)) { -+ if (slot2 != null && slot2.m_8010_(this.f_96541_.f_91074_) && slot2.m_6657_() && slot2.isSameInventory(slot) && AbstractContainerMenu.m_38899_(slot2, this.f_97724_, true)) { - this.m_6597_(slot2, slot2.f_40219_, p_97814_, ClickType.QUICK_MOVE); + if (hasShiftDown()) { + if (!this.lastQuickMoved.isEmpty()) { + for(Slot slot2 : this.menu.slots) { +- if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() && slot2.container == slot.container && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { ++ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() && slot2.isSameInventory(slot) && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { + this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE); } } @@ -496,7 +_,7 @@ - this.m_6597_((Slot)null, -999, AbstractContainerMenu.m_38930_(2, this.f_97717_), ClickType.QUICK_CRAFT); - } else if (!this.f_97732_.m_142621_().m_41619_()) { -- if (this.f_96541_.f_91066_.f_92097_.m_90830_(p_97814_)) { -+ if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { - this.m_6597_(slot, k, p_97814_, ClickType.CLONE); + this.slotClicked((Slot)null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); + } else if (!this.menu.getCarried().isEmpty()) { +- if (this.minecraft.options.keyPickItem.matchesMouse(p_97814_)) { ++ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + this.slotClicked(slot, k, p_97814_, ClickType.CLONE); } else { - boolean flag1 = k != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); + boolean flag1 = k != -999 && (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 340) || InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 344)); @@ -538,34 +_,39 @@ } - public boolean m_7933_(int p_97765_, int p_97766_, int p_97767_) { -+ InputConstants.Key mouseKey = InputConstants.m_84827_(p_97765_, p_97766_); - if (super.m_7933_(p_97765_, p_97766_, p_97767_)) { + public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) { ++ InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_); + if (super.keyPressed(p_97765_, p_97766_, p_97767_)) { return true; -- } else if (this.f_96541_.f_91066_.f_92092_.m_90832_(p_97765_, p_97766_)) { -+ } else if (this.f_96541_.f_91066_.f_92092_.isActiveAndMatches(mouseKey)) { - this.m_7379_(); +- } else if (this.minecraft.options.keyInventory.matches(p_97765_, p_97766_)) { ++ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { + this.onClose(); return true; } else { -- this.m_97805_(p_97765_, p_97766_); -+ boolean handled = this.m_97805_(p_97765_, p_97766_);// Forge MC-146650: Needs to return true when the key is handled - if (this.f_97734_ != null && this.f_97734_.m_6657_()) { -- if (this.f_96541_.f_91066_.f_92097_.m_90832_(p_97765_, p_97766_)) { -+ if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { - this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, 0, ClickType.CLONE); -- } else if (this.f_96541_.f_91066_.f_92094_.m_90832_(p_97765_, p_97766_)) { +- this.checkHotbarKeyPressed(p_97765_, p_97766_); ++ boolean handled = this.checkHotbarKeyPressed(p_97765_, p_97766_);// Forge MC-146650: Needs to return true when the key is handled + if (this.hoveredSlot != null && this.hoveredSlot.hasItem()) { +- if (this.minecraft.options.keyPickItem.matches(p_97765_, p_97766_)) { ++ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 0, ClickType.CLONE); +- } else if (this.minecraft.options.keyDrop.matches(p_97765_, p_97766_)) { + handled = true; -+ } else if (this.f_96541_.f_91066_.f_92094_.isActiveAndMatches(mouseKey)) { - this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, m_96637_() ? 1 : 0, ClickType.THROW); ++ } else if (this.minecraft.options.keyDrop.isActiveAndMatches(mouseKey)) { + this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, hasControlDown() ? 1 : 0, ClickType.THROW); + handled = true; } -+ } else if (this.f_96541_.f_91066_.f_92094_.isActiveAndMatches(mouseKey)) { ++ } else if (this.minecraft.options.keyDrop.isActiveAndMatches(mouseKey)) { + handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item. } @@ -150,36 +150,36 @@ } } - protected boolean m_97805_(int p_97806_, int p_97807_) { - if (this.f_97732_.m_142621_().m_41619_() && this.f_97734_ != null) { -- if (this.f_96541_.f_91066_.f_92093_.m_90832_(p_97806_, p_97807_)) { -+ if (this.f_96541_.f_91066_.f_92093_.isActiveAndMatches(InputConstants.m_84827_(p_97806_, p_97807_))) { - this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, 40, ClickType.SWAP); + protected boolean checkHotbarKeyPressed(int p_97806_, int p_97807_) { + if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null) { +- if (this.minecraft.options.keySwapOffhand.matches(p_97806_, p_97807_)) { ++ if (this.minecraft.options.keySwapOffhand.isActiveAndMatches(InputConstants.getKey(p_97806_, p_97807_))) { + this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 40, ClickType.SWAP); return true; } for(int i = 0; i < 9; ++i) { -- if (this.f_96541_.f_91066_.f_92056_[i].m_90832_(p_97806_, p_97807_)) { -+ if (this.f_96541_.f_91066_.f_92056_[i].isActiveAndMatches(InputConstants.m_84827_(p_97806_, p_97807_))) { - this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, i, ClickType.SWAP); +- if (this.minecraft.options.keyHotbarSlots[i].matches(p_97806_, p_97807_)) { ++ if (this.minecraft.options.keyHotbarSlots[i].isActiveAndMatches(InputConstants.getKey(p_97806_, p_97807_))) { + this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ClickType.SWAP); return true; } @@ -600,6 +_,18 @@ - public T m_6262_() { - return this.f_97732_; + public T getMenu() { + return this.menu; + } + + @javax.annotation.Nullable -+ public Slot getSlotUnderMouse() { return this.f_97734_; } -+ public int getGuiLeft() { return f_97735_; } -+ public int getGuiTop() { return f_97736_; } -+ public int getXSize() { return f_97726_; } -+ public int getYSize() { return f_97727_; } ++ public Slot getSlotUnderMouse() { return this.hoveredSlot; } ++ public int getGuiLeft() { return leftPos; } ++ 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; } - public void m_7379_() { + public void onClose() { 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 a4a9ca7e..f65def60 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,62 +1,62 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java @@ -73,6 +_,8 @@ - private Slot f_98512_; - private CreativeInventoryListener f_98513_; - private boolean f_98514_; + private Slot destroyItemSlot; + private CreativeInventoryListener listener; + private boolean ignoreTextInput; + private static int tabPage = 0; + private int maxPages = 0; - private boolean f_98515_; - private final Set> f_98516_ = new HashSet<>(); + private boolean hasClickedOutside; + private final Set> visibleTags = new HashSet<>(); @@ -232,6 +_,12 @@ - protected void m_7856_() { - if (this.f_96541_.f_91072_.m_105290_()) { - super.m_7856_(); -+ int tabCount = CreativeModeTab.f_40748_.length; + protected void init() { + if (this.minecraft.gameMode.hasInfiniteItems()) { + super.init(); ++ int tabCount = CreativeModeTab.TABS.length; + if (tabCount > 12) { -+ m_142416_(new net.minecraft.client.gui.components.Button(f_97735_, f_97736_ - 50, 20, 20, new TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); -+ m_142416_(new net.minecraft.client.gui.components.Button(f_97735_ + f_97726_ - 20, f_97736_ - 50, 20, 20, new TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); ++ addRenderableWidget(new net.minecraft.client.gui.components.Button(leftPos, topPos - 50, 20, 20, new TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); ++ addRenderableWidget(new net.minecraft.client.gui.components.Button(leftPos + imageWidth - 20, topPos - 50, 20, 20, new TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); + maxPages = (int) Math.ceil((tabCount - 12) / 10D); + } - this.f_96541_.f_91068_.m_90926_(true); - this.f_98510_ = new EditBox(this.f_96547_, this.f_97735_ + 82, this.f_97736_ + 6, 80, 9, new TranslatableComponent("itemGroup.search")); - this.f_98510_.m_94199_(50); + this.minecraft.keyboardHandler.setSendRepeatsToGui(true); + this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, new TranslatableComponent("itemGroup.search")); + this.searchBox.setMaxLength(50); @@ -273,7 +_,7 @@ - public boolean m_5534_(char p_98521_, int p_98522_) { - if (this.f_98514_) { + public boolean charTyped(char p_98521_, int p_98522_) { + if (this.ignoreTextInput) { return false; -- } else if (f_98507_ != CreativeModeTab.f_40754_.m_40775_()) { -+ } else if (!CreativeModeTab.f_40748_[f_98507_].hasSearchBar()) { +- } else if (selectedTab != CreativeModeTab.TAB_SEARCH.getId()) { ++ } else if (!CreativeModeTab.TABS[selectedTab].hasSearchBar()) { return false; } else { - String s = this.f_98510_.m_94155_(); + String s = this.searchBox.getValue(); @@ -291,7 +_,7 @@ - public boolean m_7933_(int p_98547_, int p_98548_, int p_98549_) { - this.f_98514_ = false; -- if (f_98507_ != CreativeModeTab.f_40754_.m_40775_()) { -+ if (!CreativeModeTab.f_40748_[f_98507_].hasSearchBar()) { - if (this.f_96541_.f_91066_.f_92098_.m_90832_(p_98547_, p_98548_)) { - this.f_98514_ = true; - this.m_98560_(CreativeModeTab.f_40754_); + public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) { + this.ignoreTextInput = false; +- if (selectedTab != CreativeModeTab.TAB_SEARCH.getId()) { ++ if (!CreativeModeTab.TABS[selectedTab].hasSearchBar()) { + if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) { + this.ignoreTextInput = true; + this.selectTab(CreativeModeTab.TAB_SEARCH); @@ -328,6 +_,32 @@ - private void m_98630_() { - (this.f_97732_).f_98639_.clear(); - this.f_98516_.clear(); + private void refreshSearchResults() { + (this.menu).items.clear(); + this.visibleTags.clear(); + -+ CreativeModeTab tab = CreativeModeTab.f_40748_[f_98507_]; -+ if (tab.hasSearchBar() && tab != CreativeModeTab.f_40754_) { -+ tab.m_6151_(f_97732_.f_98639_); -+ if (!this.f_98510_.m_94155_().isEmpty()) { ++ CreativeModeTab tab = CreativeModeTab.TABS[selectedTab]; ++ if (tab.hasSearchBar() && tab != CreativeModeTab.TAB_SEARCH) { ++ tab.fillItemList(menu.items); ++ if (!this.searchBox.getValue().isEmpty()) { + //TODO: Make this a SearchTree not a manual search -+ String search = this.f_98510_.m_94155_().toLowerCase(Locale.ROOT); -+ java.util.Iterator itr = f_97732_.f_98639_.iterator(); ++ String search = this.searchBox.getValue().toLowerCase(Locale.ROOT); ++ java.util.Iterator itr = menu.items.iterator(); + while (itr.hasNext()) { + ItemStack stack = itr.next(); + boolean matches = false; -+ for (Component line : stack.m_41651_(this.f_96541_.f_91074_, this.f_96541_.f_91066_.f_92125_ ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL)) { -+ if (ChatFormatting.m_126649_(line.getString()).toLowerCase(Locale.ROOT).contains(search)) { ++ for (Component line : stack.getTooltipLines(this.minecraft.player, this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL)) { ++ if (ChatFormatting.stripFormatting(line.getString()).toLowerCase(Locale.ROOT).contains(search)) { + matches = true; + break; + } @@ -65,194 +65,194 @@ + itr.remove(); + } + } -+ this.f_98508_ = 0.0F; -+ f_97732_.m_98642_(0.0F); ++ this.scrollOffs = 0.0F; ++ menu.scrollTo(0.0F); + return; + } + - String s = this.f_98510_.m_94155_(); + String s = this.searchBox.getValue(); if (s.isEmpty()) { - for(Item item : Registry.f_122827_) { + for(Item item : Registry.ITEM) { @@ -372,9 +_,9 @@ - protected void m_7027_(PoseStack p_98616_, int p_98617_, int p_98618_) { - CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; -- if (creativemodetab.m_40789_()) { -+ if (creativemodetab != null && creativemodetab.m_40789_()) { - RenderSystem.m_69461_(); -- this.f_96547_.m_92889_(p_98616_, creativemodetab.m_40786_(), 8.0F, 6.0F, 4210752); -+ this.f_96547_.m_92889_(p_98616_, creativemodetab.m_40786_(), 8.0F, 6.0F, creativemodetab.getLabelColor()); + protected void renderLabels(PoseStack p_98616_, int p_98617_, int p_98618_) { + CreativeModeTab creativemodetab = CreativeModeTab.TABS[selectedTab]; +- if (creativemodetab.showTitle()) { ++ if (creativemodetab != null && creativemodetab.showTitle()) { + RenderSystem.disableBlend(); +- this.font.draw(p_98616_, creativemodetab.getDisplayName(), 8.0F, 6.0F, 4210752); ++ this.font.draw(p_98616_, creativemodetab.getDisplayName(), 8.0F, 6.0F, creativemodetab.getLabelColor()); } } @@ -385,7 +_,7 @@ - double d1 = p_98532_ - (double)this.f_97736_; + double d1 = p_98532_ - (double)this.topPos; - for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { -- if (this.m_98562_(creativemodetab, d0, d1)) { -+ if (creativemodetab != null && this.m_98562_(creativemodetab, d0, d1)) { + for(CreativeModeTab creativemodetab : CreativeModeTab.TABS) { +- if (this.checkTabClicked(creativemodetab, d0, d1)) { ++ if (creativemodetab != null && this.checkTabClicked(creativemodetab, d0, d1)) { return true; } } @@ -406,7 +_,7 @@ - this.f_98509_ = false; + this.scrolling = false; - for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { -- if (this.m_98562_(creativemodetab, d0, d1)) { -+ if (creativemodetab != null && this.m_98562_(creativemodetab, d0, d1)) { - this.m_98560_(creativemodetab); + for(CreativeModeTab creativemodetab : CreativeModeTab.TABS) { +- if (this.checkTabClicked(creativemodetab, d0, d1)) { ++ if (creativemodetab != null && this.checkTabClicked(creativemodetab, d0, d1)) { + this.selectTab(creativemodetab); return true; } @@ -417,12 +_,15 @@ } - private boolean m_98631_() { -+ if (CreativeModeTab.f_40748_[f_98507_] == null) return false; - return f_98507_ != CreativeModeTab.f_40761_.m_40775_() && CreativeModeTab.f_40748_[f_98507_].m_40791_() && this.f_97732_.m_98654_(); + private boolean canScroll() { ++ if (CreativeModeTab.TABS[selectedTab] == null) return false; + return selectedTab != CreativeModeTab.TAB_INVENTORY.getId() && CreativeModeTab.TABS[selectedTab].canScroll() && this.menu.canScroll(); } - private void m_98560_(CreativeModeTab p_98561_) { + private void selectTab(CreativeModeTab p_98561_) { + if (p_98561_ == null) return; - int i = f_98507_; - f_98507_ = p_98561_.m_40775_(); + int i = selectedTab; + selectedTab = p_98561_.getId(); + slotColor = p_98561_.getSlotColor(); - this.f_97737_.clear(); - (this.f_97732_).f_98639_.clear(); - if (p_98561_ == CreativeModeTab.f_40760_) { + this.quickCraftSlots.clear(); + (this.menu).items.clear(); + if (p_98561_ == CreativeModeTab.TAB_HOTBAR) { @@ -499,13 +_,15 @@ } - if (this.f_98510_ != null) { -- if (p_98561_ == CreativeModeTab.f_40754_) { + if (this.searchBox != null) { +- if (p_98561_ == CreativeModeTab.TAB_SEARCH) { + if (p_98561_.hasSearchBar()) { - this.f_98510_.m_94194_(true); - this.f_98510_.m_94190_(false); - this.f_98510_.m_94178_(true); - if (i != p_98561_.m_40775_()) { - this.f_98510_.m_94144_(""); + this.searchBox.setVisible(true); + this.searchBox.setCanLoseFocus(false); + this.searchBox.setFocus(true); + if (i != p_98561_.getId()) { + this.searchBox.setValue(""); } -+ this.f_98510_.m_93674_(p_98561_.getSearchbarWidth()); -+ this.f_98510_.f_93620_ = this.f_97735_ + (82 /*default left*/ + 89 /*default width*/) - this.f_98510_.m_5711_(); ++ this.searchBox.setWidth(p_98561_.getSearchbarWidth()); ++ this.searchBox.x = this.leftPos + (82 /*default left*/ + 89 /*default width*/) - this.searchBox.getWidth(); - this.m_98630_(); + this.refreshSearchResults(); } else { @@ -565,16 +_,34 @@ - this.m_7333_(p_98577_); - super.m_6305_(p_98577_, p_98578_, p_98579_, p_98580_); + this.renderBackground(p_98577_); + super.render(p_98577_, p_98578_, p_98579_, p_98580_); -- for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { -- if (this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { +- for(CreativeModeTab creativemodetab : CreativeModeTab.TABS) { +- if (this.checkTabHovering(p_98577_, creativemodetab, p_98578_, p_98579_)) { + int start = tabPage * 10; -+ int end = Math.min(CreativeModeTab.f_40748_.length, ((tabPage + 1) * 10) + 2); ++ int end = Math.min(CreativeModeTab.TABS.length, ((tabPage + 1) * 10) + 2); + if (tabPage != 0) start += 2; + boolean rendered = false; + + for (int x = start; x < end; x++) { -+ CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[x]; -+ if (creativemodetab != null && this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { ++ CreativeModeTab creativemodetab = CreativeModeTab.TABS[x]; ++ if (creativemodetab != null && this.checkTabHovering(p_98577_, creativemodetab, p_98578_, p_98579_)) { + rendered = true; break; } } -+ if (!rendered && !this.m_98584_(p_98577_, CreativeModeTab.f_40754_, p_98578_, p_98579_)) -+ this.m_98584_(p_98577_, CreativeModeTab.f_40761_, p_98578_, p_98579_); ++ if (!rendered && !this.checkTabHovering(p_98577_, CreativeModeTab.TAB_SEARCH, p_98578_, p_98579_)) ++ this.checkTabHovering(p_98577_, CreativeModeTab.TAB_INVENTORY, p_98578_, p_98579_); - if (this.f_98512_ != null && f_98507_ == CreativeModeTab.f_40761_.m_40775_() && this.m_6774_(this.f_98512_.f_40220_, this.f_98512_.f_40221_, 16, 16, (double)p_98578_, (double)p_98579_)) { - this.m_96602_(p_98577_, f_98506_, p_98578_, p_98579_); + if (this.destroyItemSlot != null && selectedTab == CreativeModeTab.TAB_INVENTORY.getId() && this.isHovering(this.destroyItemSlot.x, this.destroyItemSlot.y, 16, 16, (double)p_98578_, (double)p_98579_)) { + this.renderTooltip(p_98577_, TRASH_SLOT_TOOLTIP, p_98578_, p_98579_); } + if (maxPages != 0) { + Component page = new TextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); -+ this.m_93250_(300); -+ this.f_96542_.f_115093_ = 300.0F; -+ f_96547_.m_92744_(p_98577_, page.m_7532_(), f_97735_ + (f_97726_ / 2) - (f_96547_.m_92852_(page) / 2), f_97736_ - 44, -1); -+ this.m_93250_(0); -+ this.f_96542_.f_115093_ = 0.0F; ++ this.setBlitOffset(300); ++ this.itemRenderer.blitOffset = 300.0F; ++ font.drawShadow(p_98577_, page.getVisualOrderText(), leftPos + (imageWidth / 2) - (font.width(page) / 2), topPos - 44, -1); ++ this.setBlitOffset(0); ++ this.itemRenderer.blitOffset = 0.0F; + } + - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); - this.m_7025_(p_98577_, p_98578_, p_98579_); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + this.renderTooltip(p_98577_, p_98578_, p_98579_); } @@ -609,7 +_,7 @@ - list1.add(1, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE)); + list1.add(1, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } -- this.m_169388_(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_); -+ this.renderTooltip(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_, p_98591_); +- this.renderTooltip(p_98590_, list1, p_98591_.getTooltipImage(), p_98592_, p_98593_); ++ this.renderTooltip(p_98590_, list1, p_98591_.getTooltipImage(), p_98592_, p_98593_, p_98591_); } else { - super.m_6057_(p_98590_, p_98591_, p_98592_, p_98593_); + super.renderTooltip(p_98590_, p_98591_, p_98592_, p_98593_); } @@ -620,16 +_,32 @@ - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); - CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + CreativeModeTab creativemodetab = CreativeModeTab.TABS[selectedTab]; -- for(CreativeModeTab creativemodetab1 : CreativeModeTab.f_40748_) { +- for(CreativeModeTab creativemodetab1 : CreativeModeTab.TABS) { + int start = tabPage * 10; -+ int end = Math.min(CreativeModeTab.f_40748_.length, ((tabPage + 1) * 10 + 2)); ++ int end = Math.min(CreativeModeTab.TABS.length, ((tabPage + 1) * 10 + 2)); + if (tabPage != 0) start += 2; + + for (int idx = start; idx < end; idx++) { - RenderSystem.m_157427_(GameRenderer::m_172817_); -- RenderSystem.m_157456_(0, f_98504_); -- if (creativemodetab1.m_40775_() != f_98507_) { -+ CreativeModeTab creativemodetab1 = CreativeModeTab.f_40748_[idx]; -+ if (creativemodetab1 != null && creativemodetab1.m_40775_() != f_98507_) { -+ RenderSystem.m_157456_(0, creativemodetab1.getTabsImage()); - this.m_98581_(p_98572_, creativemodetab1); + RenderSystem.setShader(GameRenderer::getPositionTexShader); +- RenderSystem.setShaderTexture(0, CREATIVE_TABS_LOCATION); +- if (creativemodetab1.getId() != selectedTab) { ++ CreativeModeTab creativemodetab1 = CreativeModeTab.TABS[idx]; ++ if (creativemodetab1 != null && creativemodetab1.getId() != selectedTab) { ++ RenderSystem.setShaderTexture(0, creativemodetab1.getTabsImage()); + this.renderTabButton(p_98572_, creativemodetab1); } } - RenderSystem.m_157427_(GameRenderer::m_172817_); -- RenderSystem.m_157456_(0, new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativemodetab.m_40788_())); + RenderSystem.setShader(GameRenderer::getPositionTexShader); +- RenderSystem.setShaderTexture(0, new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativemodetab.getBackgroundSuffix())); + if (tabPage != 0) { -+ if (creativemodetab != CreativeModeTab.f_40754_) { -+ RenderSystem.m_157456_(0, CreativeModeTab.f_40754_.getTabsImage()); -+ m_98581_(p_98572_, CreativeModeTab.f_40754_); ++ if (creativemodetab != CreativeModeTab.TAB_SEARCH) { ++ RenderSystem.setShaderTexture(0, CreativeModeTab.TAB_SEARCH.getTabsImage()); ++ renderTabButton(p_98572_, CreativeModeTab.TAB_SEARCH); + } -+ if (creativemodetab != CreativeModeTab.f_40761_) { -+ RenderSystem.m_157456_(0, CreativeModeTab.f_40761_.getTabsImage()); -+ m_98581_(p_98572_, CreativeModeTab.f_40761_); ++ if (creativemodetab != CreativeModeTab.TAB_INVENTORY) { ++ RenderSystem.setShaderTexture(0, CreativeModeTab.TAB_INVENTORY.getTabsImage()); ++ renderTabButton(p_98572_, CreativeModeTab.TAB_INVENTORY); + } + } + -+ RenderSystem.m_157456_(0, creativemodetab.getBackgroundImage()); - this.m_93228_(p_98572_, this.f_97735_, this.f_97736_, 0, 0, this.f_97726_, this.f_97727_); - this.f_98510_.m_6305_(p_98572_, p_98574_, p_98575_, p_98573_); - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); ++ RenderSystem.setShaderTexture(0, creativemodetab.getBackgroundImage()); + this.blit(p_98572_, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + this.searchBox.render(p_98572_, p_98574_, p_98575_, p_98573_); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); @@ -637,11 +_,14 @@ - int j = this.f_97736_ + 18; + int j = this.topPos + 18; int k = j + 112; - RenderSystem.m_157427_(GameRenderer::m_172817_); -- RenderSystem.m_157456_(0, f_98504_); -+ RenderSystem.m_157456_(0, creativemodetab.getTabsImage()); - if (creativemodetab.m_40791_()) { - this.m_93228_(p_98572_, i, j + (int)((float)(k - j - 17) * this.f_98508_), 232 + (this.m_98631_() ? 0 : 12), 0, 12, 15); + RenderSystem.setShader(GameRenderer::getPositionTexShader); +- RenderSystem.setShaderTexture(0, CREATIVE_TABS_LOCATION); ++ RenderSystem.setShaderTexture(0, creativemodetab.getTabsImage()); + if (creativemodetab.canScroll()) { + this.blit(p_98572_, i, j + (int)((float)(k - j - 17) * this.scrollOffs), 232 + (this.canScroll() ? 0 : 12), 0, 12, 15); } -+ if ((creativemodetab == null || creativemodetab.getTabPage() != tabPage) && (creativemodetab != CreativeModeTab.f_40754_ && creativemodetab != CreativeModeTab.f_40761_)) ++ if ((creativemodetab == null || creativemodetab.getTabPage() != tabPage) && (creativemodetab != CreativeModeTab.TAB_SEARCH && creativemodetab != CreativeModeTab.TAB_INVENTORY)) + return; + - this.m_98581_(p_98572_, creativemodetab); - if (creativemodetab == CreativeModeTab.f_40761_) { - InventoryScreen.m_98850_(this.f_97735_ + 88, this.f_97736_ + 45, 20, (float)(this.f_97735_ + 88 - p_98574_), (float)(this.f_97736_ + 45 - 30 - p_98575_), this.f_96541_.f_91074_); + this.renderTabButton(p_98572_, creativemodetab); + if (creativemodetab == CreativeModeTab.TAB_INVENTORY) { + InventoryScreen.renderEntityInInventory(this.leftPos + 88, this.topPos + 45, 20, (float)(this.leftPos + 88 - p_98574_), (float)(this.topPos + 45 - 30 - p_98575_), this.minecraft.player); @@ -650,6 +_,7 @@ } - protected boolean m_98562_(CreativeModeTab p_98563_, double p_98564_, double p_98565_) { -+ if (p_98563_.getTabPage() != tabPage && p_98563_ != CreativeModeTab.f_40754_ && p_98563_ != CreativeModeTab.f_40761_) return false; - int i = p_98563_.m_40793_(); + protected boolean checkTabClicked(CreativeModeTab p_98563_, double p_98564_, double p_98565_) { ++ if (p_98563_.getTabPage() != tabPage && p_98563_ != CreativeModeTab.TAB_SEARCH && p_98563_ != CreativeModeTab.TAB_INVENTORY) return false; + int i = p_98563_.getColumn(); int j = 28 * i; int k = 0; @@ -718,6 +_,7 @@ - i1 += this.f_97727_ - 4; + i1 += this.imageHeight - 4; } -+ RenderSystem.m_69478_(); //Forge: Make sure blend is enabled else tabs show a white border. - this.m_93228_(p_98582_, l, i1, j, k, 28, 32); - this.f_96542_.f_115093_ = 100.0F; ++ RenderSystem.enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. + this.blit(p_98582_, l, i1, j, k, 28, 32); + this.itemRenderer.blitOffset = 100.0F; l += 6; @@ -823,6 +_,11 @@ - return this.f_98639_.size() > 45; + return this.items.size() > 45; } + @Override @@ -260,28 +260,28 @@ + return null; + } + - public ItemStack m_7648_(Player p_98650_, int p_98651_) { - if (p_98651_ >= this.f_38839_.size() - 9 && p_98651_ < this.f_38839_.size()) { - Slot slot = this.f_38839_.get(p_98651_); + public ItemStack quickMoveStack(Player p_98650_, int p_98651_) { + if (p_98651_ >= this.slots.size() - 9 && p_98651_ < this.slots.size()) { + Slot slot = this.slots.get(p_98651_); @@ -907,6 +_,22 @@ - public boolean m_8010_(Player p_98665_) { - return this.f_98655_.m_8010_(p_98665_); + public boolean mayPickup(Player p_98665_) { + return this.target.mayPickup(p_98665_); + } + + @Override + public int getSlotIndex() { -+ return this.f_98655_.getSlotIndex(); ++ return this.target.getSlotIndex(); + } + + @Override + public boolean isSameInventory(Slot other) { -+ return this.f_98655_.isSameInventory(other); ++ return this.target.isSameInventory(other); + } + + @Override + public Slot setBackground(ResourceLocation atlas, ResourceLocation sprite) { -+ this.f_98655_.setBackground(atlas, sprite); ++ this.target.setBackground(atlas, sprite); + return this; } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch index bea69fe6..f922ab65 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java @@ -44,12 +_,15 @@ if (!collection.isEmpty() && j >= 32) { - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); boolean flag = j >= 120; + var event = net.minecraftforge.client.ForgeHooksClient.onScreenPotionSize(this); + if (event != net.minecraftforge.eventbus.api.Event.Result.DEFAULT) flag = event == net.minecraftforge.eventbus.api.Event.Result.DENY; // true means classic mode @@ -14,19 +14,19 @@ - Iterable iterable = Ordering.natural().sortedCopy(collection); + + Iterable iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRenderEffect).sorted().collect(java.util.stream.Collectors.toList()); - this.m_194002_(p_194015_, i, k, iterable, flag); - this.m_194008_(p_194015_, i, k, iterable, flag); + this.renderBackgrounds(p_194015_, i, k, iterable, flag); + this.renderIcons(p_194015_, i, k, iterable, flag); if (flag) { @@ -110,6 +_,12 @@ - int i = this.f_97736_; + int i = this.topPos; for(MobEffectInstance mobeffectinstance : p_98726_) { + net.minecraftforge.client.EffectRenderer renderer = net.minecraftforge.client.RenderProperties.getEffectRenderer(mobeffectinstance); -+ renderer.renderInventoryEffect(mobeffectinstance, this, p_98723_, p_98724_, i, this.m_93252_()); ++ renderer.renderInventoryEffect(mobeffectinstance, this, p_98723_, p_98724_, i, this.getBlitOffset()); + if (!renderer.shouldRenderInvText(mobeffectinstance)) { + i += p_98725_; + continue; + } - Component component = this.m_194000_(mobeffectinstance); - this.f_96547_.m_92763_(p_98723_, component, (float)(p_98724_ + 10 + 18), (float)(i + 6), 16777215); - String s = MobEffectUtil.m_19581_(mobeffectinstance, 1.0F); + Component component = this.getEffectName(mobeffectinstance); + this.font.drawShadow(p_98723_, component, (float)(p_98724_ + 10 + 18), (float)(i + 6), 16777215); + String s = MobEffectUtil.formatDuration(mobeffectinstance, 1.0F); 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 a88da97c..32d0d622 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,28 +1,28 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java @@ -151,7 +_,7 @@ - int i2 = 86 - this.f_96547_.m_92895_(s); - FormattedText formattedtext = EnchantmentNames.m_98734_().m_98737_(this.f_96547_, i2); + int i2 = 86 - this.font.width(s); + FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, i2); int j2 = 6839882; -- if ((l < i1 + 1 || this.f_96541_.f_91074_.f_36078_ < l1) && !this.f_96541_.f_91074_.m_150110_().f_35937_) { -+ if (((l < i1 + 1 || this.f_96541_.f_91074_.f_36078_ < l1) && !this.f_96541_.f_91074_.m_150110_().f_35937_) || this.f_97732_.f_39447_[i1] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels - this.m_93228_(p_98762_, j1, j + 14 + 19 * i1, 0, 185, 108, 19); - this.m_93228_(p_98762_, j1 + 1, j + 15 + 19 * i1, 16 * i1, 239, 16, 16); - this.f_96547_.m_92857_(formattedtext, k1, j + 16 + 19 * i1, i2, (j2 & 16711422) >> 1); +- if ((l < i1 + 1 || this.minecraft.player.experienceLevel < l1) && !this.minecraft.player.getAbilities().instabuild) { ++ if (((l < i1 + 1 || this.minecraft.player.experienceLevel < l1) && !this.minecraft.player.getAbilities().instabuild) || this.menu.enchantClue[i1] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels + this.blit(p_98762_, j1, j + 14 + 19 * i1, 0, 185, 108, 19); + this.blit(p_98762_, j1 + 1, j + 15 + 19 * i1, 16 * i1, 239, 16, 16); + this.font.drawWordWrap(formattedtext, k1, j + 16 + 19 * i1, i2, (j2 & 16711422) >> 1); @@ -190,10 +_,13 @@ - Enchantment enchantment = Enchantment.m_44697_((this.f_97732_).f_39447_[j]); - int l = (this.f_97732_).f_39448_[j]; + Enchantment enchantment = Enchantment.byId((this.menu).enchantClue[j]); + int l = (this.menu).levelClue[j]; int i1 = j + 1; -- if (this.m_6774_(60, 14 + 19 * j, 108, 17, (double)p_98768_, (double)p_98769_) && k > 0 && l >= 0 && enchantment != null) { -+ if (this.m_6774_(60, 14 + 19 * j, 108, 17, (double)p_98768_, (double)p_98769_) && k > 0) { +- if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_98768_, (double)p_98769_) && k > 0 && l >= 0 && enchantment != null) { ++ if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_98768_, (double)p_98769_) && k > 0) { List list = Lists.newArrayList(); -- list.add((new TranslatableComponent("container.enchant.clue", enchantment.m_44700_(l))).m_130940_(ChatFormatting.WHITE)); +- list.add((new TranslatableComponent("container.enchant.clue", enchantment.getFullname(l))).withStyle(ChatFormatting.WHITE)); - if (!flag) { -+ list.add((new TranslatableComponent("container.enchant.clue", enchantment == null ? "" : enchantment.m_44700_(l))).m_130940_(ChatFormatting.WHITE)); ++ list.add((new TranslatableComponent("container.enchant.clue", enchantment == null ? "" : enchantment.getFullname(l))).withStyle(ChatFormatting.WHITE)); + if (enchantment == null) { + list.add(new TextComponent("")); -+ list.add(new TranslatableComponent("forge.container.enchant.limitedEnchantability").m_130940_(ChatFormatting.RED)); ++ list.add(new TranslatableComponent("forge.container.enchant.limitedEnchantability").withStyle(ChatFormatting.RED)); + } else if (!flag) { - list.add(TextComponent.f_131282_); - if (this.f_96541_.f_91074_.f_36078_ < k) { - list.add((new TranslatableComponent("container.enchant.level.requirement", (this.f_97732_).f_39446_[j])).m_130940_(ChatFormatting.RED)); + list.add(TextComponent.EMPTY); + if (this.minecraft.player.experienceLevel < k) { + list.add((new TranslatableComponent("container.enchant.level.requirement", (this.menu).costs[j])).withStyle(ChatFormatting.RED)); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/LoomScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/LoomScreen.java.patch index cc67b94c..8037424e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/LoomScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/LoomScreen.java.patch @@ -2,43 +2,43 @@ +++ b/net/minecraft/client/gui/screens/inventory/LoomScreen.java @@ -125,20 +_,20 @@ int l2 = j + 13; - int l = this.f_99072_ + 16; + int l = this.startIndex + 16; -- for(int i1 = this.f_99072_; i1 < l && i1 < BannerPattern.f_58526_ - BannerPattern.f_58527_; ++i1) { -+ for(int i1 = this.f_99072_; i1 < l && i1 < net.minecraftforge.common.ForgeHooks.getNonPatternItemCount(); ++i1) { - int j1 = i1 - this.f_99072_; +- for(int i1 = this.startIndex; i1 < l && i1 < BannerPattern.COUNT - BannerPattern.PATTERN_ITEM_COUNT; ++i1) { ++ for(int i1 = this.startIndex; i1 < l && i1 < net.minecraftforge.common.ForgeHooks.getNonPatternItemCount(); ++i1) { + int j1 = i1 - this.startIndex; int k1 = j2 + j1 % 4 * 14; int l1 = l2 + j1 / 4 * 14; - RenderSystem.m_157456_(0, f_99060_); - int i2 = this.f_97727_; -- if (i1 == this.f_97732_.m_39891_()) { -+ if (net.minecraftforge.common.ForgeHooks.getActualPatternIndex(i1) == this.f_97732_.m_39891_()) { + RenderSystem.setShaderTexture(0, BG_LOCATION); + int i2 = this.imageHeight; +- if (i1 == this.menu.getSelectedBannerPatternIndex()) { ++ if (net.minecraftforge.common.ForgeHooks.getActualPatternIndex(i1) == this.menu.getSelectedBannerPatternIndex()) { i2 += 14; } else if (p_99101_ >= k1 && p_99102_ >= l1 && p_99101_ < k1 + 14 && p_99102_ < l1 + 14) { i2 += 28; } - this.m_93228_(p_99099_, k1, l1, 0, i2, 14, 14); -- this.m_99108_(i1, k1, l1); -+ this.m_99108_(net.minecraftforge.common.ForgeHooks.getActualPatternIndex(i1), k1, l1); + this.blit(p_99099_, k1, l1, 0, i2, 14, 14); +- this.renderPattern(i1, k1, l1); ++ this.renderPattern(net.minecraftforge.common.ForgeHooks.getActualPatternIndex(i1), k1, l1); } - } else if (this.f_99068_) { + } else if (this.displaySpecialPattern) { int k2 = i + 60; @@ -209,7 +_,7 @@ int j = i + 56; - this.f_99070_ = ((float)p_99088_ - (float)i - 7.5F) / ((float)(j - i) - 15.0F); - this.f_99070_ = Mth.m_14036_(this.f_99070_, 0.0F, 1.0F); -- int k = f_99061_ - 4; + this.scrollOffs = ((float)p_99088_ - (float)i - 7.5F) / ((float)(j - i) - 15.0F); + this.scrollOffs = Mth.clamp(this.scrollOffs, 0.0F, 1.0F); +- int k = TOTAL_PATTERN_ROWS - 4; + int k = net.minecraftforge.common.ForgeHooks.getTotalPatternRows() - 4; - int l = (int)((double)(this.f_99070_ * (float)k) + 0.5D); + int l = (int)((double)(this.scrollOffs * (float)k) + 0.5D); if (l < 0) { l = 0; @@ -224,7 +_,7 @@ - public boolean m_6050_(double p_99079_, double p_99080_, double p_99081_) { - if (this.f_99067_) { -- int i = f_99061_ - 4; + public boolean mouseScrolled(double p_99079_, double p_99080_, double p_99081_) { + if (this.displayPatterns) { +- int i = TOTAL_PATTERN_ROWS - 4; + int i = net.minecraftforge.common.ForgeHooks.getTotalPatternRows() - 4; float f = (float)p_99081_ / (float)i; - this.f_99070_ = Mth.m_14036_(this.f_99070_ - f, 0.0F, 1.0F); - this.f_99072_ = 1 + (int)(this.f_99070_ * (float)i + 0.5F) * 4; + this.scrollOffs = Mth.clamp(this.scrollOffs - f, 0.0F, 1.0F); + this.startIndex = 1 + (int)(this.scrollOffs * (float)i + 0.5F) * 4; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch index a4c259b7..6d831528 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch @@ -5,10 +5,10 @@ } + @Override -+ public void m_7379_() { -+ this.f_96541_.m_91152_(this.f_99676_); ++ public void onClose() { ++ this.minecraft.setScreen(this.lastScreen); + } + - public ServerStatusPinger m_99731_() { - return this.f_99675_; + public ServerStatusPinger getPinger() { + return this.pinger; } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch index f6fa61b2..94fde99c 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java @@ -334,6 +_,8 @@ - this.f_99855_.m_99707_(list1); + this.screen.setToolTip(list1); } -+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.f_99855_, f_99857_, p_99879_, p_99882_, p_99881_, p_99883_, i1, j1); ++ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_99879_, p_99882_, p_99881_, p_99883_, i1, j1); + - if (this.f_99856_.f_91066_.f_92051_ || p_99887_) { - RenderSystem.m_157456_(0, ServerSelectionList.f_99759_); - GuiComponent.m_93172_(p_99879_, p_99882_, p_99881_, p_99882_ + 32, p_99881_ + 32, -1601138544); + if (this.minecraft.options.touchscreen || p_99887_) { + RenderSystem.setShaderTexture(0, ServerSelectionList.ICON_OVERLAY_LOCATION); + GuiComponent.fill(p_99879_, p_99882_, p_99881_, p_99882_ + 32, p_99881_ + 32, -1601138544); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch index 13567ec1..98d5adea 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionModel.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java +++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java @@ -102,6 +_,8 @@ - boolean m_7802_(); + boolean canMoveUp(); - boolean m_7803_(); + boolean canMoveDown(); + + default boolean notHidden() { return true; } } @@ -11,13 +11,13 @@ @OnlyIn(Dist.CLIENT) @@ -176,6 +_,11 @@ - public void m_7845_() { - this.m_99938_(1); + public void moveDown() { + this.move(1); + } + + @Override + public boolean notHidden() { -+ return !f_99933_.isHidden(); ++ return !pack.isHidden(); } } 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 6afde4d1..d3b9acc4 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 @@ -2,10 +2,10 @@ +++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java @@ -139,7 +_,7 @@ - private void m_100013_(TransferableSelectionList p_100014_, Stream p_100015_) { - p_100014_.m_6702_().clear(); + private void updateList(TransferableSelectionList p_100014_, Stream p_100015_) { + p_100014_.children().clear(); - p_100015_.forEach((p_170000_) -> { + p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach((p_170000_) -> { - p_100014_.m_6702_().add(new TransferableSelectionList.PackEntry(this.f_96541_, p_100014_, this, p_170000_)); + p_100014_.children().add(new TransferableSelectionList.PackEntry(this.minecraft, p_100014_, this, p_170000_)); }); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch index 4dd1b853..6dc92e67 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java +++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java @@ -107,7 +_,7 @@ - this.m_5674_(); - this.f_100279_.clear(); + this.initFilterButtonTextures(); + this.tabButtons.clear(); -- for(RecipeBookCategories recipebookcategories : RecipeBookCategories.m_92269_(this.f_100271_.m_5867_())) { -+ for(RecipeBookCategories recipebookcategories : this.f_100271_.getRecipeBookCategories()) { - this.f_100279_.add(new RecipeBookTabButton(recipebookcategories)); +- for(RecipeBookCategories recipebookcategories : RecipeBookCategories.getCategories(this.menu.getRecipeBookType())) { ++ for(RecipeBookCategories recipebookcategories : this.menu.getRecipeBookCategories()) { + this.tabButtons.add(new RecipeBookTabButton(recipebookcategories)); } @@ -319,7 +_,7 @@ } - if (itemstack != null && this.f_100272_.f_91080_ != null) { -- this.f_100272_.f_91080_.m_96597_(p_100375_, this.f_100272_.f_91080_.m_96555_(itemstack), p_100378_, p_100379_); -+ this.f_100272_.f_91080_.renderComponentTooltip(p_100375_, this.f_100272_.f_91080_.m_96555_(itemstack), p_100378_, p_100379_, itemstack); + if (itemstack != null && this.minecraft.screen != null) { +- this.minecraft.screen.renderComponentTooltip(p_100375_, this.minecraft.screen.getTooltipFromItem(itemstack), p_100378_, p_100379_); ++ this.minecraft.screen.renderComponentTooltip(p_100375_, this.minecraft.screen.getTooltipFromItem(itemstack), p_100378_, p_100379_, itemstack); } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java.patch index 215f0c4a..4c0a62d8 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java @@ -115,7 +_,7 @@ - public void m_100417_(PoseStack p_100418_, int p_100419_, int p_100420_) { - if (this.f_100397_.f_91080_ != null && this.f_100395_ != null && !this.f_100396_.m_100212_()) { -- this.f_100397_.f_91080_.m_96597_(p_100418_, this.f_100395_.m_100477_(this.f_100397_.f_91080_), p_100419_, p_100420_); -+ this.f_100397_.f_91080_.renderComponentTooltip(p_100418_, this.f_100395_.m_100477_(this.f_100397_.f_91080_), p_100419_, p_100420_, this.f_100395_.m_100488_().m_8043_()); + public void renderTooltip(PoseStack p_100418_, int p_100419_, int p_100420_) { + if (this.minecraft.screen != null && this.hoveredButton != null && !this.overlay.isVisible()) { +- this.minecraft.screen.renderComponentTooltip(p_100418_, this.hoveredButton.getTooltipText(this.minecraft.screen), p_100419_, p_100420_); ++ this.minecraft.screen.renderComponentTooltip(p_100418_, this.hoveredButton.getTooltipText(this.minecraft.screen), p_100419_, p_100420_, this.hoveredButton.getRecipe().getResultItem()); } } 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 cb3134c5..230bf612 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 @@ -2,30 +2,30 @@ +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java @@ -106,7 +_,7 @@ - public static CreateWorldScreen m_205424_(@Nullable Screen p_205425_) { - RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.f_123049_.get(); -- return new CreateWorldScreen(p_205425_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$frozen, WorldGenSettings.m_190050_(registryaccess$frozen), Optional.of(WorldPreset.f_101506_), OptionalLong.empty())); -+ return new CreateWorldScreen(p_205425_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$frozen, net.minecraftforge.client.ForgeHooksClient.getDefaultWorldPreset().map(type -> type.m_205485_(registryaccess$frozen, new java.util.Random().nextLong(), true, false)).orElseGet(() -> WorldGenSettings.m_190050_(registryaccess$frozen)), net.minecraftforge.client.ForgeHooksClient.getDefaultWorldPreset(), OptionalLong.empty())); + public static CreateWorldScreen createFresh(@Nullable Screen p_205425_) { + RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.BUILTIN.get(); +- return new CreateWorldScreen(p_205425_, DataPackConfig.DEFAULT, new WorldGenSettingsComponent(registryaccess$frozen, WorldGenSettings.makeDefault(registryaccess$frozen), Optional.of(WorldPreset.NORMAL), OptionalLong.empty())); ++ return new CreateWorldScreen(p_205425_, DataPackConfig.DEFAULT, new WorldGenSettingsComponent(registryaccess$frozen, net.minecraftforge.client.ForgeHooksClient.getDefaultWorldPreset().map(type -> type.create(registryaccess$frozen, new java.util.Random().nextLong(), true, false)).orElseGet(() -> WorldGenSettings.makeDefault(registryaccess$frozen)), net.minecraftforge.client.ForgeHooksClient.getDefaultWorldPreset(), OptionalLong.empty())); } - public static CreateWorldScreen m_205426_(@Nullable Screen p_205427_, WorldStem p_205428_, @Nullable Path p_205429_) { + public static CreateWorldScreen createFromExisting(@Nullable Screen p_205427_, WorldStem p_205428_, @Nullable Path p_205429_) { @@ -252,9 +_,9 @@ if (p_205448_) { GameRules gamerules = new GameRules(); - gamerules.m_46170_(GameRules.f_46140_).m_46246_(false, (MinecraftServer)null); -- return new LevelSettings(s, GameType.SPECTATOR, false, Difficulty.PEACEFUL, true, gamerules, DataPackConfig.f_45842_); -+ return new LevelSettings(s, GameType.SPECTATOR, false, Difficulty.PEACEFUL, true, gamerules, DataPackConfig.f_45842_, com.mojang.serialization.Lifecycle.stable()); + gamerules.getRule(GameRules.RULE_DAYLIGHT).set(false, (MinecraftServer)null); +- return new LevelSettings(s, GameType.SPECTATOR, false, Difficulty.PEACEFUL, true, gamerules, DataPackConfig.DEFAULT); ++ return new LevelSettings(s, GameType.SPECTATOR, false, Difficulty.PEACEFUL, true, gamerules, DataPackConfig.DEFAULT, com.mojang.serialization.Lifecycle.stable()); } else { -- return new LevelSettings(s, this.f_100858_.f_101029_, this.f_100845_, this.m_170205_(), this.f_100829_ && !this.f_100845_, this.f_100844_, this.f_100846_); -+ return new LevelSettings(s, this.f_100858_.f_101029_, this.f_100845_, this.m_170205_(), this.f_100829_ && !this.f_100845_, this.f_100844_, this.f_100846_, com.mojang.serialization.Lifecycle.stable()); +- return new LevelSettings(s, this.gameMode.gameType, this.hardCore, this.getEffectiveDifficulty(), this.commands && !this.hardCore, this.gameRules, this.dataPacks); ++ return new LevelSettings(s, this.gameMode.gameType, this.hardCore, this.getEffectiveDifficulty(), this.commands && !this.hardCore, this.gameRules, this.dataPacks, com.mojang.serialization.Lifecycle.stable()); } } @@ -625,6 +_,7 @@ File file1 = path.toFile(); - if (this.f_100832_ == null) { - this.f_100832_ = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(file1, PackSource.f_10527_)); -+ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); - this.f_100832_.m_10506_(); + if (this.tempDataPackRepository == null) { + this.tempDataPackRepository = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(file1, PackSource.DEFAULT)); ++ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.tempDataPackRepository, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); + this.tempDataPackRepository.reload(); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch index b69f42ad..3a198486 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java @@ -107,6 +_,7 @@ - this.f_170244_.f_93624_ = false; - this.f_101391_ = p_101430_.m_142416_(new Button(j, 120, 150, 20, new TranslatableComponent("selectWorld.customizeType"), (p_170248_) -> { - WorldPreset.PresetEditor worldpreset$preseteditor = WorldPreset.f_101509_.get(this.f_101395_); -+ worldpreset$preseteditor = net.minecraftforge.client.ForgeHooksClient.getPresetEditor(this.f_101395_, worldpreset$preseteditor); + this.customWorldDummyButton.visible = false; + this.customizeTypeButton = p_101430_.addRenderableWidget(new Button(j, 120, 150, 20, new TranslatableComponent("selectWorld.customizeType"), (p_170248_) -> { + WorldPreset.PresetEditor worldpreset$preseteditor = WorldPreset.EDITORS.get(this.preset); ++ worldpreset$preseteditor = net.minecraftforge.client.ForgeHooksClient.getPresetEditor(this.preset, worldpreset$preseteditor); if (worldpreset$preseteditor != null) { - p_101431_.m_91152_(worldpreset$preseteditor.m_101642_(p_101430_, this.f_101394_)); + p_101431_.setScreen(worldpreset$preseteditor.createEditScreen(p_101430_, this.settings)); } @@ -273,7 +_,7 @@ } else { - this.f_101389_.f_93624_ = p_170288_; - this.f_101380_.f_93624_ = p_170288_; -- this.f_101391_.f_93624_ = p_170288_ && WorldPreset.f_101509_.containsKey(this.f_101395_); -+ this.f_101391_.f_93624_ = p_170288_ && (WorldPreset.f_101509_.containsKey(this.f_101395_) || net.minecraftforge.client.ForgeHooksClient.hasPresetEditor(this.f_101395_)); - this.f_101392_.f_93624_ = p_170288_; + this.featuresButton.visible = p_170288_; + this.bonusItemsButton.visible = p_170288_; +- this.customizeTypeButton.visible = p_170288_ && WorldPreset.EDITORS.containsKey(this.preset); ++ this.customizeTypeButton.visible = p_170288_ && (WorldPreset.EDITORS.containsKey(this.preset) || net.minecraftforge.client.ForgeHooksClient.hasPresetEditor(this.preset)); + this.importSettingsButton.visible = p_170288_; } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch index a4680d87..0232fb1f 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch @@ -2,20 +2,20 @@ +++ b/net/minecraft/client/gui/screens/worldselection/WorldPreset.java @@ -93,6 +_,9 @@ WorldPreset(String p_101519_) { - this.f_101516_ = new TranslatableComponent("generator." + p_101519_); + this.description = new TranslatableComponent("generator." + p_101519_); } + public WorldPreset(Component displayName) { -+ this.f_101516_ = displayName; ++ this.description = displayName; + } - private static WorldGenSettings m_205493_(RegistryAccess p_205494_, WorldGenSettings p_205495_, Holder p_205496_) { + private static WorldGenSettings fromBuffetSettings(RegistryAccess p_205494_, WorldGenSettings p_205495_, Holder p_205496_) { BiomeSource biomesource = new FixedBiomeSource(p_205496_); @@ -134,4 +_,8 @@ public interface PresetEditor { - Screen m_101642_(CreateWorldScreen p_101643_, WorldGenSettings p_101644_); + Screen createEditScreen(CreateWorldScreen p_101643_, WorldGenSettings p_101644_); } + + // Forge start + // For internal use only, automatically called for all ForgeWorldTypes. Register your ForgeWorldType in the forge registry! -+ public static void registerGenerator(WorldPreset gen) { f_101508_.add(gen); } ++ public static void registerGenerator(WorldPreset gen) { PRESETS.add(gen); } } 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 bde14a17..e9f63a10 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 @@ -1,122 +1,122 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java @@ -64,6 +_,7 @@ - static final DateFormat f_101646_ = new SimpleDateFormat(); - static final ResourceLocation f_101647_ = new ResourceLocation("textures/misc/unknown_server.png"); - static final ResourceLocation f_101648_ = new ResourceLocation("textures/gui/world_selection.png"); + static final DateFormat DATE_FORMAT = new SimpleDateFormat(); + static final ResourceLocation ICON_MISSING = new ResourceLocation("textures/misc/unknown_server.png"); + static final ResourceLocation ICON_OVERLAY_LOCATION = new ResourceLocation("textures/gui/world_selection.png"); + private static final ResourceLocation FORGE_EXPERIMENTAL_WARNING_ICON = new ResourceLocation("forge","textures/gui/experimental_warning.png"); - static final Component f_101649_ = (new TranslatableComponent("selectWorld.tooltip.fromNewerVersion1")).m_130940_(ChatFormatting.RED); - static final Component f_101650_ = (new TranslatableComponent("selectWorld.tooltip.fromNewerVersion2")).m_130940_(ChatFormatting.RED); - static final Component f_101651_ = (new TranslatableComponent("selectWorld.tooltip.snapshot1")).m_130940_(ChatFormatting.GOLD); + static final Component FROM_NEWER_TOOLTIP_1 = (new TranslatableComponent("selectWorld.tooltip.fromNewerVersion1")).withStyle(ChatFormatting.RED); + static final Component FROM_NEWER_TOOLTIP_2 = (new TranslatableComponent("selectWorld.tooltip.fromNewerVersion2")).withStyle(ChatFormatting.RED); + static final Component SNAPSHOT_TOOLTIP_1 = (new TranslatableComponent("selectWorld.tooltip.snapshot1")).withStyle(ChatFormatting.GOLD); @@ -198,15 +_,16 @@ } - Component component = this.f_101695_.m_78376_(); -- this.f_101693_.f_91062_.m_92883_(p_101721_, s, (float)(p_101724_ + 32 + 3), (float)(p_101723_ + 1), 16777215); -- this.f_101693_.f_91062_.m_92883_(p_101721_, s1, (float)(p_101724_ + 32 + 3), (float)(p_101723_ + 9 + 3), 8421504); -- this.f_101693_.f_91062_.m_92889_(p_101721_, component, (float)(p_101724_ + 32 + 3), (float)(p_101723_ + 9 + 9 + 3), 8421504); -+ this.f_101693_.f_91062_.m_92883_(p_101721_, s, (float) (p_101724_ + 32 + 3), (float) (p_101723_ + 1), 16777215); -+ this.f_101693_.f_91062_.m_92883_(p_101721_, s1, (float) (p_101724_ + 32 + 3), (float) (p_101723_ + 9 + 3), 8421504); -+ this.f_101693_.f_91062_.m_92889_(p_101721_, component, (float) (p_101724_ + 32 + 3), (float) (p_101723_ + 9 + 9 + 3), 8421504); - RenderSystem.m_157427_(GameRenderer::m_172817_); - RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.m_157456_(0, this.f_101698_ != null ? this.f_101696_ : WorldSelectionList.f_101647_); - RenderSystem.m_69478_(); - GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 0.0F, 0.0F, 32, 32, 32, 32); - RenderSystem.m_69461_(); + Component component = this.summary.getInfo(); +- this.minecraft.font.draw(p_101721_, s, (float)(p_101724_ + 32 + 3), (float)(p_101723_ + 1), 16777215); +- this.minecraft.font.draw(p_101721_, s1, (float)(p_101724_ + 32 + 3), (float)(p_101723_ + 9 + 3), 8421504); +- this.minecraft.font.draw(p_101721_, component, (float)(p_101724_ + 32 + 3), (float)(p_101723_ + 9 + 9 + 3), 8421504); ++ this.minecraft.font.draw(p_101721_, s, (float) (p_101724_ + 32 + 3), (float) (p_101723_ + 1), 16777215); ++ this.minecraft.font.draw(p_101721_, s1, (float) (p_101724_ + 32 + 3), (float) (p_101723_ + 9 + 3), 8421504); ++ this.minecraft.font.draw(p_101721_, component, (float) (p_101724_ + 32 + 3), (float) (p_101723_ + 9 + 9 + 3), 8421504); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, this.icon != null ? this.iconLocation : WorldSelectionList.ICON_MISSING); + RenderSystem.enableBlend(); + GuiComponent.blit(p_101721_, p_101724_, p_101723_, 0.0F, 0.0F, 32, 32, 32, 32); + RenderSystem.disableBlend(); + renderExperimentalWarning(p_101721_, p_101727_, p_101728_, p_101723_, p_101724_); - if (this.f_101693_.f_91066_.f_92051_ || p_101729_) { - RenderSystem.m_157456_(0, WorldSelectionList.f_101648_); - GuiComponent.m_93172_(p_101721_, p_101724_, p_101723_, p_101724_ + 32, p_101723_ + 32, -1601138544); + if (this.minecraft.options.touchscreen || p_101729_) { + RenderSystem.setShaderTexture(0, WorldSelectionList.ICON_OVERLAY_LOCATION); + GuiComponent.fill(p_101721_, p_101724_, p_101723_, p_101724_ + 32, p_101723_ + 32, -1601138544); @@ -216,30 +_,30 @@ boolean flag = i < 32; int j = flag ? 32 : 0; - if (this.f_101695_.m_78375_()) { -- GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 96.0F, (float)j, 32, 32, 256, 256); -+ GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 96.0F, (float) j, 32, 32, 256, 256); + if (this.summary.isLocked()) { +- GuiComponent.blit(p_101721_, p_101724_, p_101723_, 96.0F, (float)j, 32, 32, 256, 256); ++ GuiComponent.blit(p_101721_, p_101724_, p_101723_, 96.0F, (float) j, 32, 32, 256, 256); if (flag) { - this.f_101694_.m_101363_(this.f_101693_.f_91062_.m_92923_(WorldSelectionList.f_101653_, 175)); + this.screen.setToolTip(this.minecraft.font.split(WorldSelectionList.WORLD_LOCKED_TOOLTIP, 175)); } - } else if (this.f_101695_.m_193020_()) { -- GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 96.0F, (float)j, 32, 32, 256, 256); -+ GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 96.0F, (float) j, 32, 32, 256, 256); + } else if (this.summary.requiresManualConversion()) { +- GuiComponent.blit(p_101721_, p_101724_, p_101723_, 96.0F, (float)j, 32, 32, 256, 256); ++ GuiComponent.blit(p_101721_, p_101724_, p_101723_, 96.0F, (float) j, 32, 32, 256, 256); if (flag) { - this.f_101694_.m_101363_(this.f_101693_.f_91062_.m_92923_(WorldSelectionList.f_194113_, 175)); + this.screen.setToolTip(this.minecraft.font.split(WorldSelectionList.WORLD_REQUIRES_CONVERSION, 175)); } - } else if (this.f_101695_.m_78372_()) { -- GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 32.0F, (float)j, 32, 32, 256, 256); -+ GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 32.0F, (float) j, 32, 32, 256, 256); - if (this.f_101695_.m_78373_()) { -- GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 96.0F, (float)j, 32, 32, 256, 256); -+ GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 96.0F, (float) j, 32, 32, 256, 256); + } else if (this.summary.markVersionInList()) { +- GuiComponent.blit(p_101721_, p_101724_, p_101723_, 32.0F, (float)j, 32, 32, 256, 256); ++ GuiComponent.blit(p_101721_, p_101724_, p_101723_, 32.0F, (float) j, 32, 32, 256, 256); + if (this.summary.askToOpenWorld()) { +- GuiComponent.blit(p_101721_, p_101724_, p_101723_, 96.0F, (float)j, 32, 32, 256, 256); ++ GuiComponent.blit(p_101721_, p_101724_, p_101723_, 96.0F, (float) j, 32, 32, 256, 256); if (flag) { - this.f_101694_.m_101363_(ImmutableList.of(WorldSelectionList.f_101649_.m_7532_(), WorldSelectionList.f_101650_.m_7532_())); + this.screen.setToolTip(ImmutableList.of(WorldSelectionList.FROM_NEWER_TOOLTIP_1.getVisualOrderText(), WorldSelectionList.FROM_NEWER_TOOLTIP_2.getVisualOrderText())); } - } else if (!SharedConstants.m_183709_().isStable()) { -- GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 64.0F, (float)j, 32, 32, 256, 256); -+ GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 64.0F, (float) j, 32, 32, 256, 256); + } else if (!SharedConstants.getCurrentVersion().isStable()) { +- GuiComponent.blit(p_101721_, p_101724_, p_101723_, 64.0F, (float)j, 32, 32, 256, 256); ++ GuiComponent.blit(p_101721_, p_101724_, p_101723_, 64.0F, (float) j, 32, 32, 256, 256); if (flag) { - this.f_101694_.m_101363_(ImmutableList.of(WorldSelectionList.f_101651_.m_7532_(), WorldSelectionList.f_101652_.m_7532_())); + this.screen.setToolTip(ImmutableList.of(WorldSelectionList.SNAPSHOT_TOOLTIP_1.getVisualOrderText(), WorldSelectionList.SNAPSHOT_TOOLTIP_2.getVisualOrderText())); } } } else { -- GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 0.0F, (float)j, 32, 32, 256, 256); -+ GuiComponent.m_93133_(p_101721_, p_101724_, p_101723_, 0.0F, (float) j, 32, 32, 256, 256); +- GuiComponent.blit(p_101721_, p_101724_, p_101723_, 0.0F, (float)j, 32, 32, 256, 256); ++ GuiComponent.blit(p_101721_, p_101724_, p_101723_, 0.0F, (float) j, 32, 32, 256, 256); } } @@ -251,7 +_,7 @@ } else { - WorldSelectionList.this.m_6987_(this); - this.f_101694_.m_101369_(WorldSelectionList.this.m_101684_().isPresent()); -- if (p_101706_ - (double)WorldSelectionList.this.m_5747_() <= 32.0D) { -+ if (p_101706_ - (double) WorldSelectionList.this.m_5747_() <= 32.0D) { - this.m_101704_(); + WorldSelectionList.this.setSelected(this); + this.screen.updateButtonStatus(WorldSelectionList.this.getSelectedOpt().isPresent()); +- if (p_101706_ - (double)WorldSelectionList.this.getRowLeft() <= 32.0D) { ++ if (p_101706_ - (double) WorldSelectionList.this.getRowLeft() <= 32.0D) { + this.joinWorld(); return true; - } else if (Util.m_137550_() - this.f_101699_ < 250L) { + } else if (Util.getMillis() - this.lastClickTime < 250L) { @@ -314,7 +_,7 @@ try { - this.m_101744_(); + this.loadWorld(); } catch (Exception exception) { -- WorldSelectionList.f_101645_.error("Failure to open 'future world'", (Throwable)exception); -+ WorldSelectionList.f_101645_.error("Failure to open 'future world'", (Throwable) exception); - this.f_101693_.m_91152_(new AlertScreen(() -> { - this.f_101693_.m_91152_(this.f_101694_); +- WorldSelectionList.LOGGER.error("Failure to open 'future world'", (Throwable)exception); ++ WorldSelectionList.LOGGER.error("Failure to open 'future world'", (Throwable) exception); + this.minecraft.setScreen(new AlertScreen(() -> { + this.minecraft.setScreen(this.screen); }, new TranslatableComponent("selectWorld.futureworld.error.title"), new TranslatableComponent("selectWorld.futureworld.error.text"))); @@ -420,7 +_,7 @@ - Path path = CreateWorldScreen.m_100906_(levelstoragesource$levelstorageaccess.m_78283_(LevelResource.f_78180_), this.f_101693_); - if (worldgensettings.m_64670_()) { - this.f_101693_.m_91152_(new ConfirmScreen((p_205503_) -> { -- this.f_101693_.m_91152_((Screen)(p_205503_ ? CreateWorldScreen.m_205426_(this.f_101694_, worldstem, path) : this.f_101694_)); -+ this.f_101693_.m_91152_((Screen) (p_205503_ ? CreateWorldScreen.m_205426_(this.f_101694_, worldstem, path) : this.f_101694_)); - }, new TranslatableComponent("selectWorld.recreate.customized.title"), new TranslatableComponent("selectWorld.recreate.customized.text"), CommonComponents.f_130659_, CommonComponents.f_130656_)); + Path path = CreateWorldScreen.createTempDataPackDirFromExistingWorld(levelstoragesource$levelstorageaccess.getLevelPath(LevelResource.DATAPACK_DIR), this.minecraft); + if (worldgensettings.isOldCustomizedWorld()) { + this.minecraft.setScreen(new ConfirmScreen((p_205503_) -> { +- this.minecraft.setScreen((Screen)(p_205503_ ? CreateWorldScreen.createFromExisting(this.screen, worldstem, path) : this.screen)); ++ this.minecraft.setScreen((Screen) (p_205503_ ? CreateWorldScreen.createFromExisting(this.screen, worldstem, path) : this.screen)); + }, new TranslatableComponent("selectWorld.recreate.customized.title"), new TranslatableComponent("selectWorld.recreate.customized.text"), CommonComponents.GUI_PROCEED, CommonComponents.GUI_CANCEL)); } else { - this.f_101693_.m_91152_(CreateWorldScreen.m_205426_(this.f_101694_, worldstem, path)); + this.minecraft.setScreen(CreateWorldScreen.createFromExisting(this.screen, worldstem, path)); @@ -456,7 +_,7 @@ levelstoragesource$levelstorageaccess.close(); } } catch (Exception exception) { -- WorldSelectionList.f_101645_.error("Unable to recreate world", (Throwable)exception); -+ WorldSelectionList.f_101645_.error("Unable to recreate world", (Throwable) exception); - this.f_101693_.m_91152_(new AlertScreen(() -> { - this.f_101693_.m_91152_(this.f_101694_); +- WorldSelectionList.LOGGER.error("Unable to recreate world", (Throwable)exception); ++ WorldSelectionList.LOGGER.error("Unable to recreate world", (Throwable) exception); + this.minecraft.setScreen(new AlertScreen(() -> { + this.minecraft.setScreen(this.screen); }, new TranslatableComponent("selectWorld.recreate.error.title"), new TranslatableComponent("selectWorld.recreate.error.text"))); @@ -524,6 +_,20 @@ - public String m_170324_() { - return this.f_101695_.m_78361_(); + public String getLevelName() { + return this.summary.getLevelName(); + } + + private void renderExperimentalWarning(PoseStack stack, int mouseX, int mouseY, int top, int left) { -+ if (this.f_101695_.isExperimental()) { -+ int leftStart = left + WorldSelectionList.this.m_5759_(); -+ RenderSystem.m_157456_(0, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON); -+ GuiComponent.m_93133_(stack, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); ++ if (this.summary.isExperimental()) { ++ int leftStart = left + WorldSelectionList.this.getRowWidth(); ++ RenderSystem.setShaderTexture(0, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON); ++ GuiComponent.blit(stack, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); + //Reset texture to what it was before -+ RenderSystem.m_157456_(0, this.f_101698_ != null ? this.f_101696_ : WorldSelectionList.f_101647_); -+ if (WorldSelectionList.this.m_93412_(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { -+ List tooltip = Minecraft.m_91087_().f_91062_.m_92923_(new TranslatableComponent("forge.experimentalsettings.tooltip"), 200); -+ WorldSelectionList.this.f_101654_.m_96617_(stack, tooltip, mouseX, mouseY); ++ RenderSystem.setShaderTexture(0, this.icon != null ? this.iconLocation : WorldSelectionList.ICON_MISSING); ++ if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { ++ List tooltip = Minecraft.getInstance().font.split(new TranslatableComponent("forge.experimentalsettings.tooltip"), 200); ++ WorldSelectionList.this.screen.renderTooltip(stack, tooltip, mouseX, mouseY); + } + } } diff --git a/patches/minecraft/net/minecraft/client/main/Main.java.patch b/patches/minecraft/net/minecraft/client/main/Main.java.patch index a937b1fc..18e3f8b4 100644 --- a/patches/minecraft/net/minecraft/client/main/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/main/Main.java.patch @@ -3,9 +3,9 @@ @@ -135,7 +_,7 @@ } - CrashReport.m_127529_(); -- Bootstrap.m_135870_(); -+ net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(()->Bootstrap.m_135870_(), net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); - Bootstrap.m_135889_(); - Util.m_137584_(); + CrashReport.preload(); +- Bootstrap.bootStrap(); ++ net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(()->Bootstrap.bootStrap(), net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); + Bootstrap.validate(); + Util.startTimerHackThread(); String s10 = optionspec23.value(optionset); 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 acf31dde..8f6be733 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java @@ -284,6 +_,7 @@ - WoodType.m_61843_().forEach((p_171114_) -> { - builder.put(ModelLayers.m_171291_(p_171114_), layerdefinition19); + WoodType.values().forEach((p_171114_) -> { + builder.put(ModelLayers.createSignModelName(p_171114_), layerdefinition19); }); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); ImmutableMap immutablemap = builder.build(); - List list = ModelLayers.m_171288_().filter((p_171117_) -> { + List list = ModelLayers.getKnownLocations().filter((p_171117_) -> { return !immutablemap.containsKey(p_171117_); 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 0ee6a42e..02969aa8 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -3,10 +3,10 @@ @@ -199,7 +_,8 @@ } - public static ModelLayerLocation m_171291_(WoodType p_171292_) { -- return m_171300_("sign/" + p_171292_.m_61846_(), "main"); -+ ResourceLocation location = new ResourceLocation(p_171292_.m_61846_()); -+ return new ModelLayerLocation(new ResourceLocation(location.m_135827_(), "sign/" + location.m_135815_()), "main"); + public static ModelLayerLocation createSignModelName(WoodType p_171292_) { +- return createLocation("sign/" + p_171292_.name(), "main"); ++ ResourceLocation location = new ResourceLocation(p_171292_.name()); ++ return new ModelLayerLocation(new ResourceLocation(location.getNamespace(), "sign/" + location.getPath()), "main"); } - public static Stream m_171288_() { + public static Stream getKnownLocations() { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 878d20f5..37678f48 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java @@ -60,6 +_,7 @@ - int i = this.f_104410_.m_104481_(p_104456_, p_104457_); - LevelChunk levelchunk = this.f_104410_.m_104479_(i); - if (m_104438_(levelchunk, p_104456_, p_104457_)) { + int i = this.storage.getIndex(p_104456_, p_104457_); + LevelChunk levelchunk = this.storage.getChunk(i); + if (isValidChunk(levelchunk, p_104456_, p_104457_)) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload(levelchunk)); - this.f_104410_.m_104487_(i, levelchunk, (LevelChunk)null); + this.storage.replace(i, levelchunk, (LevelChunk)null); } @@ -100,6 +_,7 @@ } - this.f_104411_.m_171649_(chunkpos); + this.level.onChunkLoaded(chunkpos); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(levelchunk)); return levelchunk; } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch index 18e17235..f15ec322 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java @@ -115,6 +_,7 @@ - this.f_104521_.accept(new TranslatableComponent("connect.joining")); - this.f_104523_ = p_104547_.m_134774_(); - this.f_104522_.m_129498_(ConnectionProtocol.PLAY); -+ net.minecraftforge.network.NetworkHooks.handleClientLoginSuccess(this.f_104522_); - this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_, this.f_104519_.m_193590_())); + this.updateStatus.accept(new TranslatableComponent("connect.joining")); + this.localGameProfile = p_104547_.getGameProfile(); + this.connection.setProtocol(ConnectionProtocol.PLAY); ++ net.minecraftforge.network.NetworkHooks.handleClientLoginSuccess(this.connection); + this.connection.setListener(new ClientPacketListener(this.minecraft, this.parent, this.connection, this.localGameProfile, this.minecraft.createTelemetryManager())); } @@ -122,7 +_,7 @@ - if (this.f_104520_ != null && this.f_104520_ instanceof RealmsScreen) { - this.f_104519_.m_91152_(new DisconnectedRealmsScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_)); + if (this.parent != null && this.parent instanceof RealmsScreen) { + this.minecraft.setScreen(new DisconnectedRealmsScreen(this.parent, CommonComponents.CONNECT_FAILED, p_104543_)); } else { -- this.f_104519_.m_91152_(new DisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_)); -+ this.f_104519_.m_91152_(net.minecraftforge.network.NetworkHooks.getModMismatchData(f_104522_) != null ? new net.minecraftforge.client.gui.ModMismatchDisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_, net.minecraftforge.network.NetworkHooks.getModMismatchData(f_104522_)) : new DisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_)); +- this.minecraft.setScreen(new DisconnectedScreen(this.parent, CommonComponents.CONNECT_FAILED, p_104543_)); ++ this.minecraft.setScreen(net.minecraftforge.network.NetworkHooks.getModMismatchData(connection) != null ? new net.minecraftforge.client.gui.ModMismatchDisconnectedScreen(this.parent, CommonComponents.CONNECT_FAILED, p_104543_, net.minecraftforge.network.NetworkHooks.getModMismatchData(connection)) : new DisconnectedScreen(this.parent, CommonComponents.CONNECT_FAILED, p_104543_)); } } @@ -143,6 +_,7 @@ } - public void m_7254_(ClientboundCustomQueryPacket p_104545_) { -+ if (net.minecraftforge.network.NetworkHooks.onCustomPayload(p_104545_, this.f_104522_)) return; - this.f_104521_.accept(new TranslatableComponent("connect.negotiating")); - this.f_104522_.m_129512_(new ServerboundCustomQueryPacket(p_104545_.m_134755_(), (FriendlyByteBuf)null)); + public void handleCustomQuery(ClientboundCustomQueryPacket p_104545_) { ++ if (net.minecraftforge.network.NetworkHooks.onCustomPayload(p_104545_, this.connection)) return; + this.updateStatus.accept(new TranslatableComponent("connect.negotiating")); + this.connection.send(new ServerboundCustomQueryPacket(p_104545_.getTransactionId(), (FriendlyByteBuf)null)); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch index 38a6528c..68d9e4c6 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,67 +1,67 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java @@ -117,6 +_,7 @@ - private final Deque f_194122_ = Queues.newArrayDeque(); - private int f_194123_; - private static final Set f_194124_ = Set.of(Items.f_42127_, Items.f_151033_); + private final Deque lightUpdateQueue = Queues.newArrayDeque(); + private int serverSimulationDistance; + 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<>(); public ClientLevel(ClientPacketListener p_205505_, ClientLevel.ClientLevelData p_205506_, ResourceKey p_205507_, Holder p_205508_, int p_205509_, int p_205510_, Supplier p_205511_, LevelRenderer p_205512_, boolean p_205513_, long p_205514_) { super(p_205506_, p_205507_, p_205508_, p_205511_, true, p_205513_, p_205514_); @@ -129,6 +_,8 @@ - this.f_194123_ = p_205510_; - this.m_46465_(); - this.m_46466_(); + this.serverSimulationDistance = p_205510_; + this.updateSkyBrightness(); + this.prepareWeather(); + this.gatherCapabilities(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(this)); } - public void m_194171_(Runnable p_194172_) { + public void queueLightUpdate(Runnable p_194172_) { @@ -215,6 +_,7 @@ - this.m_46473_().m_6521_(() -> { - return Registry.f_122826_.m_7981_(p_104640_.m_6095_()).toString(); + this.getProfiler().push(() -> { + return Registry.ENTITY_TYPE.getKey(p_104640_.getType()).toString(); }); + if (p_104640_.canUpdate()) - p_104640_.m_8119_(); - this.m_46473_().m_7238_(); + p_104640_.tick(); + this.getProfiler().pop(); @@ -277,8 +_,10 @@ } - private void m_104739_(int p_104740_, Entity p_104741_) { + private void addEntity(int p_104740_, Entity p_104741_) { + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_104741_, this))) return; - this.m_171642_(p_104740_, Entity.RemovalReason.DISCARDED); - this.f_171631_.m_157653_(p_104741_); + this.removeEntity(p_104740_, Entity.RemovalReason.DISCARDED); + this.entityStorage.addEntity(p_104741_); + p_104741_.onAddedToWorld(); } - public void m_171642_(int p_171643_, Entity.RemovalReason p_171644_) { + public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { @@ -409,6 +_,11 @@ } - public void m_6263_(@Nullable Player p_104645_, double p_104646_, double p_104647_, double p_104648_, SoundEvent p_104649_, SoundSource p_104650_, float p_104651_, float p_104652_) { + public void playSound(@Nullable Player p_104645_, double p_104646_, double p_104647_, double p_104648_, SoundEvent p_104649_, SoundSource p_104650_, float p_104651_, float p_104652_) { + net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_104645_, p_104649_, p_104650_, p_104651_, p_104652_); + if (event.isCanceled() || event.getSound() == null) return; + p_104649_ = event.getSound(); + p_104650_ = event.getCategory(); + p_104651_ = event.getVolume(); - if (p_104645_ == this.f_104565_.f_91074_) { - this.m_7785_(p_104646_, p_104647_, p_104648_, p_104649_, p_104650_, p_104651_, p_104652_, false); + if (p_104645_ == this.minecraft.player) { + this.playLocalSound(p_104646_, p_104647_, p_104648_, p_104649_, p_104650_, p_104651_, p_104652_, false); } @@ -416,6 +_,11 @@ } - public void m_6269_(@Nullable Player p_104659_, Entity p_104660_, SoundEvent p_104661_, SoundSource p_104662_, float p_104663_, float p_104664_) { + public void playSound(@Nullable Player p_104659_, Entity p_104660_, SoundEvent p_104661_, SoundSource p_104662_, float p_104663_, float p_104664_) { + net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_104659_, p_104661_, p_104662_, p_104663_, p_104664_); + if (event.isCanceled() || event.getSound() == null) return; + p_104661_ = event.getSound(); + p_104662_ = event.getCategory(); + p_104663_ = event.getVolume(); - if (p_104659_ == this.f_104565_.f_91074_) { - this.f_104565_.m_91106_().m_120367_(new EntityBoundSoundInstance(p_104661_, p_104662_, p_104663_, p_104664_, p_104660_)); + if (p_104659_ == this.minecraft.player) { + this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_104661_, p_104662_, p_104663_, p_104664_, p_104660_)); } @@ -732,6 +_,11 @@ - public void m_142346_(@Nullable Entity p_171646_, GameEvent p_171647_, BlockPos p_171648_) { + public void gameEvent(@Nullable Entity p_171646_, GameEvent p_171647_, BlockPos p_171648_) { } + @Override @@ -69,20 +69,20 @@ + return null; + } + - protected Map m_171684_() { - return ImmutableMap.copyOf(this.f_104556_); + protected Map getAllMapData() { + return ImmutableMap.copyOf(this.mapData); } @@ -740,7 +_,7 @@ - this.f_104556_.putAll(p_171673_); + this.mapData.putAll(p_171673_); } -- protected LevelEntityGetter m_142646_() { -+ public LevelEntityGetter m_142646_() { - return this.f_171631_.m_157645_(); +- protected LevelEntityGetter getEntities() { ++ public LevelEntityGetter getEntities() { + return this.entityStorage.getEntityGetter(); } @@ -748,6 +_,11 @@ - return "Chunks[C] W: " + this.f_104559_.m_6754_() + " E: " + this.f_171631_.m_157664_(); + return "Chunks[C] W: " + this.chunkSource.gatherStats() + " E: " + this.entityStorage.gatherStats(); } + @Override @@ -90,38 +90,38 @@ + return null; + } + - public void m_142052_(BlockPos p_171667_, BlockState p_171668_) { - this.f_104565_.f_91061_.m_107355_(p_171667_, p_171668_); + public void addDestroyBlockEffect(BlockPos p_171667_, BlockState p_171668_) { + this.minecraft.particleEngine.destroy(p_171667_, p_171668_); } @@ -870,6 +_,7 @@ } - public void m_104851_(Difficulty p_104852_) { -+ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_104852_, this.f_104840_); - this.f_104840_ = p_104852_; + public void setDifficulty(Difficulty p_104852_) { ++ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_104852_, this.difficulty); + this.difficulty = p_104852_; } @@ -907,11 +_,30 @@ - ClientLevel.this.f_104566_.add((AbstractClientPlayer)p_171712_); + ClientLevel.this.players.add((AbstractClientPlayer)p_171712_); } + if (p_171712_.isMultipartEntity()) { + for (net.minecraftforge.entity.PartEntity part : p_171712_.getParts()) { -+ ClientLevel.this.partEntities.put(part.m_142049_(), part); ++ ClientLevel.this.partEntities.put(part.getId(), part); + } + } } - public void m_141981_(Entity p_171716_) { - p_171716_.m_19877_(); - ClientLevel.this.f_104566_.remove(p_171716_); + public void onTrackingEnd(Entity p_171716_) { + p_171716_.unRide(); + ClientLevel.this.players.remove(p_171716_); + + p_171716_.onRemovedFromWorld(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_171716_, ClientLevel.this)); + + if (p_171716_.isMultipartEntity()) { + for (net.minecraftforge.entity.PartEntity part : p_171716_.getParts()) { -+ ClientLevel.this.partEntities.remove(part.m_142049_()); ++ ClientLevel.this.partEntities.remove(part.getId()); + } + } } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index b6963259..72027038 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -2,94 +2,94 @@ +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java @@ -360,6 +_,7 @@ - this.f_104888_.f_91064_.m_113434_(); - this.f_104888_.f_91074_.m_172530_(); -+ net.minecraftforge.client.ForgeHooksClient.firePlayerLogin(this.f_104888_.f_91072_, this.f_104888_.f_91074_, this.f_104888_.m_91403_().m_6198_()); - int i = p_105030_.f_132360_(); - this.f_104888_.f_91074_.m_20234_(i); - this.f_104889_.m_104630_(i, this.f_104888_.f_91074_); + this.minecraft.debugRenderer.clear(); + this.minecraft.player.resetPos(); ++ net.minecraftforge.client.ForgeHooksClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().getConnection()); + int i = p_105030_.playerId(); + this.minecraft.player.setId(i); + this.level.addPlayer(i, this.minecraft.player); @@ -371,6 +_,7 @@ - this.f_104888_.f_91074_.m_108711_(p_105030_.f_132372_()); - this.f_104888_.f_91072_.m_171805_(p_105030_.f_132363_(), p_105030_.f_132364_()); - this.f_104888_.f_91066_.m_193770_(p_105030_.f_132370_()); -+ net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(f_104885_, "PLAY_TO_SERVER"); - this.f_104888_.f_91066_.m_92172_(); - this.f_104885_.m_129512_(new ServerboundCustomPayloadPacket(ServerboundCustomPayloadPacket.f_133979_, (new FriendlyByteBuf(Unpooled.buffer())).m_130070_(ClientBrandRetriever.m_129629_()))); - this.f_104888_.m_91309_().m_90739_(); + this.minecraft.player.setShowDeathScreen(p_105030_.showDeathScreen()); + this.minecraft.gameMode.setLocalMode(p_105030_.gameType(), p_105030_.previousGameType()); + this.minecraft.options.setServerRenderDistance(p_105030_.chunkRadius()); ++ net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(connection, "PLAY_TO_SERVER"); + this.minecraft.options.broadcastOptions(); + this.connection.send(new ServerboundCustomPayloadPacket(ServerboundCustomPayloadPacket.BRAND, (new FriendlyByteBuf(Unpooled.buffer())).writeUtf(ClientBrandRetriever.getClientModName()))); + this.minecraft.getGame().onStartGameSession(); @@ -712,7 +_,9 @@ - public void m_5784_(ClientboundChatPacket p_104986_) { - PacketUtils.m_131363_(p_104986_, this, this.f_104888_); -- this.f_104888_.f_91065_.m_93051_(p_104986_.m_131840_(), p_104986_.m_131836_(), p_104986_.m_131841_()); -+ net.minecraft.network.chat.Component message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_104986_.m_131840_(), p_104986_.m_131836_(), p_104986_.m_131841_()); + public void handleChat(ClientboundChatPacket p_104986_) { + PacketUtils.ensureRunningOnSameThread(p_104986_, this, this.minecraft); +- this.minecraft.gui.handleChat(p_104986_.getType(), p_104986_.getMessage(), p_104986_.getSender()); ++ net.minecraft.network.chat.Component message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_104986_.getType(), p_104986_.getMessage(), p_104986_.getSender()); + if (message == null) return; -+ this.f_104888_.f_91065_.m_93051_(p_104986_.m_131840_(), message, p_104986_.m_131841_()); ++ this.minecraft.gui.handleChat(p_104986_.getType(), message, p_104986_.getSender()); } - public void m_7791_(ClientboundAnimatePacket p_104968_) { + public void handleAnimate(ClientboundAnimatePacket p_104968_) { @@ -894,8 +_,10 @@ - localplayer1.m_21204_().m_22159_(localplayer.m_21204_()); + localplayer1.getAttributes().assignValues(localplayer.getAttributes()); } + localplayer1.updateSyncFields(localplayer); // Forge: fix MC-10657 - localplayer1.m_172530_(); - localplayer1.m_108748_(s); -+ net.minecraftforge.client.ForgeHooksClient.firePlayerRespawn(this.f_104888_.f_91072_, localplayer, localplayer1, localplayer1.f_108617_.m_6198_()); - this.f_104889_.m_104630_(i, localplayer1); - localplayer1.m_146922_(-180.0F); - localplayer1.f_108618_ = new KeyboardInput(this.f_104888_.f_91066_); + localplayer1.resetPos(); + localplayer1.setServerBrand(s); ++ net.minecraftforge.client.ForgeHooksClient.firePlayerRespawn(this.minecraft.gameMode, localplayer, localplayer1, localplayer1.connection.getConnection()); + this.level.addPlayer(i, localplayer1); + localplayer1.setYRot(-180.0F); + localplayer1.input = new KeyboardInput(this.minecraft.options); @@ -998,10 +_,7 @@ - PacketUtils.m_131363_(p_104976_, this, this.f_104888_); - BlockPos blockpos = p_104976_.m_131704_(); - this.f_104888_.f_91073_.m_141902_(blockpos, p_104976_.m_195645_()).ifPresent((p_205557_) -> { -- CompoundTag compoundtag = p_104976_.m_131708_(); + PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft); + BlockPos blockpos = p_104976_.getPos(); + this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent((p_205557_) -> { +- CompoundTag compoundtag = p_104976_.getTag(); - if (compoundtag != null) { -- p_205557_.m_142466_(compoundtag); +- p_205557_.load(compoundtag); - } -+ p_205557_.onDataPacket(f_104885_, p_104976_); ++ p_205557_.onDataPacket(connection, p_104976_); - if (p_205557_ instanceof CommandBlockEntity && this.f_104888_.f_91080_ instanceof CommandBlockEditScreen) { - ((CommandBlockEditScreen)this.f_104888_.f_91080_).m_98398_(); + if (p_205557_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) { + ((CommandBlockEditScreen)this.minecraft.screen).updateGui(); @@ -1147,6 +_,7 @@ - public void m_7443_(ClientboundCommandsPacket p_104990_) { - PacketUtils.m_131363_(p_104990_, this, this.f_104888_); - this.f_104899_ = new CommandDispatcher<>(p_104990_.m_131884_()); -+ this.f_104899_ = net.minecraftforge.client.ClientCommandHandler.mergeServerCommands(this.f_104899_); + public void handleCommands(ClientboundCommandsPacket p_104990_) { + PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft); + this.commands = new CommandDispatcher<>(p_104990_.getRoot()); ++ this.commands = net.minecraftforge.client.ClientCommandHandler.mergeServerCommands(this.commands); } - public void m_7183_(ClientboundStopSoundPacket p_105116_) { + public void handleStopSoundEvent(ClientboundStopSoundPacket p_105116_) { @@ -1168,6 +_,7 @@ - clientrecipebook.m_90625_(this.f_104900_.m_44051_()); - clientrecipebook.m_90639_().forEach(mutablesearchtree::m_8080_); - mutablesearchtree.m_7729_(); -+ net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(this.f_104900_); + clientrecipebook.setupCollections(this.recipeManager.getRecipes()); + clientrecipebook.getCollections().forEach(mutablesearchtree::add); + mutablesearchtree.refresh(); ++ net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(this.recipeManager); } - public void m_7244_(ClientboundPlayerLookAtPacket p_105054_) { + public void handleLookAt(ClientboundPlayerLookAtPacket p_105054_) { @@ -1245,7 +_,7 @@ - PacketUtils.m_131363_(p_105130_, this, this.f_104888_); - Entity entity = this.f_104889_.m_6815_(p_105130_.m_133622_()); + PacketUtils.ensureRunningOnSameThread(p_105130_, this, this.minecraft); + Entity entity = this.level.getEntity(p_105130_.getEntityId()); if (entity instanceof LivingEntity) { -- MobEffect mobeffect = MobEffect.m_19453_(p_105130_.m_211135_()); -+ MobEffect mobeffect = MobEffect.m_19453_(p_105130_.m_211135_() & 0xFF); +- MobEffect mobeffect = MobEffect.byId(p_105130_.getEffectId()); ++ MobEffect mobeffect = MobEffect.byId(p_105130_.getEffectId() & 0xFF); if (mobeffect != null) { - MobEffectInstance mobeffectinstance = new MobEffectInstance(mobeffect, p_105130_.m_133625_(), p_105130_.m_133624_(), p_105130_.m_133627_(), p_105130_.m_133626_(), p_105130_.m_133628_()); - mobeffectinstance.m_19562_(p_105130_.m_133619_()); + MobEffectInstance mobeffectinstance = new MobEffectInstance(mobeffect, p_105130_.getEffectDurationTicks(), p_105130_.getEffectAmplifier(), p_105130_.isEffectAmbient(), p_105130_.isEffectVisible(), p_105130_.effectShowsIcon()); + mobeffectinstance.setNoCounter(p_105130_.isSuperLongDuration()); @@ -1262,6 +_,7 @@ } - this.f_104888_.m_91171_(SearchRegistry.f_119942_).m_7729_(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_, true, f_104885_.m_129531_())); + this.minecraft.getSearchTree(SearchRegistry.CREATIVE_TAGS).refresh(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.registryAccess, true, connection.isMemoryConnection())); } - private void m_205560_(ResourceKey> p_205561_, TagNetworkSerialization.NetworkPayload p_205562_) { + private void updateTagsForRegistry(ResourceKey> p_205561_, TagNetworkSerialization.NetworkPayload p_205562_) { @@ -1815,7 +_,8 @@ - int i5 = friendlybytebuf.m_130242_(); - this.f_104888_.f_91064_.f_173815_.m_173830_(positionsource, i5); + int i5 = friendlybytebuf.readVarInt(); + this.minecraft.debugRenderer.gameEventListenerRenderer.trackListener(positionsource, i5); } else { -- f_104883_.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); -+ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_105004_, this.f_104885_)) -+ f_104883_.warn("Unknown custom packet identifier: {}", (Object)resourcelocation); +- LOGGER.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); ++ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_105004_, this.connection)) ++ LOGGER.warn("Unknown custom packet identifier: {}", (Object)resourcelocation); } } finally { if (friendlybytebuf != null) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index e63e45d8..a77b01cb 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -3,151 +3,151 @@ @@ -102,6 +_,7 @@ } - public boolean m_105267_(BlockPos p_105268_) { -+ if (f_105189_.f_91074_.m_21205_().onBlockStartBreak(p_105268_, f_105189_.f_91074_)) return false; - if (this.f_105189_.f_91074_.m_36187_(this.f_105189_.f_91073_, p_105268_, this.f_105197_)) { + public boolean destroyBlock(BlockPos p_105268_) { ++ if (minecraft.player.getMainHandItem().onBlockStartBreak(p_105268_, minecraft.player)) return false; + if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) { return false; } else { @@ -116,9 +_,8 @@ - } else if (blockstate.m_60795_()) { + } else if (blockstate.isAir()) { return false; } else { -- block.m_5707_(level, p_105268_, blockstate, this.f_105189_.f_91074_); - FluidState fluidstate = level.m_6425_(p_105268_); -- boolean flag = level.m_7731_(p_105268_, fluidstate.m_76188_(), 11); -+ boolean flag = blockstate.onDestroyedByPlayer(level, p_105268_, f_105189_.f_91074_, false, fluidstate); +- block.playerWillDestroy(level, p_105268_, blockstate, this.minecraft.player); + FluidState fluidstate = level.getFluidState(p_105268_); +- boolean flag = level.setBlock(p_105268_, fluidstate.createLegacyBlock(), 11); ++ boolean flag = blockstate.onDestroyedByPlayer(level, p_105268_, minecraft.player, false, fluidstate); if (flag) { - block.m_6786_(level, p_105268_, blockstate); + block.destroy(level, p_105268_, blockstate); } @@ -139,21 +_,25 @@ - BlockState blockstate = this.f_105189_.f_91073_.m_8055_(p_105270_); - this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105270_, blockstate, 1.0F); - this.m_105272_(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_); -+ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105270_, p_105271_).isCanceled()) - this.m_105267_(p_105270_); - this.f_105195_ = 5; - } else if (!this.f_105196_ || !this.m_105281_(p_105270_)) { - if (this.f_105196_) { - this.m_105272_(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.f_105191_, p_105271_); + BlockState blockstate = this.minecraft.level.getBlockState(p_105270_); + this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F); + this.sendBlockAction(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_); ++ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.minecraft.player, p_105270_, p_105271_).isCanceled()) + this.destroyBlock(p_105270_); + this.destroyDelay = 5; + } else if (!this.isDestroying || !this.sameDestroyTarget(p_105270_)) { + if (this.isDestroying) { + this.sendBlockAction(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_); } -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105270_, p_105271_); ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.minecraft.player, p_105270_, p_105271_); - BlockState blockstate1 = this.f_105189_.f_91073_.m_8055_(p_105270_); - this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105270_, blockstate1, 0.0F); - this.m_105272_(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_); - boolean flag = !blockstate1.m_60795_(); - if (flag && this.f_105193_ == 0.0F) { + BlockState blockstate1 = this.minecraft.level.getBlockState(p_105270_); + this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate1, 0.0F); + this.sendBlockAction(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_); + boolean flag = !blockstate1.isAir(); + if (flag && this.destroyProgress == 0.0F) { + if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) - blockstate1.m_60686_(this.f_105189_.f_91073_, p_105270_, this.f_105189_.f_91074_); + blockstate1.attack(this.minecraft.level, p_105270_, this.minecraft.player); } + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; - if (flag && blockstate1.m_60625_(this.f_105189_.f_91074_, this.f_105189_.f_91074_.f_19853_, p_105270_) >= 1.0F) { - this.m_105267_(p_105270_); + if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level, p_105270_) >= 1.0F) { + this.destroyBlock(p_105270_); } else { @@ -193,6 +_,7 @@ - BlockState blockstate1 = this.f_105189_.f_91073_.m_8055_(p_105284_); - this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105284_, blockstate1, 1.0F); - this.m_105272_(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_); -+ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105284_, p_105285_).isCanceled()) - this.m_105267_(p_105284_); + BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_); + this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F); + this.sendBlockAction(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_); ++ if (!net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.minecraft.player, p_105284_, p_105285_).isCanceled()) + this.destroyBlock(p_105284_); return true; - } else if (this.m_105281_(p_105284_)) { + } else if (this.sameDestroyTarget(p_105284_)) { @@ -203,12 +_,13 @@ } else { - this.f_105193_ += blockstate.m_60625_(this.f_105189_.f_91074_, this.f_105189_.f_91074_.f_19853_, p_105284_); - if (this.f_105194_ % 4.0F == 0.0F) { -- SoundType soundtype = blockstate.m_60827_(); -+ SoundType soundtype = blockstate.getSoundType(this.f_105189_.f_91073_, p_105284_, this.f_105189_.f_91074_); - this.f_105189_.m_91106_().m_120367_(new SimpleSoundInstance(soundtype.m_56778_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 8.0F, soundtype.m_56774_() * 0.5F, p_105284_)); + this.destroyProgress += blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level, p_105284_); + if (this.destroyTicks % 4.0F == 0.0F) { +- SoundType soundtype = blockstate.getSoundType(); ++ SoundType soundtype = blockstate.getSoundType(this.minecraft.level, p_105284_, this.minecraft.player); + this.minecraft.getSoundManager().play(new SimpleSoundInstance(soundtype.getHitSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, p_105284_)); } - ++this.f_105194_; - this.f_105189_.m_91301_().m_120581_(this.f_105189_.f_91073_, p_105284_, blockstate, Mth.m_14036_(this.f_105193_, 0.0F, 1.0F)); -+ if (net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105284_, p_105285_).getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; - if (this.f_105193_ >= 1.0F) { - this.f_105196_ = false; - this.m_105272_(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, p_105284_, p_105285_); + ++this.destroyTicks; + this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); ++ if (net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.minecraft.player, p_105284_, p_105285_).getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; + if (this.destroyProgress >= 1.0F) { + this.isDestroying = false; + this.sendBlockAction(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, p_105284_, p_105285_); @@ -227,7 +_,7 @@ } - public float m_105286_() { -- return this.f_105197_.m_46408_() ? 5.0F : 4.5F; -+ return (float) this.f_105189_.f_91074_.getReachDistance(); + public float getPickRange() { +- return this.localPlayerMode.isCreative() ? 5.0F : 4.5F; ++ return (float) this.minecraft.player.getReachDistance(); } - public void m_105287_() { + public void tick() { @@ -244,7 +_,7 @@ - ItemStack itemstack = this.f_105189_.f_91074_.m_21205_(); - boolean flag = this.f_105192_.m_41619_() && itemstack.m_41619_(); - if (!this.f_105192_.m_41619_() && !itemstack.m_41619_()) { -- flag = itemstack.m_150930_(this.f_105192_.m_41720_()) && ItemStack.m_41658_(itemstack, this.f_105192_) && (itemstack.m_41763_() || itemstack.m_41773_() == this.f_105192_.m_41773_()); -+ flag = !this.f_105192_.shouldCauseBlockBreakReset(itemstack); + ItemStack itemstack = this.minecraft.player.getMainHandItem(); + boolean flag = this.destroyingItem.isEmpty() && itemstack.isEmpty(); + if (!this.destroyingItem.isEmpty() && !itemstack.isEmpty()) { +- flag = itemstack.is(this.destroyingItem.getItem()) && ItemStack.tagMatches(itemstack, this.destroyingItem) && (itemstack.isDamageableItem() || itemstack.getDamageValue() == this.destroyingItem.getDamageValue()); ++ flag = !this.destroyingItem.shouldCauseBlockBreakReset(itemstack); } - return p_105282_.equals(this.f_105191_) && flag; + return p_105282_.equals(this.destroyBlockPos) && flag; @@ -266,13 +_,27 @@ return InteractionResult.FAIL; } else { - ItemStack itemstack = p_105263_.m_21120_(p_105265_); + ItemStack itemstack = p_105263_.getItemInHand(p_105265_); + net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks + .onRightClickBlock(p_105263_, p_105265_, blockpos, p_105266_); + if (event.isCanceled()) { -+ this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); ++ this.connection.send(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); + return event.getCancellationResult(); + } - if (this.f_105197_ == GameType.SPECTATOR) { - this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); + if (this.localPlayerMode == GameType.SPECTATOR) { + this.connection.send(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); return InteractionResult.SUCCESS; } else { -- boolean flag = !p_105263_.m_21205_().m_41619_() || !p_105263_.m_21206_().m_41619_(); +- boolean flag = !p_105263_.getMainHandItem().isEmpty() || !p_105263_.getOffhandItem().isEmpty(); + UseOnContext useoncontext = new UseOnContext(p_105263_, p_105265_, p_105266_); + if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { + InteractionResult result = itemstack.onItemUseFirst(useoncontext); + if (result != InteractionResult.PASS) { -+ this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); ++ this.connection.send(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); + return result; + } + } -+ boolean flag = !p_105263_.m_21205_().doesSneakBypassUse(p_105264_,blockpos,p_105263_) || !p_105263_.m_21206_().doesSneakBypassUse(p_105264_,blockpos,p_105263_); - boolean flag1 = p_105263_.m_36341_() && flag; ++ boolean flag = !p_105263_.getMainHandItem().doesSneakBypassUse(p_105264_,blockpos,p_105263_) || !p_105263_.getOffhandItem().doesSneakBypassUse(p_105264_,blockpos,p_105263_); + boolean flag1 = p_105263_.isSecondaryUseActive() && flag; - if (!flag1) { + if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { - InteractionResult interactionresult = p_105264_.m_8055_(blockpos).m_60664_(p_105264_, p_105263_, p_105265_, p_105266_); - if (interactionresult.m_19077_()) { - this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); + InteractionResult interactionresult = p_105264_.getBlockState(blockpos).use(p_105264_, p_105263_, p_105265_, p_105266_); + if (interactionresult.consumesAction()) { + this.connection.send(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); @@ -281,8 +_,8 @@ } - this.f_105190_.m_104955_(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); -- if (!itemstack.m_41619_() && !p_105263_.m_36335_().m_41519_(itemstack.m_41720_())) { + this.connection.send(new ServerboundUseItemOnPacket(p_105265_, p_105266_)); +- if (!itemstack.isEmpty() && !p_105263_.getCooldowns().isOnCooldown(itemstack.getItem())) { - UseOnContext useoncontext = new UseOnContext(p_105263_, p_105265_, p_105266_); + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS; -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.m_41619_() && !p_105263_.m_36335_().m_41519_(itemstack.m_41720_()))) { ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.isEmpty() && !p_105263_.getCooldowns().isOnCooldown(itemstack.getItem()))) { InteractionResult interactionresult1; - if (this.f_105197_.m_46408_()) { - int i = itemstack.m_41613_(); + if (this.localPlayerMode.isCreative()) { + int i = itemstack.getCount(); @@ -311,10 +_,13 @@ - if (p_105236_.m_36335_().m_41519_(itemstack.m_41720_())) { + if (p_105236_.getCooldowns().isOnCooldown(itemstack.getItem())) { return InteractionResult.PASS; } else { + InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_105236_, p_105238_); + if (cancelResult != null) return cancelResult; - InteractionResultHolder interactionresultholder = itemstack.m_41682_(p_105237_, p_105236_, p_105238_); - ItemStack itemstack1 = interactionresultholder.m_19095_(); + InteractionResultHolder interactionresultholder = itemstack.use(p_105237_, p_105236_, p_105238_); + ItemStack itemstack1 = interactionresultholder.getObject(); if (itemstack1 != itemstack) { - p_105236_.m_21008_(p_105238_, itemstack1); -+ if (itemstack1.m_41619_()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_105236_, itemstack, p_105238_); + p_105236_.setItemInHand(p_105238_, itemstack1); ++ if (itemstack1.isEmpty()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_105236_, itemstack, p_105238_); } - return interactionresultholder.m_19089_(); + return interactionresultholder.getResult(); @@ -350,6 +_,9 @@ - this.m_105297_(); - Vec3 vec3 = p_105233_.m_82450_().m_82492_(p_105232_.m_20185_(), p_105232_.m_20186_(), p_105232_.m_20189_()); - this.f_105190_.m_104955_(ServerboundInteractPacket.m_179612_(p_105232_, p_105231_.m_6144_(), p_105234_, vec3)); -+ if (this.f_105197_ == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract + 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)); ++ if (this.localPlayerMode == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract + InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAt(p_105231_, p_105232_, p_105233_, p_105234_); + if(cancelResult != null) return cancelResult; - return this.f_105197_ == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.m_7111_(p_105231_, vec3, p_105234_); + return 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 c61b6fea..c55fdca7 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -3,8 +3,8 @@ @@ -50,6 +_,7 @@ } - protected void m_105317_(GameType p_105318_) { -+ net.minecraftforge.client.ForgeHooksClient.onClientChangeGameType(this, this.f_105300_, p_105318_); - this.f_105300_ = p_105318_; + protected void setGameMode(GameType p_105318_) { ++ net.minecraftforge.client.ForgeHooksClient.onClientChangeGameType(this, this.gameMode, p_105318_); + this.gameMode = p_105318_; } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch index a4803b21..ea729ac3 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/client/multiplayer/ServerData.java @@ -26,6 +_,7 @@ @Nullable - private String f_105372_; - private boolean f_105373_; + private String iconB64; + private boolean lan; + public net.minecraftforge.client.ExtendedServerListData forgeData = null; public ServerData(String p_105375_, String p_105376_, boolean p_105377_) { - this.f_105362_ = p_105375_; + this.name = p_105375_; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch index 06788506..a5134241 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch @@ -5,6 +5,6 @@ } + net.minecraftforge.client.ForgeHooksClient.processForgeListPingData(serverstatus, p_105460_); - this.f_105477_ = Util.m_137550_(); - connection.m_129512_(new ServerboundPingRequestPacket(this.f_105477_)); - this.f_105475_ = true; + this.pingStart = Util.getMillis(); + connection.send(new ServerboundPingRequestPacket(this.pingStart)); + this.success = true; diff --git a/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch index 0357c211..2b5695ae 100644 --- a/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch @@ -4,9 +4,9 @@ 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.0D, 0.0D, 0.0D); -- this.m_108337_(Minecraft.m_91087_().m_91291_().m_174264_(p_105669_, p_105665_, (LivingEntity)null, 0).m_6160_()); -+ var model = Minecraft.m_91087_().m_91291_().m_174264_(p_105669_, p_105665_, (LivingEntity)null, 0); -+ this.m_108337_(model.m_7343_().m_173464_(model, p_105669_, p_105665_, null, 0).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE)); - this.f_107226_ = 1.0F; - this.f_107663_ /= 2.0F; - this.f_105643_ = this.f_107223_.nextFloat() * 3.0F; +- this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, (LivingEntity)null, 0).getParticleIcon()); ++ var model = Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, (LivingEntity)null, 0); ++ this.setSprite(model.getOverrides().resolve(model, p_105669_, p_105665_, null, 0).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE)); + this.gravity = 1.0F; + this.quadSize /= 2.0F; + this.uo = this.random.nextFloat() * 3.0F; diff --git a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch index db479a31..8d025385 100644 --- a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/particle/Particle.java +++ b/net/minecraft/client/particle/Particle.java @@ -226,4 +_,12 @@ - public Optional m_142654_() { + public Optional getParticleGroup() { return Optional.empty(); } + diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index f4fb172b..32b0ad8d 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,42 +1,42 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java @@ -66,11 +_,11 @@ - private static final int f_172264_ = 16384; - private static final List f_107288_ = ImmutableList.of(ParticleRenderType.f_107429_, ParticleRenderType.f_107430_, ParticleRenderType.f_107432_, ParticleRenderType.f_107431_, ParticleRenderType.f_107433_); - protected ClientLevel f_107287_; -- private final Map> f_107289_ = Maps.newIdentityHashMap(); -+ private final Map> f_107289_ = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(f_107288_)); - private final Queue f_107290_ = Queues.newArrayDeque(); - private final TextureManager f_107291_; - private final Random f_107292_ = new Random(); -- private final Int2ObjectMap> f_107293_ = new Int2ObjectOpenHashMap<>(); -+ private final Map> f_107293_ = new java.util.HashMap<>(); - private final Queue f_107294_ = Queues.newArrayDeque(); - private final Map f_107295_ = Maps.newHashMap(); - private final TextureAtlas f_107296_; + private static final int MAX_PARTICLES_PER_LAYER = 16384; + private static final List RENDER_ORDER = ImmutableList.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_LIT, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM); + protected ClientLevel level; +- private final Map> particles = Maps.newIdentityHashMap(); ++ private final Map> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER)); + private final Queue trackingEmitters = Queues.newArrayDeque(); + private final TextureManager textureManager; + private final Random random = new Random(); +- private final Int2ObjectMap> providers = new Int2ObjectOpenHashMap<>(); ++ private final Map> providers = new java.util.HashMap<>(); + private final Queue particlesToAdd = Queues.newArrayDeque(); + private final Map spriteSets = Maps.newHashMap(); + private final TextureAtlas textureAtlas; @@ -176,13 +_,13 @@ } - public void m_107381_(ParticleType p_107382_, ParticleProvider p_107383_) { -- this.f_107293_.put(Registry.f_122829_.m_7447_(p_107382_), p_107383_); -+ this.f_107293_.put(Registry.f_122829_.m_7981_(p_107382_), p_107383_); + public void register(ParticleType p_107382_, ParticleProvider p_107383_) { +- this.providers.put(Registry.PARTICLE_TYPE.getId(p_107382_), p_107383_); ++ this.providers.put(Registry.PARTICLE_TYPE.getKey(p_107382_), p_107383_); } - public void m_107378_(ParticleType p_107379_, ParticleEngine.SpriteParticleRegistration p_107380_) { + public void register(ParticleType p_107379_, ParticleEngine.SpriteParticleRegistration p_107380_) { ParticleEngine.MutableSpriteSet particleengine$mutablespriteset = new ParticleEngine.MutableSpriteSet(); - this.f_107295_.put(Registry.f_122829_.m_7981_(p_107379_), particleengine$mutablespriteset); -- this.f_107293_.put(Registry.f_122829_.m_7447_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); -+ this.f_107293_.put(Registry.f_122829_.m_7981_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); + this.spriteSets.put(Registry.PARTICLE_TYPE.getKey(p_107379_), particleengine$mutablespriteset); +- this.providers.put(Registry.PARTICLE_TYPE.getId(p_107379_), p_107380_.create(particleengine$mutablespriteset)); ++ this.providers.put(Registry.PARTICLE_TYPE.getKey(p_107379_), p_107380_.create(particleengine$mutablespriteset)); } - public CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { + public CompletableFuture reload(PreparableReloadListener.PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { @@ -300,7 +_,7 @@ @Nullable - private Particle m_107395_(T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_) { -- ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(Registry.f_122829_.m_7447_(p_107396_.m_6012_())); -+ ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(Registry.f_122829_.m_7981_(p_107396_.m_6012_())); - return particleprovider == null ? null : particleprovider.m_6966_(p_107396_, this.f_107287_, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); + private Particle makeParticle(T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_) { +- ParticleProvider particleprovider = (ParticleProvider)this.providers.get(Registry.PARTICLE_TYPE.getId(p_107396_.getType())); ++ ParticleProvider particleprovider = (ParticleProvider)this.providers.get(Registry.PARTICLE_TYPE.getKey(p_107396_.getType())); + return particleprovider == null ? null : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); } @@ -381,15 +_,25 @@ @@ -45,70 +45,70 @@ + /**@deprecated Forge: use {@link #render(PoseStack, MultiBufferSource.BufferSource, LightTexture, Camera, float, net.minecraft.client.renderer.culling.Frustum)} with Frustum as additional parameter*/ + @Deprecated - public void m_107336_(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_, LightTexture p_107339_, Camera p_107340_, float p_107341_) { + public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_, LightTexture p_107339_, Camera p_107340_, float p_107341_) { + render(p_107337_, p_107338_, p_107339_, p_107340_, p_107341_, null); + } + + public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_, LightTexture p_107339_, Camera p_107340_, float p_107341_, @Nullable net.minecraft.client.renderer.culling.Frustum clippingHelper) { - p_107339_.m_109896_(); - RenderSystem.m_69482_(); -+ RenderSystem.m_69388_(org.lwjgl.opengl.GL13.GL_TEXTURE2); -+ RenderSystem.m_69493_(); -+ RenderSystem.m_69388_(org.lwjgl.opengl.GL13.GL_TEXTURE0); - PoseStack posestack = RenderSystem.m_157191_(); - posestack.m_85836_(); - posestack.m_166854_(p_107337_.m_85850_().m_85861_()); - RenderSystem.m_157182_(); + p_107339_.turnOnLightLayer(); + RenderSystem.enableDepthTest(); ++ RenderSystem.activeTexture(org.lwjgl.opengl.GL13.GL_TEXTURE2); ++ RenderSystem.enableTexture(); ++ RenderSystem.activeTexture(org.lwjgl.opengl.GL13.GL_TEXTURE0); + PoseStack posestack = RenderSystem.getModelViewStack(); + posestack.pushPose(); + posestack.mulPoseMatrix(p_107337_.last().pose()); + RenderSystem.applyModelViewMatrix(); -- for(ParticleRenderType particlerendertype : f_107288_) { -+ for(ParticleRenderType particlerendertype : this.f_107289_.keySet()) { // Forge: allow custom IParticleRenderType's -+ if (particlerendertype == ParticleRenderType.f_107434_) continue; - Iterable iterable = this.f_107289_.get(particlerendertype); +- for(ParticleRenderType particlerendertype : RENDER_ORDER) { ++ for(ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom IParticleRenderType's ++ if (particlerendertype == ParticleRenderType.NO_RENDER) continue; + Iterable iterable = this.particles.get(particlerendertype); if (iterable != null) { - RenderSystem.m_157427_(GameRenderer::m_172829_); + RenderSystem.setShader(GameRenderer::getParticleShader); @@ -399,6 +_,7 @@ - particlerendertype.m_6505_(bufferbuilder, this.f_107291_); + particlerendertype.begin(bufferbuilder, this.textureManager); for(Particle particle : iterable) { -+ if (clippingHelper != null && particle.shouldCull() && !clippingHelper.m_113029_(particle.m_107277_())) continue; ++ if (clippingHelper != null && particle.shouldCull() && !clippingHelper.isVisible(particle.getBoundingBox())) continue; try { - particle.m_5744_(bufferbuilder, p_107340_, p_107341_); + particle.render(bufferbuilder, p_107340_, p_107341_); } catch (Throwable throwable) { @@ -429,7 +_,7 @@ } - public void m_107355_(BlockPos p_107356_, BlockState p_107357_) { -- if (!p_107357_.m_60795_()) { -+ if (!p_107357_.m_60795_() && !net.minecraftforge.client.RenderProperties.get(p_107357_).addDestroyEffects(p_107357_, this.f_107287_, p_107356_, this)) { - VoxelShape voxelshape = p_107357_.m_60808_(this.f_107287_, p_107356_); + public void destroy(BlockPos p_107356_, BlockState p_107357_) { +- if (!p_107357_.isAir()) { ++ if (!p_107357_.isAir() && !net.minecraftforge.client.RenderProperties.get(p_107357_).addDestroyEffects(p_107357_, this.level, p_107356_, this)) { + VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_); double d0 = 0.25D; - voxelshape.m_83286_((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> { + voxelshape.forAllBoxes((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> { @@ -449,7 +_,7 @@ double d7 = d4 * d1 + p_172273_; double d8 = d5 * d2 + p_172274_; double d9 = d6 * d3 + p_172275_; -- this.m_107344_(new TerrainParticle(this.f_107287_, (double)p_107356_.m_123341_() + d7, (double)p_107356_.m_123342_() + d8, (double)p_107356_.m_123343_() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_)); -+ this.m_107344_(new TerrainParticle(this.f_107287_, (double)p_107356_.m_123341_() + d7, (double)p_107356_.m_123342_() + d8, (double)p_107356_.m_123343_() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_).updateSprite(p_107357_, p_107356_)); +- this.add(new TerrainParticle(this.level, (double)p_107356_.getX() + d7, (double)p_107356_.getY() + d8, (double)p_107356_.getZ() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_)); ++ this.add(new TerrainParticle(this.level, (double)p_107356_.getX() + d7, (double)p_107356_.getY() + d8, (double)p_107356_.getZ() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_).updateSprite(p_107357_, p_107356_)); } } } @@ -493,12 +_,18 @@ - d0 = (double)i + aabb.f_82291_ + (double)0.1F; + d0 = (double)i + aabb.maxX + (double)0.1F; } -- this.m_107344_((new TerrainParticle(this.f_107287_, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_)).m_107268_(0.2F).m_6569_(0.6F)); -+ this.m_107344_((new TerrainParticle(this.f_107287_, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_).updateSprite(blockstate, p_107368_)).m_107268_(0.2F).m_6569_(0.6F)); +- this.add((new TerrainParticle(this.level, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_)).setPower(0.2F).scale(0.6F)); ++ this.add((new TerrainParticle(this.level, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_).updateSprite(blockstate, p_107368_)).setPower(0.2F).scale(0.6F)); } } - public String m_107403_() { - return String.valueOf(this.f_107289_.values().stream().mapToInt(Collection::size).sum()); + public String countParticles() { + return String.valueOf(this.particles.values().stream().mapToInt(Collection::size).sum()); + } + + public void addBlockHitEffects(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) { -+ BlockState state = f_107287_.m_8055_(pos); -+ if (!net.minecraftforge.client.RenderProperties.get(state).addHitEffects(state, f_107287_, target, this)) -+ m_107367_(pos, target.m_82434_()); ++ BlockState state = level.getBlockState(pos); ++ if (!net.minecraftforge.client.RenderProperties.get(state).addHitEffects(state, level, target, this)) ++ crack(pos, target.getDirection()); } - private boolean m_172279_(ParticleGroup p_172280_) { + private boolean hasSpaceInParticleLimit(ParticleGroup p_172280_) { diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch index 86b99200..27c96766 100644 --- a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/client/particle/TerrainParticle.java @@ -69,7 +_,13 @@ public static class Provider implements ParticleProvider { - public Particle m_6966_(BlockParticleOption p_108304_, ClientLevel p_108305_, double p_108306_, double p_108307_, double p_108308_, double p_108309_, double p_108310_, double p_108311_) { - BlockState blockstate = p_108304_.m_123642_(); -- return !blockstate.m_60795_() && !blockstate.m_60713_(Blocks.f_50110_) ? new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate) : null; -+ return !blockstate.m_60795_() && !blockstate.m_60713_(Blocks.f_50110_) ? (new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate)).updateSprite(blockstate, p_108304_.getPos()) : null; + public Particle createParticle(BlockParticleOption p_108304_, ClientLevel p_108305_, double p_108306_, double p_108307_, double p_108308_, double p_108309_, double p_108310_, double p_108311_) { + BlockState blockstate = p_108304_.getState(); +- return !blockstate.isAir() && !blockstate.is(Blocks.MOVING_PISTON) ? new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate) : null; ++ return !blockstate.isAir() && !blockstate.is(Blocks.MOVING_PISTON) ? (new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate)).updateSprite(blockstate, p_108304_.getPos()) : null; } + } + + public Particle updateSprite(BlockState state, BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block. + if (pos != null) // There are cases where we are not able to obtain the correct source pos, and need to fallback to the non-model data version -+ this.m_108337_(Minecraft.m_91087_().m_91289_().m_110907_().getTexture(state, f_107208_, pos)); ++ this.setSprite(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getTexture(state, level, pos)); + return this; } } diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index 7d52bf21..4fac8cbd 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -4,7 +4,7 @@ } } -- return Mth.m_14179_(Minecraft.m_91087_().f_91066_.f_92070_, 1.0F, f); +- return Mth.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, f); + return net.minecraftforge.client.ForgeHooksClient.getFieldOfView(this, f); } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index 6910353f..65d874dd 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -3,7 +3,7 @@ @@ -145,6 +_,7 @@ } - public boolean m_6469_(DamageSource p_108662_, float p_108663_) { + public boolean hurt(DamageSource p_108662_, float p_108663_) { + net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_108662_, p_108663_); return false; } @@ -11,56 +11,56 @@ @@ -461,6 +_,11 @@ } - public void m_5496_(SoundEvent p_108651_, float p_108652_, float p_108653_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_108651_, this.m_5720_(), p_108652_, p_108653_); + public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_108651_, this.getSoundSource(), p_108652_, p_108653_); + if (event.isCanceled() || event.getSound() == null) return; + p_108651_ = event.getSound(); + p_108652_ = event.getVolume(); + p_108653_ = event.getPitch(); - this.f_19853_.m_7785_(this.m_20185_(), this.m_20186_(), this.m_20189_(), p_108651_, this.m_5720_(), p_108652_, p_108653_, false); + this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), p_108651_, this.getSoundSource(), p_108652_, p_108653_, false); } @@ -616,6 +_,7 @@ - boolean flag2 = this.m_108733_(); - this.f_108601_ = !this.m_150110_().f_35935_ && !this.m_6069_() && this.m_20175_(Pose.CROUCHING) && (this.m_6144_() || !this.m_5803_() && !this.m_20175_(Pose.STANDING)); - this.f_108618_.m_7606_(this.m_108635_()); -+ net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.f_108618_); - this.f_108619_.m_91301_().m_120586_(this.f_108618_); - if (this.m_6117_() && !this.m_20159_()) { - this.f_108618_.f_108566_ *= 0.2F; + boolean flag2 = this.hasEnoughImpulseToStartSprinting(); + this.crouching = !this.getAbilities().flying && !this.isSwimming() && this.canEnterPose(Pose.CROUCHING) && (this.isShiftKeyDown() || !this.isSleeping() && !this.canEnterPose(Pose.STANDING)); + this.input.tick(this.isMovingSlowly()); ++ net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.input); + this.minecraft.getTutorial().onInput(this.input); + if (this.isUsingItem() && !this.isPassenger()) { + this.input.leftImpulse *= 0.2F; @@ -688,7 +_,7 @@ - if (this.f_108618_.f_108572_ && !flag7 && !flag && !this.m_150110_().f_35935_ && !this.m_20159_() && !this.m_6147_()) { - ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); -- if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack) && this.m_36319_()) { -+ if (itemstack.canElytraFly(this) && this.m_36319_()) { - this.f_108617_.m_104955_(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); + if (this.input.jumping && !flag7 && !flag && !this.getAbilities().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)); } } @@ -806,6 +_,7 @@ - public void m_6083_() { - super.m_6083_(); -+ if (this.m_36342_() && this.m_20159_()) this.f_108618_.f_108573_ = false; - this.f_108611_ = false; - if (this.m_20202_() instanceof Boat) { - Boat boat = (Boat)this.m_20202_(); + public void rideTick() { + super.rideTick(); ++ if (this.wantsToStopRiding() && this.isPassenger()) this.input.shiftKeyDown = false; + this.handsBusy = false; + if (this.getVehicle() instanceof Boat) { + Boat boat = (Boat)this.getVehicle(); @@ -1019,6 +_,18 @@ } else { - return super.m_7398_(p_108758_); + return super.getRopeHoldPosition(p_108758_); } + } + + public void updateSyncFields(LocalPlayer old) { -+ this.f_108595_ = old.f_108595_; -+ this.f_108596_ = old.f_108596_; -+ this.f_108597_ = old.f_108597_; -+ this.f_108598_ = old.f_108598_; -+ this.f_108599_ = old.f_108599_; -+ this.f_108600_ = old.f_108600_; -+ this.f_108602_ = old.f_108602_; -+ this.f_108603_ = old.f_108603_; -+ this.f_108604_ = old.f_108604_; ++ this.xLast = old.xLast; ++ this.yLast1 = old.yLast1; ++ this.zLast = old.zLast; ++ this.yRotLast = old.yRotLast; ++ this.xRotLast = old.xRotLast; ++ this.lastOnGround = old.lastOnGround; ++ this.wasShiftKeyDown = old.wasShiftKeyDown; ++ this.wasSprinting = old.wasSprinting; ++ this.positionReminder = old.positionReminder; } - public void m_141945_(ItemStack p_172532_, ItemStack p_172533_, ClickAction p_172534_) { + public void updateTutorialInventoryAction(ItemStack p_172532_, ItemStack p_172533_, ClickAction p_172534_) { diff --git a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch index e838305c..946fdaac 100644 --- a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch @@ -3,7 +3,7 @@ @@ -29,6 +_,7 @@ } - public boolean m_6469_(DamageSource p_108772_, float p_108773_) { + 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 bd013144..6409f295 100644 --- a/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/client/renderer/DimensionSpecialEffects.java +++ b/net/minecraft/client/renderer/DimensionSpecialEffects.java @@ -26,6 +_,10 @@ - private final DimensionSpecialEffects.SkyType f_108861_; - private final boolean f_108862_; - private final boolean f_108863_; + private final DimensionSpecialEffects.SkyType skyType; + private final boolean forceBrightLightmap; + private final boolean constantAmbientLight; + private net.minecraftforge.client.IWeatherRenderHandler weatherRenderHandler = null; + private net.minecraftforge.client.IWeatherParticleRenderHandler weatherParticleRenderHandler = null; + private net.minecraftforge.client.ISkyRenderHandler skyRenderHandler = null; + private net.minecraftforge.client.ICloudRenderHandler cloudRenderHandler = null; public DimensionSpecialEffects(float p_108866_, boolean p_108867_, DimensionSpecialEffects.SkyType p_108868_, boolean p_108869_, boolean p_108870_) { - this.f_108859_ = p_108866_; + this.cloudLevel = p_108866_; @@ -80,6 +_,35 @@ - public boolean m_108885_() { - return this.f_108863_; + public boolean constantAmbientLight() { + return this.constantAmbientLight; + } + + public void setWeatherRenderHandler(net.minecraftforge.client.IWeatherRenderHandler weatherRenderHandler) { diff --git a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch index 9b6d4d00..f3871b15 100644 --- a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/client/renderer/EffectInstance.java +++ b/net/minecraft/client/renderer/EffectInstance.java @@ -60,7 +_,8 @@ - private final EffectProgram f_108938_; + private final EffectProgram fragmentProgram; public EffectInstance(ResourceManager p_108941_, String p_108942_) throws IOException { - ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_108942_ + ".json"); -+ ResourceLocation rl = ResourceLocation.m_135820_(p_108942_); -+ ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "shaders/program/" + rl.m_135815_() + ".json"); - this.f_108932_ = p_108942_; ++ ResourceLocation rl = ResourceLocation.tryParse(p_108942_); ++ ResourceLocation resourcelocation = new ResourceLocation(rl.getNamespace(), "shaders/program/" + rl.getPath() + ".json"); + this.name = p_108942_; Resource resource = null; @@ -162,7 +_,8 @@ } else { EffectProgram effectprogram; if (program == null) { -- ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_172569_ + p_172568_.m_85569_()); -+ ResourceLocation rl = ResourceLocation.m_135820_(p_172569_); -+ ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "shaders/program/" + rl.m_135815_() + p_172568_.m_85569_()); - Resource resource = p_172567_.m_142591_(resourcelocation); +- ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_172569_ + p_172568_.getExtension()); ++ ResourceLocation rl = ResourceLocation.tryParse(p_172569_); ++ ResourceLocation resourcelocation = new ResourceLocation(rl.getNamespace(), "shaders/program/" + rl.getPath() + p_172568_.getExtension()); + Resource resource = p_172567_.getResource(resourcelocation); try { diff --git a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch index f83f9277..3f17a0d6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch @@ -2,37 +2,37 @@ +++ b/net/minecraft/client/renderer/FogRenderer.java @@ -173,24 +_,43 @@ - if (f_109010_ != 0.0F && f_109011_ != 0.0F && f_109012_ != 0.0F) { - float f8 = Math.min(1.0F / f_109010_, Math.min(1.0F / f_109011_, 1.0F / f_109012_)); + if (fogRed != 0.0F && fogGreen != 0.0F && fogBlue != 0.0F) { + float f8 = Math.min(1.0F / fogRed, Math.min(1.0F / fogGreen, 1.0F / fogBlue)); + // Forge: fix MC-4647 and MC-10480 + if (Float.isInfinite(f8)) f8 = Math.nextAfter(f8, 0.0); - f_109010_ = f_109010_ * (1.0F - f6) + f_109010_ * f8 * f6; - f_109011_ = f_109011_ * (1.0F - f6) + f_109011_ * f8 * f6; - f_109012_ = f_109012_ * (1.0F - f6) + f_109012_ * f8 * f6; + fogRed = fogRed * (1.0F - f6) + fogRed * f8 * f6; + fogGreen = fogGreen * (1.0F - f6) + fogGreen * f8 * f6; + fogBlue = fogBlue * (1.0F - f6) + fogBlue * f8 * f6; } -+ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(p_109019_, p_109020_, f_109010_, f_109011_, f_109012_); ++ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(p_109019_, p_109020_, fogRed, fogGreen, fogBlue); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + -+ f_109010_ = event.getRed(); -+ f_109011_ = event.getGreen(); -+ f_109012_ = event.getBlue(); ++ fogRed = event.getRed(); ++ fogGreen = event.getGreen(); ++ fogBlue = event.getBlue(); + - RenderSystem.m_69424_(f_109010_, f_109011_, f_109012_, 0.0F); + RenderSystem.clearColor(fogRed, fogGreen, fogBlue, 0.0F); } - public static void m_109017_() { - RenderSystem.m_157445_(Float.MAX_VALUE); + public static void setupNoFog() { + RenderSystem.setShaderFogStart(Float.MAX_VALUE); } - + @Deprecated // FORGE: Pass in partialTicks - public static void m_109024_(Camera p_109025_, FogRenderer.FogMode p_109026_, float p_109027_, boolean p_109028_) { + public static void setupFog(Camera p_109025_, FogRenderer.FogMode p_109026_, float p_109027_, boolean p_109028_) { + setupFog(p_109025_, p_109026_, p_109027_, p_109028_, 0); + } + + public static void setupFog(Camera p_109025_, FogRenderer.FogMode p_109026_, float p_109027_, boolean p_109028_, float partialTicks) { - FogType fogtype = p_109025_.m_167685_(); - Entity entity = p_109025_.m_90592_(); + FogType fogtype = p_109025_.getFluidInCamera(); + Entity entity = p_109025_.getEntity(); FogShape fogshape = FogShape.SPHERE; float f; float f1; @@ -43,13 +43,13 @@ + f1 = hook * 0.5F; + } else if (fogtype == FogType.LAVA) { - if (entity.m_5833_()) { + if (entity.isSpectator()) { f = -8.0F; @@ -253,6 +_,7 @@ - RenderSystem.m_157445_(f); - RenderSystem.m_157443_(f1); - RenderSystem.m_202160_(fogshape); + RenderSystem.setShaderFogStart(f); + RenderSystem.setShaderFogEnd(f1); + RenderSystem.setShaderFogShape(fogshape); + net.minecraftforge.client.ForgeHooksClient.onFogRender(p_109026_, p_109025_, partialTicks, f1); } - public static void m_109036_() { + 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 3f6a32b7..08f3baca 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java @@ -288,6 +_,8 @@ - this.m_109128_(new ResourceLocation("shaders/post/spider.json")); + this.loadEffect(new ResourceLocation("shaders/post/spider.json")); } else if (p_109107_ instanceof EnderMan) { - this.m_109128_(new ResourceLocation("shaders/post/invert.json")); + this.loadEffect(new ResourceLocation("shaders/post/invert.json")); + } else { + net.minecraftforge.client.ForgeHooksClient.loadEntityShader(p_109107_, this); } } @@ -544,6 +_,7 @@ - list1.add(Pair.of(new ShaderInstance(p_172768_, "rendertype_crumbling", DefaultVertexFormat.f_85811_), (p_172733_) -> { - f_172607_ = p_172733_; + list1.add(Pair.of(new ShaderInstance(p_172768_, "rendertype_crumbling", DefaultVertexFormat.BLOCK), (p_172733_) -> { + rendertypeCrumblingShader = p_172733_; })); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterShadersEvent(p_172768_, list1)); } catch (IOException ioexception) { @@ -21,8 +21,8 @@ boolean flag = false; int i = 3; double d1 = d0; -+ double atkRange = this.f_109059_.f_91074_.getAttackRange(); - if (this.f_109059_.f_91072_.m_105291_()) { ++ double atkRange = this.minecraft.player.getAttackRange(); + if (this.minecraft.gameMode.hasFarPickRange()) { - d1 = 6.0D; + d1 = Math.max(d0, atkRange); d0 = d1; @@ -37,22 +37,22 @@ } d1 *= d1; -- if (this.f_109059_.f_91077_ != null) { -+ if (this.f_109059_.f_91077_ != null && this.f_109059_.f_91077_.m_6662_() != HitResult.Type.MISS) { // Add != MISS to ensure Attack Range is not clamped at the value of Reach Distance. - d1 = this.f_109059_.f_91077_.m_82450_().m_82557_(vec3); +- if (this.minecraft.hitResult != null) { ++ if (this.minecraft.hitResult != null && this.minecraft.hitResult.getType() != HitResult.Type.MISS) { // Add != MISS to ensure Attack Range is not clamped at the value of Reach Distance. + d1 = this.minecraft.hitResult.getLocation().distanceToSqr(vec3); } @@ -652,7 +_,7 @@ - Entity entity1 = entityhitresult.m_82443_(); - Vec3 vec33 = entityhitresult.m_82450_(); - double d2 = vec3.m_82557_(vec33); + Entity entity1 = entityhitresult.getEntity(); + Vec3 vec33 = entityhitresult.getLocation(); + double d2 = vec3.distanceToSqr(vec33); - if (flag && d2 > 9.0D) { + if (false && flag && d2 > 9.0D) { //Forge: Always keep the entity result to allow for extended reach interactions. - this.f_109059_.f_91077_ = BlockHitResult.m_82426_(vec33, Direction.m_122366_(vec31.f_82479_, vec31.f_82480_, vec31.f_82481_), new BlockPos(vec33)); - } else if (d2 < d1 || this.f_109059_.f_91077_ == null) { - this.f_109059_.f_91077_ = entityhitresult; + this.minecraft.hitResult = BlockHitResult.miss(vec33, Direction.getNearest(vec31.x, vec31.y, vec31.z), new BlockPos(vec33)); + } else if (d2 < d1 || this.minecraft.hitResult == null) { + this.minecraft.hitResult = entityhitresult; @@ -706,7 +_,7 @@ - d0 *= (double)Mth.m_14179_(this.f_109059_.f_91066_.f_92070_, 1.0F, 0.85714287F); + d0 *= (double)Mth.lerp(this.minecraft.options.fovEffectScale, 1.0F, 0.85714287F); } - return d0; @@ -62,45 +62,45 @@ @@ -843,11 +_,11 @@ - Window window = this.f_109059_.m_91268_(); - RenderSystem.m_69421_(256, Minecraft.f_91002_); -- Matrix4f matrix4f = Matrix4f.m_162203_(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), 0.0F, (float)((double)window.m_85442_() / window.m_85449_()), 1000.0F, 3000.0F); -+ Matrix4f matrix4f = Matrix4f.m_162203_(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), 0.0F, (float)((double)window.m_85442_() / window.m_85449_()), 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); - RenderSystem.m_157425_(matrix4f); - PoseStack posestack = RenderSystem.m_157191_(); - posestack.m_166856_(); -- posestack.m_85837_(0.0D, 0.0D, -2000.0D); -+ posestack.m_85837_(0.0D, 0.0D, 1000F-net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); - RenderSystem.m_157182_(); - Lighting.m_84931_(); + Window window = this.minecraft.getWindow(); + RenderSystem.clear(256, Minecraft.ON_OSX); +- Matrix4f matrix4f = Matrix4f.orthographic(0.0F, (float)((double)window.getWidth() / window.getGuiScale()), 0.0F, (float)((double)window.getHeight() / window.getGuiScale()), 1000.0F, 3000.0F); ++ Matrix4f matrix4f = Matrix4f.orthographic(0.0F, (float)((double)window.getWidth() / window.getGuiScale()), 0.0F, (float)((double)window.getHeight() / window.getGuiScale()), 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); + RenderSystem.setProjectionMatrix(matrix4f); + PoseStack posestack = RenderSystem.getModelViewStack(); + posestack.setIdentity(); +- posestack.translate(0.0D, 0.0D, -2000.0D); ++ posestack.translate(0.0D, 0.0D, 1000F-net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); + RenderSystem.applyModelViewMatrix(); + Lighting.setupFor3DItems(); PoseStack posestack1 = new PoseStack(); @@ -882,7 +_,7 @@ } - } else if (this.f_109059_.f_91080_ != null) { + } else if (this.minecraft.screen != null) { try { -- this.f_109059_.f_91080_.m_6305_(posestack1, i, j, this.f_109059_.m_91297_()); -+ net.minecraftforge.client.ForgeHooksClient.drawScreen(this.f_109059_.f_91080_, posestack1, i, j, this.f_109059_.m_91297_()); +- this.minecraft.screen.render(posestack1, i, j, this.minecraft.getDeltaFrameTime()); ++ net.minecraftforge.client.ForgeHooksClient.drawScreen(this.minecraft.screen, posestack1, i, j, this.minecraft.getDeltaFrameTime()); } catch (Throwable throwable1) { - CrashReport crashreport1 = CrashReport.m_127521_(throwable1, "Rendering screen"); - CrashReportCategory crashreportcategory1 = crashreport1.m_127514_("Screen render details"); + CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); + CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); @@ -1040,6 +_,11 @@ - Matrix4f matrix4f = posestack.m_85850_().m_85861_(); - this.m_109111_(matrix4f); - camera.m_90575_(this.f_109059_.f_91073_, (Entity)(this.f_109059_.m_91288_() == null ? this.f_109059_.f_91074_ : this.f_109059_.m_91288_()), !this.f_109059_.f_91066_.m_92176_().m_90612_(), this.f_109059_.f_91066_.m_92176_().m_90613_(), p_109090_); + Matrix4f matrix4f = posestack.last().pose(); + this.resetProjectionMatrix(matrix4f); + camera.setup(this.minecraft.level, (Entity)(this.minecraft.getCameraEntity() == null ? this.minecraft.player : this.minecraft.getCameraEntity()), !this.minecraft.options.getCameraType().isFirstPerson(), this.minecraft.options.getCameraType().isMirrored(), p_109090_); + + net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup cameraSetup = net.minecraftforge.client.ForgeHooksClient.onCameraSetup(this, camera, p_109090_); + camera.setAnglesInternal(cameraSetup.getYaw(), cameraSetup.getPitch()); -+ p_109092_.m_85845_(Vector3f.f_122227_.m_122240_(cameraSetup.getRoll())); ++ p_109092_.mulPose(Vector3f.ZP.rotationDegrees(cameraSetup.getRoll())); + - p_109092_.m_85845_(Vector3f.f_122223_.m_122240_(camera.m_90589_())); - p_109092_.m_85845_(Vector3f.f_122225_.m_122240_(camera.m_90590_() + 180.0F)); - Matrix3f matrix3f = p_109092_.m_85850_().m_85864_().m_8183_(); + p_109092_.mulPose(Vector3f.XP.rotationDegrees(camera.getXRot())); + p_109092_.mulPose(Vector3f.YP.rotationDegrees(camera.getYRot() + 180.0F)); + Matrix3f matrix3f = p_109092_.last().normal().copy(); @@ -1049,6 +_,8 @@ - this.f_109059_.f_91060_.m_172961_(p_109092_, camera.m_90583_(), this.m_172716_(Math.max(d0, this.f_109059_.f_91066_.f_92068_))); - this.f_109059_.f_91060_.m_109599_(p_109092_, p_109090_, p_109091_, flag, camera, this, this.f_109074_, matrix4f); -+ this.f_109059_.m_91307_().m_6182_("forge_render_last"); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderLast(this.f_109059_.f_91060_, p_109092_, p_109090_, matrix4f, p_109091_); - this.f_109059_.m_91307_().m_6182_("hand"); - if (this.f_109070_) { - RenderSystem.m_69421_(256, Minecraft.f_91002_); + this.minecraft.levelRenderer.prepareCullFrustum(p_109092_, camera.getPosition(), this.getProjectionMatrix(Math.max(d0, this.minecraft.options.fov))); + this.minecraft.levelRenderer.renderLevel(p_109092_, p_109090_, p_109091_, flag, camera, this, this.lightTexture, matrix4f); ++ this.minecraft.getProfiler().popPush("forge_render_last"); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderLast(this.minecraft.levelRenderer, p_109092_, p_109090_, matrix4f, p_109091_); + this.minecraft.getProfiler().popPush("hand"); + if (this.renderHand) { + RenderSystem.clear(256, Minecraft.ON_OSX); diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index 66c31de5..5dcc9686 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -5,66 +5,66 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map f_109275_ = Util.m_137469_(Maps.newHashMap(), (p_109296_) -> { - RenderType rendertype = RenderType.m_110503_(); - p_109296_.put(Blocks.f_50267_, rendertype); + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), (p_109296_) -> { + RenderType rendertype = RenderType.tripwire(); + p_109296_.put(Blocks.TRIPWIRE, rendertype); @@ -286,6 +_,7 @@ - p_109296_.put(Blocks.f_50628_, rendertype3); - p_109296_.put(Blocks.f_152498_, rendertype3); + p_109296_.put(Blocks.BUBBLE_COLUMN, rendertype3); + p_109296_.put(Blocks.TINTED_GLASS, rendertype3); }); + @Deprecated - private static final Map f_109276_ = Util.m_137469_(Maps.newHashMap(), (p_109290_) -> { - RenderType rendertype = RenderType.m_110466_(); - p_109290_.put(Fluids.f_76192_, rendertype); + private static final Map TYPE_BY_FLUID = Util.make(Maps.newHashMap(), (p_109290_) -> { + RenderType rendertype = RenderType.translucent(); + p_109290_.put(Fluids.FLOWING_WATER, rendertype); @@ -293,6 +_,7 @@ }); - private static boolean f_109277_; + private static boolean renderCutout; + @Deprecated // FORGE: Use canRenderInLayer - public static RenderType m_109282_(BlockState p_109283_) { - Block block = p_109283_.m_60734_(); + public static RenderType getChunkRenderType(BlockState p_109283_) { + Block block = p_109283_.getBlock(); if (block instanceof LeavesBlock) { @@ -303,6 +_,7 @@ } } + @Deprecated // FORGE: Use canRenderInLayer - public static RenderType m_109293_(BlockState p_109294_) { - Block block = p_109294_.m_60734_(); + public static RenderType getMovingBlockRenderType(BlockState p_109294_) { + Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { @@ -318,8 +_,7 @@ } - public static RenderType m_109284_(BlockState p_109285_, boolean p_109286_) { -- RenderType rendertype = m_109282_(p_109285_); -- if (rendertype == RenderType.m_110466_()) { -+ if (canRenderInLayer(p_109285_, RenderType.m_110466_())) { - if (!Minecraft.m_91085_()) { - return Sheets.m_110792_(); + public static RenderType getRenderType(BlockState p_109285_, boolean p_109286_) { +- RenderType rendertype = getChunkRenderType(p_109285_); +- if (rendertype == RenderType.translucent()) { ++ if (canRenderInLayer(p_109285_, RenderType.translucent())) { + if (!Minecraft.useShaderTransparency()) { + return Sheets.translucentCullBlockSheet(); } else { @@ -340,9 +_,111 @@ } } + @Deprecated // FORGE: Use canRenderInLayer - public static RenderType m_109287_(FluidState p_109288_) { - RenderType rendertype = f_109276_.get(p_109288_.m_76152_()); - return rendertype != null ? rendertype : RenderType.m_110451_(); + public static RenderType getRenderLayer(FluidState p_109288_) { + RenderType rendertype = TYPE_BY_FLUID.get(p_109288_.getType()); + return rendertype != null ? rendertype : RenderType.solid(); + } + + // FORGE START + -+ private static final java.util.function.Predicate SOLID_PREDICATE = type -> type == RenderType.m_110451_(); ++ private static final java.util.function.Predicate SOLID_PREDICATE = type -> type == RenderType.solid(); + // Access to the two following editable maps is guarded by synchronization and they are lazily copied to the "readonly" maps on first read after modification -+ private static final Map, java.util.function.Predicate> blockRenderChecks = createRenderCheckMap(f_109275_); -+ private static final Map, java.util.function.Predicate> fluidRenderChecks = createRenderCheckMap(f_109276_); ++ private static final Map, java.util.function.Predicate> blockRenderChecks = createRenderCheckMap(TYPE_BY_BLOCK); ++ private static final Map, java.util.function.Predicate> fluidRenderChecks = createRenderCheckMap(TYPE_BY_FLUID); + @org.jetbrains.annotations.Nullable private static volatile Map, java.util.function.Predicate> blockRenderChecksReadOnly = null; + @org.jetbrains.annotations.Nullable private static volatile Map, java.util.function.Predicate> fluidRenderChecksReadOnly = null; + + private static > Map, java.util.function.Predicate> createRenderCheckMap( + Map vanillaMap + ) { -+ return Util.m_137469_(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(vanillaMap.size(), 0.5F), map -> { ++ return Util.make(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(vanillaMap.size(), 0.5F), map -> { + map.defaultReturnValue(SOLID_PREDICATE); + for (Map.Entry entry : vanillaMap.entrySet()) { + map.put(entry.getKey().delegate, createMatchingLayerPredicate(entry.getValue())); @@ -73,16 +73,16 @@ + } + + public static boolean canRenderInLayer(BlockState state, RenderType type) { -+ Block block = state.m_60734_(); ++ Block block = state.getBlock(); + if (block instanceof LeavesBlock) { -+ return f_109277_ ? type == RenderType.m_110457_() : type == RenderType.m_110451_(); ++ return renderCutout ? type == RenderType.cutoutMipped() : type == RenderType.solid(); + } else { + return getBlockLayerPredicates().get(block.delegate).test(type); + } + } + + public static boolean canRenderInLayer(FluidState fluid, RenderType type) { -+ return getFluidLayerPredicates().get(fluid.m_76152_().delegate).test(type); ++ return getFluidLayerPredicates().get(fluid.getType().delegate).test(type); + } + + public static void setRenderLayer(Block block, RenderType type) { @@ -153,4 +153,4 @@ + return type::equals; } - public static void m_109291_(boolean p_109292_) { + public static void setFancy(boolean p_109292_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index deb2c7f2..995cdc3e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,45 +1,45 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java @@ -286,12 +_,14 @@ - if (iteminhandrenderer$handrenderselection.f_172921_) { + if (iteminhandrenderer$handrenderselection.renderMainHand) { float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; - float f5 = 1.0F - Mth.m_14179_(p_109315_, this.f_109303_, this.f_109302_); -+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f4, f5, this.f_109300_)) - this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.f_109300_, f5, p_109316_, p_109317_, p_109319_); + float f5 = 1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight); ++ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f4, f5, this.mainHandItem)) + this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.mainHandItem, f5, p_109316_, p_109317_, p_109319_); } - if (iteminhandrenderer$handrenderselection.f_172922_) { + if (iteminhandrenderer$handrenderselection.renderOffHand) { float f6 = interactionhand == InteractionHand.OFF_HAND ? f : 0.0F; - float f7 = 1.0F - Mth.m_14179_(p_109315_, this.f_109305_, this.f_109304_); -+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f6, f7, this.f_109301_)) - this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.f_109301_, f7, p_109316_, p_109317_, p_109319_); + float f7 = 1.0F - Mth.lerp(p_109315_, this.oOffHandHeight, this.offHandHeight); ++ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f6, f7, this.offHandItem)) + this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_); } @@ -342,7 +_,7 @@ } else { - this.m_109353_(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); + this.renderOneHandedMap(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); } -- } else if (p_109377_.m_150930_(Items.f_42717_)) { -+ } else if (p_109377_.m_41720_() instanceof CrossbowItem) { - boolean flag1 = CrossbowItem.m_40932_(p_109377_); +- } else if (p_109377_.is(Items.CROSSBOW)) { ++ } else if (p_109377_.getItem() instanceof CrossbowItem) { + boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; @@ -487,8 +_,16 @@ - this.f_109304_ = Mth.m_14036_(this.f_109304_ - 0.4F, 0.0F, 1.0F); + this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { - float f = localplayer.m_36403_(1.0F); -- this.f_109302_ += Mth.m_14036_((this.f_109300_ == itemstack ? f * f * f : 0.0F) - this.f_109302_, -0.4F, 0.4F); -- this.f_109304_ += Mth.m_14036_((float)(this.f_109301_ == itemstack1 ? 1 : 0) - this.f_109304_, -0.4F, 0.4F); -+ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.f_109300_, itemstack, localplayer.m_150109_().f_35977_); -+ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.f_109301_, itemstack1, -1); + float f = localplayer.getAttackStrengthScale(1.0F); +- this.mainHandHeight += Mth.clamp((this.mainHandItem == itemstack ? f * f * f : 0.0F) - this.mainHandHeight, -0.4F, 0.4F); +- this.offHandHeight += Mth.clamp((float)(this.offHandItem == itemstack1 ? 1 : 0) - this.offHandHeight, -0.4F, 0.4F); ++ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, itemstack, localplayer.getInventory().selected); ++ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.offHandItem, itemstack1, -1); + -+ if (!requipM && this.f_109300_ != itemstack) -+ this.f_109300_ = itemstack; -+ if (!requipO && this.f_109301_ != itemstack1) -+ this.f_109301_ = itemstack1; ++ if (!requipM && this.mainHandItem != itemstack) ++ this.mainHandItem = itemstack; ++ if (!requipO && this.offHandItem != itemstack1) ++ this.offHandItem = itemstack1; + -+ this.f_109302_ += Mth.m_14036_((!requipM ? f * f * f : 0.0F) - this.f_109302_, -0.4F, 0.4F); -+ this.f_109304_ += Mth.m_14036_((float)(!requipO ? 1 : 0) - this.f_109304_, -0.4F, 0.4F); ++ this.mainHandHeight += Mth.clamp((!requipM ? f * f * f : 0.0F) - this.mainHandHeight, -0.4F, 0.4F); ++ this.offHandHeight += Mth.clamp((float)(!requipO ? 1 : 0) - this.offHandHeight, -0.4F, 0.4F); } - if (this.f_109302_ < 0.1F) { + if (this.mainHandHeight < 0.1F) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch index 7856b9b5..34323e4d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/client/renderer/ItemModelShaper.java @@ -24,6 +_,7 @@ - public BakedModel m_109406_(ItemStack p_109407_) { - BakedModel bakedmodel = this.m_109394_(p_109407_.m_41720_()); + public BakedModel getItemModel(ItemStack p_109407_) { + BakedModel bakedmodel = this.getItemModel(p_109407_.getItem()); + // FORGE: Make sure to call the item overrides - return bakedmodel == null ? this.f_109390_.m_119409_() : bakedmodel; + return bakedmodel == null ? this.modelManager.getMissingModel() : bakedmodel; } diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index aa344331..f35ff48c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -3,215 +3,215 @@ @@ -259,6 +_,11 @@ } - private void m_109703_(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { -+ net.minecraftforge.client.IWeatherRenderHandler renderHandler = f_109465_.m_104583_().getWeatherRenderHandler(); + private void renderSnowAndRain(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { ++ net.minecraftforge.client.IWeatherRenderHandler renderHandler = level.effects().getWeatherRenderHandler(); + if (renderHandler != null) { -+ renderHandler.render(f_109477_, p_109705_, f_109465_, f_109461_, p_109704_, p_109706_, p_109707_, p_109708_); ++ renderHandler.render(ticks, p_109705_, level, minecraft, p_109704_, p_109706_, p_109707_, p_109708_); + return; + } - float f = this.f_109461_.f_91073_.m_46722_(p_109705_); + float f = this.minecraft.level.getRainLevel(p_109705_); if (!(f <= 0.0F)) { - p_109704_.m_109896_(); + p_109704_.turnOnLightLayer(); @@ -379,6 +_,11 @@ } - public void m_109693_(Camera p_109694_) { -+ net.minecraftforge.client.IWeatherParticleRenderHandler renderHandler = f_109465_.m_104583_().getWeatherParticleRenderHandler(); + public void tickRain(Camera p_109694_) { ++ net.minecraftforge.client.IWeatherParticleRenderHandler renderHandler = level.effects().getWeatherParticleRenderHandler(); + if (renderHandler != null) { -+ renderHandler.render(f_109477_, f_109465_, f_109461_, p_109694_); ++ renderHandler.render(ticks, level, minecraft, p_109694_); + return; + } - float f = this.f_109461_.f_91073_.m_46722_(1.0F) / (Minecraft.m_91405_() ? 1.0F : 2.0F); + float f = this.minecraft.level.getRainLevel(1.0F) / (Minecraft.useFancyGraphics() ? 1.0F : 2.0F); if (!(f <= 0.0F)) { - Random random = new Random((long)this.f_109477_ * 312987231L); + Random random = new Random((long)this.ticks * 312987231L); @@ -1134,20 +_,24 @@ - RenderSystem.m_69421_(16640, Minecraft.f_91002_); - float f = p_109605_.m_109152_(); - boolean flag2 = this.f_109461_.f_91073_.m_104583_().m_5781_(Mth.m_14107_(d0), Mth.m_14107_(d1)) || this.f_109461_.f_91065_.m_93090_().m_93715_(); + RenderSystem.clear(16640, Minecraft.ON_OSX); + float f = p_109605_.getRenderDistance(); + boolean flag2 = this.minecraft.level.effects().isFoggyAt(Mth.floor(d0), Mth.floor(d1)) || this.minecraft.gui.getBossOverlay().shouldCreateWorldFog(); + FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2, p_109601_); - profilerfiller.m_6182_("sky"); - RenderSystem.m_157427_(GameRenderer::m_172808_); - this.m_202423_(p_109600_, p_109607_, p_109601_, p_109604_, flag2, () -> { -- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2); + profilerfiller.popPush("sky"); + RenderSystem.setShader(GameRenderer::getPositionShader); + this.renderSky(p_109600_, p_109607_, p_109601_, p_109604_, flag2, () -> { +- FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2); + FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2, p_109601_); }); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); - profilerfiller.m_6182_("fog"); -- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, p_109600_, p_109607_, this.ticks, p_109604_, frustum); + profilerfiller.popPush("fog"); +- FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2); + FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2, p_109601_); - profilerfiller.m_6182_("terrain_setup"); - this.m_194338_(p_109604_, frustum, flag1, this.f_109461_.f_91074_.m_5833_()); - profilerfiller.m_6182_("compilechunks"); - this.m_194370_(p_109604_); - profilerfiller.m_6182_("terrain"); - this.m_172993_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_109607_); -+ this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).setBlurMipmap(false, this.f_109461_.f_91066_.f_92027_ > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings - this.m_172993_(RenderType.m_110457_(), p_109600_, d0, d1, d2, p_109607_); -+ this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).restoreLastBlurMipmap(); - this.m_172993_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_109607_); - if (this.f_109465_.m_104583_().m_108885_()) { - Lighting.m_84925_(p_109600_.m_85850_().m_85861_()); + profilerfiller.popPush("terrain_setup"); + this.setupRender(p_109604_, frustum, flag1, this.minecraft.player.isSpectator()); + profilerfiller.popPush("compilechunks"); + this.compileChunks(p_109604_); + profilerfiller.popPush("terrain"); + this.renderChunkLayer(RenderType.solid(), p_109600_, d0, d1, d2, p_109607_); ++ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).setBlurMipmap(false, this.minecraft.options.mipmapLevels > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings + this.renderChunkLayer(RenderType.cutoutMipped(), p_109600_, d0, d1, d2, p_109607_); ++ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).restoreLastBlurMipmap(); + this.renderChunkLayer(RenderType.cutout(), p_109600_, d0, d1, d2, p_109607_); + if (this.level.effects().constantAmbientLight()) { + Lighting.setupNetherLevel(p_109600_.last().pose()); @@ -1179,7 +_,7 @@ - for(Entity entity : this.f_109465_.m_104735_()) { - if (this.f_109463_.m_114397_(entity, frustum, d0, d1, d2) || entity.m_20367_(this.f_109461_.f_91074_)) { - BlockPos blockpos = entity.m_142538_(); -- if ((this.f_109465_.m_151562_(blockpos.m_123342_()) || this.m_202430_(blockpos)) && (entity != p_109604_.m_90592_() || p_109604_.m_90594_() || p_109604_.m_90592_() instanceof LivingEntity && ((LivingEntity)p_109604_.m_90592_()).m_5803_()) && (!(entity instanceof LocalPlayer) || p_109604_.m_90592_() == entity)) { -+ if ((this.f_109465_.m_151562_(blockpos.m_123342_()) || this.m_202430_(blockpos)) && (entity != p_109604_.m_90592_() || p_109604_.m_90594_() || p_109604_.m_90592_() instanceof LivingEntity && ((LivingEntity)p_109604_.m_90592_()).m_5803_()) && (!(entity instanceof LocalPlayer) || p_109604_.m_90592_() == entity || (entity == f_109461_.f_91074_ && !f_109461_.f_91074_.m_5833_()))) { //FORGE: render local player entity when it is not the renderViewEntity - ++this.f_109439_; - if (entity.f_19797_ == 0) { - entity.f_19790_ = entity.m_20185_(); + for(Entity entity : this.level.entitiesForRendering()) { + if (this.entityRenderDispatcher.shouldRender(entity, frustum, d0, d1, d2) || entity.hasIndirectPassenger(this.minecraft.player)) { + BlockPos blockpos = entity.blockPosition(); +- if ((this.level.isOutsideBuildHeight(blockpos.getY()) || this.isChunkCompiled(blockpos)) && (entity != p_109604_.getEntity() || p_109604_.isDetached() || p_109604_.getEntity() instanceof LivingEntity && ((LivingEntity)p_109604_.getEntity()).isSleeping()) && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity)) { ++ if ((this.level.isOutsideBuildHeight(blockpos.getY()) || this.isChunkCompiled(blockpos)) && (entity != p_109604_.getEntity() || p_109604_.isDetached() || p_109604_.getEntity() instanceof LivingEntity && ((LivingEntity)p_109604_.getEntity()).isSleeping()) && (!(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(); @@ -1219,6 +_,7 @@ - List list = levelrenderer$renderchunkinfo.f_109839_.m_112835_().m_112773_(); + List list = levelrenderer$renderchunkinfo.chunk.getCompiledChunk().getRenderableBlockEntities(); if (!list.isEmpty()) { for(BlockEntity blockentity1 : list) { -+ if(!frustum.m_113029_(blockentity1.getRenderBoundingBox())) continue; - BlockPos blockpos4 = blockentity1.m_58899_(); ++ if(!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue; + BlockPos blockpos4 = blockentity1.getBlockPos(); MultiBufferSource multibuffersource1 = multibuffersource$buffersource; - p_109600_.m_85836_(); + p_109600_.pushPose(); @@ -1244,6 +_,7 @@ - synchronized(this.f_109468_) { - for(BlockEntity blockentity : this.f_109468_) { -+ if(!frustum.m_113029_(blockentity.getRenderBoundingBox())) continue; - BlockPos blockpos3 = blockentity.m_58899_(); - p_109600_.m_85836_(); - p_109600_.m_85837_((double)blockpos3.m_123341_() - d0, (double)blockpos3.m_123342_() - d1, (double)blockpos3.m_123343_() - d2); + synchronized(this.globalBlockEntities) { + for(BlockEntity blockentity : this.globalBlockEntities) { ++ if(!frustum.isVisible(blockentity.getRenderBoundingBox())) continue; + BlockPos blockpos3 = blockentity.getBlockPos(); + p_109600_.pushPose(); + p_109600_.translate((double)blockpos3.getX() - d0, (double)blockpos3.getY() - d1, (double)blockpos3.getZ() - d2); @@ -1295,10 +_,13 @@ - profilerfiller.m_6182_("outline"); - BlockPos blockpos1 = ((BlockHitResult)hitresult).m_82425_(); - BlockState blockstate = this.f_109465_.m_8055_(blockpos1); + profilerfiller.popPush("outline"); + BlockPos blockpos1 = ((BlockHitResult)hitresult).getBlockPos(); + BlockState blockstate = this.level.getBlockState(blockpos1); + if (!net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource)) - if (!blockstate.m_60795_() && this.f_109465_.m_6857_().m_61937_(blockpos1)) { - VertexConsumer vertexconsumer2 = multibuffersource$buffersource.m_6299_(RenderType.m_110504_()); - this.m_109637_(p_109600_, vertexconsumer2, p_109604_.m_90592_(), d0, d1, d2, blockpos1, blockstate); + if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos1)) { + VertexConsumer vertexconsumer2 = multibuffersource$buffersource.getBuffer(RenderType.lines()); + this.renderHitOutline(p_109600_, vertexconsumer2, p_109604_.getEntity(), d0, d1, d2, blockpos1, blockstate); } -+ } else if (hitresult != null && hitresult.m_6662_() == HitResult.Type.ENTITY) { ++ } else if (hitresult != null && hitresult.getType() == HitResult.Type.ENTITY) { + net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource); } - PoseStack posestack = RenderSystem.m_157191_(); + PoseStack posestack = RenderSystem.getModelViewStack(); @@ -1333,7 +_,8 @@ - this.f_109415_.m_83945_(this.f_109461_.m_91385_()); - RenderStateShard.f_110126_.m_110185_(); - profilerfiller.m_6182_("particles"); -- this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); -+ this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); - RenderStateShard.f_110126_.m_110188_(); + this.particlesTarget.copyDepthFrom(this.minecraft.getMainRenderTarget()); + RenderStateShard.PARTICLES_TARGET.setupRenderState(); + profilerfiller.popPush("particles"); +- this.minecraft.particleEngine.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); ++ this.minecraft.particleEngine.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.ticks, p_109604_, frustum); + RenderStateShard.PARTICLES_TARGET.clearRenderState(); } else { - profilerfiller.m_6182_("translucent"); + profilerfiller.popPush("translucent"); @@ -1347,7 +_,8 @@ - profilerfiller.m_6182_("string"); - this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_109607_); - profilerfiller.m_6182_("particles"); -- this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); -+ this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); + profilerfiller.popPush("string"); + this.renderChunkLayer(RenderType.tripwire(), p_109600_, d0, d1, d2, p_109607_); + profilerfiller.popPush("particles"); +- this.minecraft.particleEngine.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); ++ this.minecraft.particleEngine.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.ticks, p_109604_, frustum); } - posestack.m_85836_(); + posestack.pushPose(); @@ -1370,6 +_,7 @@ - if (this.f_109418_ != null) { - RenderStateShard.f_110127_.m_110185_(); - profilerfiller.m_6182_("weather"); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); - this.m_109703_(p_109606_, p_109601_, d0, d1, d2); - this.m_173012_(p_109604_); - RenderStateShard.f_110127_.m_110188_(); + if (this.transparencyChain != null) { + RenderStateShard.WEATHER_TARGET.setupRenderState(); + profilerfiller.popPush("weather"); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.ticks, p_109604_, frustum); + this.renderSnowAndRain(p_109606_, p_109601_, d0, d1, d2); + this.renderWorldBorder(p_109604_); + RenderStateShard.WEATHER_TARGET.clearRenderState(); @@ -1379,6 +_,7 @@ - RenderSystem.m_69458_(false); - profilerfiller.m_6182_("weather"); - this.m_109703_(p_109606_, p_109601_, d0, d1, d2); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); - this.m_173012_(p_109604_); - RenderSystem.m_69458_(true); + RenderSystem.depthMask(false); + profilerfiller.popPush("weather"); + this.renderSnowAndRain(p_109606_, p_109601_, d0, d1, d2); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.ticks, p_109604_, frustum); + this.renderWorldBorder(p_109604_); + RenderSystem.depthMask(true); } @@ -1521,6 +_,7 @@ - VertexBuffer.m_85931_(); - VertexBuffer.m_166875_(); - this.f_109461_.m_91307_().m_7238_(); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_172994_, this, p_172995_, p_172999_, this.f_109477_, this.f_109461_.f_91063_.m_109153_(), this.f_109442_ != null ? this.f_109442_ : this.f_172938_); - p_172994_.m_110188_(); + VertexBuffer.unbind(); + VertexBuffer.unbindVertexArray(); + this.minecraft.getProfiler().pop(); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_172994_, this, p_172995_, p_172999_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum); + p_172994_.clearRenderState(); } @@ -1783,6 +_,11 @@ - public void m_202423_(PoseStack p_202424_, Matrix4f p_202425_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { + public void renderSky(PoseStack p_202424_, Matrix4f p_202425_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { p_202429_.run(); -+ net.minecraftforge.client.ISkyRenderHandler renderHandler = f_109465_.m_104583_().getSkyRenderHandler(); ++ net.minecraftforge.client.ISkyRenderHandler renderHandler = level.effects().getSkyRenderHandler(); + if (renderHandler != null) { -+ renderHandler.render(f_109477_, p_202426_, p_202424_, f_109465_, f_109461_); ++ renderHandler.render(ticks, p_202426_, p_202424_, level, minecraft); + return; + } if (!p_202428_) { - FogType fogtype = p_202427_.m_167685_(); + FogType fogtype = p_202427_.getFluidInCamera(); if (fogtype != FogType.POWDER_SNOW && fogtype != FogType.LAVA) { @@ -1910,6 +_,11 @@ } - public void m_172954_(PoseStack p_172955_, Matrix4f p_172956_, float p_172957_, double p_172958_, double p_172959_, double p_172960_) { -+ net.minecraftforge.client.ICloudRenderHandler renderHandler = f_109465_.m_104583_().getCloudRenderHandler(); + public void renderClouds(PoseStack p_172955_, Matrix4f p_172956_, float p_172957_, double p_172958_, double p_172959_, double p_172960_) { ++ net.minecraftforge.client.ICloudRenderHandler renderHandler = level.effects().getCloudRenderHandler(); + if (renderHandler != null) { -+ renderHandler.render(f_109477_, p_172957_, p_172955_, f_109465_, f_109461_, p_172958_, p_172959_, p_172960_); ++ renderHandler.render(ticks, p_172957_, p_172955_, level, minecraft, p_172958_, p_172959_, p_172960_); + return; + } - float f = this.f_109465_.m_104583_().m_108871_(); + float f = this.level.effects().getCloudHeight(); if (!Float.isNaN(f)) { - RenderSystem.m_69464_(); + RenderSystem.disableCull(); @@ -2095,7 +_,7 @@ } } else { - BlockPos blockpos1 = chunkrenderdispatcher$renderchunk.m_112839_().m_142082_(8, 8, 8); -- flag = blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_(); -+ flag = !net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && (blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_()); // the target is the else block below, so invert the forge addition to get there early + BlockPos blockpos1 = chunkrenderdispatcher$renderchunk.getOrigin().offset(8, 8, 8); +- flag = blockpos1.distSqr(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.isDirtyFromPlayer(); ++ flag = !net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && (blockpos1.distSqr(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.isDirtyFromPlayer()); // the target is the else block below, so invert the forge addition to get there early } if (flag) { @@ -2393,7 +_,12 @@ - this.f_109469_.m_110859_(p_109502_, p_109503_, p_109504_, p_109505_); + this.viewArea.setDirty(p_109502_, p_109503_, p_109504_, p_109505_); } + @Deprecated // Forge: use item aware function below - public void m_109514_(@Nullable SoundEvent p_109515_, BlockPos p_109516_) { -+ this.playStreamingMusic(p_109515_, p_109516_, p_109515_ == null? null : RecordItem.m_43040_(p_109515_)); + public void playStreamingMusic(@Nullable SoundEvent p_109515_, BlockPos p_109516_) { ++ this.playStreamingMusic(p_109515_, p_109516_, p_109515_ == null? null : RecordItem.getBySound(p_109515_)); + } + + public void playStreamingMusic(@Nullable SoundEvent p_109515_, BlockPos p_109516_, @Nullable RecordItem musicDiscItem) { - SoundInstance soundinstance = this.f_109410_.get(p_109516_); + SoundInstance soundinstance = this.playingRecords.get(p_109516_); if (soundinstance != null) { - this.f_109461_.m_91106_().m_120399_(soundinstance); + this.minecraft.getSoundManager().stop(soundinstance); @@ -2401,7 +_,7 @@ } if (p_109515_ != null) { -- RecordItem recorditem = RecordItem.m_43040_(p_109515_); +- RecordItem recorditem = RecordItem.getBySound(p_109515_); + RecordItem recorditem = musicDiscItem; if (recorditem != null) { - this.f_109461_.f_91065_.m_93055_(recorditem.m_43050_()); + this.minecraft.gui.setNowPlaying(recorditem.getDisplayName()); } @@ -2553,7 +_,7 @@ break; case 1010: - if (Item.m_41445_(p_109536_) instanceof RecordItem) { -- this.m_109514_(((RecordItem)Item.m_41445_(p_109536_)).m_43051_(), p_109535_); -+ this.playStreamingMusic(((RecordItem)Item.m_41445_(p_109536_)).m_43051_(), p_109535_, (RecordItem) Item.m_41445_(p_109536_)); + if (Item.byId(p_109536_) instanceof RecordItem) { +- this.playStreamingMusic(((RecordItem)Item.byId(p_109536_)).getSound(), p_109535_); ++ this.playStreamingMusic(((RecordItem)Item.byId(p_109536_)).getSound(), p_109535_, (RecordItem) Item.byId(p_109536_)); } else { - this.m_109514_((SoundEvent)null, p_109535_); + this.playStreamingMusic((SoundEvent)null, p_109535_); } @@ -2723,7 +_,7 @@ case 2001: - BlockState blockstate = Block.m_49803_(p_109536_); - if (!blockstate.m_60795_()) { -- SoundType soundtype = blockstate.m_60827_(); -+ SoundType soundtype = blockstate.getSoundType(this.f_109465_, p_109535_, null); - this.f_109465_.m_104677_(p_109535_, soundtype.m_56775_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F, false); + BlockState blockstate = Block.stateById(p_109536_); + if (!blockstate.isAir()) { +- SoundType soundtype = blockstate.getSoundType(); ++ SoundType soundtype = blockstate.getSoundType(this.level, p_109535_, null); + this.level.playLocalSound(p_109535_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false); } @@ -2888,7 +_,7 @@ } else { - int i = p_109538_.m_45517_(LightLayer.SKY, p_109540_); - int j = p_109538_.m_45517_(LightLayer.BLOCK, p_109540_); -- int k = p_109539_.m_60791_(); + int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); + int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); +- int k = p_109539_.getLightEmission(); + int k = p_109539_.getLightEmission(p_109538_, p_109540_); if (j < k) { j = k; diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index 5905d2bf..f9de6a66 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch @@ -3,9 +3,9 @@ @@ -160,7 +_,7 @@ } - public static int m_109883_(int p_109884_) { + public static int block(int p_109884_) { - return p_109884_ >> 4 & '\uffff'; + return (p_109884_ & 0xFFFF) >> 4; // Forge: Fix fullbright quads showing dark artifacts. Reported as MC-169806 } - public static int m_109894_(int p_109895_) { + public static int sky(int p_109895_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/OutlineBufferSource.java.patch b/patches/minecraft/net/minecraft/client/renderer/OutlineBufferSource.java.patch index ac4117c6..23e5baea 100644 --- a/patches/minecraft/net/minecraft/client/renderer/OutlineBufferSource.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/OutlineBufferSource.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/client/renderer/OutlineBufferSource.java +++ b/net/minecraft/client/renderer/OutlineBufferSource.java @@ -105,5 +_,9 @@ - public void m_5752_() { - this.f_109936_.m_5483_(this.f_109937_, this.f_109938_, this.f_109939_).m_6122_(this.f_85825_, this.f_85826_, this.f_85827_, this.f_85828_).m_7421_(this.f_109940_, this.f_109941_).m_5752_(); + public void endVertex() { + this.delegate.vertex(this.x, this.y, this.z).color(this.defaultR, this.defaultG, this.defaultB, this.defaultA).uv(this.u, this.v).endVertex(); } + + public com.mojang.blaze3d.vertex.VertexFormat getVertexFormat() { -+ return this.f_109936_.getVertexFormat(); ++ return this.delegate.getVertexFormat(); + } } } diff --git a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch index 4117e205..48faefda 100644 --- a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch @@ -5,16 +5,16 @@ } - ResourceLocation resourcelocation = new ResourceLocation("textures/effect/" + s4 + ".png"); -+ ResourceLocation rl = ResourceLocation.m_135820_(s4); -+ ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "textures/effect/" + rl.m_135815_() + ".png"); ++ ResourceLocation rl = ResourceLocation.tryParse(s4); ++ ResourceLocation resourcelocation = new ResourceLocation(rl.getNamespace(), "textures/effect/" + rl.getPath() + ".png"); Resource resource = null; try { @@ -279,6 +_,7 @@ - public void m_110038_(String p_110039_, int p_110040_, int p_110041_) { - RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.f_91002_); - rendertarget.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); -+ if (f_110006_.isStencilEnabled()) { rendertarget.enableStencil(); } - this.f_110010_.put(p_110039_, rendertarget); - if (p_110040_ == this.f_110013_ && p_110041_ == this.f_110014_) { - this.f_110011_.add(rendertarget); + 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 3a5f3ceb..e0e13905 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch @@ -3,34 +3,34 @@ @@ -288,27 +_,27 @@ } - public static RenderType m_110497_(ResourceLocation p_110498_) { -- return f_173173_.apply(p_110498_); + public static RenderType text(ResourceLocation p_110498_) { +- return TEXT.apply(p_110498_); + return net.minecraftforge.client.ForgeRenderTypes.getText(p_110498_); } - public static RenderType m_173237_(ResourceLocation p_173238_) { -- return f_173174_.apply(p_173238_); + public static RenderType textIntensity(ResourceLocation p_173238_) { +- return TEXT_INTENSITY.apply(p_173238_); + return net.minecraftforge.client.ForgeRenderTypes.getTextIntensity(p_173238_); } - public static RenderType m_181444_(ResourceLocation p_181445_) { -- return f_181442_.apply(p_181445_); + public static RenderType textPolygonOffset(ResourceLocation p_181445_) { +- return TEXT_POLYGON_OFFSET.apply(p_181445_); + return net.minecraftforge.client.ForgeRenderTypes.getTextPolygonOffset(p_181445_); } - public static RenderType m_181446_(ResourceLocation p_181447_) { -- return f_181443_.apply(p_181447_); + public static RenderType textIntensityPolygonOffset(ResourceLocation p_181447_) { +- return TEXT_INTENSITY_POLYGON_OFFSET.apply(p_181447_); + return net.minecraftforge.client.ForgeRenderTypes.getTextIntensityPolygonOffset(p_181447_); } - public static RenderType m_110500_(ResourceLocation p_110501_) { -- return f_173175_.apply(p_110501_); + public static RenderType textSeeThrough(ResourceLocation p_110501_) { +- return TEXT_SEE_THROUGH.apply(p_110501_); + return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(p_110501_); } - public static RenderType m_173240_(ResourceLocation p_173241_) { -- return f_173176_.apply(p_173241_); + public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { +- return TEXT_INTENSITY_SEE_THROUGH.apply(p_173241_); + return net.minecraftforge.client.ForgeRenderTypes.getTextIntensitySeeThrough(p_173241_); } - public static RenderType m_110502_() { + public static RenderType lightning() { diff --git a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index f9e15bac..12a657ee 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -1,34 +1,34 @@ --- a/net/minecraft/client/renderer/ScreenEffectRenderer.java +++ b/net/minecraft/client/renderer/ScreenEffectRenderer.java @@ -30,18 +_,21 @@ - public static void m_110718_(Minecraft p_110719_, PoseStack p_110720_) { - Player player = p_110719_.f_91074_; - if (!player.f_19794_) { -- BlockState blockstate = m_110716_(player); + public static void renderScreenEffect(Minecraft p_110719_, PoseStack p_110720_) { + Player player = p_110719_.player; + if (!player.noPhysics) { +- BlockState blockstate = getViewBlockingState(player); - if (blockstate != null) { -- m_173296_(p_110719_.m_91289_().m_110907_().m_110882_(blockstate), p_110720_); +- renderTex(p_110719_.getBlockRenderer().getBlockModelShaper().getParticleIcon(blockstate), p_110720_); + org.apache.commons.lang3.tuple.Pair overlay = getOverlayBlock(player); + if (overlay != null) { + if (!net.minecraftforge.event.ForgeEventFactory.renderBlockOverlay(player, p_110720_, net.minecraftforge.client.event.RenderBlockOverlayEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight())) -+ m_173296_(p_110719_.m_91289_().m_110907_().getTexture(overlay.getLeft(), p_110719_.f_91073_, overlay.getRight()), p_110720_); ++ renderTex(p_110719_.getBlockRenderer().getBlockModelShaper().getTexture(overlay.getLeft(), p_110719_.level, overlay.getRight()), p_110720_); } } - if (!p_110719_.f_91074_.m_5833_()) { - if (p_110719_.f_91074_.m_204029_(FluidTags.f_13131_)) { + if (!p_110719_.player.isSpectator()) { + if (p_110719_.player.isEyeInFluid(FluidTags.WATER)) { + if (!net.minecraftforge.event.ForgeEventFactory.renderWaterOverlay(player, p_110720_)) - m_110725_(p_110719_, p_110720_); + renderWater(p_110719_, p_110720_); } - if (p_110719_.f_91074_.m_6060_()) { + if (p_110719_.player.isOnFire()) { + if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(player, p_110720_)) - m_110728_(p_110719_, p_110720_); + renderFire(p_110719_, p_110720_); } } @@ -50,6 +_,11 @@ @Nullable - private static BlockState m_110716_(Player p_110717_) { + private static BlockState getViewBlockingState(Player p_110717_) { + return getOverlayBlock(p_110717_).getLeft(); + } + @@ -38,11 +38,11 @@ for(int i = 0; i < 8; ++i) { @@ -59,7 +_,7 @@ - blockpos$mutableblockpos.m_122169_(d0, d1, d2); - BlockState blockstate = p_110717_.f_19853_.m_8055_(blockpos$mutableblockpos); - if (blockstate.m_60799_() != RenderShape.INVISIBLE && blockstate.m_60831_(p_110717_.f_19853_, blockpos$mutableblockpos)) { + blockpos$mutableblockpos.set(d0, d1, d2); + BlockState blockstate = p_110717_.level.getBlockState(blockpos$mutableblockpos); + if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.isViewBlocking(p_110717_.level, blockpos$mutableblockpos)) { - return blockstate; -+ return org.apache.commons.lang3.tuple.Pair.of(blockstate, blockpos$mutableblockpos.m_7949_()); ++ return org.apache.commons.lang3.tuple.Pair.of(blockstate, blockpos$mutableblockpos.immutable()); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch index cb8c9d08..708a52b1 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch @@ -2,30 +2,30 @@ +++ b/net/minecraft/client/renderer/ShaderInstance.java @@ -96,10 +_,14 @@ @Nullable - public final Uniform f_173320_; + 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.f_173300_ = p_173337_; +- this.name = p_173337_; + this(p_173336_, new ResourceLocation(p_173337_), p_173338_); + } + public ShaderInstance(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException { -+ this.f_173300_ = shaderLocation.m_135827_().equals("minecraft") ? shaderLocation.m_135815_() : shaderLocation.toString(); - this.f_173307_ = p_173338_; ++ this.name = shaderLocation.getNamespace().equals("minecraft") ? shaderLocation.getPath() : shaderLocation.toString(); + this.vertexFormat = p_173338_; - ResourceLocation resourcelocation = new ResourceLocation("shaders/core/" + p_173337_ + ".json"); -+ ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.m_135827_(), "shaders/core/" + shaderLocation.m_135815_() + ".json"); ++ ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.getNamespace(), "shaders/core/" + shaderLocation.getPath() + ".json"); Resource resource = null; try { @@ -209,8 +_,9 @@ - Program program1 = p_173342_.m_85570_().get(p_173343_); + Program program1 = p_173342_.getPrograms().get(p_173343_); Program program; if (program1 == null) { -- String s = "shaders/core/" + p_173343_ + p_173342_.m_85569_(); +- String s = "shaders/core/" + p_173343_ + p_173342_.getExtension(); - ResourceLocation resourcelocation = new ResourceLocation(s); + ResourceLocation loc = new ResourceLocation(p_173343_); -+ String s = "shaders/core/" + loc.m_135815_() + p_173342_.m_85569_(); -+ ResourceLocation resourcelocation = new ResourceLocation(loc.m_135827_(), s); - Resource resource = p_173341_.m_142591_(resourcelocation); - final String s1 = FileUtil.m_179922_(s); ++ String s = "shaders/core/" + loc.getPath() + p_173342_.getExtension(); ++ ResourceLocation resourcelocation = new ResourceLocation(loc.getNamespace(), s); + Resource resource = p_173341_.getResource(resourcelocation); + final String s1 = FileUtil.getFullResourcePath(s); diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index 9ae21778..aaff5217 100644 --- a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -3,13 +3,13 @@ @@ -127,7 +_,8 @@ } - private static Material m_173385_(WoodType p_173386_) { -- return new Material(f_110739_, new ResourceLocation("entity/signs/" + p_173386_.m_61846_())); -+ ResourceLocation location = new ResourceLocation(p_173386_.m_61846_()); -+ return new Material(f_110739_, new ResourceLocation(location.m_135827_(), "entity/signs/" + location.m_135815_())); + private static Material createSignMaterial(WoodType p_173386_) { +- return new Material(SIGN_SHEET, new ResourceLocation("entity/signs/" + p_173386_.name())); ++ ResourceLocation location = new ResourceLocation(p_173386_.name()); ++ return new Material(SIGN_SHEET, new ResourceLocation(location.getNamespace(), "entity/signs/" + location.getPath())); } - public static Material m_173381_(WoodType p_173382_) { + public static Material getSignMaterial(WoodType p_173382_) { @@ -174,5 +_,12 @@ default: return p_110773_; @@ -20,6 +20,6 @@ + * Not threadsafe. Enqueue it in client setup. + */ + public static void addWoodType(WoodType woodType) { -+ f_110743_.put(woodType, m_173385_(woodType)); ++ SIGN_MATERIALS.put(woodType, createSignMaterial(woodType)); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch b/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch index b6a15c83..92b37b97 100644 --- a/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/SpriteCoordinateExpander.java +++ b/net/minecraft/client/renderer/SpriteCoordinateExpander.java @@ -54,4 +_,8 @@ - public void m_5954_(float p_110808_, float p_110809_, float p_110810_, float p_110811_, float p_110812_, float p_110813_, float p_110814_, float p_110815_, float p_110816_, int p_110817_, int p_110818_, float p_110819_, float p_110820_, float p_110821_) { - this.f_110795_.m_5954_(p_110808_, p_110809_, p_110810_, p_110811_, p_110812_, p_110813_, p_110814_, this.f_110796_.m_118367_((double)(p_110815_ * 16.0F)), this.f_110796_.m_118393_((double)(p_110816_ * 16.0F)), p_110817_, p_110818_, p_110819_, p_110820_, p_110821_); + public void vertex(float p_110808_, float p_110809_, float p_110810_, float p_110811_, float p_110812_, float p_110813_, float p_110814_, float p_110815_, float p_110816_, int p_110817_, int p_110818_, float p_110819_, float p_110820_, float p_110821_) { + this.delegate.vertex(p_110808_, p_110809_, p_110810_, p_110811_, p_110812_, p_110813_, p_110814_, this.sprite.getU((double)(p_110815_ * 16.0F)), this.sprite.getV((double)(p_110816_ * 16.0F)), p_110817_, p_110818_, p_110819_, p_110820_, p_110821_); } + + public com.mojang.blaze3d.vertex.VertexFormat getVertexFormat() { -+ return this.f_110795_.getVertexFormat(); ++ return this.delegate.getVertexFormat(); + } } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch index 02c3137a..c8aa957e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/client/renderer/block/BlockModelShaper.java +++ b/net/minecraft/client/renderer/block/BlockModelShaper.java @@ -24,8 +_,15 @@ - this.f_110878_ = p_110880_; + this.modelManager = p_110880_; } + @Deprecated - public TextureAtlasSprite m_110882_(BlockState p_110883_) { -- return this.m_110893_(p_110883_).m_6160_(); -+ return this.m_110893_(p_110883_).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + public TextureAtlasSprite getParticleIcon(BlockState p_110883_) { +- return this.getBlockModel(p_110883_).getParticleIcon(); ++ return this.getBlockModel(p_110883_).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + + public TextureAtlasSprite getTexture(BlockState p_110883_, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) { + net.minecraftforge.client.model.data.IModelData data = net.minecraftforge.client.model.ModelDataManager.getModelData(level, pos); -+ BakedModel model = this.m_110893_(p_110883_); ++ BakedModel model = this.getBlockModel(p_110883_); + return model.getParticleIcon(model.getModelData(level, pos, p_110883_, data == null ? net.minecraftforge.client.model.data.EmptyModelData.INSTANCE : data)); } - public BakedModel m_110893_(BlockState p_110894_) { + public BakedModel getBlockModel(BlockState p_110894_) { 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 3582193e..159a34b9 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -1,66 +1,66 @@ --- a/net/minecraft/client/renderer/block/BlockRenderDispatcher.java +++ b/net/minecraft/client/renderer/block/BlockRenderDispatcher.java @@ -37,7 +_,7 @@ - this.f_110899_ = p_173399_; - this.f_173397_ = p_173400_; - this.f_110903_ = p_173401_; -- this.f_110900_ = new ModelBlockRenderer(this.f_110903_); -+ this.f_110900_ = new net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer(this.f_110903_); - this.f_110901_ = new LiquidBlockRenderer(); + this.blockModelShaper = p_173399_; + this.blockEntityRenderer = p_173400_; + this.blockColors = p_173401_; +- this.modelRenderer = new ModelBlockRenderer(this.blockColors); ++ this.modelRenderer = new net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer(this.blockColors); + this.liquidBlockRenderer = new LiquidBlockRenderer(); } @@ -45,18 +_,26 @@ - return this.f_110899_; + return this.blockModelShaper; } + @Deprecated //Forge: Model parameter - public void m_110918_(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_) { + public void renderBreakingTexture(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_) { + renderBreakingTexture(p_110919_,p_110920_, p_110921_, p_110922_, p_110923_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public void renderBreakingTexture(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_, net.minecraftforge.client.model.data.IModelData modelData) { - if (p_110919_.m_60799_() == RenderShape.MODEL) { - BakedModel bakedmodel = this.f_110899_.m_110893_(p_110919_); - long i = p_110919_.m_60726_(p_110920_); -- this.f_110900_.m_111047_(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.f_110902_, i, OverlayTexture.f_118083_); -+ this.f_110900_.tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.f_110902_, i, OverlayTexture.f_118083_, modelData); + if (p_110919_.getRenderShape() == RenderShape.MODEL) { + BakedModel bakedmodel = this.blockModelShaper.getBlockModel(p_110919_); + long i = p_110919_.getSeed(p_110920_); +- this.modelRenderer.tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.random, i, OverlayTexture.NO_OVERLAY); ++ this.modelRenderer.tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.random, i, OverlayTexture.NO_OVERLAY, modelData); } } + @Deprecated //Forge: Model parameter - public boolean m_110924_(BlockState p_110925_, BlockPos p_110926_, BlockAndTintGetter p_110927_, PoseStack p_110928_, VertexConsumer p_110929_, boolean p_110930_, Random p_110931_) { + public boolean renderBatched(BlockState p_110925_, BlockPos p_110926_, BlockAndTintGetter p_110927_, PoseStack p_110928_, VertexConsumer p_110929_, boolean p_110930_, Random p_110931_) { + return renderBatched(p_110925_, p_110926_, p_110927_, p_110928_, p_110929_, p_110930_, p_110931_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public boolean renderBatched(BlockState p_110925_, BlockPos p_110926_, BlockAndTintGetter p_110927_, PoseStack p_110928_, VertexConsumer p_110929_, boolean p_110930_, Random p_110931_, net.minecraftforge.client.model.data.IModelData modelData) { try { - RenderShape rendershape = p_110925_.m_60799_(); -- return rendershape != RenderShape.MODEL ? false : this.f_110900_.m_111047_(p_110927_, this.m_110910_(p_110925_), p_110925_, p_110926_, p_110928_, p_110929_, p_110930_, p_110931_, p_110925_.m_60726_(p_110926_), OverlayTexture.f_118083_); -+ return rendershape != RenderShape.MODEL ? false : this.f_110900_.tesselateBlock(p_110927_, this.m_110910_(p_110925_), p_110925_, p_110926_, p_110928_, p_110929_, p_110930_, p_110931_, p_110925_.m_60726_(p_110926_), OverlayTexture.f_118083_, modelData); + RenderShape rendershape = p_110925_.getRenderShape(); +- return rendershape != RenderShape.MODEL ? false : this.modelRenderer.tesselateBlock(p_110927_, this.getBlockModel(p_110925_), p_110925_, p_110926_, p_110928_, p_110929_, p_110930_, p_110931_, p_110925_.getSeed(p_110926_), OverlayTexture.NO_OVERLAY); ++ return rendershape != RenderShape.MODEL ? false : this.modelRenderer.tesselateBlock(p_110927_, this.getBlockModel(p_110925_), p_110925_, p_110926_, p_110928_, p_110929_, p_110930_, p_110931_, p_110925_.getSeed(p_110926_), OverlayTexture.NO_OVERLAY, modelData); } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.m_127521_(throwable, "Tesselating block in world"); - CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being tesselated"); + CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block in world"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Block being tesselated"); @@ -84,7 +_,11 @@ - return this.f_110899_.m_110893_(p_110911_); + return this.blockModelShaper.getBlockModel(p_110911_); } + @Deprecated //Forge: Model parameter - public void m_110912_(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_) { + public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_) { + renderSingleBlock(p_110913_, p_110914_, p_110915_, p_110916_, p_110917_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, net.minecraftforge.client.model.data.IModelData modelData) { - RenderShape rendershape = p_110913_.m_60799_(); + RenderShape rendershape = p_110913_.getRenderShape(); if (rendershape != RenderShape.INVISIBLE) { switch(rendershape) { @@ -94,10 +_,11 @@ float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; -- this.f_110900_.m_111067_(p_110914_.m_85850_(), p_110915_.m_6299_(ItemBlockRenderTypes.m_109284_(p_110913_, false)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_); -+ this.f_110900_.renderModel(p_110914_.m_85850_(), p_110915_.m_6299_(ItemBlockRenderTypes.m_109284_(p_110913_, false)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_, modelData); +- this.modelRenderer.renderModel(p_110914_.last(), p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_, false)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_); ++ this.modelRenderer.renderModel(p_110914_.last(), p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_, false)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_, modelData); break; case ENTITYBLOCK_ANIMATED: -- this.f_173397_.m_108829_(new ItemStack(p_110913_.m_60734_()), ItemTransforms.TransformType.NONE, p_110914_, p_110915_, p_110916_, p_110917_); -+ ItemStack stack = new ItemStack(p_110913_.m_60734_()); -+ net.minecraftforge.client.RenderProperties.get(stack).getItemStackRenderer().m_108829_(stack, ItemTransforms.TransformType.NONE, p_110914_, p_110915_, p_110916_, p_110917_); +- this.blockEntityRenderer.renderByItem(new ItemStack(p_110913_.getBlock()), ItemTransforms.TransformType.NONE, p_110914_, p_110915_, p_110916_, p_110917_); ++ ItemStack stack = new ItemStack(p_110913_.getBlock()); ++ net.minecraftforge.client.RenderProperties.get(stack).getItemStackRenderer().renderByItem(stack, ItemTransforms.TransformType.NONE, p_110914_, p_110915_, p_110916_, p_110917_); } } 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 c12129af..11b5e353 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/client/renderer/block/LiquidBlockRenderer.java @@ -68,8 +_,9 @@ - public boolean m_203173_(BlockAndTintGetter p_203174_, BlockPos p_203175_, VertexConsumer p_203176_, BlockState p_203177_, FluidState p_203178_) { - boolean flag = p_203178_.m_205070_(FluidTags.f_13132_); -- TextureAtlasSprite[] atextureatlassprite = flag ? this.f_110940_ : this.f_110941_; -- int i = flag ? 16777215 : BiomeColors.m_108811_(p_203174_, p_203175_); + public boolean tesselate(BlockAndTintGetter p_203174_, BlockPos p_203175_, VertexConsumer p_203176_, BlockState p_203177_, FluidState p_203178_) { + boolean flag = p_203178_.is(FluidTags.LAVA); +- TextureAtlasSprite[] atextureatlassprite = flag ? this.lavaIcons : this.waterIcons; +- int i = flag ? 16777215 : BiomeColors.getAverageWaterColor(p_203174_, p_203175_); + TextureAtlasSprite[] atextureatlassprite = net.minecraftforge.client.ForgeHooksClient.getFluidSprites(p_203174_, p_203175_, p_203178_); -+ int i = p_203178_.m_76152_().getAttributes().getColor(p_203174_, p_203175_); ++ int i = p_203178_.getType().getAttributes().getColor(p_203174_, p_203175_); + float alpha = (float)(i >> 24 & 255) / 255.0F; float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; @@ -16,20 +16,20 @@ float f30 = f4 * f; float f31 = f4 * f1; float f32 = f4 * f2; -- this.m_110984_(p_203176_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, f18, f22, j); -- this.m_110984_(p_203176_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, f19, f23, j); -- this.m_110984_(p_203176_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, f20, f24, j); -- this.m_110984_(p_203176_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, f21, f25, j); +- this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, f18, f22, j); +- this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, f19, f23, j); +- this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, f20, f24, j); +- this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, f21, f25, j); + + this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, alpha, f18, f22, j); + this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, alpha, f19, f23, j); + this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, alpha, f20, f24, j); + this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, alpha, f21, f25, j); - if (p_203178_.m_76171_(p_203174_, p_203175_.m_7494_())) { -- this.m_110984_(p_203176_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, f18, f22, j); -- this.m_110984_(p_203176_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, f21, f25, j); -- this.m_110984_(p_203176_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, f20, f24, j); -- this.m_110984_(p_203176_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, f19, f23, j); + if (p_203178_.shouldRenderBackwardUpFace(p_203174_, p_203175_.above())) { +- this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, f18, f22, j); +- this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, f21, f25, j); +- this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, f20, f24, j); +- this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, f19, f23, j); + this.vertex(p_203176_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, alpha, f18, f22, j); + this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, alpha, f21, f25, j); + this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, alpha, f20, f24, j); @@ -41,10 +41,10 @@ float f46 = f3 * f; float f47 = f3 * f1; float f48 = f3 * f2; -- this.m_110984_(p_203176_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f40, f43, l); -- this.m_110984_(p_203176_, d1, d2 + (double)f17, d0, f46, f47, f48, f40, f42, l); -- this.m_110984_(p_203176_, d1 + 1.0D, d2 + (double)f17, d0, f46, f47, f48, f41, f42, l); -- this.m_110984_(p_203176_, d1 + 1.0D, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f41, f43, l); +- this.vertex(p_203176_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f40, f43, l); +- this.vertex(p_203176_, d1, d2 + (double)f17, d0, f46, f47, f48, f40, f42, l); +- this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f17, d0, f46, f47, f48, f41, f42, l); +- this.vertex(p_203176_, d1 + 1.0D, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f41, f43, l); + + this.vertex(p_203176_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, alpha, f40, f43, l); + this.vertex(p_203176_, d1, d2 + (double)f17, d0, f46, f47, f48, alpha, f40, f42, l); @@ -55,14 +55,14 @@ @@ -264,10 +_,9 @@ flag7 = true; - BlockPos blockpos = p_203175_.m_142300_(direction); + BlockPos blockpos = p_203175_.relative(direction); TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; - if (!flag) { -- Block block = p_203174_.m_8055_(blockpos).m_60734_(); +- Block block = p_203174_.getBlockState(blockpos).getBlock(); - if (block instanceof HalfTransparentBlock || block instanceof LeavesBlock) { -- textureatlassprite2 = this.f_110942_; +- textureatlassprite2 = this.waterOverlay; + if (atextureatlassprite[2] != null) { -+ if (p_203174_.m_8055_(blockpos).shouldDisplayFluidOverlay(p_203174_, blockpos, p_203178_)) { ++ if (p_203174_.getBlockState(blockpos).shouldDisplayFluidOverlay(p_203174_, blockpos, p_203178_)) { + textureatlassprite2 = atextureatlassprite[2]; } } @@ -71,20 +71,20 @@ float f37 = f4 * f36 * f; float f38 = f4 * f36 * f1; float f39 = f4 * f36 * f2; -- this.m_110984_(p_203176_, d3, d2 + (double)f44, d4, f37, f38, f39, f54, f33, k); -- this.m_110984_(p_203176_, d5, d2 + (double)f45, d6, f37, f38, f39, f55, f34, k); -- this.m_110984_(p_203176_, d5, d2 + (double)f17, d6, f37, f38, f39, f55, f35, k); -- this.m_110984_(p_203176_, d3, d2 + (double)f17, d4, f37, f38, f39, f54, f35, k); +- this.vertex(p_203176_, d3, d2 + (double)f44, d4, f37, f38, f39, f54, f33, k); +- this.vertex(p_203176_, d5, d2 + (double)f45, d6, f37, f38, f39, f55, f34, k); +- this.vertex(p_203176_, d5, d2 + (double)f17, d6, f37, f38, f39, f55, f35, k); +- this.vertex(p_203176_, d3, d2 + (double)f17, d4, f37, f38, f39, f54, f35, k); + + this.vertex(p_203176_, d3, d2 + (double)f44, d4, f37, f38, f39, alpha, f54, f33, k); + this.vertex(p_203176_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f55, f34, k); + this.vertex(p_203176_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f55, f35, k); + this.vertex(p_203176_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f54, f35, k); - if (textureatlassprite2 != this.f_110942_) { -- this.m_110984_(p_203176_, d3, d2 + (double)f17, d4, f37, f38, f39, f54, f35, k); -- this.m_110984_(p_203176_, d5, d2 + (double)f17, d6, f37, f38, f39, f55, f35, k); -- this.m_110984_(p_203176_, d5, d2 + (double)f45, d6, f37, f38, f39, f55, f34, k); -- this.m_110984_(p_203176_, d3, d2 + (double)f44, d4, f37, f38, f39, f54, f33, k); + if (textureatlassprite2 != this.waterOverlay) { +- this.vertex(p_203176_, d3, d2 + (double)f17, d4, f37, f38, f39, f54, f35, k); +- this.vertex(p_203176_, d5, d2 + (double)f17, d6, f37, f38, f39, f55, f35, k); +- this.vertex(p_203176_, d5, d2 + (double)f45, d6, f37, f38, f39, f55, f34, k); +- this.vertex(p_203176_, d3, d2 + (double)f44, d4, f37, f38, f39, f54, f33, k); + this.vertex(p_203176_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f54, f35, k); + this.vertex(p_203176_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f55, f35, k); + this.vertex(p_203176_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f55, f34, k); @@ -96,10 +96,10 @@ } } -- private void m_110984_(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float p_110992_, float p_110993_, int p_110994_) { -- p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, 1.0F).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); +- private void vertex(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float p_110992_, float p_110993_, int p_110994_) { +- p_110985_.vertex(p_110986_, p_110987_, p_110988_).color(p_110989_, p_110990_, p_110991_, 1.0F).uv(p_110992_, p_110993_).uv2(p_110994_).normal(0.0F, 1.0F, 0.0F).endVertex(); + private void vertex(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float alpha, float p_110992_, float p_110993_, int p_110994_) { -+ p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, alpha).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); ++ p_110985_.vertex(p_110986_, p_110987_, p_110988_).color(p_110989_, p_110990_, p_110991_, alpha).uv(p_110992_, p_110993_).uv2(p_110994_).normal(0.0F, 1.0F, 0.0F).endVertex(); } - private int m_110945_(BlockAndTintGetter p_110946_, BlockPos p_110947_) { + private int getLightColor(BlockAndTintGetter p_110946_, BlockPos p_110947_) { 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 fe8f2041..77375ed4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -1,106 +1,106 @@ --- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java +++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java @@ -40,13 +_,18 @@ - this.f_110995_ = p_110999_; + this.blockColors = p_110999_; } + @Deprecated //Forge: Model data argument - public boolean m_111047_(BlockAndTintGetter p_111048_, BakedModel p_111049_, BlockState p_111050_, BlockPos p_111051_, PoseStack p_111052_, VertexConsumer p_111053_, boolean p_111054_, Random p_111055_, long p_111056_, int p_111057_) { -- boolean flag = Minecraft.m_91086_() && p_111050_.m_60791_() == 0 && p_111049_.m_7541_(); + public boolean tesselateBlock(BlockAndTintGetter p_111048_, BakedModel p_111049_, BlockState p_111050_, BlockPos p_111051_, PoseStack p_111052_, VertexConsumer p_111053_, boolean p_111054_, Random p_111055_, long p_111056_, int p_111057_) { +- boolean flag = Minecraft.useAmbientOcclusion() && p_111050_.getLightEmission() == 0 && p_111049_.useAmbientOcclusion(); + return tesselateBlock(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public boolean tesselateBlock(BlockAndTintGetter p_111048_, BakedModel p_111049_, BlockState p_111050_, BlockPos p_111051_, PoseStack p_111052_, VertexConsumer p_111053_, boolean p_111054_, Random p_111055_, long p_111056_, int p_111057_, net.minecraftforge.client.model.data.IModelData modelData) { -+ boolean flag = Minecraft.m_91086_() && p_111050_.getLightEmission(p_111048_, p_111051_) == 0 && p_111049_.m_7541_(); - Vec3 vec3 = p_111050_.m_60824_(p_111048_, p_111051_); - p_111052_.m_85837_(vec3.f_82479_, vec3.f_82480_, vec3.f_82481_); ++ boolean flag = Minecraft.useAmbientOcclusion() && p_111050_.getLightEmission(p_111048_, p_111051_) == 0 && p_111049_.useAmbientOcclusion(); + Vec3 vec3 = p_111050_.getOffset(p_111048_, p_111051_); + p_111052_.translate(vec3.x, vec3.y, vec3.z); + modelData = p_111049_.getModelData(p_111048_, p_111051_, p_111050_, modelData); try { -- return flag ? this.m_111078_(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_) : this.m_111090_(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_); +- return flag ? this.tesselateWithAO(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_) : this.tesselateWithoutAO(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_); + return flag ? this.tesselateWithAO(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_, modelData) : this.tesselateWithoutAO(p_111048_, p_111049_, p_111050_, p_111051_, p_111052_, p_111053_, p_111054_, p_111055_, p_111056_, p_111057_, modelData); } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.m_127521_(throwable, "Tesselating block model"); - CrashReportCategory crashreportcategory = crashreport.m_127514_("Block model being tesselated"); + CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Block model being tesselated"); @@ -56,7 +_,11 @@ } } + @Deprecated //Forge: Model data argument - public boolean m_111078_(BlockAndTintGetter p_111079_, BakedModel p_111080_, BlockState p_111081_, BlockPos p_111082_, PoseStack p_111083_, VertexConsumer p_111084_, boolean p_111085_, Random p_111086_, long p_111087_, int p_111088_) { + public boolean tesselateWithAO(BlockAndTintGetter p_111079_, BakedModel p_111080_, BlockState p_111081_, BlockPos p_111082_, PoseStack p_111083_, VertexConsumer p_111084_, boolean p_111085_, Random p_111086_, long p_111087_, int p_111088_) { + return tesselateWithAO(p_111079_, p_111080_, p_111081_, p_111082_, p_111083_, p_111084_, p_111085_, p_111086_, p_111087_, p_111088_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public boolean tesselateWithAO(BlockAndTintGetter p_111079_, BakedModel p_111080_, BlockState p_111081_, BlockPos p_111082_, PoseStack p_111083_, VertexConsumer p_111084_, boolean p_111085_, Random p_111086_, long p_111087_, int p_111088_, net.minecraftforge.client.model.data.IModelData modelData) { boolean flag = false; - float[] afloat = new float[f_173405_.length * 2]; + float[] afloat = new float[DIRECTIONS.length * 2]; BitSet bitset = new BitSet(3); @@ -65,7 +_,7 @@ - for(Direction direction : f_173405_) { + for(Direction direction : DIRECTIONS) { p_111086_.setSeed(p_111087_); -- List list = p_111080_.m_6840_(p_111081_, direction, p_111086_); +- List list = p_111080_.getQuads(p_111081_, direction, p_111086_); + List list = p_111080_.getQuads(p_111081_, direction, p_111086_, modelData); if (!list.isEmpty()) { - blockpos$mutableblockpos.m_122159_(p_111082_, direction); - if (!p_111085_ || Block.m_152444_(p_111081_, p_111079_, p_111082_, direction, blockpos$mutableblockpos)) { + blockpos$mutableblockpos.setWithOffset(p_111082_, direction); + if (!p_111085_ || Block.shouldRenderFace(p_111081_, p_111079_, p_111082_, direction, blockpos$mutableblockpos)) { @@ -76,7 +_,7 @@ } p_111086_.setSeed(p_111087_); -- List list1 = p_111080_.m_6840_(p_111081_, (Direction)null, p_111086_); +- List list1 = p_111080_.getQuads(p_111081_, (Direction)null, p_111086_); + List list1 = p_111080_.getQuads(p_111081_, (Direction)null, p_111086_, modelData); if (!list1.isEmpty()) { - this.m_111012_(p_111079_, p_111081_, p_111082_, p_111083_, p_111084_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_111088_); + this.renderModelFaceAO(p_111079_, p_111081_, p_111082_, p_111083_, p_111084_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_111088_); flag = true; @@ -85,14 +_,18 @@ return flag; } + @Deprecated //Forge: Model data argument - public boolean m_111090_(BlockAndTintGetter p_111091_, BakedModel p_111092_, BlockState p_111093_, BlockPos p_111094_, PoseStack p_111095_, VertexConsumer p_111096_, boolean p_111097_, Random p_111098_, long p_111099_, int p_111100_) { + public boolean tesselateWithoutAO(BlockAndTintGetter p_111091_, BakedModel p_111092_, BlockState p_111093_, BlockPos p_111094_, PoseStack p_111095_, VertexConsumer p_111096_, boolean p_111097_, Random p_111098_, long p_111099_, int p_111100_) { + return tesselateWithoutAO(p_111091_, p_111092_, p_111093_, p_111094_, p_111095_, p_111096_, p_111097_, p_111098_, p_111099_, p_111100_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public boolean tesselateWithoutAO(BlockAndTintGetter p_111091_, BakedModel p_111092_, BlockState p_111093_, BlockPos p_111094_, PoseStack p_111095_, VertexConsumer p_111096_, boolean p_111097_, Random p_111098_, long p_111099_, int p_111100_, net.minecraftforge.client.model.data.IModelData modelData) { boolean flag = false; BitSet bitset = new BitSet(3); - BlockPos.MutableBlockPos blockpos$mutableblockpos = p_111094_.m_122032_(); + BlockPos.MutableBlockPos blockpos$mutableblockpos = p_111094_.mutable(); - for(Direction direction : f_173405_) { + for(Direction direction : DIRECTIONS) { p_111098_.setSeed(p_111099_); -- List list = p_111092_.m_6840_(p_111093_, direction, p_111098_); +- List list = p_111092_.getQuads(p_111093_, direction, p_111098_); + List list = p_111092_.getQuads(p_111093_, direction, p_111098_, modelData); if (!list.isEmpty()) { - blockpos$mutableblockpos.m_122159_(p_111094_, direction); - if (!p_111097_ || Block.m_152444_(p_111093_, p_111091_, p_111094_, direction, blockpos$mutableblockpos)) { + blockpos$mutableblockpos.setWithOffset(p_111094_, direction); + if (!p_111097_ || Block.shouldRenderFace(p_111093_, p_111091_, p_111094_, direction, blockpos$mutableblockpos)) { @@ -104,7 +_,7 @@ } p_111098_.setSeed(p_111099_); -- List list1 = p_111092_.m_6840_(p_111093_, (Direction)null, p_111098_); +- List list1 = p_111092_.getQuads(p_111093_, (Direction)null, p_111098_); + List list1 = p_111092_.getQuads(p_111093_, (Direction)null, p_111098_, modelData); if (!list1.isEmpty()) { - this.m_111001_(p_111091_, p_111093_, p_111094_, -1, p_111100_, true, p_111095_, p_111096_, list1, bitset); + this.renderModelFaceFlat(p_111091_, p_111093_, p_111094_, -1, p_111100_, true, p_111095_, p_111096_, list1, bitset); flag = true; @@ -220,17 +_,21 @@ } + @Deprecated //Forge: Model data argument - public void m_111067_(PoseStack.Pose p_111068_, VertexConsumer p_111069_, @Nullable BlockState p_111070_, BakedModel p_111071_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_) { + public void renderModel(PoseStack.Pose p_111068_, VertexConsumer p_111069_, @Nullable BlockState p_111070_, BakedModel p_111071_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_) { + renderModel(p_111068_, p_111069_, p_111070_, p_111071_, p_111072_, p_111073_, p_111074_, p_111075_, p_111076_, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + } + public void renderModel(PoseStack.Pose p_111068_, VertexConsumer p_111069_, @Nullable BlockState p_111070_, BakedModel p_111071_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_, net.minecraftforge.client.model.data.IModelData modelData) { Random random = new Random(); long i = 42L; - for(Direction direction : f_173405_) { + for(Direction direction : DIRECTIONS) { random.setSeed(42L); -- m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.m_6840_(p_111070_, direction, random), p_111075_, p_111076_); -+ m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, random, modelData), p_111075_, p_111076_); +- renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, random), p_111075_, p_111076_); ++ renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, random, modelData), p_111075_, p_111076_); } random.setSeed(42L); -- m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.m_6840_(p_111070_, (Direction)null, random), p_111075_, p_111076_); -+ m_111058_(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, (Direction)null, random, modelData), p_111075_, p_111076_); +- renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, (Direction)null, random), p_111075_, p_111076_); ++ renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, (Direction)null, random, modelData), p_111075_, p_111076_); } - private static void m_111058_(PoseStack.Pose p_111059_, VertexConsumer p_111060_, float p_111061_, float p_111062_, float p_111063_, List p_111064_, int p_111065_, int p_111066_) { + private static void renderQuadList(PoseStack.Pose p_111059_, VertexConsumer p_111060_, float p_111061_, float p_111062_, float p_111063_, List p_111064_, int p_111065_, int p_111066_) { 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 e1183a0c..fbf5a647 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 @@ -6,13 +6,13 @@ @OnlyIn(Dist.CLIENT) -public class BakedQuad { +public class BakedQuad implements net.minecraftforge.client.model.pipeline.IVertexProducer { - protected final int[] f_111292_; - protected final int f_111293_; - protected final Direction f_111294_; + protected final int[] vertices; + protected final int tintIndex; + protected final Direction direction; @@ -39,6 +_,11 @@ - public Direction m_111306_() { - return this.f_111294_; + public Direction getDirection() { + return this.direction; + } + + @Override @@ -20,4 +20,4 @@ + net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this); } - public boolean m_111307_() { + public boolean isShade() { 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 6d2de87c..ccbb99bc 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,94 +1,94 @@ --- a/net/minecraft/client/renderer/block/model/BlockModel.java +++ b/net/minecraft/client/renderer/block/model/BlockModel.java @@ -66,9 +_,10 @@ - public BlockModel f_111418_; + public BlockModel parent; @Nullable - protected ResourceLocation f_111419_; + protected ResourceLocation parentLocation; + public final net.minecraftforge.client.model.BlockModelConfiguration customData = new net.minecraftforge.client.model.BlockModelConfiguration(this); - public static BlockModel m_111461_(Reader p_111462_) { -- return GsonHelper.m_13776_(f_111415_, p_111462_, BlockModel.class); -+ return GsonHelper.m_13776_(net.minecraftforge.client.model.ModelLoaderRegistry.ExpandedBlockModelDeserializer.INSTANCE, p_111462_, BlockModel.class); + public static BlockModel fromStream(Reader p_111462_) { +- return GsonHelper.fromJson(GSON, p_111462_, BlockModel.class); ++ return GsonHelper.fromJson(net.minecraftforge.client.model.ModelLoaderRegistry.ExpandedBlockModelDeserializer.INSTANCE, p_111462_, BlockModel.class); } - public static BlockModel m_111463_(String p_111464_) { + public static BlockModel fromString(String p_111464_) { @@ -85,10 +_,15 @@ - this.f_111426_ = p_111435_; + this.overrides = p_111435_; } + @Deprecated - public List m_111436_() { + public List getElements() { + if (customData.hasCustomGeometry()) return java.util.Collections.emptyList(); - return this.f_111422_.isEmpty() && this.f_111418_ != null ? this.f_111418_.m_111436_() : this.f_111422_; + return this.elements.isEmpty() && this.parent != null ? this.parent.getElements() : this.elements; } + @Nullable -+ public ResourceLocation getParentLocation() { return f_111419_; } ++ public ResourceLocation getParentLocation() { return parentLocation; } + - public boolean m_111476_() { - return this.f_111418_ != null ? this.f_111418_.m_111476_() : this.f_111424_; + public boolean hasAmbientOcclusion() { + return this.parent != null ? this.parent.hasAmbientOcclusion() : this.hasAmbientOcclusion; } @@ -113,6 +_,10 @@ - return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_111447_, p_111448_, p_111447_::m_119341_, this.f_111426_); + return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_111447_, p_111448_, p_111447_::getModel, this.overrides); } + public ItemOverrides getOverrides(ModelBakery p_111447_, BlockModel p_111448_, Function textureGetter) { -+ return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_111447_, p_111448_, p_111447_::m_119341_, textureGetter, this.f_111426_); ++ return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_111447_, p_111448_, p_111447_::getModel, textureGetter, this.overrides); + } + - public Collection m_7970_() { + public Collection getDependencies() { Set set = Sets.newHashSet(); @@ -156,6 +_,9 @@ - Set set1 = Sets.newHashSet(this.m_111480_("particle")); + Set set1 = Sets.newHashSet(this.getMaterial("particle")); + if (customData.hasCustomGeometry()) + set1.addAll(customData.getTextureDependencies(p_111469_, p_111470_)); + else - for(BlockElement blockelement : this.m_111436_()) { - for(BlockElementFace blockelementface : blockelement.f_111310_.values()) { - Material material = this.m_111480_(blockelementface.f_111356_); + for(BlockElement blockelement : this.getElements()) { + for(BlockElementFace blockelementface : blockelement.faces.values()) { + Material material = this.getMaterial(blockelementface.texture); @@ -182,11 +_,17 @@ return set1; } + @Deprecated //Forge: Use Boolean variant - public BakedModel m_7611_(ModelBakery p_111457_, Function p_111458_, ModelState p_111459_, ResourceLocation p_111460_) { - return this.m_111449_(p_111457_, this, p_111458_, p_111459_, p_111460_, true); + public BakedModel bake(ModelBakery p_111457_, Function p_111458_, ModelState p_111459_, ResourceLocation p_111460_) { + return this.bake(p_111457_, this, p_111458_, p_111459_, p_111460_, true); } - public BakedModel m_111449_(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { + public BakedModel bake(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { + return net.minecraftforge.client.model.ModelLoaderRegistry.bakeHelper(this, p_111450_, p_111451_, p_111452_, p_111453_, p_111454_, p_111455_); + } + + @Deprecated //Forge: exposed for our callbacks only. Use the above function. + public BakedModel bakeVanilla(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { - TextureAtlasSprite textureatlassprite = p_111452_.apply(this.m_111480_("particle")); - if (this.m_111490_() == ModelBakery.f_119233_) { - return new BuiltInModel(this.m_111491_(), this.m_111446_(p_111450_, p_111451_), textureatlassprite, this.m_111479_().m_111526_()); + TextureAtlasSprite textureatlassprite = p_111452_.apply(this.getMaterial("particle")); + if (this.getRootModel() == ModelBakery.BLOCK_ENTITY_MARKER) { + return new BuiltInModel(this.getTransforms(), this.getItemOverrides(p_111450_, p_111451_), textureatlassprite, this.getGuiLight().lightLikeBlock()); @@ -213,6 +_,10 @@ - return f_111421_.m_111600_(p_111438_.f_111308_, p_111438_.f_111309_, p_111439_, p_111440_, p_111441_, p_111442_, p_111438_.f_111311_, p_111438_.f_111312_, p_111443_); + return FACE_BAKERY.bakeQuad(p_111438_.from, p_111438_.to, p_111439_, p_111440_, p_111441_, p_111442_, p_111438_.rotation, p_111438_.shade, p_111443_); } + public static BakedQuad makeBakedQuad(BlockElement p_111438_, BlockElementFace p_111439_, TextureAtlasSprite p_111440_, Direction p_111441_, ModelState p_111442_, ResourceLocation p_111443_) { -+ return m_111437_(p_111438_, p_111439_, p_111440_, p_111441_, p_111442_, p_111443_); ++ return bakeFace(p_111438_, p_111439_, p_111440_, p_111441_, p_111442_, p_111443_); + } + - public boolean m_111477_(String p_111478_) { - return !MissingTextureAtlasSprite.m_118071_().equals(this.m_111480_(p_111478_).m_119203_()); + public boolean hasTexture(String p_111478_) { + return !MissingTextureAtlasSprite.getLocation().equals(this.getMaterial(p_111478_).texture()); } @@ -269,7 +_,18 @@ - ItemTransform itemtransform5 = this.m_111444_(ItemTransforms.TransformType.GUI); - ItemTransform itemtransform6 = this.m_111444_(ItemTransforms.TransformType.GROUND); - ItemTransform itemtransform7 = this.m_111444_(ItemTransforms.TransformType.FIXED); + ItemTransform itemtransform5 = this.getTransform(ItemTransforms.TransformType.GUI); + ItemTransform itemtransform6 = this.getTransform(ItemTransforms.TransformType.GROUND); + ItemTransform itemtransform7 = this.getTransform(ItemTransforms.TransformType.FIXED); - return new ItemTransforms(itemtransform, itemtransform1, itemtransform2, itemtransform3, itemtransform4, itemtransform5, itemtransform6, itemtransform7); + + var builder = com.google.common.collect.ImmutableMap.builder(); + for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values()) { + if (type.isModded()) { -+ var transform = this.m_111444_(type); -+ if (transform != ItemTransform.f_111754_) { ++ var transform = this.getTransform(type); ++ if (transform != ItemTransform.NO_TRANSFORM) { + builder.put(type, transform); + } + } @@ -97,13 +97,13 @@ + return new ItemTransforms(itemtransform, itemtransform1, itemtransform2, itemtransform3, itemtransform4, itemtransform5, itemtransform6, itemtransform7, builder.build()); } - private ItemTransform m_111444_(ItemTransforms.TransformType p_111445_) { + private ItemTransform getTransform(ItemTransforms.TransformType p_111445_) { @@ -388,6 +_,8 @@ - public boolean m_111526_() { + public boolean lightLikeBlock() { return this == SIDE; } + -+ public String getSerializedName() { return f_111519_; } ++ public String getSerializedName() { return name; } } @OnlyIn(Dist.CLIENT) 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 b9e7626b..29be7881 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,21 +1,21 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java @@ -49,6 +_,7 @@ - this.m_111630_(aint, direction); + this.recalculateWinding(aint, direction); } + net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, direction); - return new BakedQuad(aint, p_111603_.f_111355_, direction, p_111604_, p_111608_); + return new BakedQuad(aint, p_111603_.tintIndex, direction, p_111604_, p_111608_); } @@ -131,8 +_,8 @@ - p_111615_[i + 1] = Float.floatToRawIntBits(p_111617_.m_122260_()); - p_111615_[i + 2] = Float.floatToRawIntBits(p_111617_.m_122269_()); + p_111615_[i + 1] = Float.floatToRawIntBits(p_111617_.y()); + p_111615_[i + 2] = Float.floatToRawIntBits(p_111617_.z()); p_111615_[i + 3] = -1; -- p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.m_118367_((double)p_111619_.m_111392_(p_111616_))); -- p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.m_118393_((double)p_111619_.m_111396_(p_111616_))); -+ p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.m_118367_((double)p_111619_.m_111392_(p_111616_) * .999 + p_111619_.m_111392_((p_111616_ + 2) % 4) * .001)); -+ p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.m_118393_((double)p_111619_.m_111396_(p_111616_) * .999 + p_111619_.m_111396_((p_111616_ + 2) % 4) * .001)); +- p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.getU((double)p_111619_.getU(p_111616_))); +- p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.getV((double)p_111619_.getV(p_111616_))); ++ p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.getU((double)p_111619_.getU(p_111616_) * .999 + p_111619_.getU((p_111616_ + 2) % 4) * .001)); ++ p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.getV((double)p_111619_.getV(p_111616_) * .999 + p_111619_.getV((p_111616_ + 2) % 4) * .001)); } - private void m_111586_(Vector3f p_111587_, @Nullable BlockElementRotation p_111588_) { + private void applyElementRotation(Vector3f p_111587_, @Nullable BlockElementRotation p_111588_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch index 5ef8da47..fc9abadf 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/renderer/block/model/ItemModelGenerator.java +++ b/net/minecraft/client/renderer/block/model/ItemModelGenerator.java @@ -39,6 +_,7 @@ - map.put("particle", p_111672_.m_111477_("particle") ? Either.left(p_111672_.m_111480_("particle")) : map.get("layer0")); - BlockModel blockmodel = new BlockModel((ResourceLocation)null, list, map, false, p_111672_.m_111479_(), p_111672_.m_111491_(), p_111672_.m_111484_()); - blockmodel.f_111416_ = p_111672_.f_111416_; + map.put("particle", p_111672_.hasTexture("particle") ? Either.left(p_111672_.getMaterial("particle")) : map.get("layer0")); + BlockModel blockmodel = new BlockModel((ResourceLocation)null, list, map, false, p_111672_.getGuiLight(), p_111672_.getTransforms(), p_111672_.getOverrides()); + blockmodel.name = p_111672_.name; + blockmodel.customData.copyFrom(p_111672_.customData); return blockmodel; } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch index d8a5f951..36fac5e7 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/client/renderer/block/model/ItemOverrides.java +++ b/net/minecraft/client/renderer/block/model/ItemOverrides.java @@ -32,7 +_,11 @@ - this.f_173461_ = new ResourceLocation[0]; + this.properties = new ResourceLocation[0]; } + @Deprecated //Forge: Use IUnbakedModel, add texture getter public ItemOverrides(ModelBakery p_111740_, BlockModel p_111741_, Function p_111742_, List p_111743_) { -+ this(p_111740_, p_111741_, p_111742_, p_111740_.getSpriteMap()::m_117971_, p_111743_); ++ this(p_111740_, p_111741_, p_111742_, p_111740_.getSpriteMap()::getSprite, p_111743_); + } + public ItemOverrides(ModelBakery p_111740_, UnbakedModel p_111741_, Function p_111742_, Function textureGetter, List p_111743_) { - this.f_173461_ = p_111743_.stream().flatMap(ItemOverride::m_173449_).map(ItemOverride.Predicate::m_173459_).distinct().toArray((p_173479_) -> { + this.properties = p_111743_.stream().flatMap(ItemOverride::getPredicates).map(ItemOverride.Predicate::getProperty).distinct().toArray((p_173479_) -> { return new ResourceLocation[p_173479_]; }); @@ -46,7 +_,7 @@ for(int j = p_111743_.size() - 1; j >= 0; --j) { ItemOverride itemoverride = p_111743_.get(j); -- BakedModel bakedmodel = this.m_173470_(p_111740_, p_111741_, p_111742_, itemoverride); +- BakedModel bakedmodel = this.bakeModel(p_111740_, p_111741_, p_111742_, itemoverride); + BakedModel bakedmodel = this.bakeModel(p_111740_, p_111741_, p_111742_, textureGetter, itemoverride); - ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.m_173449_().map((p_173477_) -> { - int k = object2intmap.getInt(p_173477_.m_173459_()); - return new ItemOverrides.PropertyMatcher(k, p_173477_.m_173460_()); + ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.getPredicates().map((p_173477_) -> { + int k = object2intmap.getInt(p_173477_.getProperty()); + return new ItemOverrides.PropertyMatcher(k, p_173477_.getValue()); @@ -60,9 +_,9 @@ } @Nullable -- private BakedModel m_173470_(ModelBakery p_173471_, BlockModel p_173472_, Function p_173473_, ItemOverride p_173474_) { +- private BakedModel bakeModel(ModelBakery p_173471_, BlockModel p_173472_, Function p_173473_, ItemOverride p_173474_) { + private BakedModel bakeModel(ModelBakery p_173471_, UnbakedModel p_173472_, Function p_173473_, Function textureGetter, ItemOverride p_173474_) { - UnbakedModel unbakedmodel = p_173473_.apply(p_173474_.m_111718_()); -- return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.m_119349_(p_173474_.m_111718_(), BlockModelRotation.X0_Y0); -+ return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.bake(p_173474_.m_111718_(), BlockModelRotation.X0_Y0, textureGetter); + UnbakedModel unbakedmodel = p_173473_.apply(p_173474_.getModel()); +- return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.bake(p_173474_.getModel(), BlockModelRotation.X0_Y0); ++ return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.bake(p_173474_.getModel(), BlockModelRotation.X0_Y0, textureGetter); } @Nullable @@ -40,7 +40,7 @@ + } + + public com.google.common.collect.ImmutableList getOverrides() { -+ return com.google.common.collect.ImmutableList.copyOf(f_111735_); ++ return com.google.common.collect.ImmutableList.copyOf(overrides); } @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch index ea9a2ca9..77628716 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch @@ -10,5 +10,5 @@ @OnlyIn(Dist.CLIENT) +@Deprecated public class ItemTransform { - public static final ItemTransform f_111754_ = new ItemTransform(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F)); - public final Vector3f f_111755_; + public static final ItemTransform NO_TRANSFORM = new ItemTransform(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F)); + public final Vector3f rotation; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch index 294e1aef..d14f578d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransforms.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/client/renderer/block/model/ItemTransforms.java +++ b/net/minecraft/client/renderer/block/model/ItemTransforms.java @@ -20,6 +_,7 @@ - public final ItemTransform f_111792_; - public final ItemTransform f_111793_; - public final ItemTransform f_111794_; + public final ItemTransform gui; + public final ItemTransform ground; + public final ItemTransform fixed; + public final com.google.common.collect.ImmutableMap moddedTransforms; private ItemTransforms() { - this(ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_); + this(ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM); @@ -34,9 +_,16 @@ - this.f_111792_ = p_111807_.f_111792_; - this.f_111793_ = p_111807_.f_111793_; - this.f_111794_ = p_111807_.f_111794_; + this.gui = p_111807_.gui; + this.ground = p_111807_.ground; + this.fixed = p_111807_.fixed; + this.moddedTransforms = p_111807_.moddedTransforms; } @@ -22,42 +22,42 @@ + + public ItemTransforms(ItemTransform p_111798_, ItemTransform p_111799_, ItemTransform p_111800_, ItemTransform p_111801_, ItemTransform p_111802_, ItemTransform p_111803_, ItemTransform p_111804_, ItemTransform p_111805_, + com.google.common.collect.ImmutableMap moddedTransforms) { - this.f_111787_ = p_111798_; - this.f_111788_ = p_111799_; - this.f_111789_ = p_111800_; + this.thirdPersonLeftHand = p_111798_; + this.thirdPersonRightHand = p_111799_; + this.firstPersonLeftHand = p_111800_; @@ -45,6 +_,7 @@ - this.f_111792_ = p_111803_; - this.f_111793_ = p_111804_; - this.f_111794_ = p_111805_; + this.gui = p_111803_; + this.ground = p_111804_; + this.fixed = p_111805_; + this.moddedTransforms = moddedTransforms; } - public ItemTransform m_111808_(ItemTransforms.TransformType p_111809_) { + public ItemTransform getTransform(ItemTransforms.TransformType p_111809_) { @@ -66,7 +_,7 @@ case FIXED: - return this.f_111794_; + return this.fixed; default: -- return ItemTransform.f_111754_; -+ return moddedTransforms.getOrDefault(p_111809_, ItemTransform.f_111754_); +- return ItemTransform.NO_TRANSFORM; ++ return moddedTransforms.getOrDefault(p_111809_, ItemTransform.NO_TRANSFORM); } } @@ -94,7 +_,23 @@ - ItemTransform itemtransform5 = this.m_111815_(p_111822_, jsonobject, "gui"); - ItemTransform itemtransform6 = this.m_111815_(p_111822_, jsonobject, "ground"); - ItemTransform itemtransform7 = this.m_111815_(p_111822_, jsonobject, "fixed"); + ItemTransform itemtransform5 = this.getTransform(p_111822_, jsonobject, "gui"); + ItemTransform itemtransform6 = this.getTransform(p_111822_, jsonobject, "ground"); + ItemTransform itemtransform7 = this.getTransform(p_111822_, jsonobject, "fixed"); - return new ItemTransforms(itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7); + + var builder = com.google.common.collect.ImmutableMap.builder(); + for (TransformType type : TransformType.values()) { + if (type.isModded()) { -+ var transform = this.m_111815_(p_111822_, jsonobject, type.getSerializeName()); ++ var transform = this.getTransform(p_111822_, jsonobject, type.getSerializeName()); + var fallbackType = type; -+ while (transform == ItemTransform.f_111754_ && fallbackType.fallback != null) { ++ while (transform == ItemTransform.NO_TRANSFORM && fallbackType.fallback != null) { + fallbackType = fallbackType.fallback; -+ transform = this.m_111815_(p_111822_, jsonobject, fallbackType.getSerializeName()); ++ transform = this.getTransform(p_111822_, jsonobject, fallbackType.getSerializeName()); + } -+ if (transform != ItemTransform.f_111754_){ ++ if (transform != ItemTransform.NO_TRANSFORM){ + builder.put(type, transform); + } + } @@ -66,7 +66,7 @@ + return new ItemTransforms(itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7, builder.build()); } - private ItemTransform m_111815_(JsonDeserializationContext p_111816_, JsonObject p_111817_, String p_111818_) { + private ItemTransform getTransform(JsonDeserializationContext p_111816_, JsonObject p_111817_, String p_111818_) { @@ -103,19 +_,63 @@ } @@ -92,7 +92,7 @@ + GROUND("ground"), + FIXED("fixed"); - public boolean m_111841_() { + public boolean firstPerson() { return this == FIRST_PERSON_LEFT_HAND || this == FIRST_PERSON_RIGHT_HAND; + } + 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 34d453bf..2f085514 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 @@ -3,9 +3,9 @@ @@ -70,7 +_,7 @@ WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); - for(Variant variant : this.m_111848_()) { -- BakedModel bakedmodel = p_111850_.m_119349_(variant.m_111883_(), variant); -+ BakedModel bakedmodel = p_111850_.bake(variant.m_111883_(), variant, p_111851_); - weightedbakedmodel$builder.m_119559_(bakedmodel, variant.m_111886_()); + for(Variant variant : this.getVariants()) { +- BakedModel bakedmodel = p_111850_.bake(variant.getModelLocation(), variant); ++ BakedModel bakedmodel = p_111850_.bake(variant.getModelLocation(), variant, p_111851_); + weightedbakedmodel$builder.add(bakedmodel, variant.getWeight()); } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch index da62612f..05448010 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/BlockEntityRenderers.java.patch @@ -4,8 +4,8 @@ @OnlyIn(Dist.CLIENT) public class BlockEntityRenderers { -- private static final Map, BlockEntityRendererProvider> f_173587_ = Maps.newHashMap(); -+ private static final Map, BlockEntityRendererProvider> f_173587_ = new java.util.concurrent.ConcurrentHashMap<>(); +- private static final Map, BlockEntityRendererProvider> PROVIDERS = Maps.newHashMap(); ++ private static final Map, BlockEntityRendererProvider> PROVIDERS = new java.util.concurrent.ConcurrentHashMap<>(); - public static void m_173590_(BlockEntityType p_173591_, BlockEntityRendererProvider p_173592_) { - f_173587_.put(p_173591_, p_173592_); + public static void register(BlockEntityType p_173591_, BlockEntityRendererProvider p_173592_) { + PROVIDERS.put(p_173591_, p_173592_); 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 f7cced50..1d51fdc7 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch @@ -3,19 +3,19 @@ @@ -120,7 +_,7 @@ f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; - int i = neighborcombineresult.m_5649_(new BrightnessCombiner<>()).applyAsInt(p_112367_); -- Material material = Sheets.m_110767_(p_112363_, chesttype, this.f_112359_); + int i = neighborcombineresult.apply(new BrightnessCombiner<>()).applyAsInt(p_112367_); +- Material material = Sheets.chooseMaterial(p_112363_, chesttype, this.xmasTextures); + Material material = this.getMaterial(p_112363_, chesttype); - VertexConsumer vertexconsumer = material.m_119194_(p_112366_, RenderType::m_110452_); + VertexConsumer vertexconsumer = material.buffer(p_112366_, RenderType::entityCutout); if (flag1) { if (chesttype == ChestType.LEFT) { @@ -142,5 +_,9 @@ - p_112372_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); - p_112373_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); - p_112374_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); + 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_); + } + + protected Material getMaterial(T blockEntity, ChestType chestType) { -+ return Sheets.m_110767_(blockEntity, chestType, this.f_112359_); ++ return Sheets.chooseMaterial(blockEntity, chestType, this.xmasTextures); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch index 4ce31025..1f0d2149 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch @@ -3,13 +3,13 @@ @@ -60,9 +_,12 @@ } - private void m_112458_(BlockPos p_112459_, BlockState p_112460_, PoseStack p_112461_, MultiBufferSource p_112462_, Level p_112463_, boolean p_112464_, int p_112465_) { -+ net.minecraftforge.client.ForgeHooksClient.renderPistonMovedBlocks(p_112459_, p_112460_, p_112461_, p_112462_, p_112463_, p_112464_, p_112465_, f_112441_ == null ? f_112441_ = net.minecraft.client.Minecraft.m_91087_().m_91289_() : f_112441_); + private void renderBlock(BlockPos p_112459_, BlockState p_112460_, PoseStack p_112461_, MultiBufferSource p_112462_, Level p_112463_, boolean p_112464_, int p_112465_) { ++ net.minecraftforge.client.ForgeHooksClient.renderPistonMovedBlocks(p_112459_, p_112460_, p_112461_, p_112462_, p_112463_, p_112464_, p_112465_, blockRenderer == null ? blockRenderer = net.minecraft.client.Minecraft.getInstance().getBlockRenderer() : blockRenderer); + if(false) { - RenderType rendertype = ItemBlockRenderTypes.m_109293_(p_112460_); - VertexConsumer vertexconsumer = p_112462_.m_6299_(rendertype); - this.f_112441_.m_110937_().m_111047_(p_112463_, this.f_112441_.m_110910_(p_112460_), p_112460_, p_112459_, p_112461_, vertexconsumer, p_112464_, new Random(), p_112460_.m_60726_(p_112459_), p_112465_); + RenderType rendertype = ItemBlockRenderTypes.getMovingBlockRenderType(p_112460_); + VertexConsumer vertexconsumer = p_112462_.getBuffer(rendertype); + this.blockRenderer.getModelRenderer().tesselateBlock(p_112463_, this.blockRenderer.getBlockModel(p_112460_), p_112460_, p_112459_, p_112461_, vertexconsumer, p_112464_, new Random(), p_112460_.getSeed(p_112459_), p_112465_); + } } - public int m_142163_() { + public int getViewDistance() { diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch index f0b31fdd..54cd9c5a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch @@ -3,16 +3,16 @@ @@ -35,7 +_,7 @@ @OnlyIn(Dist.CLIENT) public class SkullBlockRenderer implements BlockEntityRenderer { - private final Map f_173658_; -- public static final Map f_112519_ = Util.m_137469_(Maps.newHashMap(), (p_112552_) -> { -+ private static final Map f_112519_ = Util.m_137469_(Maps.newHashMap(), (p_112552_) -> { + private final Map modelByType; +- public static final Map SKIN_BY_TYPE = Util.make(Maps.newHashMap(), (p_112552_) -> { ++ private static final Map SKIN_BY_TYPE = Util.make(Maps.newHashMap(), (p_112552_) -> { p_112552_.put(SkullBlock.Types.SKELETON, new ResourceLocation("textures/entity/skeleton/skeleton.png")); p_112552_.put(SkullBlock.Types.WITHER_SKELETON, new ResourceLocation("textures/entity/skeleton/wither_skeleton.png")); p_112552_.put(SkullBlock.Types.ZOMBIE, new ResourceLocation("textures/entity/zombie/zombie.png")); @@ -52,6 +_,7 @@ - builder.put(SkullBlock.Types.ZOMBIE, new SkullModel(p_173662_.m_171103_(ModelLayers.f_171224_))); - builder.put(SkullBlock.Types.CREEPER, new SkullModel(p_173662_.m_171103_(ModelLayers.f_171130_))); - builder.put(SkullBlock.Types.DRAGON, new DragonHeadModel(p_173662_.m_171103_(ModelLayers.f_171135_))); + builder.put(SkullBlock.Types.ZOMBIE, new SkullModel(p_173662_.bakeLayer(ModelLayers.ZOMBIE_HEAD))); + builder.put(SkullBlock.Types.CREEPER, new SkullModel(p_173662_.bakeLayer(ModelLayers.CREEPER_HEAD))); + builder.put(SkullBlock.Types.DRAGON, new DragonHeadModel(p_173662_.bakeLayer(ModelLayers.DRAGON_SKULL))); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.CreateSkullModels(builder, p_173662_)); return builder.build(); } diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch index 1a00e0a5..812b9dcf 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch @@ -1,44 +1,44 @@ --- a/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java +++ b/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java @@ -73,12 +_,15 @@ - private Vec3 f_112683_ = Vec3.f_82478_; + private Vec3 camera = Vec3.ZERO; public ChunkRenderDispatcher(ClientLevel p_194405_, LevelRenderer p_194406_, Executor p_194407_, boolean p_194408_, ChunkBufferBuilderPack p_194409_) { + this(p_194405_, p_194406_, p_194407_, p_194408_, p_194409_, -1); + } + public ChunkRenderDispatcher(ClientLevel p_194405_, LevelRenderer p_194406_, Executor p_194407_, boolean p_194408_, ChunkBufferBuilderPack p_194409_, int countRenderBuilders) { - this.f_112681_ = p_194405_; - this.f_112682_ = p_194406_; - int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / (RenderType.m_110506_().stream().mapToInt(RenderType::m_110507_).sum() * 4) - 1); + this.level = p_194405_; + this.renderer = p_194406_; + int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / (RenderType.chunkBufferLayers().stream().mapToInt(RenderType::bufferSize).sum() * 4) - 1); int j = Runtime.getRuntime().availableProcessors(); int k = p_194408_ ? j : Math.min(j, 4); - int l = Math.max(1, Math.min(k, i)); + int l = countRenderBuilders < 0 ? Math.max(1, Math.min(k, i)) : countRenderBuilders; - this.f_112678_ = p_194409_; + this.fixedBuffers = p_194409_; List list = Lists.newArrayListWithExpectedSize(l); @@ -420,7 +_,7 @@ - if (!chunkrenderdispatcher$compiledchunk.f_112750_.contains(p_112810_)) { + if (!chunkrenderdispatcher$compiledchunk.hasLayer.contains(p_112810_)) { return false; } else { -- this.f_112788_ = new ChunkRenderDispatcher.RenderChunk.ResortTransparencyTask(this.m_112832_(), chunkrenderdispatcher$compiledchunk); -+ this.f_112788_ = new ChunkRenderDispatcher.RenderChunk.ResortTransparencyTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), chunkrenderdispatcher$compiledchunk); - p_112811_.m_112709_(this.f_112788_); +- this.lastResortTransparencyTask = new ChunkRenderDispatcher.RenderChunk.ResortTransparencyTask(this.getDistToPlayerSqr(), chunkrenderdispatcher$compiledchunk); ++ this.lastResortTransparencyTask = new ChunkRenderDispatcher.RenderChunk.ResortTransparencyTask(new net.minecraft.world.level.ChunkPos(getOrigin()), this.getDistToPlayerSqr(), chunkrenderdispatcher$compiledchunk); + p_112811_.schedule(this.lastResortTransparencyTask); return true; } @@ -452,7 +_,7 @@ - this.f_202433_.incrementAndGet(); + this.initialCompilationCancelCount.incrementAndGet(); } -- this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(this.m_112832_(), renderchunkregion, !flag1 || this.f_202433_.get() > 2); -+ this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), renderchunkregion, flag || this.f_112784_.get() != ChunkRenderDispatcher.CompiledChunk.f_112748_); - return this.f_112787_; +- this.lastRebuildTask = new ChunkRenderDispatcher.RenderChunk.RebuildTask(this.getDistToPlayerSqr(), renderchunkregion, !flag1 || this.initialCompilationCancelCount.get() > 2); ++ this.lastRebuildTask = new ChunkRenderDispatcher.RenderChunk.RebuildTask(new net.minecraft.world.level.ChunkPos(getOrigin()), this.getDistToPlayerSqr(), renderchunkregion, flag || this.compiled.get() != ChunkRenderDispatcher.CompiledChunk.UNCOMPILED); + return this.lastRebuildTask; } @@ -485,10 +_,20 @@ - protected final double f_112847_; - protected final AtomicBoolean f_112848_ = new AtomicBoolean(false); - protected final boolean f_194420_; + protected final double distAtCreation; + protected final AtomicBoolean isCancelled = new AtomicBoolean(false); + protected final boolean isHighPriority; + protected java.util.Map modelData; public ChunkCompileTask(double p_194423_, boolean p_194424_) { @@ -46,19 +46,19 @@ + } + + public ChunkCompileTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_194423_, boolean p_194424_) { - this.f_112847_ = p_194423_; - this.f_194420_ = p_194424_; + this.distAtCreation = p_194423_; + this.isHighPriority = p_194424_; + if (pos == null) { + this.modelData = java.util.Collections.emptyMap(); + } else { -+ this.modelData = net.minecraftforge.client.model.ModelDataManager.getModelData(net.minecraft.client.Minecraft.m_91087_().f_91073_, pos); ++ this.modelData = net.minecraftforge.client.model.ModelDataManager.getModelData(net.minecraft.client.Minecraft.getInstance().level, pos); + } } - public abstract CompletableFuture m_5869_(ChunkBufferBuilderPack p_112853_); + public abstract CompletableFuture doTask(ChunkBufferBuilderPack p_112853_); @@ -500,6 +_,10 @@ public int compareTo(ChunkRenderDispatcher.RenderChunk.ChunkCompileTask p_112855_) { - return Doubles.compare(this.f_112847_, p_112855_.f_112847_); + return Doubles.compare(this.distAtCreation, p_112855_.distAtCreation); } + + public net.minecraftforge.client.model.data.IModelData getModelData(net.minecraft.core.BlockPos pos) { @@ -69,7 +69,7 @@ @OnlyIn(Dist.CLIENT) @@ -507,8 +_,13 @@ @Nullable - protected RenderChunkRegion f_112858_; + protected RenderChunkRegion region; + @Deprecated public RebuildTask(@Nullable double p_194427_, RenderChunkRegion p_194428_, boolean p_194429_) { @@ -79,66 +79,66 @@ + + public RebuildTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_194427_, @Nullable RenderChunkRegion p_194428_, boolean p_194429_) { + super(pos, p_194427_, p_194429_); - this.f_112858_ = p_194428_; + this.region = p_194428_; } @@ -591,8 +_,10 @@ - BlockState blockstate1 = renderchunkregion.m_8055_(blockpos2); - FluidState fluidstate = blockstate1.m_60819_(); -- if (!fluidstate.m_76178_()) { -- RenderType rendertype = ItemBlockRenderTypes.m_109287_(fluidstate); + BlockState blockstate1 = renderchunkregion.getBlockState(blockpos2); + FluidState fluidstate = blockstate1.getFluidState(); +- if (!fluidstate.isEmpty()) { +- RenderType rendertype = ItemBlockRenderTypes.getRenderLayer(fluidstate); + net.minecraftforge.client.model.data.IModelData modelData = getModelData(blockpos2); -+ for (RenderType rendertype : RenderType.m_110506_()) { ++ for (RenderType rendertype : RenderType.chunkBufferLayers()) { + net.minecraftforge.client.ForgeHooksClient.setRenderType(rendertype); -+ if (!fluidstate.m_76178_() && ItemBlockRenderTypes.canRenderInLayer(fluidstate, rendertype)) { - BufferBuilder bufferbuilder = p_112870_.m_108839_(rendertype); - if (p_112869_.f_112750_.add(rendertype)) { - RenderChunk.this.m_112805_(bufferbuilder); ++ if (!fluidstate.isEmpty() && ItemBlockRenderTypes.canRenderInLayer(fluidstate, rendertype)) { + BufferBuilder bufferbuilder = p_112870_.builder(rendertype); + if (p_112869_.hasLayer.add(rendertype)) { + RenderChunk.this.beginLayer(bufferbuilder); @@ -604,8 +_,8 @@ } } -- if (blockstate.m_60799_() != RenderShape.INVISIBLE) { -- RenderType rendertype1 = ItemBlockRenderTypes.m_109282_(blockstate); -+ if (blockstate.m_60799_() != RenderShape.INVISIBLE && ItemBlockRenderTypes.canRenderInLayer(blockstate, rendertype)) { +- if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { +- RenderType rendertype1 = ItemBlockRenderTypes.getChunkRenderType(blockstate); ++ if (blockstate.getRenderShape() != RenderShape.INVISIBLE && ItemBlockRenderTypes.canRenderInLayer(blockstate, rendertype)) { + RenderType rendertype1 = rendertype; - BufferBuilder bufferbuilder2 = p_112870_.m_108839_(rendertype1); - if (p_112869_.f_112750_.add(rendertype1)) { - RenderChunk.this.m_112805_(bufferbuilder2); + BufferBuilder bufferbuilder2 = p_112870_.builder(rendertype1); + if (p_112869_.hasLayer.add(rendertype1)) { + RenderChunk.this.beginLayer(bufferbuilder2); @@ -613,14 +_,16 @@ - posestack.m_85836_(); - posestack.m_85837_((double)(blockpos2.m_123341_() & 15), (double)(blockpos2.m_123342_() & 15), (double)(blockpos2.m_123343_() & 15)); -- if (blockrenderdispatcher.m_110924_(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, random)) { + posestack.pushPose(); + posestack.translate((double)(blockpos2.getX() & 15), (double)(blockpos2.getY() & 15), (double)(blockpos2.getZ() & 15)); +- if (blockrenderdispatcher.renderBatched(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, random)) { + if (blockrenderdispatcher.renderBatched(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, random, modelData)) { - p_112869_.f_112751_ = false; - p_112869_.f_112749_.add(rendertype1); + p_112869_.isCompletelyEmpty = false; + p_112869_.hasBlocks.add(rendertype1); } - posestack.m_85849_(); + posestack.popPose(); } + } } + net.minecraftforge.client.ForgeHooksClient.setRenderType(null); - if (p_112869_.f_112749_.contains(RenderType.m_110466_())) { - BufferBuilder bufferbuilder1 = p_112870_.m_108839_(RenderType.m_110466_()); + if (p_112869_.hasBlocks.contains(RenderType.translucent())) { + BufferBuilder bufferbuilder1 = p_112870_.builder(RenderType.translucent()); @@ -639,10 +_,10 @@ - private void m_112877_(ChunkRenderDispatcher.CompiledChunk p_112878_, Set p_112879_, E p_112880_) { - BlockEntityRenderer blockentityrenderer = Minecraft.m_91087_().m_167982_().m_112265_(p_112880_); + private void handleBlockEntity(ChunkRenderDispatcher.CompiledChunk p_112878_, Set p_112879_, E p_112880_) { + BlockEntityRenderer blockentityrenderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(p_112880_); if (blockentityrenderer != null) { -- p_112878_.f_112752_.add(p_112880_); - if (blockentityrenderer.m_5932_(p_112880_)) { +- p_112878_.renderableBlockEntities.add(p_112880_); + if (blockentityrenderer.shouldRenderOffScreen(p_112880_)) { p_112879_.add(p_112880_); } -+ else p_112878_.f_112752_.add(p_112880_); //FORGE: Fix MC-112730 ++ else p_112878_.renderableBlockEntities.add(p_112880_); //FORGE: Fix MC-112730 } } @@ -660,8 +_,13 @@ class ResortTransparencyTask extends ChunkRenderDispatcher.RenderChunk.ChunkCompileTask { - private final ChunkRenderDispatcher.CompiledChunk f_112886_; + private final ChunkRenderDispatcher.CompiledChunk compiledChunk; + @Deprecated public ResortTransparencyTask(double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { @@ -148,6 +148,6 @@ + + public ResortTransparencyTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { + super(pos, p_112889_, true); - this.f_112886_ = p_112890_; + this.compiledChunk = p_112890_; } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch index 40d7e505..ff992d76 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/client/renderer/entity/BoatRenderer.java +++ b/net/minecraft/client/renderer/entity/BoatRenderer.java @@ -52,7 +_,7 @@ - p_113932_.m_85845_(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), p_113929_.m_38352_(p_113931_), true)); + p_113932_.mulPose(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), p_113929_.getBubbleAngle(p_113931_), true)); } -- Pair pair = this.f_173934_.get(p_113929_.m_38387_()); +- Pair pair = this.boatResources.get(p_113929_.getBoatType()); + Pair pair = getModelWithLocation(p_113929_); ResourceLocation resourcelocation = pair.getFirst(); BoatModel boatmodel = pair.getSecond(); - p_113932_.m_85841_(-1.0F, -1.0F, 1.0F); + p_113932_.scale(-1.0F, -1.0F, 1.0F); @@ -69,7 +_,10 @@ - super.m_7392_(p_113929_, p_113930_, p_113931_, p_113932_, p_113933_, p_113934_); + 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 m_5478_(Boat p_113927_) { -- return this.f_173934_.get(p_113927_.m_38387_()).getFirst(); + public ResourceLocation getTextureLocation(Boat p_113927_) { +- return this.boatResources.get(p_113927_.getBoatType()).getFirst(); + return getModelWithLocation(p_113927_).getFirst(); } + -+ public Pair getModelWithLocation(Boat boat) { return this.f_173934_.get(boat.m_38387_()); } ++ public Pair getModelWithLocation(Boat boat) { return this.boatResources.get(boat.getBoatType()); } } 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 797d26d3..dc96047a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java @@ -161,12 +_,12 @@ - private static void m_114441_(PoseStack p_114442_, VertexConsumer p_114443_, Entity p_114444_, float p_114445_) { - AABB aabb = p_114444_.m_142469_().m_82386_(-p_114444_.m_20185_(), -p_114444_.m_20186_(), -p_114444_.m_20189_()); - LevelRenderer.m_109646_(p_114442_, p_114443_, aabb, 1.0F, 1.0F, 1.0F, 1.0F); + private static void renderHitbox(PoseStack p_114442_, VertexConsumer p_114443_, Entity p_114444_, float p_114445_) { + AABB aabb = p_114444_.getBoundingBox().move(-p_114444_.getX(), -p_114444_.getY(), -p_114444_.getZ()); + LevelRenderer.renderLineBox(p_114442_, p_114443_, aabb, 1.0F, 1.0F, 1.0F, 1.0F); - if (p_114444_ instanceof EnderDragon) { + if (p_114444_.isMultipartEntity()) { - double d0 = -Mth.m_14139_((double)p_114445_, p_114444_.f_19790_, p_114444_.m_20185_()); - double d1 = -Mth.m_14139_((double)p_114445_, p_114444_.f_19791_, p_114444_.m_20186_()); - double d2 = -Mth.m_14139_((double)p_114445_, p_114444_.f_19792_, p_114444_.m_20189_()); + double d0 = -Mth.lerp((double)p_114445_, p_114444_.xOld, p_114444_.getX()); + double d1 = -Mth.lerp((double)p_114445_, p_114444_.yOld, p_114444_.getY()); + double d2 = -Mth.lerp((double)p_114445_, p_114444_.zOld, p_114444_.getZ()); -- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_114444_).m_31156_()) { +- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_114444_).getSubEntities()) { + for(net.minecraftforge.entity.PartEntity enderdragonpart : p_114444_.getParts()) { - p_114442_.m_85836_(); - double d3 = d0 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19790_, enderdragonpart.m_20185_()); - double d4 = d1 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19791_, enderdragonpart.m_20186_()); + 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()); @@ -324,9 +_,14 @@ - return this.f_114367_; + return this.cameraOrientation; } + public Map> getSkinMap() { -+ return java.util.Collections.unmodifiableMap(f_114363_); ++ return java.util.Collections.unmodifiableMap(playerRenderers); + } + - public void m_6213_(ResourceManager p_174004_) { - EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context(this, this.f_173995_, p_174004_, this.f_173996_, this.f_114365_); - this.f_114362_ = EntityRenderers.m_174049_(entityrendererprovider$context); - this.f_114363_ = EntityRenderers.m_174051_(entityrendererprovider$context); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.AddLayers(f_114362_, f_114363_)); + public void onResourceManagerReload(ResourceManager p_174004_) { + EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context(this, this.itemRenderer, p_174004_, this.entityModels, this.font); + this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); + this.playerRenderers = EntityRenderers.createPlayerRenderers(entityrendererprovider$context); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.AddLayers(renderers, playerRenderers)); } } 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 e9ea8b88..ab043d50 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -3,22 +3,22 @@ @@ -63,8 +_,10 @@ } - public void m_7392_(T p_114485_, float p_114486_, float p_114487_, PoseStack p_114488_, MultiBufferSource p_114489_, int p_114490_) { -- if (this.m_6512_(p_114485_)) { -- this.m_7649_(p_114485_, p_114485_.m_5446_(), p_114488_, p_114489_, p_114490_); -+ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_114485_, p_114485_.m_5446_(), this, p_114488_, p_114489_, p_114490_, p_114487_); + public void render(T p_114485_, float p_114486_, float p_114487_, PoseStack p_114488_, MultiBufferSource p_114489_, int p_114490_) { +- if (this.shouldShowName(p_114485_)) { +- this.renderNameTag(p_114485_, p_114485_.getDisplayName(), p_114488_, p_114489_, p_114490_); ++ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_114485_, p_114485_.getDisplayName(), this, p_114488_, p_114489_, p_114490_, p_114487_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(renderNameplateEvent); -+ if (renderNameplateEvent.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY && (renderNameplateEvent.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || this.m_6512_(p_114485_))) { -+ this.m_7649_(p_114485_, renderNameplateEvent.getContent(), p_114488_, p_114489_, p_114490_); ++ if (renderNameplateEvent.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY && (renderNameplateEvent.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || this.shouldShowName(p_114485_))) { ++ this.renderNameTag(p_114485_, renderNameplateEvent.getContent(), p_114488_, p_114489_, p_114490_); } } @@ -80,7 +_,7 @@ - protected void m_7649_(T p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_) { - double d0 = this.f_114476_.m_114471_(p_114498_); + protected void renderNameTag(T p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_) { + double d0 = this.entityRenderDispatcher.distanceToSqr(p_114498_); - if (!(d0 > 4096.0D)) { + if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_114498_, d0)) { - boolean flag = !p_114498_.m_20163_(); - float f = p_114498_.m_20206_() + 0.5F; + boolean flag = !p_114498_.isDiscrete(); + float f = p_114498_.getBbHeight() + 0.5F; int i = "deadmau5".equals(p_114499_.getString()) ? -10 : 0; diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch index 9e90b95e..f7db599e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/client/renderer/entity/FallingBlockRenderer.java +++ b/net/minecraft/client/renderer/entity/FallingBlockRenderer.java @@ -33,7 +_,13 @@ - BlockPos blockpos = new BlockPos(p_114634_.m_20185_(), p_114634_.m_142469_().f_82292_, p_114634_.m_20189_()); - p_114637_.m_85837_(-0.5D, 0.0D, -0.5D); - BlockRenderDispatcher blockrenderdispatcher = Minecraft.m_91087_().m_91289_(); -- blockrenderdispatcher.m_110937_().m_111047_(level, blockrenderdispatcher.m_110910_(blockstate), blockstate, blockpos, p_114637_, p_114638_.m_6299_(ItemBlockRenderTypes.m_109293_(blockstate)), false, new Random(), blockstate.m_60726_(p_114634_.m_31978_()), OverlayTexture.f_118083_); -+ for (net.minecraft.client.renderer.RenderType type : net.minecraft.client.renderer.RenderType.m_110506_()) { + BlockPos blockpos = new BlockPos(p_114634_.getX(), p_114634_.getBoundingBox().maxY, p_114634_.getZ()); + p_114637_.translate(-0.5D, 0.0D, -0.5D); + BlockRenderDispatcher blockrenderdispatcher = Minecraft.getInstance().getBlockRenderer(); +- blockrenderdispatcher.getModelRenderer().tesselateBlock(level, blockrenderdispatcher.getBlockModel(blockstate), blockstate, blockpos, p_114637_, p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), false, new Random(), blockstate.getSeed(p_114634_.getStartPos()), OverlayTexture.NO_OVERLAY); ++ for (net.minecraft.client.renderer.RenderType type : net.minecraft.client.renderer.RenderType.chunkBufferLayers()) { + if (ItemBlockRenderTypes.canRenderInLayer(blockstate, type)) { + net.minecraftforge.client.ForgeHooksClient.setRenderType(type); -+ blockrenderdispatcher.m_110937_().m_111047_(level, blockrenderdispatcher.m_110910_(blockstate), blockstate, blockpos, p_114637_, p_114638_.m_6299_(type), false, new Random(), blockstate.m_60726_(p_114634_.m_31978_()), OverlayTexture.f_118083_); ++ blockrenderdispatcher.getModelRenderer().tesselateBlock(level, blockrenderdispatcher.getBlockModel(blockstate), blockstate, blockpos, p_114637_, p_114638_.getBuffer(type), false, new Random(), blockstate.getSeed(p_114634_.getStartPos()), OverlayTexture.NO_OVERLAY); + } + } + net.minecraftforge.client.ForgeHooksClient.setRenderType(null); - p_114637_.m_85849_(); - super.m_7392_(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_); + 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/ItemEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch index b498636b..a3c2d3ec 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/client/renderer/entity/ItemEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemEntityRenderer.java @@ -62,17 +_,14 @@ - int j = this.m_115042_(itemstack); + int j = this.getRenderAmount(itemstack); float f = 0.25F; - float f1 = Mth.m_14031_(((float)p_115036_.m_32059_() + p_115038_) / 10.0F + p_115036_.f_31983_) * 0.1F + 0.1F; -- float f2 = bakedmodel.m_7442_().m_111808_(ItemTransforms.TransformType.GROUND).f_111757_.m_122260_(); -+ float f2 = shouldBob() ? bakedmodel.m_7442_().m_111808_(ItemTransforms.TransformType.GROUND).f_111757_.m_122260_() : 0; - p_115039_.m_85837_(0.0D, (double)(f1 + 0.25F * f2), 0.0D); - float f3 = p_115036_.m_32008_(p_115038_); - p_115039_.m_85845_(Vector3f.f_122225_.m_122270_(f3)); -- float f4 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122239_(); -- float f5 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122260_(); -- float f6 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122269_(); + float f1 = Mth.sin(((float)p_115036_.getAge() + p_115038_) / 10.0F + p_115036_.bobOffs) * 0.1F + 0.1F; +- float f2 = bakedmodel.getTransforms().getTransform(ItemTransforms.TransformType.GROUND).scale.y(); ++ float f2 = shouldBob() ? bakedmodel.getTransforms().getTransform(ItemTransforms.TransformType.GROUND).scale.y() : 0; + p_115039_.translate(0.0D, (double)(f1 + 0.25F * f2), 0.0D); + float f3 = p_115036_.getSpin(p_115038_); + p_115039_.mulPose(Vector3f.YP.rotation(f3)); +- float f4 = bakedmodel.getTransforms().ground.scale.x(); +- float f5 = bakedmodel.getTransforms().ground.scale.y(); +- float f6 = bakedmodel.getTransforms().ground.scale.z(); if (!flag) { - float f7 = -0.0F * (float)(j - 1) * 0.5F * f4; - float f8 = -0.0F * (float)(j - 1) * 0.5F * f5; @@ -19,34 +19,34 @@ + float f7 = -0.0F * (float)(j - 1) * 0.5F; + float f8 = -0.0F * (float)(j - 1) * 0.5F; + float f9 = -0.09375F * (float)(j - 1) * 0.5F; - p_115039_.m_85837_((double)f7, (double)f8, (double)f9); + p_115039_.translate((double)f7, (double)f8, (double)f9); } @@ -83,18 +_,18 @@ - float f11 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F; - float f13 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F; - float f10 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F; -- p_115039_.m_85837_((double)f11, (double)f13, (double)f10); -+ p_115039_.m_85837_(shouldSpreadItems() ? f11 : 0, shouldSpreadItems() ? f13 : 0, shouldSpreadItems() ? f10 : 0); + float f11 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F; + float f13 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F; + float f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F; +- p_115039_.translate((double)f11, (double)f13, (double)f10); ++ p_115039_.translate(shouldSpreadItems() ? f11 : 0, shouldSpreadItems() ? f13 : 0, shouldSpreadItems() ? f10 : 0); } else { - float f12 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; - float f14 = (this.f_115020_.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; -- p_115039_.m_85837_((double)f12, (double)f14, 0.0D); -+ p_115039_.m_85837_(shouldSpreadItems() ? f12 : 0, shouldSpreadItems() ? f14 : 0, 0.0D); + float f12 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; + float f14 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F; +- p_115039_.translate((double)f12, (double)f14, 0.0D); ++ p_115039_.translate(shouldSpreadItems() ? f12 : 0, shouldSpreadItems() ? f14 : 0, 0.0D); } } - this.f_115019_.m_115143_(itemstack, ItemTransforms.TransformType.GROUND, false, p_115039_, p_115040_, p_115041_, OverlayTexture.f_118083_, bakedmodel); - p_115039_.m_85849_(); + this.itemRenderer.render(itemstack, ItemTransforms.TransformType.GROUND, false, p_115039_, p_115040_, p_115041_, OverlayTexture.NO_OVERLAY, bakedmodel); + p_115039_.popPose(); if (!flag) { -- p_115039_.m_85837_((double)(0.0F * f4), (double)(0.0F * f5), (double)(0.09375F * f6)); -+ p_115039_.m_85837_(0.0, 0.0, 0.09375F); +- p_115039_.translate((double)(0.0F * f4), (double)(0.0F * f5), (double)(0.09375F * f6)); ++ p_115039_.translate(0.0, 0.0, 0.09375F); } } @@ -105,4 +_,21 @@ - public ResourceLocation m_5478_(ItemEntity p_115034_) { - return TextureAtlas.f_118259_; + public ResourceLocation getTextureLocation(ItemEntity p_115034_) { + return TextureAtlas.LOCATION_BLOCKS; } + + /*==================================== FORGE START ===========================================*/ 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 03ab6b99..7d079ed4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -2,44 +2,44 @@ +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java @@ -61,7 +_,7 @@ if (!flag) { - BlockRenderDispatcher blockrenderdispatcher = this.f_115046_.m_91289_(); - ModelManager modelmanager = blockrenderdispatcher.m_110907_().m_110881_(); -- ModelResourceLocation modelresourcelocation = this.m_174212_(p_115076_, itemstack); -+ ModelResourceLocation modelresourcelocation = p_115076_.m_31822_().m_41720_() instanceof MapItem ? f_115045_ : f_115044_; - p_115079_.m_85836_(); - p_115079_.m_85837_(-0.5D, -0.5D, -0.5D); - blockrenderdispatcher.m_110937_().m_111067_(p_115079_.m_85850_(), p_115080_.m_6299_(Sheets.m_110789_()), (BlockState)null, modelmanager.m_119422_(modelresourcelocation), 1.0F, 1.0F, 1.0F, p_115081_, OverlayTexture.f_118083_); + BlockRenderDispatcher blockrenderdispatcher = this.minecraft.getBlockRenderer(); + ModelManager modelmanager = blockrenderdispatcher.getBlockModelShaper().getModelManager(); +- ModelResourceLocation modelresourcelocation = this.getFrameModelResourceLoc(p_115076_, itemstack); ++ ModelResourceLocation modelresourcelocation = p_115076_.getItem().getItem() instanceof MapItem ? MAP_FRAME_LOCATION : FRAME_LOCATION; + p_115079_.pushPose(); + p_115079_.translate(-0.5D, -0.5D, -0.5D); + blockrenderdispatcher.getModelRenderer().renderModel(p_115079_.last(), p_115080_.getBuffer(Sheets.solidBlockSheet()), (BlockState)null, modelmanager.getModel(modelresourcelocation), 1.0F, 1.0F, 1.0F, p_115081_, OverlayTexture.NO_OVERLAY); @@ -69,22 +_,22 @@ } - if (!itemstack.m_41619_()) { -- boolean flag1 = itemstack.m_150930_(Items.f_42573_); -+ MapItemSavedData mapitemsaveddata = MapItem.m_42853_(itemstack, p_115076_.f_19853_); + if (!itemstack.isEmpty()) { +- boolean flag1 = itemstack.is(Items.FILLED_MAP); ++ MapItemSavedData mapitemsaveddata = MapItem.getSavedData(itemstack, p_115076_.level); if (flag) { - p_115079_.m_85837_(0.0D, 0.0D, 0.5D); + p_115079_.translate(0.0D, 0.0D, 0.5D); } else { - p_115079_.m_85837_(0.0D, 0.0D, 0.4375D); + p_115079_.translate(0.0D, 0.0D, 0.4375D); } -- int j = flag1 ? p_115076_.m_31823_() % 4 * 2 : p_115076_.m_31823_(); -+ int j = mapitemsaveddata != null ? p_115076_.m_31823_() % 4 * 2 : p_115076_.m_31823_(); - p_115079_.m_85845_(Vector3f.f_122227_.m_122240_((float)j * 360.0F / 8.0F)); +- int j = flag1 ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); ++ int j = mapitemsaveddata != null ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); + p_115079_.mulPose(Vector3f.ZP.rotationDegrees((float)j * 360.0F / 8.0F)); - if (flag1) { + if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderItemInFrameEvent(p_115076_, this, p_115079_, p_115080_, p_115081_))) { + if (mapitemsaveddata != null) { - p_115079_.m_85845_(Vector3f.f_122227_.m_122240_(180.0F)); + p_115079_.mulPose(Vector3f.ZP.rotationDegrees(180.0F)); float f = 0.0078125F; - p_115079_.m_85841_(0.0078125F, 0.0078125F, 0.0078125F); - p_115079_.m_85837_(-64.0D, -64.0D, 0.0D); - Integer integer = MapItem.m_151131_(itemstack); -- MapItemSavedData mapitemsaveddata = MapItem.m_151128_(integer, p_115076_.f_19853_); - p_115079_.m_85837_(0.0D, 0.0D, -1.0D); + p_115079_.scale(0.0078125F, 0.0078125F, 0.0078125F); + p_115079_.translate(-64.0D, -64.0D, 0.0D); + Integer integer = MapItem.getMapId(itemstack); +- MapItemSavedData mapitemsaveddata = MapItem.getSavedData(integer, p_115076_.level); + p_115079_.translate(0.0D, 0.0D, -1.0D); if (mapitemsaveddata != null) { - int i = this.m_174208_(p_115076_, 15728850, p_115081_); + int i = this.getLightVal(p_115076_, 15728850, p_115081_); @@ -94,6 +_,7 @@ - int k = this.m_174208_(p_115076_, 15728880, p_115081_); - p_115079_.m_85841_(0.5F, 0.5F, 0.5F); - this.f_115047_.m_174269_(itemstack, ItemTransforms.TransformType.FIXED, k, OverlayTexture.f_118083_, p_115079_, p_115080_, p_115076_.m_142049_()); + int k = this.getLightVal(p_115076_, 15728880, p_115081_); + p_115079_.scale(0.5F, 0.5F, 0.5F); + this.itemRenderer.renderStatic(itemstack, ItemTransforms.TransformType.FIXED, k, OverlayTexture.NO_OVERLAY, p_115079_, p_115080_, p_115076_.getId()); + } } } 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 d4728f2f..f1fb21ae 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -3,21 +3,21 @@ @@ -76,8 +_,8 @@ public ItemRenderer(TextureManager p_174225_, ModelManager p_174226_, ItemColors p_174227_, BlockEntityWithoutLevelRenderer p_174228_) { - this.f_115096_ = p_174225_; -- this.f_115095_ = new ItemModelShaper(p_174226_); - this.f_174223_ = p_174228_; -+ this.f_115095_ = new net.minecraftforge.client.ItemModelMesherForge(p_174226_); + this.textureManager = p_174225_; +- this.itemModelShaper = new ItemModelShaper(p_174226_); + this.blockEntityRenderer = p_174228_; ++ this.itemModelShaper = new net.minecraftforge.client.ItemModelMesherForge(p_174226_); - for(Item item : Registry.f_122827_) { - if (!f_115094_.contains(item)) { + for(Item item : Registry.ITEM) { + if (!IGNORED.contains(item)) { @@ -117,7 +_,7 @@ } } -- p_115151_.m_7442_().m_111808_(p_115145_).m_111763_(p_115146_, p_115147_); +- p_115151_.getTransforms().getTransform(p_115145_).apply(p_115146_, p_115147_); + p_115151_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_115147_, p_115151_, p_115145_, p_115146_); - p_115147_.m_85837_(-0.5D, -0.5D, -0.5D); - if (!p_115151_.m_7521_() && (!p_115144_.m_150930_(Items.f_42713_) || flag)) { + p_115147_.translate(-0.5D, -0.5D, -0.5D); + if (!p_115151_.isCustomRenderer() && (!p_115144_.is(Items.TRIDENT) || flag)) { boolean flag1; @@ -127,7 +_,8 @@ } else { @@ -26,44 +26,44 @@ - + if (p_115151_.isLayered()) { net.minecraftforge.client.ForgeHooksClient.drawItemLayered(this, p_115151_, p_115144_, p_115147_, p_115148_, p_115149_, p_115150_, flag1); } + else { - RenderType rendertype = ItemBlockRenderTypes.m_109279_(p_115144_, flag1); + RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_115144_, flag1); VertexConsumer vertexconsumer; - if (p_115144_.m_150930_(Items.f_42522_) && p_115144_.m_41790_()) { + if (p_115144_.is(Items.COMPASS) && p_115144_.hasFoil()) { @@ -153,8 +_,9 @@ } - this.m_115189_(p_115151_, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); + this.renderModelLists(p_115151_, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); + } } else { -- this.f_174223_.m_108829_(p_115144_, p_115145_, p_115147_, p_115148_, p_115149_, p_115150_); -+ net.minecraftforge.client.RenderProperties.get(p_115144_).getItemStackRenderer().m_108829_(p_115144_, p_115145_, p_115147_, p_115148_, p_115149_, p_115150_); +- this.blockEntityRenderer.renderByItem(p_115144_, p_115145_, p_115147_, p_115148_, p_115149_, p_115150_); ++ net.minecraftforge.client.RenderProperties.get(p_115144_).getItemStackRenderer().renderByItem(p_115144_, p_115145_, p_115147_, p_115148_, p_115149_, p_115150_); } - p_115147_.m_85849_(); + p_115147_.popPose(); @@ -198,7 +_,7 @@ float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; -- p_115164_.m_85987_(posestack$pose, bakedquad, f, f1, f2, p_115167_, p_115168_); +- p_115164_.putBulkData(posestack$pose, bakedquad, f, f1, f2, p_115167_, p_115168_); + p_115164_.putBulkData(posestack$pose, bakedquad, f, f1, f2, p_115167_, p_115168_, true); } } @@ -301,6 +_,7 @@ - crashreportcategory.m_128165_("Item Type", () -> { - return String.valueOf((Object)p_174237_.m_41720_()); + crashreportcategory.setDetail("Item Type", () -> { + return String.valueOf((Object)p_174237_.getItem()); }); -+ crashreportcategory.m_128165_("Registry Name", () -> String.valueOf(p_174237_.m_41720_().getRegistryName())); - crashreportcategory.m_128165_("Item Damage", () -> { - return String.valueOf(p_174237_.m_41773_()); ++ crashreportcategory.setDetail("Registry Name", () -> String.valueOf(p_174237_.getItem().getRegistryName())); + crashreportcategory.setDetail("Item Damage", () -> { + return String.valueOf(p_174237_.getDamageValue()); }); @@ -377,5 +_,9 @@ - public void m_6213_(ResourceManager p_115105_) { - this.f_115095_.m_109403_(); + public void onResourceManagerReload(ResourceManager p_115105_) { + this.itemModelShaper.rebuildCache(); + } + + public BlockEntityWithoutLevelRenderer getBlockEntityRenderer() { -+ return f_174223_; ++ return blockEntityRenderer; } } 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 e4acb6ae..99a10e93 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -3,36 +3,36 @@ @@ -49,14 +_,17 @@ } - public void m_7392_(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { + public void render(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_))) return; - p_115311_.m_85836_(); - this.f_115290_.f_102608_ = this.m_115342_(p_115308_, p_115310_); -- this.f_115290_.f_102609_ = p_115308_.m_20159_(); + p_115311_.pushPose(); + this.model.attackTime = this.getAttackAnim(p_115308_, p_115310_); +- this.model.riding = p_115308_.isPassenger(); + -+ boolean shouldSit = p_115308_.m_20159_() && (p_115308_.m_20202_() != null && p_115308_.m_20202_().shouldRiderSit()); -+ this.f_115290_.f_102609_ = shouldSit; - this.f_115290_.f_102610_ = p_115308_.m_6162_(); - float f = Mth.m_14189_(p_115310_, p_115308_.f_20884_, p_115308_.f_20883_); - float f1 = Mth.m_14189_(p_115310_, p_115308_.f_20886_, p_115308_.f_20885_); ++ 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_.m_20159_() && p_115308_.m_20202_() instanceof LivingEntity) { -+ if (shouldSit && p_115308_.m_20202_() instanceof LivingEntity) { - LivingEntity livingentity = (LivingEntity)p_115308_.m_20202_(); - f = Mth.m_14189_(p_115310_, livingentity.f_20884_, livingentity.f_20883_); +- if (p_115308_.isPassenger() && p_115308_.getVehicle() instanceof LivingEntity) { ++ if (shouldSit && p_115308_.getVehicle() instanceof LivingEntity) { + LivingEntity livingentity = (LivingEntity)p_115308_.getVehicle(); + f = Mth.rotLerp(p_115310_, livingentity.yBodyRotO, livingentity.yBodyRot); f2 = f1 - f; @@ -98,7 +_,7 @@ - p_115311_.m_85837_(0.0D, (double)-1.501F, 0.0D); + p_115311_.translate(0.0D, (double)-1.501F, 0.0D); float f8 = 0.0F; float f5 = 0.0F; -- if (!p_115308_.m_20159_() && p_115308_.m_6084_()) { -+ if (!shouldSit && p_115308_.m_6084_()) { - f8 = Mth.m_14179_(p_115310_, p_115308_.f_20923_, p_115308_.f_20924_); - f5 = p_115308_.f_20925_ - p_115308_.f_20924_ * (1.0F - p_115310_); - if (p_115308_.m_6162_()) { +- if (!p_115308_.isPassenger() && p_115308_.isAlive()) { ++ if (!shouldSit && p_115308_.isAlive()) { + f8 = Mth.lerp(p_115310_, p_115308_.animationSpeedOld, p_115308_.animationSpeed); + f5 = p_115308_.animationPosition - p_115308_.animationSpeed * (1.0F - p_115310_); + if (p_115308_.isBaby()) { @@ -131,6 +_,7 @@ - p_115311_.m_85849_(); - super.m_7392_(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); + p_115311_.popPose(); + super.render(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)); } 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 index 887023f7..7aede0b7 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch @@ -2,29 +2,29 @@ +++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java @@ -33,7 +_,7 @@ - public void m_6494_(PoseStack p_116951_, MultiBufferSource p_116952_, int p_116953_, T p_116954_, float p_116955_, float p_116956_, float p_116957_, float p_116958_, float p_116959_, float p_116960_) { - ItemStack itemstack = p_116954_.m_6844_(EquipmentSlot.CHEST); -- if (itemstack.m_150930_(Items.f_42741_)) { + public void render(PoseStack p_116951_, MultiBufferSource p_116952_, int p_116953_, T p_116954_, float p_116955_, float p_116956_, float p_116957_, float p_116958_, float p_116959_, 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 abstractclientplayer = (AbstractClientPlayer)p_116954_; @@ -42,10 +_,10 @@ - } else if (abstractclientplayer.m_108555_() && abstractclientplayer.m_108561_() != null && abstractclientplayer.m_36170_(PlayerModelPart.CAPE)) { - resourcelocation = abstractclientplayer.m_108561_(); + } else if (abstractclientplayer.isCapeLoaded() && abstractclientplayer.getCloakTextureLocation() != null && abstractclientplayer.isModelPartShown(PlayerModelPart.CAPE)) { + resourcelocation = abstractclientplayer.getCloakTextureLocation(); } else { -- resourcelocation = f_116934_; +- resourcelocation = WINGS_LOCATION; + resourcelocation = getElytraTexture(itemstack, p_116954_); } } else { -- resourcelocation = f_116934_; +- resourcelocation = WINGS_LOCATION; + resourcelocation = getElytraTexture(itemstack, p_116954_); } - p_116951_.m_85836_(); + p_116951_.pushPose(); @@ -56,5 +_,30 @@ - this.f_116935_.m_7695_(p_116951_, vertexconsumer, p_116953_, OverlayTexture.f_118083_, 1.0F, 1.0F, 1.0F, 1.0F); - p_116951_.m_85849_(); + this.elytraModel.renderToBuffer(p_116951_, vertexconsumer, p_116953_, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); + p_116951_.popPose(); } + } + @@ -38,7 +38,7 @@ + * @return If the ElytraLayer should render. + */ + public boolean shouldRender(ItemStack stack, T entity) { -+ return stack.m_41720_() == Items.f_42741_; ++ return stack.getItem() == Items.ELYTRA; + } + + /** @@ -50,6 +50,6 @@ + * @return The texture. + */ + public ResourceLocation getElytraTexture(ItemStack stack, T entity) { -+ return f_116934_; ++ return WINGS_LOCATION; } } 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 ab576768..e511a54c 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,25 +1,25 @@ --- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java +++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java @@ -46,17 +_,18 @@ - if (armoritem.m_40402_() == p_117122_) { - this.m_117386_().m_102872_(p_117124_); - this.m_117125_(p_117124_, p_117122_); + if (armoritem.getSlot() == 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.m_117128_(p_117122_); - boolean flag1 = itemstack.m_41790_(); + boolean flag = this.usesInnerModel(p_117122_); + boolean flag1 = itemstack.hasFoil(); - if (armoritem instanceof DyeableArmorItem) { -- int i = ((DyeableArmorItem)armoritem).m_41121_(itemstack); +- int i = ((DyeableArmorItem)armoritem).getColor(itemstack); + if (armoritem instanceof net.minecraft.world.item.DyeableLeatherItem) { -+ int i = ((net.minecraft.world.item.DyeableLeatherItem)armoritem).m_41121_(itemstack); ++ int i = ((net.minecraft.world.item.DyeableLeatherItem)armoritem).getColor(itemstack); float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; -- this.m_117106_(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, f, f1, f2, (String)null); -- this.m_117106_(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, 1.0F, 1.0F, 1.0F, "overlay"); +- this.renderModel(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, f, f1, f2, (String)null); +- this.renderModel(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, 1.0F, 1.0F, 1.0F, "overlay"); + this.renderModel(p_117119_, p_117120_, p_117123_, flag1, model, f, f1, f2, this.getArmorResource(p_117121_, itemstack, p_117122_, null)); + this.renderModel(p_117119_, p_117120_, p_117123_, flag1, model, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_117121_, itemstack, p_117122_, "overlay")); } else { -- this.m_117106_(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, 1.0F, 1.0F, 1.0F, (String)null); +- this.renderModel(p_117119_, p_117120_, p_117123_, armoritem, flag1, p_117124_, flag, 1.0F, 1.0F, 1.0F, (String)null); + this.renderModel(p_117119_, p_117120_, p_117123_, flag1, model, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_117121_, itemstack, p_117122_, null)); } @@ -27,13 +27,13 @@ @@ -88,7 +_,10 @@ } - private void m_117106_(PoseStack p_117107_, MultiBufferSource p_117108_, int p_117109_, ArmorItem p_117110_, boolean p_117111_, A p_117112_, boolean p_117113_, float p_117114_, float p_117115_, float p_117116_, @Nullable String p_117117_) { -- VertexConsumer vertexconsumer = ItemRenderer.m_115184_(p_117108_, RenderType.m_110431_(this.m_117080_(p_117110_, p_117113_, p_117117_)), false, p_117111_); -+ renderModel(p_117107_, p_117108_, p_117109_, p_117111_, p_117112_, p_117114_, p_117115_, p_117116_, this.m_117080_(p_117110_, p_117113_, p_117117_)); + private void renderModel(PoseStack p_117107_, MultiBufferSource p_117108_, int p_117109_, ArmorItem p_117110_, boolean p_117111_, A p_117112_, boolean p_117113_, float p_117114_, float p_117115_, float p_117116_, @Nullable String p_117117_) { +- VertexConsumer vertexconsumer = ItemRenderer.getArmorFoilBuffer(p_117108_, RenderType.armorCutoutNoCull(this.getArmorLocation(p_117110_, p_117113_, p_117117_)), false, p_117111_); ++ renderModel(p_117107_, p_117108_, p_117109_, p_117111_, p_117112_, p_117114_, p_117115_, p_117116_, this.getArmorLocation(p_117110_, p_117113_, p_117117_)); + } + private void renderModel(PoseStack p_117107_, MultiBufferSource p_117108_, int p_117109_, boolean p_117111_, net.minecraft.client.model.Model p_117112_, float p_117114_, float p_117115_, float p_117116_, ResourceLocation armorResource) { -+ VertexConsumer vertexconsumer = ItemRenderer.m_115184_(p_117108_, RenderType.m_110431_(armorResource), false, p_117111_); - p_117112_.m_7695_(p_117107_, vertexconsumer, p_117109_, OverlayTexture.f_118083_, p_117114_, p_117115_, p_117116_, 1.0F); ++ VertexConsumer vertexconsumer = ItemRenderer.getArmorFoilBuffer(p_117108_, RenderType.armorCutoutNoCull(armorResource), false, p_117111_); + p_117112_.renderToBuffer(p_117107_, vertexconsumer, p_117109_, OverlayTexture.NO_OVERLAY, p_117114_, p_117115_, p_117116_, 1.0F); } @@ -100,8 +_,50 @@ @@ -41,9 +41,9 @@ } + @Deprecated //Use the more sensitive version getArmorResource below - private ResourceLocation m_117080_(ArmorItem p_117081_, boolean p_117082_, @Nullable String p_117083_) { - String s = "textures/models/armor/" + p_117081_.m_40401_().m_6082_() + "_layer_" + (p_117082_ ? 2 : 1) + (p_117083_ == null ? "" : "_" + p_117083_) + ".png"; - return f_117070_.computeIfAbsent(s, ResourceLocation::new); + private ResourceLocation getArmorLocation(ArmorItem p_117081_, boolean p_117082_, @Nullable String p_117083_) { + String s = "textures/models/armor/" + p_117081_.getMaterial().getName() + "_layer_" + (p_117082_ ? 2 : 1) + (p_117083_ == null ? "" : "_" + p_117083_) + ".png"; + return ARMOR_LOCATION_CACHE.computeIfAbsent(s, ResourceLocation::new); } + + /*=================================== FORGE START =========================================*/ @@ -65,22 +65,22 @@ + * @return ResourceLocation pointing at the armor's texture + */ + public ResourceLocation getArmorResource(net.minecraft.world.entity.Entity entity, ItemStack stack, EquipmentSlot slot, @Nullable String type) { -+ ArmorItem item = (ArmorItem)stack.m_41720_(); -+ String texture = item.m_40401_().m_6082_(); ++ ArmorItem item = (ArmorItem)stack.getItem(); ++ String texture = item.getMaterial().getName(); + String domain = "minecraft"; + int idx = texture.indexOf(':'); + if (idx != -1) { + domain = texture.substring(0, idx); + texture = texture.substring(idx + 1); + } -+ String s1 = String.format(java.util.Locale.ROOT, "%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (m_117128_(slot) ? 2 : 1), type == null ? "" : String.format(java.util.Locale.ROOT, "_%s", type)); ++ String s1 = String.format(java.util.Locale.ROOT, "%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (usesInnerModel(slot) ? 2 : 1), type == null ? "" : String.format(java.util.Locale.ROOT, "_%s", type)); + + s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type); -+ ResourceLocation resourcelocation = f_117070_.get(s1); ++ ResourceLocation resourcelocation = ARMOR_LOCATION_CACHE.get(s1); + + if (resourcelocation == null) { + resourcelocation = new ResourceLocation(s1); -+ f_117070_.put(s1, resourcelocation); ++ ARMOR_LOCATION_CACHE.put(s1, resourcelocation); + } + + return resourcelocation; 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 18cb8578..b381c516 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 @@ -2,33 +2,33 @@ +++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java @@ -58,7 +_,9 @@ - public void m_7392_(AbstractClientPlayer p_117788_, float p_117789_, float p_117790_, PoseStack p_117791_, MultiBufferSource p_117792_, int p_117793_) { - this.m_117818_(p_117788_); + 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.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_))) return; - super.m_7392_(p_117788_, p_117789_, p_117790_, p_117791_, p_117792_, p_117793_); + super.render(p_117788_, p_117789_, p_117790_, p_117791_, p_117792_, p_117793_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)); } - public Vec3 m_7860_(AbstractClientPlayer p_117785_, float p_117786_) { + public Vec3 getRenderOffset(AbstractClientPlayer p_117785_, float p_117786_) { @@ -123,7 +_,7 @@ if (useanim == UseAnim.SPYGLASS) { return HumanoidModel.ArmPose.SPYGLASS; } -- } else if (!p_117795_.f_20911_ && itemstack.m_150930_(Items.f_42717_) && CrossbowItem.m_40932_(itemstack)) { -+ } else if (!p_117795_.f_20911_ && itemstack.m_41720_() instanceof CrossbowItem && CrossbowItem.m_40932_(itemstack)) { +- } else if (!p_117795_.swinging && itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack)) { ++ } else if (!p_117795_.swinging && itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack)) { return HumanoidModel.ArmPose.CROSSBOW_HOLD; } @@ -158,10 +_,12 @@ } - public void m_117770_(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, AbstractClientPlayer p_117774_) { + public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, AbstractClientPlayer p_117774_) { + if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonArm(p_117771_, p_117772_, p_117773_, p_117774_, HumanoidArm.RIGHT)) - this.m_117775_(p_117771_, p_117772_, p_117773_, p_117774_, (this.f_115290_).f_102811_, (this.f_115290_).f_103375_); + this.renderHand(p_117771_, p_117772_, p_117773_, p_117774_, (this.model).rightArm, (this.model).rightSleeve); } - public void m_117813_(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, AbstractClientPlayer p_117817_) { + public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, AbstractClientPlayer p_117817_) { + if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonArm(p_117814_, p_117815_, p_117816_, p_117817_, HumanoidArm.LEFT)) - this.m_117775_(p_117814_, p_117815_, p_117816_, p_117817_, (this.f_115290_).f_102812_, (this.f_115290_).f_103374_); + this.renderHand(p_117814_, p_117815_, p_117816_, p_117817_, (this.model).leftArm, (this.model).leftSleeve); } diff --git a/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch b/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch index d84c628a..67b21eb5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/item/ItemProperties.java.patch @@ -2,114 +2,19 @@ +++ b/net/minecraft/client/renderer/item/ItemProperties.java @@ -47,7 +_,7 @@ }; - private static final Map> f_117825_ = Maps.newHashMap(); + private static final Map> PROPERTIES = Maps.newHashMap(); -- private static ClampedItemPropertyFunction m_174581_(ResourceLocation p_174582_, ClampedItemPropertyFunction p_174583_) { +- private static ClampedItemPropertyFunction registerGeneric(ResourceLocation p_174582_, ClampedItemPropertyFunction p_174583_) { + public static ItemPropertyFunction registerGeneric(ResourceLocation p_174582_, ItemPropertyFunction p_174583_) { - f_117820_.put(p_174582_, p_174583_); + GENERIC_PROPERTIES.put(p_174582_, p_174583_); return p_174583_; } @@ -56,7 +_,7 @@ - f_117820_.put(new ResourceLocation("custom_model_data"), p_174580_); + GENERIC_PROPERTIES.put(new ResourceLocation("custom_model_data"), p_174580_); } -- private static void m_174570_(Item p_174571_, ResourceLocation p_174572_, ClampedItemPropertyFunction p_174573_) { +- private static void register(Item p_174571_, ResourceLocation p_174572_, ClampedItemPropertyFunction p_174573_) { + public static void register(Item p_174571_, ResourceLocation p_174572_, ItemPropertyFunction p_174573_) { - f_117825_.computeIfAbsent(p_174571_, (p_117828_) -> { + PROPERTIES.computeIfAbsent(p_174571_, (p_117828_) -> { return Maps.newHashMap(); }).put(p_174572_, p_174573_); -@@ -84,29 +_,29 @@ - } - - static { -- m_174581_(new ResourceLocation("lefthanded"), (p_174650_, p_174651_, p_174652_, p_174653_) -> { -+ registerGeneric(new ResourceLocation("lefthanded"), (p_174650_, p_174651_, p_174652_, p_174653_) -> { - return p_174652_ != null && p_174652_.m_5737_() != HumanoidArm.RIGHT ? 1.0F : 0.0F; - }); -- m_174581_(new ResourceLocation("cooldown"), (p_174645_, p_174646_, p_174647_, p_174648_) -> { -+ registerGeneric(new ResourceLocation("cooldown"), (p_174645_, p_174646_, p_174647_, p_174648_) -> { - return p_174647_ instanceof Player ? ((Player)p_174647_).m_36335_().m_41521_(p_174645_.m_41720_(), 0.0F) : 0.0F; - }); - m_174579_((p_174640_, p_174641_, p_174642_, p_174643_) -> { - return p_174640_.m_41782_() ? (float)p_174640_.m_41783_().m_128451_("CustomModelData") : 0.0F; - }); -- m_174570_(Items.f_42411_, new ResourceLocation("pull"), (p_174635_, p_174636_, p_174637_, p_174638_) -> { -+ register(Items.f_42411_, new ResourceLocation("pull"), (p_174635_, p_174636_, p_174637_, p_174638_) -> { - if (p_174637_ == null) { - return 0.0F; - } else { - return p_174637_.m_21211_() != p_174635_ ? 0.0F : (float)(p_174635_.m_41779_() - p_174637_.m_21212_()) / 20.0F; - } - }); -- m_174570_(Items.f_42411_, new ResourceLocation("pulling"), (p_174630_, p_174631_, p_174632_, p_174633_) -> { -+ register(Items.f_42411_, new ResourceLocation("pulling"), (p_174630_, p_174631_, p_174632_, p_174633_) -> { - return p_174632_ != null && p_174632_.m_6117_() && p_174632_.m_21211_() == p_174630_ ? 1.0F : 0.0F; - }); -- m_174570_(Items.f_151058_, new ResourceLocation("filled"), (p_174625_, p_174626_, p_174627_, p_174628_) -> { -+ register(Items.f_151058_, new ResourceLocation("filled"), (p_174625_, p_174626_, p_174627_, p_174628_) -> { - return BundleItem.m_150766_(p_174625_); - }); -- m_174570_(Items.f_42524_, new ResourceLocation("time"), new ClampedItemPropertyFunction() { -+ register(Items.f_42524_, new ResourceLocation("time"), new ClampedItemPropertyFunction() { - private double f_117899_; - private double f_117900_; - private long f_117901_; -@@ -149,7 +_,7 @@ - return this.f_117899_; - } - }); -- m_174570_(Items.f_42522_, new ResourceLocation("angle"), new ClampedItemPropertyFunction() { -+ register(Items.f_42522_, new ResourceLocation("angle"), new ClampedItemPropertyFunction() { - private final ItemProperties.CompassWobble f_117910_ = new ItemProperties.CompassWobble(); - private final ItemProperties.CompassWobble f_117911_ = new ItemProperties.CompassWobble(); - -@@ -235,26 +_,26 @@ - return Math.atan2(p_117919_.m_7094_() - p_117920_.m_20189_(), p_117919_.m_7096_() - p_117920_.m_20185_()); - } - }); -- m_174570_(Items.f_42717_, new ResourceLocation("pull"), (p_174620_, p_174621_, p_174622_, p_174623_) -> { -+ register(Items.f_42717_, new ResourceLocation("pull"), (p_174620_, p_174621_, p_174622_, p_174623_) -> { - if (p_174622_ == null) { - return 0.0F; - } else { - return CrossbowItem.m_40932_(p_174620_) ? 0.0F : (float)(p_174620_.m_41779_() - p_174622_.m_21212_()) / (float)CrossbowItem.m_40939_(p_174620_); - } - }); -- m_174570_(Items.f_42717_, new ResourceLocation("pulling"), (p_174615_, p_174616_, p_174617_, p_174618_) -> { -+ register(Items.f_42717_, new ResourceLocation("pulling"), (p_174615_, p_174616_, p_174617_, p_174618_) -> { - return p_174617_ != null && p_174617_.m_6117_() && p_174617_.m_21211_() == p_174615_ && !CrossbowItem.m_40932_(p_174615_) ? 1.0F : 0.0F; - }); -- m_174570_(Items.f_42717_, new ResourceLocation("charged"), (p_174610_, p_174611_, p_174612_, p_174613_) -> { -+ register(Items.f_42717_, new ResourceLocation("charged"), (p_174610_, p_174611_, p_174612_, p_174613_) -> { - return p_174612_ != null && CrossbowItem.m_40932_(p_174610_) ? 1.0F : 0.0F; - }); -- m_174570_(Items.f_42717_, new ResourceLocation("firework"), (p_174605_, p_174606_, p_174607_, p_174608_) -> { -+ register(Items.f_42717_, new ResourceLocation("firework"), (p_174605_, p_174606_, p_174607_, p_174608_) -> { - return p_174607_ != null && CrossbowItem.m_40932_(p_174605_) && CrossbowItem.m_40871_(p_174605_, Items.f_42688_) ? 1.0F : 0.0F; - }); -- m_174570_(Items.f_42741_, new ResourceLocation("broken"), (p_174600_, p_174601_, p_174602_, p_174603_) -> { -+ register(Items.f_42741_, new ResourceLocation("broken"), (p_174600_, p_174601_, p_174602_, p_174603_) -> { - return ElytraItem.m_41140_(p_174600_) ? 0.0F : 1.0F; - }); -- m_174570_(Items.f_42523_, new ResourceLocation("cast"), (p_174595_, p_174596_, p_174597_, p_174598_) -> { -+ register(Items.f_42523_, new ResourceLocation("cast"), (p_174595_, p_174596_, p_174597_, p_174598_) -> { - if (p_174597_ == null) { - return 0.0F; - } else { -@@ -267,13 +_,13 @@ - return (flag || flag1) && p_174597_ instanceof Player && ((Player)p_174597_).f_36083_ != null ? 1.0F : 0.0F; - } - }); -- m_174570_(Items.f_42740_, new ResourceLocation("blocking"), (p_174590_, p_174591_, p_174592_, p_174593_) -> { -+ register(Items.f_42740_, new ResourceLocation("blocking"), (p_174590_, p_174591_, p_174592_, p_174593_) -> { - return p_174592_ != null && p_174592_.m_6117_() && p_174592_.m_21211_() == p_174590_ ? 1.0F : 0.0F; - }); -- m_174570_(Items.f_42713_, new ResourceLocation("throwing"), (p_174585_, p_174586_, p_174587_, p_174588_) -> { -+ register(Items.f_42713_, new ResourceLocation("throwing"), (p_174585_, p_174586_, p_174587_, p_174588_) -> { - return p_174587_ != null && p_174587_.m_6117_() && p_174587_.m_21211_() == p_174585_ ? 1.0F : 0.0F; - }); -- m_174570_(Items.f_151033_, new ResourceLocation("level"), (p_174575_, p_174576_, p_174577_, p_174578_) -> { -+ register(Items.f_151033_, new ResourceLocation("level"), (p_174575_, p_174576_, p_174577_, p_174578_) -> { - CompoundTag compoundtag = p_174575_.m_41737_("BlockStateTag"); - - try { 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 8f67c13f..1ed17f18 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/texture/AbstractTexture.java +++ b/net/minecraft/client/renderer/texture/AbstractTexture.java @@ -36,6 +_,20 @@ - GlStateManager.m_84331_(3553, 10240, j); + GlStateManager._texParameter(3553, 10240, j); } + // FORGE: This seems to have been stripped out, but we need it @@ -9,15 +9,15 @@ + private boolean lastMipmap; + + public void setBlurMipmap(boolean blur, boolean mipmap) { -+ this.lastBlur = this.f_117951_; -+ this.lastMipmap = this.f_117952_; -+ m_117960_(blur, mipmap); ++ this.lastBlur = this.blur; ++ this.lastMipmap = this.mipmap; ++ setFilter(blur, mipmap); + } + + public void restoreLastBlurMipmap() { -+ m_117960_(this.lastBlur, this.lastMipmap); ++ setFilter(this.lastBlur, this.lastMipmap); + } + - public int m_117963_() { - RenderSystem.m_187555_(); - if (this.f_117950_ == -1) { + public int getId() { + RenderSystem.assertOnRenderThreadOrInit(); + if (this.id == -1) { 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 76739e70..0f9b5ea0 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch @@ -4,24 +4,24 @@ } } -+ int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(p_118055_.m_84982_(), p_118055_.m_85084_()); ++ int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(p_118055_.getWidth(), p_118055_.getHeight()); for(int k1 = 1; k1 <= p_118056_; ++k1) { NativeImage nativeimage1 = anativeimage[k1 - 1]; -- NativeImage nativeimage = new NativeImage(nativeimage1.m_84982_() >> 1, nativeimage1.m_85084_() >> 1, false); -- int k = nativeimage.m_84982_(); -- int l = nativeimage.m_85084_(); +- NativeImage nativeimage = new NativeImage(nativeimage1.getWidth() >> 1, nativeimage1.getHeight() >> 1, false); +- int k = nativeimage.getWidth(); +- int l = nativeimage.getHeight(); + // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ NativeImage nativeimage = new NativeImage(Math.max(1, nativeimage1.m_84982_() >> 1), Math.max(1, nativeimage1.m_85084_() >> 1), false); ++ NativeImage nativeimage = new NativeImage(Math.max(1, nativeimage1.getWidth() >> 1), Math.max(1, nativeimage1.getHeight() >> 1), false); + if (k1 <= maxMipmapLevel) { -+ int k = nativeimage.m_84982_(); -+ int l = nativeimage.m_85084_(); ++ int k = nativeimage.getWidth(); ++ int l = nativeimage.getHeight(); - for(int i1 = 0; i1 < k; ++i1) { - for(int j1 = 0; j1 < l; ++j1) { -- nativeimage.m_84988_(i1, j1, m_118048_(nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 1), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 1), flag)); +- nativeimage.setPixelRGBA(i1, j1, alphaBlend(nativeimage1.getPixelRGBA(i1 * 2 + 0, j1 * 2 + 0), nativeimage1.getPixelRGBA(i1 * 2 + 1, j1 * 2 + 0), nativeimage1.getPixelRGBA(i1 * 2 + 0, j1 * 2 + 1), nativeimage1.getPixelRGBA(i1 * 2 + 1, j1 * 2 + 1), flag)); + for (int i1 = 0; i1 < k; ++i1) { + for (int j1 = 0; j1 < l; ++j1) { -+ nativeimage.m_84988_(i1, j1, m_118048_(nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 1), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 1), flag)); ++ nativeimage.setPixelRGBA(i1, j1, alphaBlend(nativeimage1.getPixelRGBA(i1 * 2 + 0, j1 * 2 + 0), nativeimage1.getPixelRGBA(i1 * 2 + 1, j1 * 2 + 0), nativeimage1.getPixelRGBA(i1 * 2 + 0, j1 * 2 + 1), nativeimage1.getPixelRGBA(i1 * 2 + 1, j1 * 2 + 1), flag)); + } } } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch index 39a9c409..ac643637 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch @@ -6,21 +6,21 @@ public class Stitcher { + private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); + - private static final Comparator f_118161_ = Comparator.comparing((p_118201_) -> { - return -p_118201_.f_118204_; + private static final Comparator HOLDER_COMPARATOR = Comparator.comparing((p_118201_) -> { + return -p_118201_.height; }).thenComparing((p_118199_) -> { @@ -53,6 +_,12 @@ for(Stitcher.Holder stitcher$holder : list) { - if (!this.m_118178_(stitcher$holder)) { + if (!this.addToStorage(stitcher$holder)) { + LOGGER.info(new net.minecraftforge.fml.loading.AdvancedLogMessageAdapter(sb->{ -+ sb.append("Unable to fit: ").append(stitcher$holder.f_118202_.m_118431_()); -+ sb.append(" - size: ").append(stitcher$holder.f_118202_.m_118434_()).append("x").append(stitcher$holder.f_118202_.m_118437_()); ++ sb.append("Unable to fit: ").append(stitcher$holder.spriteInfo.name()); ++ sb.append(" - size: ").append(stitcher$holder.spriteInfo.width()).append("x").append(stitcher$holder.spriteInfo.height()); + sb.append(" - Maybe try a lower resolution resourcepack?\n"); + list.forEach(h-> sb.append("\t").append(h).append("\n")); + })); - throw new StitcherException(stitcher$holder.f_118202_, list.stream().map((p_118195_) -> { - return p_118195_.f_118202_; + throw new StitcherException(stitcher$holder.spriteInfo, list.stream().map((p_118195_) -> { + return p_118195_.spriteInfo; }).collect(ImmutableList.toImmutableList())); @@ -102,7 +_,7 @@ boolean flag4 = flag2 && j != l; @@ -35,8 +35,8 @@ } public String toString() { -- return "Holder{width=" + this.f_118203_ + ", height=" + this.f_118204_ + "}"; -+ return "Holder{width=" + this.f_118203_ + ", height=" + this.f_118204_ + ", name=" + this.f_118202_.m_118431_() + '}'; +- return "Holder{width=" + this.width + ", height=" + this.height + "}"; ++ return "Holder{width=" + this.width + ", height=" + this.height + ", name=" + this.spriteInfo.name() + '}'; } } 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 1ccc48f3..8e737d1a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -7,29 +7,29 @@ + net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); } - public TextureAtlas.Preparations m_118307_(ResourceManager p_118308_, Stream p_118309_, ProfilerFiller p_118310_, int p_118311_) { + public TextureAtlas.Preparations prepareToStitch(ResourceManager p_118308_, Stream p_118309_, ProfilerFiller p_118310_, int p_118311_) { @@ -99,6 +_,7 @@ int j = Integer.MAX_VALUE; int k = 1 << p_118311_; - p_118310_.m_6182_("extracting_frames"); + p_118310_.popPush("extracting_frames"); + net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPre(this, set); - for(TextureAtlasSprite.Info textureatlassprite$info : this.m_118304_(p_118308_, set)) { - j = Math.min(j, Math.min(textureatlassprite$info.m_118434_(), textureatlassprite$info.m_118437_())); + for(TextureAtlasSprite.Info textureatlassprite$info : this.getBasicSpriteInfos(p_118308_, set)) { + j = Math.min(j, Math.min(textureatlassprite$info.width(), textureatlassprite$info.height())); @@ -113,7 +_,8 @@ int i1 = Math.min(j, k); - int j1 = Mth.m_14173_(i1); + int j1 = Mth.log2(i1); - int k1; + int k1 = p_118311_; + if (false) // FORGE: do not lower the mipmap level if (j1 < p_118311_) { - f_118261_.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.f_118265_, p_118311_, j1, i1); + LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_118311_, j1, i1); k1 = j1; @@ -229,6 +_,8 @@ TextureAtlasSprite textureatlassprite; try { - NativeImage nativeimage = NativeImage.m_85058_(resource.m_6679_()); + NativeImage nativeimage = NativeImage.read(resource.getInputStream()); + textureatlassprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this, p_118288_, p_118289_, resource, p_118290_, p_118291_, p_118293_, p_118294_, p_118292_, nativeimage); + if (textureatlassprite == null) textureatlassprite = new TextureAtlasSprite(this, p_118289_, p_118292_, p_118290_, p_118291_, p_118293_, p_118294_, nativeimage); 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 a4d048c5..82bff624 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -2,26 +2,26 @@ +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java @@ -145,6 +_,7 @@ - void m_118375_(int p_118376_, int p_118377_, NativeImage[] p_118378_) { - for(int i = 0; i < this.f_118342_.length; ++i) { -+ if ((this.f_174723_ >> i <= 0) || (this.f_174724_ >> i <= 0)) break; - p_118378_[i].m_85003_(i, this.f_118349_ >> i, this.f_118350_ >> i, p_118376_ >> i, p_118377_ >> i, this.f_174723_ >> i, this.f_174724_ >> i, this.f_118342_.length > 1, false); + void upload(int p_118376_, int p_118377_, NativeImage[] p_118378_) { + for(int i = 0; i < this.mainImage.length; ++i) { ++ if ((this.width >> i <= 0) || (this.height >> i <= 0)) break; + p_118378_[i].upload(i, this.x >> i, this.y >> i, p_118376_ >> i, p_118377_ >> i, this.width >> i, this.height >> i, this.mainImage.length > 1, false); } @@ -389,7 +_,8 @@ - int j = p_118446_.f_118423_ >> i; - int k = p_118446_.f_118424_ >> i; - if (this.f_118443_[i] == null) { -- this.f_118443_[i] = new NativeImage(j, k, false); + int j = p_118446_.width >> i; + int k = p_118446_.height >> i; + if (this.activeFrame[i] == null) { +- this.activeFrame[i] = new NativeImage(j, k, false); + // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ this.f_118443_[i] = new NativeImage(Math.max(1, j), Math.max(1, k), false); ++ this.activeFrame[i] = new NativeImage(Math.max(1, j), Math.max(1, k), false); } } @@ -404,6 +_,8 @@ - for(int k = 0; k < this.f_118443_.length; ++k) { - int l = TextureAtlasSprite.this.f_174723_ >> k; - int i1 = TextureAtlasSprite.this.f_174724_ >> k; + for(int k = 0; k < this.activeFrame.length; ++k) { + int l = TextureAtlasSprite.this.width >> k; + int i1 = TextureAtlasSprite.this.height >> k; + // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes + if (l == 0 || i1 == 0) continue; @@ -35,11 +35,11 @@ + + // Forge Start + public int getPixelRGBA(int frameIndex, int x, int y) { -+ if (this.f_174725_ != null) { -+ x += this.f_174725_.m_174759_(frameIndex) * this.f_174723_; -+ y += this.f_174725_.m_174764_(frameIndex) * this.f_174724_; ++ if (this.animatedTexture != null) { ++ x += this.animatedTexture.getFrameX(frameIndex) * this.width; ++ y += this.animatedTexture.getFrameY(frameIndex) * this.height; + } + -+ return this.f_118342_[0].m_84985_(x, y); ++ return this.mainImage[0].getPixelRGBA(x, y); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch index a46ecc88..73d96b1b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/renderer/texture/TextureManager.java +++ b/net/minecraft/client/renderer/texture/TextureManager.java @@ -167,6 +_,7 @@ - public void m_118513_(ResourceLocation p_118514_) { - AbstractTexture abstracttexture = this.m_174786_(p_118514_, MissingTextureAtlasSprite.m_118080_()); - if (abstracttexture != MissingTextureAtlasSprite.m_118080_()) { -+ this.f_118468_.remove(p_118514_); // Forge: fix MC-98707 - TextureUtil.m_85281_(abstracttexture.m_117963_()); + public void release(ResourceLocation p_118514_) { + AbstractTexture abstracttexture = this.getTexture(p_118514_, MissingTextureAtlasSprite.getTexture()); + if (abstracttexture != MissingTextureAtlasSprite.getTexture()) { ++ this.byPath.remove(p_118514_); // Forge: fix MC-98707 + TextureUtil.releaseTextureId(abstracttexture.getId()); } 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 09faaacf..7a95ed3d 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/client/resources/language/ClientLanguage.java +++ b/net/minecraft/client/resources/language/ClientLanguage.java @@ -95,4 +_,9 @@ - public FormattedCharSequence m_5536_(FormattedText p_118925_) { - return FormattedBidiReorder.m_118931_(p_118925_, this.f_118911_); + public FormattedCharSequence getVisualOrder(FormattedText p_118925_) { + return FormattedBidiReorder.reorder(p_118925_, this.defaultRightToLeft); } + + @Override + public Map getLanguageData() { -+ return f_118910_; ++ return storage; + } } diff --git a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch index a9dc2375..8e809944 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/client/resources/language/I18n.java @@ -14,6 +_,7 @@ - static void m_118941_(Language p_118942_) { - f_118934_ = p_118942_; + static void setLanguage(Language p_118942_) { + language = p_118942_; + net.minecraftforge.common.ForgeI18n.loadLanguageData(p_118942_.getLanguageData()); } - public static String m_118938_(String p_118939_, Object... p_118940_) { + public static String get(String p_118939_, Object... p_118940_) { diff --git a/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch b/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch index a3ad6705..5bc2549c 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/LanguageInfo.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/client/resources/language/LanguageInfo.java +++ b/net/minecraft/client/resources/language/LanguageInfo.java @@ -16,6 +_,12 @@ - this.f_118944_ = p_118949_; - this.f_118945_ = p_118950_; - this.f_118946_ = p_118951_; -+ String[] splitLangCode = f_118943_.split("_", 2); + this.region = p_118949_; + this.name = p_118950_; + this.bidirectional = p_118951_; ++ String[] splitLangCode = code.split("_", 2); + if (splitLangCode.length == 1) { // Vanilla has some languages without underscores -+ this.javaLocale = new java.util.Locale(f_118943_); ++ this.javaLocale = new java.util.Locale(code); + } else { + this.javaLocale = new java.util.Locale(splitLangCode[0], splitLangCode[1]); + } @@ -15,7 +15,7 @@ public String getCode() { @@ -53,4 +_,8 @@ public int compareTo(LanguageInfo p_118954_) { - return this.f_118943_.compareTo(p_118954_.f_118943_); + return this.code.compareTo(p_118954_.code); } + + // Forge: add access to Locale so modders can create correct string and number formatters 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 f70f6d8e..cd1bfeca 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch @@ -8,21 +8,21 @@ +public interface BakedModel extends net.minecraftforge.client.extensions.IForgeBakedModel { + /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getQuads(BlockState, Direction, Random, net.minecraftforge.client.model.data.IModelData)}*/ + @Deprecated - List m_6840_(@Nullable BlockState p_119123_, @Nullable Direction p_119124_, Random p_119125_); + List getQuads(@Nullable BlockState p_119123_, @Nullable Direction p_119124_, Random p_119125_); - boolean m_7541_(); + boolean useAmbientOcclusion(); @@ -24,9 +_,13 @@ - boolean m_7521_(); + boolean isCustomRenderer(); + /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getParticleIcon(net.minecraftforge.client.model.data.IModelData)}*/ + @Deprecated - TextureAtlasSprite m_6160_(); + TextureAtlasSprite getParticleIcon(); -- ItemTransforms m_7442_(); +- ItemTransforms getTransforms(); + /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective(ItemTransforms.TransformType, com.mojang.blaze3d.vertex.PoseStack)} instead */ + @Deprecated -+ default ItemTransforms m_7442_() { return ItemTransforms.f_111786_; } ++ default ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; } - ItemOverrides m_7343_(); + ItemOverrides getOverrides(); } 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 a934ddc7..cc331aa2 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -9,84 +9,84 @@ + } + + protected ModelBakery(ResourceManager p_119247_, BlockColors p_119248_, boolean vanillaBakery) { - this.f_119243_ = p_119247_; - this.f_119209_ = p_119248_; + this.resourceManager = p_119247_; + this.blockColors = p_119248_; + } + + protected void processLoading(ProfilerFiller p_119249_, int p_119250_) { + net.minecraftforge.client.model.ModelLoaderRegistry.onModelLoadingStart(); - p_119249_.m_6180_("missing_model"); + p_119249_.push("missing_model"); try { @@ -190,12 +_,16 @@ - p_119249_.m_6182_("special"); - this.m_119306_(new ModelResourceLocation("minecraft:trident_in_hand#inventory")); - this.m_119306_(new ModelResourceLocation("minecraft:spyglass_in_hand#inventory")); + p_119249_.popPush("special"); + this.loadTopLevel(new ModelResourceLocation("minecraft:trident_in_hand#inventory")); + this.loadTopLevel(new ModelResourceLocation("minecraft:spyglass_in_hand#inventory")); + for (ResourceLocation rl : getSpecialModels()) { + addModelToCache(rl); + } - p_119249_.m_6182_("textures"); + p_119249_.popPush("textures"); Set> set = Sets.newLinkedHashSet(); - Set set1 = this.f_119214_.values().stream().flatMap((p_119340_) -> { - return p_119340_.m_5500_(this::m_119341_, set).stream(); + Set set1 = this.topLevelModels.values().stream().flatMap((p_119340_) -> { + return p_119340_.getMaterials(this::getModel, set).stream(); }).collect(Collectors.toSet()); - set1.addAll(f_119234_); + set1.addAll(UNREFERENCED_TEXTURES); + net.minecraftforge.client.ForgeHooksClient.gatherFluidTextures(set1); set.stream().filter((p_119357_) -> { - return !p_119357_.getSecond().equals(f_119236_); + return !p_119357_.getSecond().equals(MISSING_MODEL_LOCATION_STRING); }).forEach((p_119292_) -> { @@ -234,6 +_,7 @@ try { - bakedmodel = this.m_119349_(p_119369_, BlockModelRotation.X0_Y0); + bakedmodel = this.bake(p_119369_, BlockModelRotation.X0_Y0); } catch (Exception exception) { + exception.printStackTrace(); - f_119235_.warn("Unable to bake model: '{}': {}", p_119369_, exception); + LOGGER.warn("Unable to bake model: '{}': {}", p_119369_, exception); } @@ -473,6 +_,13 @@ - this.f_119210_.addAll(p_119354_.m_7970_()); + this.loadingStack.addAll(p_119354_.getDependencies()); } + // Same as loadTopLevel but without restricting to MRL's + private void addModelToCache(ResourceLocation p_217843_1_) { -+ UnbakedModel unbakedmodel = this.m_119341_(p_217843_1_); -+ this.f_119212_.put(p_217843_1_, unbakedmodel); -+ this.f_119214_.put(p_217843_1_, unbakedmodel); ++ UnbakedModel unbakedmodel = this.getModel(p_217843_1_); ++ this.unbakedCache.put(p_217843_1_, unbakedmodel); ++ this.topLevelModels.put(p_217843_1_, unbakedmodel); + } + - private void m_119306_(ModelResourceLocation p_119307_) { - UnbakedModel unbakedmodel = this.m_119341_(p_119307_); - this.f_119212_.put(p_119307_, unbakedmodel); + private void loadTopLevel(ModelResourceLocation p_119307_) { + UnbakedModel unbakedmodel = this.getModel(p_119307_); + this.unbakedCache.put(p_119307_, unbakedmodel); @@ -487,7 +_,13 @@ } @Nullable + @Deprecated - public BakedModel m_119349_(ResourceLocation p_119350_, ModelState p_119351_) { -+ return bake(p_119350_, p_119351_, this.f_119244_::m_117971_); + public BakedModel bake(ResourceLocation p_119350_, ModelState p_119351_) { ++ return bake(p_119350_, p_119351_, this.atlasSet::getSprite); + } + + @Nullable + public BakedModel bake(ResourceLocation p_119350_, ModelState p_119351_, java.util.function.Function sprites) { - Triple triple = Triple.of(p_119350_, p_119351_.m_6189_(), p_119351_.m_7538_()); - if (this.f_119213_.containsKey(triple)) { - return this.f_119213_.get(triple); + Triple triple = Triple.of(p_119350_, p_119351_.getRotation(), p_119351_.isUvLocked()); + if (this.bakedCache.containsKey(triple)) { + return this.bakedCache.get(triple); @@ -498,11 +_,11 @@ if (unbakedmodel instanceof BlockModel) { BlockModel blockmodel = (BlockModel)unbakedmodel; - if (blockmodel.m_111490_() == f_119232_) { -- return f_119241_.m_111670_(this.f_119244_::m_117971_, blockmodel).m_111449_(this, blockmodel, this.f_119244_::m_117971_, p_119351_, p_119350_, false); -+ return f_119241_.m_111670_(sprites, blockmodel).m_111449_(this, blockmodel, this.f_119244_::m_117971_, p_119351_, p_119350_, false); + if (blockmodel.getRootModel() == GENERATION_MARKER) { +- return ITEM_MODEL_GENERATOR.generateBlockModel(this.atlasSet::getSprite, blockmodel).bake(this, blockmodel, this.atlasSet::getSprite, p_119351_, p_119350_, false); ++ return ITEM_MODEL_GENERATOR.generateBlockModel(sprites, blockmodel).bake(this, blockmodel, this.atlasSet::getSprite, p_119351_, p_119350_, false); } } -- BakedModel bakedmodel = unbakedmodel.m_7611_(this, this.f_119244_::m_117971_, p_119351_, p_119350_); -+ BakedModel bakedmodel = unbakedmodel.m_7611_(this, sprites, p_119351_, p_119350_); - this.f_119213_.put(triple, bakedmodel); +- BakedModel bakedmodel = unbakedmodel.bake(this, this.atlasSet::getSprite, p_119351_, p_119350_); ++ BakedModel bakedmodel = unbakedmodel.bake(this, sprites, p_119351_, p_119350_); + this.bakedCache.put(triple, bakedmodel); return bakedmodel; } @@ -555,11 +_,19 @@ - return this.f_119218_; + return this.modelGroups; } + public Set getSpecialModels() { @@ -101,7 +101,7 @@ + } + + public AtlasSet getSpriteMap() { -+ return this.f_119244_; ++ return this.atlasSet; } @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch index a20d4348..284c915d 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -4,44 +4,44 @@ @OnlyIn(Dist.CLIENT) public class ModelManager extends SimplePreparableReloadListener implements AutoCloseable { -- private Map f_119397_; -+ private Map f_119397_ = new java.util.HashMap<>(); +- private Map bakedRegistry; ++ private Map bakedRegistry = new java.util.HashMap<>(); @Nullable - private AtlasSet f_119398_; - private final BlockModelShaper f_119399_; + private AtlasSet atlases; + private final BlockModelShaper blockModelShaper; @@ -36,6 +_,10 @@ - this.f_119399_ = new BlockModelShaper(this); + this.blockModelShaper = new BlockModelShaper(this); } + public BakedModel getModel(ResourceLocation modelLocation) { -+ return this.f_119397_.getOrDefault(modelLocation, this.f_119403_); ++ return this.bakedRegistry.getOrDefault(modelLocation, this.missingModel); + } + - public BakedModel m_119422_(ModelResourceLocation p_119423_) { - return this.f_119397_.getOrDefault(p_119423_, this.f_119403_); + public BakedModel getModel(ModelResourceLocation p_119423_) { + return this.bakedRegistry.getOrDefault(p_119423_, this.missingModel); } @@ -50,7 +_,7 @@ - protected ModelBakery m_5944_(ResourceManager p_119413_, ProfilerFiller p_119414_) { - p_119414_.m_7242_(); -- ModelBakery modelbakery = new ModelBakery(p_119413_, this.f_119401_, p_119414_, this.f_119402_); -+ net.minecraftforge.client.model.ForgeModelBakery modelbakery = new net.minecraftforge.client.model.ForgeModelBakery(p_119413_, this.f_119401_, p_119414_, this.f_119402_); - p_119414_.m_7241_(); + protected ModelBakery prepare(ResourceManager p_119413_, ProfilerFiller p_119414_) { + p_119414_.startTick(); +- ModelBakery modelbakery = new ModelBakery(p_119413_, this.blockColors, p_119414_, this.maxMipmapLevels); ++ net.minecraftforge.client.model.ForgeModelBakery modelbakery = new net.minecraftforge.client.model.ForgeModelBakery(p_119413_, this.blockColors, p_119414_, this.maxMipmapLevels); + p_119414_.endTick(); return modelbakery; } @@ -66,6 +_,7 @@ - this.f_119397_ = p_119419_.m_119251_(); - this.f_119404_ = p_119419_.m_119355_(); - this.f_119403_ = this.f_119397_.get(ModelBakery.f_119230_); -+ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.f_119397_, (net.minecraftforge.client.model.ForgeModelBakery) p_119419_); - p_119421_.m_6182_("cache"); - this.f_119399_.m_110892_(); - p_119421_.m_7238_(); + this.bakedRegistry = p_119419_.getBakedTopLevelModels(); + this.modelGroups = p_119419_.getModelGroups(); + this.missingModel = this.bakedRegistry.get(ModelBakery.MISSING_MODEL_LOCATION); ++ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.bakedRegistry, (net.minecraftforge.client.model.ForgeModelBakery) p_119419_); + p_119421_.popPush("cache"); + this.blockModelShaper.rebuildCache(); + p_119421_.pop(); @@ -91,6 +_,7 @@ } - public TextureAtlas m_119428_(ResourceLocation p_119429_) { -+ if (this.f_119398_ == null) throw new RuntimeException("getAtlasTexture called too early!"); - return this.f_119398_.m_117973_(p_119429_); + public TextureAtlas getAtlas(ResourceLocation p_119429_) { ++ if (this.atlases == null) throw new RuntimeException("getAtlasTexture called too early!"); + return this.atlases.getAtlas(p_119429_); } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch index d3aebed4..f7cee609 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelState.java.patch @@ -6,6 +6,6 @@ @OnlyIn(Dist.CLIENT) -public interface ModelState { +public interface ModelState extends net.minecraftforge.client.extensions.IForgeModelState { - default Transformation m_6189_() { - return Transformation.m_121093_(); + default Transformation getRotation() { + return Transformation.identity(); } 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 b15a2595..13d255b1 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch @@ -6,27 +6,27 @@ @OnlyIn(Dist.CLIENT) -public class MultiPartBakedModel implements BakedModel { +public class MultiPartBakedModel implements net.minecraftforge.client.model.data.IDynamicBakedModel { - private final List, BakedModel>> f_119459_; - protected final boolean f_119453_; - protected final boolean f_119454_; + private final List, BakedModel>> selectors; + protected final boolean hasAmbientOcclusion; + protected final boolean isGui3d; @@ -30,10 +_,12 @@ - protected final ItemTransforms f_119457_; - protected final ItemOverrides f_119458_; - private final Map f_119460_ = new Object2ObjectOpenCustomHashMap<>(Util.m_137583_()); + protected final ItemTransforms transforms; + protected final ItemOverrides overrides; + private final Map selectorCache = new Object2ObjectOpenCustomHashMap<>(Util.identityStrategy()); + private final BakedModel defaultModel; public MultiPartBakedModel(List, BakedModel>> p_119462_) { - this.f_119459_ = p_119462_; + this.selectors = p_119462_; BakedModel bakedmodel = p_119462_.iterator().next().getRight(); + this.defaultModel = bakedmodel; - this.f_119453_ = bakedmodel.m_7541_(); - this.f_119454_ = bakedmodel.m_7539_(); - this.f_119455_ = bakedmodel.m_7547_(); + this.hasAmbientOcclusion = bakedmodel.useAmbientOcclusion(); + this.isGui3d = bakedmodel.isGui3d(); + this.usesBlockLight = bakedmodel.usesBlockLight(); @@ -42,7 +_,8 @@ - this.f_119458_ = bakedmodel.m_7343_(); + this.overrides = bakedmodel.getOverrides(); } -- public List m_6840_(@Nullable BlockState p_119465_, @Nullable Direction p_119466_, Random p_119467_) { +- public List getQuads(@Nullable BlockState p_119465_, @Nullable Direction p_119466_, Random p_119467_) { + // FORGE: Implement our overloads (here and below) so child models can have custom logic + public List getQuads(@Nullable BlockState p_119465_, @Nullable Direction p_119466_, Random p_119467_, net.minecraftforge.client.model.data.IModelData modelData) { if (p_119465_ == null) { @@ -36,29 +36,29 @@ for(int j = 0; j < bitset.length(); ++j) { if (bitset.get(j)) { -- list.addAll(this.f_119459_.get(j).getRight().m_6840_(p_119465_, p_119466_, new Random(k))); -+ list.addAll(this.f_119459_.get(j).getRight().getQuads(p_119465_, p_119466_, new Random(k), net.minecraftforge.client.model.data.MultipartModelData.resolve(this.f_119459_.get(j).getRight(), modelData))); +- list.addAll(this.selectors.get(j).getRight().getQuads(p_119465_, p_119466_, new Random(k))); ++ list.addAll(this.selectors.get(j).getRight().getQuads(p_119465_, p_119466_, new Random(k), net.minecraftforge.client.model.data.MultipartModelData.resolve(this.selectors.get(j).getRight(), modelData))); } } @@ -77,6 +_,10 @@ - return this.f_119453_; + return this.hasAmbientOcclusion; } + public boolean useAmbientOcclusion(BlockState state) { + return this.defaultModel.useAmbientOcclusion(state); + } + - public boolean m_7539_() { - return this.f_119454_; + public boolean isGui3d() { + return this.isGui3d; } @@ -89,16 +_,31 @@ return false; } + @Deprecated - public TextureAtlasSprite m_6160_() { - return this.f_119456_; + public TextureAtlasSprite getParticleIcon() { + return this.particleIcon; } + public TextureAtlasSprite getParticleIcon(net.minecraftforge.client.model.data.IModelData modelData) { @@ -66,21 +66,21 @@ + } + + @Deprecated - public ItemTransforms m_7442_() { - return this.f_119457_; + public ItemTransforms getTransforms() { + return this.transforms; } + public BakedModel handlePerspective(net.minecraft.client.renderer.block.model.ItemTransforms.TransformType transformType, com.mojang.blaze3d.vertex.PoseStack poseStack) { + return this.defaultModel.handlePerspective(transformType, poseStack); + } + - public ItemOverrides m_7343_() { - return this.f_119458_; + public ItemOverrides getOverrides() { + return this.overrides; + } + + @Override + public net.minecraftforge.client.model.data.IModelData getModelData(net.minecraft.world.level.BlockAndTintGetter world, net.minecraft.core.BlockPos pos, BlockState state, net.minecraftforge.client.model.data.IModelData tileData) { -+ return net.minecraftforge.client.model.data.MultipartModelData.create(f_119459_, world, pos, state, tileData); ++ return net.minecraftforge.client.model.data.MultipartModelData.create(selectors, world, pos, state, tileData); } @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 7a9bad2f..db2d2f28 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/client/resources/model/SimpleBakedModel.java +++ b/net/minecraft/client/resources/model/SimpleBakedModel.java @@ -81,6 +_,10 @@ - private final boolean f_119514_; - private final ItemTransforms f_119515_; + private final boolean isGui3d; + private final ItemTransforms transforms; + public Builder(net.minecraftforge.client.model.IModelConfiguration model, ItemOverrides overrides) { + this(model.useSmoothLighting(), model.isSideLit(), model.isShadedInGui(), model.getCameraTransforms(), overrides); + } + public Builder(BlockModel p_119517_, ItemOverrides p_119518_, boolean p_119519_) { - this(p_119517_.m_111476_(), p_119517_.m_111479_().m_111526_(), p_119519_, p_119517_.m_111491_(), p_119518_); + this(p_119517_.hasAmbientOcclusion(), p_119517_.getGuiLight().lightLikeBlock(), p_119519_, p_119517_.getTransforms(), p_119518_); } 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 f17f0e67..5e0e269d 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch @@ -6,50 +6,50 @@ @OnlyIn(Dist.CLIENT) -public class WeightedBakedModel implements BakedModel { +public class WeightedBakedModel implements net.minecraftforge.client.model.data.IDynamicBakedModel { - private final int f_119540_; - private final List> f_119541_; - private final BakedModel f_119542_; + private final int totalWeight; + private final List> list; + private final BakedModel wrapped; @@ -28,16 +_,22 @@ - this.f_119542_ = p_119544_.get(0).m_146310_(); + this.wrapped = p_119544_.get(0).getData(); } -- public List m_6840_(@Nullable BlockState p_119547_, @Nullable Direction p_119548_, Random p_119549_) { -- return WeightedRandom.m_146314_(this.f_119541_, Math.abs((int)p_119549_.nextLong()) % this.f_119540_).map((p_174916_) -> { -- return p_174916_.m_146310_().m_6840_(p_119547_, p_119548_, p_119549_); +- public List getQuads(@Nullable BlockState p_119547_, @Nullable Direction p_119548_, Random p_119549_) { +- return WeightedRandom.getWeightedItem(this.list, Math.abs((int)p_119549_.nextLong()) % this.totalWeight).map((p_174916_) -> { +- return p_174916_.getData().getQuads(p_119547_, p_119548_, p_119549_); - }).orElse(Collections.emptyList()); + // FORGE: Implement our overloads (here and below) so child models can have custom logic + public List getQuads(@Nullable BlockState p_119547_, @Nullable Direction p_119548_, Random p_119549_, net.minecraftforge.client.model.data.IModelData modelData) { -+ return WeightedRandom.m_146314_(this.f_119541_, Math.abs((int)p_119549_.nextLong()) % this.f_119540_).map((p_174916_) -> { -+ return p_174916_.m_146310_().getQuads(p_119547_, p_119548_, p_119549_, modelData); ++ return WeightedRandom.getWeightedItem(this.list, Math.abs((int)p_119549_.nextLong()) % this.totalWeight).map((p_174916_) -> { ++ return p_174916_.getData().getQuads(p_119547_, p_119548_, p_119549_, modelData); + }).orElse(Collections.emptyList()); } - public boolean m_7541_() { - return this.f_119542_.m_7541_(); + public boolean useAmbientOcclusion() { + return this.wrapped.useAmbientOcclusion(); } + @Override + public boolean useAmbientOcclusion(BlockState state) { -+ return this.f_119542_.useAmbientOcclusion(state); ++ return this.wrapped.useAmbientOcclusion(state); + } + - public boolean m_7539_() { - return this.f_119542_.m_7539_(); + public boolean isGui3d() { + return this.wrapped.isGui3d(); } @@ -54,8 +_,16 @@ - return this.f_119542_.m_6160_(); + return this.wrapped.getParticleIcon(); } + public TextureAtlasSprite getParticleIcon(net.minecraftforge.client.model.data.IModelData modelData) { -+ return this.f_119542_.getParticleIcon(modelData); ++ return this.wrapped.getParticleIcon(modelData); + } + - public ItemTransforms m_7442_() { - return this.f_119542_.m_7442_(); + public ItemTransforms getTransforms() { + return this.wrapped.getTransforms(); + } + + public BakedModel handlePerspective(net.minecraft.client.renderer.block.model.ItemTransforms.TransformType transformType, com.mojang.blaze3d.vertex.PoseStack poseStack) { -+ return this.f_119542_.handlePerspective(transformType, poseStack); ++ return this.wrapped.handlePerspective(transformType, poseStack); } - public ItemOverrides m_7343_() { + public ItemOverrides getOverrides() { diff --git a/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch b/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch index 035f1694..1779855c 100644 --- a/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/sounds/SoundInstance.java.patch @@ -8,7 +8,7 @@ + /*================================ FORGE START ================================================*/ + + default java.util.concurrent.CompletableFuture getStream(net.minecraft.client.sounds.SoundBufferLibrary soundBuffers, Sound sound, boolean looping) { -+ return soundBuffers.m_120204_(sound.m_119787_(), looping); ++ return soundBuffers.getStream(sound.getLocation(), looping); + } + } diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedPlayerList.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedPlayerList.java.patch index b1264b3f..d80356bd 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedPlayerList.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedPlayerList.java.patch @@ -3,9 +3,9 @@ @@ -30,7 +_,7 @@ } - public Component m_6418_(SocketAddress p_120007_, GameProfile p_120008_) { -- return (Component)(p_120008_.getName().equalsIgnoreCase(this.m_7873_().m_129791_()) && this.m_11255_(p_120008_.getName()) != null ? new TranslatableComponent("multiplayer.disconnect.name_taken") : super.m_6418_(p_120007_, p_120008_)); + public Component canPlayerLogin(SocketAddress p_120007_, GameProfile p_120008_) { +- return (Component)(p_120008_.getName().equalsIgnoreCase(this.getServer().getSingleplayerName()) && this.getPlayerByName(p_120008_.getName()) != null ? new TranslatableComponent("multiplayer.disconnect.name_taken") : super.canPlayerLogin(p_120007_, p_120008_)); + return null; } - public IntegratedServer m_7873_() { + public IntegratedServer getServer() { diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index e11a506d..d858cbd3 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java @@ -60,9 +_,10 @@ - this.m_129997_(true); - this.m_129999_(true); - this.m_129793_(); -- this.m_130006_(); + this.setPvpAllowed(true); + this.setFlightAllowed(true); + this.initializeKeyPair(); +- this.loadLevel(); + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; -+ this.m_130006_(); // Magma - this.m_129989_(this.m_129791_() + " - " + this.m_129910_().m_5462_()); ++ this.loadLevel(); // Magma + this.setMotd(this.getSingleplayerName() + " - " + this.getWorldData().getLevelName()); - return true; + return net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(this); } - public void m_5705_(BooleanSupplier p_120049_) { + public void tickServer(BooleanSupplier p_120049_) { @@ -112,6 +_,11 @@ return true; } @@ -22,14 +22,14 @@ + return null; + } + - public File m_6237_() { - return this.f_120015_.f_91069_; + public File getServerDirectory() { + return this.minecraft.gameDirectory; } @@ -179,6 +_,7 @@ } - public void m_7570_(boolean p_120053_) { -+ if (m_130010_()) - this.m_18709_(() -> { - for(ServerPlayer serverplayer : Lists.newArrayList(this.m_6846_().m_11314_())) { - if (!serverplayer.m_142081_().equals(this.f_120019_)) { + public void halt(boolean p_120053_) { ++ if (isRunning()) + this.executeBlocking(() -> { + for(ServerPlayer serverplayer : Lists.newArrayList(this.getPlayerList().getPlayers())) { + if (!serverplayer.getUUID().equals(this.uuid)) { diff --git a/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch b/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch index 6d07e0ad..d0834aac 100644 --- a/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch +++ b/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/client/server/LanServerDetection.java @@ -33,7 +_,7 @@ this.setDaemon(true); - this.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LanServerDetection.f_120082_)); - this.f_120088_ = new MulticastSocket(4445); -- this.f_120087_ = InetAddress.getByName("224.0.2.60"); -+ this.f_120087_ = InetAddress.getByName(LanServerPinger.f_174974_); - this.f_120088_.setSoTimeout(5000); - this.f_120088_.joinGroup(this.f_120087_); + this.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LanServerDetection.LOGGER)); + this.socket = new MulticastSocket(4445); +- this.pingGroup = InetAddress.getByName("224.0.2.60"); ++ this.pingGroup = InetAddress.getByName(LanServerPinger.MULTICAST_GROUP); + this.socket.setSoTimeout(5000); + this.socket.joinGroup(this.pingGroup); } @@ -88,7 +_,19 @@ - String s = LanServerPinger.m_120111_(p_120097_); - String s1 = LanServerPinger.m_120116_(p_120097_); + String s = LanServerPinger.parseMotd(p_120097_); + String s1 = LanServerPinger.parseAddress(p_120097_); if (s1 != null) { - s1 = p_120098_.getHostAddress() + ":" + s1; + if (net.minecraftforge.network.DualStackUtils.checkIPv6(p_120098_)) { @@ -29,4 +29,4 @@ + } boolean flag = false; - for(LanServer lanserver : this.f_120092_) { + for(LanServer lanserver : this.servers) { diff --git a/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch b/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch index e89de405..7ffcbeb0 100644 --- a/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/server/LanServerPinger.java.patch @@ -2,19 +2,19 @@ +++ b/net/minecraft/client/server/LanServerPinger.java @@ -16,7 +_,7 @@ public class LanServerPinger extends Thread { - private static final AtomicInteger f_120101_ = new AtomicInteger(0); - private static final Logger f_120102_ = LogUtils.getLogger(); -- public static final String f_174974_ = "224.0.2.60"; -+ public static final String f_174974_ = net.minecraftforge.network.DualStackUtils.getMulticastGroup(); - public static final int f_174975_ = 4445; - private static final long f_174976_ = 1500L; - private final String f_120103_; + private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); + private static final Logger LOGGER = LogUtils.getLogger(); +- public static final String MULTICAST_GROUP = "224.0.2.60"; ++ public static final String MULTICAST_GROUP = net.minecraftforge.network.DualStackUtils.getMulticastGroup(); + public static final int PING_PORT = 4445; + private static final long PING_INTERVAL = 1500L; + private final String motd; @@ -39,7 +_,7 @@ - while(!this.isInterrupted() && this.f_120105_) { + while(!this.isInterrupted() && this.isRunning) { try { - InetAddress inetaddress = InetAddress.getByName("224.0.2.60"); -+ InetAddress inetaddress = InetAddress.getByName(f_174974_); ++ InetAddress inetaddress = InetAddress.getByName(MULTICAST_GROUP); DatagramPacket datagrampacket = new DatagramPacket(abyte, abyte.length, inetaddress, 4445); - this.f_120104_.send(datagrampacket); + this.socket.send(datagrampacket); } catch (IOException ioexception) { diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch index e29c9c5c..b8307fdd 100644 --- a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -1,49 +1,49 @@ --- a/net/minecraft/client/sounds/SoundEngine.java +++ b/net/minecraft/client/sounds/SoundEngine.java @@ -76,6 +_,7 @@ - this.f_120217_ = p_120236_; - this.f_120218_ = p_120237_; - this.f_120222_ = new SoundBufferLibrary(p_120238_); + this.soundManager = p_120236_; + this.options = p_120237_; + this.soundBuffers = new SoundBufferLibrary(p_120238_); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); } - public void m_120239_() { + public void reload() { @@ -91,6 +_,7 @@ - this.m_120304_(); - this.m_120323_(); + this.destroy(); + this.loadLibrary(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); } - private synchronized void m_120323_() { + private synchronized void loadLibrary() { @@ -321,7 +_,8 @@ - public void m_120312_(SoundInstance p_120313_) { - if (this.f_120219_) { -- if (p_120313_.m_7767_()) { + public void play(SoundInstance p_120313_) { + if (this.loaded) { +- if (p_120313_.canPlaySound()) { + p_120313_ = net.minecraftforge.client.ForgeHooksClient.playSound(this, p_120313_); -+ if (p_120313_ != null && p_120313_.m_7767_()) { - WeighedSoundEvents weighedsoundevents = p_120313_.m_6775_(this.f_120217_); - ResourceLocation resourcelocation = p_120313_.m_7904_(); ++ if (p_120313_ != null && p_120313_.canPlaySound()) { + WeighedSoundEvents weighedsoundevents = p_120313_.resolve(this.soundManager); + ResourceLocation resourcelocation = p_120313_.getLocation(); if (weighedsoundevents == null) { @@ -389,11 +_,13 @@ - p_194488_.m_83654_(vec3); - p_194488_.m_83670_(flag); + p_194488_.setSelfPosition(vec3); + p_194488_.setRelative(flag); }); + final SoundInstance soundinstance = p_120313_; if (!flag3) { - this.f_120222_.m_120202_(sound.m_119790_()).thenAccept((p_194501_) -> { - channelaccess$channelhandle.m_120154_((p_194495_) -> { - p_194495_.m_83656_(p_194501_); - p_194495_.m_83672_(); + this.soundBuffers.getCompleteBuffer(sound.getPath()).thenAccept((p_194501_) -> { + channelaccess$channelhandle.execute((p_194495_) -> { + p_194495_.attachStaticBuffer(p_194501_); + p_194495_.play(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlaySoundSourceEvent(this, soundinstance, p_194495_)); }); }); } else { @@ -401,6 +_,7 @@ - channelaccess$channelhandle.m_120154_((p_194498_) -> { - p_194498_.m_83658_(p_194504_); - p_194498_.m_83672_(); + channelaccess$channelhandle.execute((p_194498_) -> { + p_194498_.attachBufferStream(p_194504_); + p_194498_.play(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlayStreamingSourceEvent(this, soundinstance, p_194498_)); }); }); diff --git a/patches/minecraft/net/minecraft/commands/CommandFunction.java.patch b/patches/minecraft/net/minecraft/commands/CommandFunction.java.patch index 856caf36..180519a6 100644 --- a/patches/minecraft/net/minecraft/commands/CommandFunction.java.patch +++ b/patches/minecraft/net/minecraft/commands/CommandFunction.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/commands/CommandFunction.java +++ b/net/minecraft/commands/CommandFunction.java @@ -17,6 +_,16 @@ - private final CommandFunction.Entry[] f_77976_; - final ResourceLocation f_77977_; + private final CommandFunction.Entry[] entries; + final ResourceLocation id; + // Paper start + public co.aikar.timings.Timing timing; @@ -15,5 +15,5 @@ + // Paper end + public CommandFunction(ResourceLocation p_77979_, CommandFunction.Entry[] p_77980_) { - this.f_77977_ = p_77979_; - this.f_77976_ = p_77980_; + this.id = p_77979_; + this.entries = p_77980_; diff --git a/patches/minecraft/net/minecraft/commands/CommandSource.java.patch b/patches/minecraft/net/minecraft/commands/CommandSource.java.patch index a1f62573..7f5f54e3 100644 --- a/patches/minecraft/net/minecraft/commands/CommandSource.java.patch +++ b/patches/minecraft/net/minecraft/commands/CommandSource.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/commands/CommandSource.java +++ b/net/minecraft/commands/CommandSource.java @@ -19,6 +_,14 @@ - public boolean m_6102_() { + public boolean shouldInformAdmins() { return false; } + @@ -14,9 +14,9 @@ + // CraftBukkit end }; - void m_6352_(Component p_80166_, UUID p_80167_); + void sendMessage(Component p_80166_, UUID p_80167_); @@ -32,4 +_,6 @@ - default boolean m_142559_() { + default boolean alwaysAccepts() { return false; } + diff --git a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch index 828cc2b9..ea5b3c3a 100644 --- a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch +++ b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch @@ -7,13 +7,13 @@ -public class CommandSourceStack implements SharedSuggestionProvider { + +public class CommandSourceStack implements SharedSuggestionProvider, net.minecraftforge.common.extensions.IForgeCommandSourceStack { - public static final SimpleCommandExceptionType f_81286_ = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.player")); - public static final SimpleCommandExceptionType f_81287_ = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.entity")); - public final CommandSource f_81288_; + public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.player")); + public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.entity")); + public final CommandSource source; @@ -52,6 +_,7 @@ - private final ResultConsumer f_81297_; - private final EntityAnchorArgument.Anchor f_81298_; - private final Vec2 f_81299_; + private final ResultConsumer consumer; + private final EntityAnchorArgument.Anchor anchor; + private final Vec2 rotation; + public volatile com.mojang.brigadier.tree.CommandNode currentCommand; // CraftBukkit public CommandSourceStack(CommandSource p_81302_, Vec3 p_81303_, Vec2 p_81304_, ServerLevel p_81305_, int p_81306_, String p_81307_, Component p_81308_, MinecraftServer p_81309_, @Nullable Entity p_81310_) { @@ -21,50 +21,50 @@ @@ -148,9 +_,22 @@ } - public boolean m_6761_(int p_81370_) { + public boolean hasPermission(int p_81370_) { + // CraftBukkit start + com.mojang.brigadier.tree.CommandNode currentCommand = this.currentCommand; + if (currentCommand != null && !currentCommand.isForgeCommand()) { //Magma - skip if forge command + return hasPermission(p_81370_, org.bukkit.craftbukkit.v1_18_R2.command.VanillaCommandWrapper.getPermission(currentCommand)); + } + // CraftBukkit end - return this.f_81291_ >= p_81370_; + return this.permissionLevel >= p_81370_; } + // CraftBukkit start + public boolean hasPermission(int i, String bukkitPermission) { + // World is null when loading functions -+ return ((m_81372_() == null || !m_81372_().getCraftServer().ignoreVanillaPermissions) && this.f_81291_ >= i) || getBukkitSender().hasPermission(bukkitPermission); ++ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission); + } + // CraftBukkit end + - public Vec3 m_81371_() { - return this.f_81289_; + public Vec3 getPosition() { + return this.worldPosition; } @@ -207,13 +_,13 @@ - Component component = (new TranslatableComponent("chat.type.admin", this.m_81357_(), p_81367_)).m_130944_(new ChatFormatting[]{ChatFormatting.GRAY, ChatFormatting.ITALIC}); - if (this.f_81294_.m_129900_().m_46207_(GameRules.f_46144_)) { - for(ServerPlayer serverplayer : this.f_81294_.m_6846_().m_11314_()) { -- if (serverplayer != this.f_81288_ && this.f_81294_.m_6846_().m_11303_(serverplayer.m_36316_())) { -+ if (serverplayer != this.f_81288_ && serverplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit - serverplayer.m_6352_(component, Util.f_137441_); + Component component = (new TranslatableComponent("chat.type.admin", this.getDisplayName(), p_81367_)).withStyle(new ChatFormatting[]{ChatFormatting.GRAY, ChatFormatting.ITALIC}); + if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { + for(ServerPlayer serverplayer : this.server.getPlayerList().getPlayers()) { +- if (serverplayer != this.source && this.server.getPlayerList().isOp(serverplayer.getGameProfile())) { ++ if (serverplayer != this.source && serverplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit + serverplayer.sendMessage(component, Util.NIL_UUID); } } } -- if (this.f_81288_ != this.f_81294_ && this.f_81294_.m_129900_().m_46207_(GameRules.f_46141_)) { -+ if (this.f_81288_ != this.f_81294_ && this.f_81294_.m_129900_().m_46207_(GameRules.f_46141_) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot - this.f_81294_.m_6352_(component, Util.f_137441_); +- if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS)) { ++ if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot + this.server.sendMessage(component, Util.NIL_UUID); } @@ -267,4 +_,10 @@ - public RegistryAccess m_5894_() { - return this.f_81294_.m_206579_(); + public RegistryAccess registryAccess() { + return this.server.registryAccess(); } + + // CraftBukkit start + public org.bukkit.command.CommandSender getBukkitSender() { -+ return f_81288_.getBukkitSender(this); ++ return source.getBukkitSender(this); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index 55c39044..275bd1f9 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,33 +1,33 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java @@ -115,8 +_,10 @@ - public static final int f_165685_ = 3; - public static final int f_165686_ = 4; - private final CommandDispatcher f_82090_ = new CommandDispatcher<>(); + public static final int LEVEL_ADMINS = 3; + public static final int LEVEL_OWNERS = 4; + private final CommandDispatcher dispatcher = new CommandDispatcher<>(); + private final CommandDispatcher forgeDispatcher = new CommandDispatcher<>(); public Commands(Commands.CommandSelection p_82093_) { + this(); // CraftBukkit - AdvancementCommands.m_136310_(this.f_82090_); - AttributeCommand.m_136444_(this.f_82090_); - ExecuteCommand.m_137042_(this.f_82090_); + AdvancementCommands.register(this.dispatcher); + AttributeCommand.register(this.dispatcher); + ExecuteCommand.register(this.dispatcher); @@ -177,7 +_,7 @@ - JfrCommand.m_183645_(this.f_82090_); + JfrCommand.register(this.dispatcher); } -- if (SharedConstants.f_136183_) { +- if (SharedConstants.IS_RUNNING_IN_IDE) { + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { - TestCommand.m_127946_(this.f_82090_); + TestCommand.register(this.dispatcher); } @@ -201,26 +_,85 @@ - if (p_82093_.f_82144_) { - PublishCommand.m_138184_(this.f_82090_); + if (p_82093_.includeIntegrated) { + PublishCommand.register(this.dispatcher); } + net.minecraftforge.event.ForgeEventFactory.onCommandRegister(this.forgeDispatcher, p_82093_); - this.f_82090_.findAmbiguities((p_82108_, p_82109_, p_82110_, p_82111_) -> { -- f_82089_.warn("Ambiguity between arguments {} and {} with inputs: {}", this.f_82090_.getPath(p_82109_), this.f_82090_.getPath(p_82110_), p_82111_); + this.dispatcher.findAmbiguities((p_82108_, p_82109_, p_82110_, p_82111_) -> { +- LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(p_82109_), this.dispatcher.getPath(p_82110_), p_82111_); + // LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(p_82109_), this.dispatcher.getPath(p_82110_), p_82111_); // CraftBukkit }); + @@ -37,8 +37,8 @@ + + public Commands() { + // CraftBukkkit end - this.f_82090_.setConsumer((p_82104_, p_82105_, p_82106_) -> { - p_82104_.getSource().m_81342_(p_82104_, p_82105_, p_82106_); + this.dispatcher.setConsumer((p_82104_, p_82105_, p_82106_) -> { + p_82104_.getSource().onCommandComplete(p_82104_, p_82105_, p_82106_); }); } @@ -75,7 +75,7 @@ + } + + // Handle vanilla commands; -+ if (sender.m_81372_().getCraftServer().getCommandBlockOverride(args[0])) { ++ if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) { + args[0] = "minecraft:" + args[0]; + } + @@ -90,7 +90,7 @@ + //Magma start - fix mixin inject on original performCommand + private @Nullable String performCommand_label = null; + private boolean performCommand_stripSlash = true; - public int m_82117_(CommandSourceStack p_82118_, String p_82119_) { + public int performCommand(CommandSourceStack p_82118_, String p_82119_) { StringReader stringreader = new StringReader(p_82119_); - if (stringreader.canRead() && stringreader.peek() == '/') { + if (this.performCommand_stripSlash && stringreader.canRead() && stringreader.peek() == '/') { @@ -98,30 +98,30 @@ + // CraftBukkit end } - p_82118_.m_81377_().m_129905_().m_6180_(p_82119_); + p_82118_.getServer().getProfiler().push(p_82119_); try { try { -- return this.f_82090_.execute(stringreader, p_82118_); +- return this.dispatcher.execute(stringreader, p_82118_); + if (parseCommand(stringreader, p_82118_).isEmpty()) + return 1; + return this.getCurrentDispatcher(stringreader).execute(parseCommand(stringreader, p_82118_).get().getParseResults()); } catch (CommandRuntimeException commandruntimeexception) { - p_82118_.m_81352_(commandruntimeexception.m_79226_()); + p_82118_.sendFailure(commandruntimeexception.getComponent()); return 0; @@ -229,7 +_,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); - MutableComponent mutablecomponent1 = (new TextComponent("")).m_130940_(ChatFormatting.GRAY).m_130938_((p_82134_) -> { -- return p_82134_.m_131142_(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, p_82119_)); -+ return p_82134_.m_131142_(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, this.performCommand_label == null ? p_82119_ : this.performCommand_label)); // CraftBukkit + MutableComponent mutablecomponent1 = (new TextComponent("")).withStyle(ChatFormatting.GRAY).withStyle((p_82134_) -> { +- return p_82134_.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, p_82119_)); ++ return p_82134_.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, this.performCommand_label == null ? p_82119_ : this.performCommand_label)); // CraftBukkit }); if (j > 10) { - mutablecomponent1.m_130946_("..."); + mutablecomponent1.append("..."); @@ -269,19 +_,100 @@ return 0; } finally { - p_82118_.m_81377_().m_129905_().m_7238_(); + p_82118_.getServer().getProfiler().pop(); - } - } - @@ -147,12 +147,12 @@ + public int performCommand(CommandSourceStack p_82118_, String p_82119_, String label, boolean stripSlash) { + this.performCommand_label = label; + this.performCommand_stripSlash = stripSlash; -+ return this.m_82117_(p_82118_, p_82119_); ++ return this.performCommand(p_82118_, p_82119_); + } + //Magma end + + //Magma start - rewrite to add forge dispatcher support - public void m_82095_(ServerPlayer p_82096_) { + public void sendCommands(ServerPlayer p_82096_) { - Map, CommandNode> map = Maps.newHashMap(); + if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot + // CraftBukkit start @@ -160,19 +160,19 @@ + Map, CommandNode> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues + + RootCommandNode vanillaRoot = new RootCommandNode<>(); -+ Commands vanillaCommands = p_82096_.f_8924_.vanillaCommandDispatcher; -+ map.put(vanillaCommands.m_82094_().getRoot(), vanillaRoot); ++ Commands vanillaCommands = p_82096_.server.vanillaCommandDispatcher; ++ map.put(vanillaCommands.getDispatcher().getRoot(), vanillaRoot); + + // FORGE: Use our own command node merging method to handle redirect nodes properly, see issue #7551 -+ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(vanillaCommands.m_82094_().getRoot(), vanillaRoot, map, p_82096_.m_20203_(), ctx -> 0, suggest -> SuggestionProviders.m_121664_((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); ++ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(vanillaCommands.getDispatcher().getRoot(), vanillaRoot, map, p_82096_.createCommandSourceStack(), ctx -> 0, suggest -> SuggestionProviders.safelySwap((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); + + // Now build the global commands in a second pass RootCommandNode rootcommandnode = new RootCommandNode<>(); - map.put(this.f_82090_.getRoot(), rootcommandnode); -- this.m_82112_(this.f_82090_.getRoot(), rootcommandnode, p_82096_.m_20203_(), map); -- p_82096_.f_8906_.m_141995_(new ClientboundCommandsPacket(rootcommandnode)); + map.put(this.dispatcher.getRoot(), rootcommandnode); +- this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, p_82096_.createCommandSourceStack(), map); +- p_82096_.connection.send(new ClientboundCommandsPacket(rootcommandnode)); + -+ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(this.f_82090_.getRoot(), rootcommandnode, map, p_82096_.m_20203_(), ctx -> 0, suggest -> SuggestionProviders.m_121664_((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); ++ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(this.dispatcher.getRoot(), rootcommandnode, map, p_82096_.createCommandSourceStack(), ctx -> 0, suggest -> SuggestionProviders.safelySwap((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); + + java.util.LinkedHashSet set = new java.util.LinkedHashSet<>(); + for (CommandNode child : rootcommandnode.getChildren()) { @@ -193,33 +193,33 @@ + RootCommandNode forgeRoot = new RootCommandNode<>(); + map.put(this.forgeDispatcher.getRoot(), forgeRoot); + -+ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(this.forgeDispatcher.getRoot(), forgeRoot, map, p_82096_.m_20203_(), ctx -> 0, suggest -> SuggestionProviders.m_121664_((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); ++ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(this.forgeDispatcher.getRoot(), forgeRoot, map, p_82096_.createCommandSourceStack(), ctx -> 0, suggest -> SuggestionProviders.safelySwap((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); + + //Add all the forge commands to the root node + forgeRoot.getChildren().forEach(rootcommandnode::addChild); + //ambassador support start + ClientboundCommandsPacket packet = new ClientboundCommandsPacket(rootcommandnode); + try{ -+ net.minecraftforge.network.ConnectionData connectionData = (net.minecraftforge.network.ConnectionData) p_82096_.f_8906_.f_9742_.channel().attr(io.netty.util.AttributeKey.valueOf("fml:conndata")).get(); ++ net.minecraftforge.network.ConnectionData connectionData = (net.minecraftforge.network.ConnectionData) p_82096_.connection.connection.channel().attr(io.netty.util.AttributeKey.valueOf("fml:conndata")).get(); + if (connectionData == null){ -+ f_82089_.info("Failed to get a channel with the attribute of fml:conndata."); -+ p_82096_.f_8906_.m_141995_(packet); ++ LOGGER.info("Failed to get a channel with the attribute of fml:conndata."); ++ p_82096_.connection.send(packet); + } else if (connectionData.getChannels().keySet().stream().anyMatch((v) -> v.equals(new net.minecraft.resources.ResourceLocation("ambassador:commands")))) { + net.minecraft.network.FriendlyByteBuf byteBuf = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.buffer()); + packet.write(byteBuf, true); -+ p_82096_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket(new net.minecraft.resources.ResourceLocation("ambassador:commands"), byteBuf)); ++ p_82096_.connection.send(new net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket(new net.minecraft.resources.ResourceLocation("ambassador:commands"), byteBuf)); + } else { -+ p_82096_.f_8906_.m_141995_(packet); ++ p_82096_.connection.send(packet); + } + }catch (ClassCastException e){ -+ f_82089_.error("Failed to get connection data for player " + p_82096_.m_7755_().getString() + ". Someone registered a channel with the fml:conndata key that isn't a net.minecraftforge.network.ConnectionData object."); -+ p_82096_.f_8906_.m_141995_(packet); ++ LOGGER.error("Failed to get connection data for player " + p_82096_.getName().getString() + ". Someone registered a channel with the fml:conndata key that isn't a net.minecraftforge.network.ConnectionData object."); ++ p_82096_.connection.send(packet); + } + //ambassador support end } + //Magma end - private void m_82112_(CommandNode p_82113_, CommandNode p_82114_, CommandSourceStack p_82115_, Map, CommandNode> p_82116_) { + private void fillUsableCommands(CommandNode p_82113_, CommandNode p_82114_, CommandSourceStack p_82115_, Map, CommandNode> p_82116_) { for(CommandNode commandnode : p_82113_.getChildren()) { + if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode.getName().contains( ":" ) ) continue; // Spigot if (commandnode.canUse(p_82115_)) { @@ -228,10 +228,10 @@ @@ -335,9 +_,16 @@ } - public CommandDispatcher m_82094_() { + public CommandDispatcher getDispatcher() { + if (org.magmafoundation.magma.commands.DispatcherRedirector.shouldBypass()) + return this.forgeDispatcher; - return this.f_82090_; + return this.dispatcher; } + //Magma - wrap the forge dispatcher to prevent LuckPerms from using this method as the vanilla dispatcher.. thanks reflection... @@ -240,7 +240,7 @@ + } + @Nullable - public static CommandSyntaxException m_82097_(ParseResults p_82098_) { + public static CommandSyntaxException getParseException(ParseResults p_82098_) { if (!p_82098_.getReader().canRead()) { @@ -362,6 +_,39 @@ throw new IllegalStateException("Unregistered argument types"); @@ -276,7 +276,7 @@ + if (found != null) + return getForgeDispatcher().unwrap(); + -+ return m_82094_(); ++ return getDispatcher(); + } + //Magma end diff --git a/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch index efd89f68..1ade9eab 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/EntityArgument.java.patch @@ -10,17 +10,17 @@ + EntitySelectorParser entityselectorparser = new EntitySelectorParser(p_91451_); + EntitySelector entityselector = entityselectorparser.parse(overridePermissions); + // CraftBukkit end -+ if (entityselector.m_121138_() > 1 && this.f_91443_) { -+ if (this.f_91444_) { ++ if (entityselector.getMaxResults() > 1 && this.single) { ++ if (this.playersOnly) { + p_91451_.setCursor(0); -+ throw f_91437_.createWithContext(p_91451_); ++ throw ERROR_NOT_SINGLE_PLAYER.createWithContext(p_91451_); + } else { + p_91451_.setCursor(0); -+ throw f_91436_.createWithContext(p_91451_); ++ throw ERROR_NOT_SINGLE_ENTITY.createWithContext(p_91451_); + } -+ } else if (entityselector.m_121159_() && this.f_91444_ && !entityselector.m_121162_()) { ++ } else if (entityselector.includesEntities() && this.playersOnly && !entityselector.isSelfSelector()) { + p_91451_.setCursor(0); -+ throw f_91438_.createWithContext(p_91451_); ++ throw ERROR_ONLY_PLAYERS_ALLOWED.createWithContext(p_91451_); + } else { + return entityselector; + } diff --git a/patches/minecraft/net/minecraft/commands/arguments/ObjectiveArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/ObjectiveArgument.java.patch index 2d60f5d5..89ae42c9 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/ObjectiveArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/ObjectiveArgument.java.patch @@ -2,19 +2,19 @@ +++ b/net/minecraft/commands/arguments/ObjectiveArgument.java @@ -31,7 +_,7 @@ - public static Objective m_101960_(CommandContext p_101961_, String p_101962_) throws CommandSyntaxException { + public static Objective getObjective(CommandContext p_101961_, String p_101962_) throws CommandSyntaxException { String s = p_101961_.getArgument(p_101962_, String.class); -- Scoreboard scoreboard = p_101961_.getSource().m_81377_().m_129896_(); +- Scoreboard scoreboard = p_101961_.getSource().getServer().getScoreboard(); + Scoreboard scoreboard = p_101961_.getSource().getScoreboard(); - Objective objective = scoreboard.m_83477_(s); + Objective objective = scoreboard.getObjective(s); if (objective == null) { - throw f_101953_.create(s); + throw ERROR_OBJECTIVE_NOT_FOUND.create(s); @@ -57,7 +_,7 @@ S s = p_101974_.getSource(); if (s instanceof CommandSourceStack) { CommandSourceStack commandsourcestack = (CommandSourceStack)s; -- return SharedSuggestionProvider.m_82970_(commandsourcestack.m_81377_().m_129896_().m_83474_(), p_101975_); -+ return SharedSuggestionProvider.m_82970_(commandsourcestack.getScoreboard().m_83474_(), p_101975_); +- return SharedSuggestionProvider.suggest(commandsourcestack.getServer().getScoreboard().getObjectiveNames(), p_101975_); ++ return SharedSuggestionProvider.suggest(commandsourcestack.getScoreboard().getObjectiveNames(), p_101975_); } else if (s instanceof SharedSuggestionProvider) { SharedSuggestionProvider sharedsuggestionprovider = (SharedSuggestionProvider)s; - return sharedsuggestionprovider.m_212155_(p_101974_); + return sharedsuggestionprovider.customSuggestion(p_101974_); diff --git a/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch index 468f7de9..39ce67f9 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch @@ -2,19 +2,19 @@ +++ b/net/minecraft/commands/arguments/ResourceLocationArgument.java @@ -39,7 +_,7 @@ - public static Advancement m_106987_(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { - ResourceLocation resourcelocation = m_107011_(p_106988_, p_106989_); -- Advancement advancement = p_106988_.getSource().m_81377_().m_129889_().m_136041_(resourcelocation); + public static Advancement getAdvancement(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { + ResourceLocation resourcelocation = getId(p_106988_, p_106989_); +- Advancement advancement = p_106988_.getSource().getServer().getAdvancements().getAdvancement(resourcelocation); + Advancement advancement = p_106988_.getSource().getAdvancement(resourcelocation); if (advancement == null) { - throw f_106978_.create(resourcelocation); + throw ERROR_UNKNOWN_ADVANCEMENT.create(resourcelocation); } else { @@ -48,7 +_,7 @@ } - public static Recipe m_106994_(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { -- RecipeManager recipemanager = p_106995_.getSource().m_81377_().m_129894_(); + public static Recipe getRecipe(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { +- RecipeManager recipemanager = p_106995_.getSource().getServer().getRecipeManager(); + RecipeManager recipemanager = p_106995_.getSource().getRecipeManager(); - ResourceLocation resourcelocation = m_107011_(p_106995_, p_106996_); - return recipemanager.m_44043_(resourcelocation).orElseThrow(() -> { - return f_106979_.create(resourcelocation); + ResourceLocation resourcelocation = getId(p_106995_, p_106996_); + return recipemanager.byKey(resourcelocation).orElseThrow(() -> { + return ERROR_UNKNOWN_RECIPE.create(resourcelocation); diff --git a/patches/minecraft/net/minecraft/commands/arguments/TeamArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/TeamArgument.java.patch index 175989fd..963f524d 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/TeamArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/TeamArgument.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/commands/arguments/TeamArgument.java @@ -28,7 +_,7 @@ - public static PlayerTeam m_112091_(CommandContext p_112092_, String p_112093_) throws CommandSyntaxException { + public static PlayerTeam getTeam(CommandContext p_112092_, String p_112093_) throws CommandSyntaxException { String s = p_112092_.getArgument(p_112093_, String.class); -- Scoreboard scoreboard = p_112092_.getSource().m_81377_().m_129896_(); +- Scoreboard scoreboard = p_112092_.getSource().getServer().getScoreboard(); + Scoreboard scoreboard = p_112092_.getSource().getScoreboard(); - PlayerTeam playerteam = scoreboard.m_83489_(s); + PlayerTeam playerteam = scoreboard.getPlayerTeam(s); if (playerteam == null) { - throw f_112085_.create(s); + throw ERROR_TEAM_NOT_FOUND.create(s); diff --git a/patches/minecraft/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch b/patches/minecraft/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch index 9556c0cc..6607f554 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/commands/arguments/blocks/BlockStateParser.java @@ -58,8 +_,8 @@ }; - private final StringReader f_116749_; - private final boolean f_116750_; -- private final Map, Comparable> f_116751_ = Maps.newHashMap(); -- private final Map f_116752_ = Maps.newHashMap(); -+ private final Map, Comparable> f_116751_ = Maps.newLinkedHashMap(); // CraftBukkit - stable -+ private final Map f_116752_ = Maps.newHashMap(); - private ResourceLocation f_116753_ = new ResourceLocation(""); - private StateDefinition f_116754_; - private BlockState f_116755_; + private final StringReader reader; + private final boolean forTesting; +- private final Map, Comparable> properties = Maps.newHashMap(); +- private final Map vagueProperties = Maps.newHashMap(); ++ private final Map, Comparable> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable ++ private final Map vagueProperties = Maps.newHashMap(); + private ResourceLocation id = new ResourceLocation(""); + private StateDefinition definition; + private BlockState state; diff --git a/patches/minecraft/net/minecraft/commands/arguments/coordinates/BlockPosArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/coordinates/BlockPosArgument.java.patch index 9be17e45..0d227bef 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/coordinates/BlockPosArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/coordinates/BlockPosArgument.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/commands/arguments/coordinates/BlockPosArgument.java @@ -30,9 +_,9 @@ - public static BlockPos m_118242_(CommandContext p_118243_, String p_118244_) throws CommandSyntaxException { - BlockPos blockpos = p_118243_.getArgument(p_118244_, Coordinates.class).m_119568_(p_118243_.getSource()); -- if (!p_118243_.getSource().m_81372_().m_46805_(blockpos)) { -+ if (!p_118243_.getSource().getUnsidedLevel().m_46805_(blockpos)) { - throw f_118234_.create(); -- } else if (!p_118243_.getSource().m_81372_().m_46739_(blockpos)) { -+ } else if (!p_118243_.getSource().getUnsidedLevel().m_46739_(blockpos)) { - throw f_118235_.create(); + public static BlockPos getLoadedBlockPos(CommandContext p_118243_, String p_118244_) throws CommandSyntaxException { + BlockPos blockpos = p_118243_.getArgument(p_118244_, Coordinates.class).getBlockPos(p_118243_.getSource()); +- if (!p_118243_.getSource().getLevel().hasChunkAt(blockpos)) { ++ if (!p_118243_.getSource().getUnsidedLevel().hasChunkAt(blockpos)) { + throw ERROR_NOT_LOADED.create(); +- } else if (!p_118243_.getSource().getLevel().isInWorldBounds(blockpos)) { ++ } else if (!p_118243_.getSource().getUnsidedLevel().isInWorldBounds(blockpos)) { + throw ERROR_OUT_OF_WORLD.create(); } else { return blockpos; diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index df111409..38eb2601 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -3,9 +3,9 @@ @@ -87,7 +_,7 @@ } - private void m_121168_(CommandSourceStack p_121169_) throws CommandSyntaxException { -- if (this.f_121123_ && !p_121169_.m_6761_(2)) { -+ if (this.f_121123_ && !p_121169_.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit - throw EntityArgument.f_91441_.create(); + private void checkPermissions(CommandSourceStack p_121169_) throws CommandSyntaxException { +- if (this.usesSelector && !p_121169_.hasPermission(2)) { ++ if (this.usesSelector && !p_121169_.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit + throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create(); } } diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index 24d76a9a..f79b22e9 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -6,96 +6,96 @@ + // CraftBukkit start + protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { -+ this.f_121189_ = !overridePermissions; ++ this.usesSelectors = !overridePermissions; + // CraftBukkit end -+ this.f_121176_ = this::m_121322_; -+ if (!this.f_121201_.canRead()) { -+ throw f_121193_.createWithContext(this.f_121201_); ++ this.suggestions = this::suggestSelector; ++ if (!this.reader.canRead()) { ++ throw ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); + } else { -+ int i = this.f_121201_.getCursor(); -+ char c0 = this.f_121201_.read(); ++ int i = this.reader.getCursor(); ++ char c0 = this.reader.read(); + if (c0 == 'p') { -+ this.f_121203_ = 1; -+ this.f_121204_ = false; -+ this.f_121171_ = f_121197_; -+ this.m_121241_(EntityType.f_20532_); ++ this.maxResults = 1; ++ this.includesEntities = false; ++ this.order = ORDER_NEAREST; ++ this.limitToType(EntityType.PLAYER); + } else if (c0 == 'a') { -+ this.f_121203_ = Integer.MAX_VALUE; -+ this.f_121204_ = false; -+ this.f_121171_ = f_121196_; -+ this.m_121241_(EntityType.f_20532_); ++ this.maxResults = Integer.MAX_VALUE; ++ this.includesEntities = false; ++ this.order = ORDER_ARBITRARY; ++ this.limitToType(EntityType.PLAYER); + } else if (c0 == 'r') { -+ this.f_121203_ = 1; -+ this.f_121204_ = false; -+ this.f_121171_ = f_121199_; -+ this.m_121241_(EntityType.f_20532_); ++ this.maxResults = 1; ++ this.includesEntities = false; ++ this.order = ORDER_RANDOM; ++ this.limitToType(EntityType.PLAYER); + } else if (c0 == 's') { -+ this.f_121203_ = 1; -+ this.f_121204_ = true; -+ this.f_121172_ = true; ++ this.maxResults = 1; ++ this.includesEntities = true; ++ this.currentEntity = true; + } else { + if (c0 != 'e') { -+ this.f_121201_.setCursor(i); -+ throw f_121191_.createWithContext(this.f_121201_, "@" + String.valueOf(c0)); ++ this.reader.setCursor(i); ++ throw ERROR_UNKNOWN_SELECTOR_TYPE.createWithContext(this.reader, "@" + String.valueOf(c0)); + } + -+ this.f_121203_ = Integer.MAX_VALUE; -+ this.f_121204_ = true; -+ this.f_121171_ = f_121196_; -+ this.f_121170_ = Entity::m_6084_; ++ this.maxResults = Integer.MAX_VALUE; ++ this.includesEntities = true; ++ this.order = ORDER_ARBITRARY; ++ this.predicate = Entity::isAlive; + } + -+ this.f_121176_ = this::m_121333_; -+ if (this.f_121201_.canRead() && this.f_121201_.peek() == '[') { -+ this.f_121201_.skip(); -+ this.f_121176_ = this::m_121341_; -+ this.m_121317_(); ++ this.suggestions = this::suggestOpenOptions; ++ if (this.reader.canRead() && this.reader.peek() == '[') { ++ this.reader.skip(); ++ this.suggestions = this::suggestOptionsKeyOrClose; ++ this.parseOptions(); + } + + } + } + - protected void m_121304_() throws CommandSyntaxException { - if (this.f_121201_.canRead()) { - this.f_121176_ = this::m_121309_; + protected void parseNameOrUUID() throws CommandSyntaxException { + if (this.reader.canRead()) { + this.suggestions = this::suggestName; @@ -461,6 +_,9 @@ } - this.f_121201_.skip(); + this.reader.skip(); + EntitySelector forgeSelector = net.minecraftforge.common.command.EntitySelectorManager.parseSelector(this); + if (forgeSelector != null) + return forgeSelector; - this.m_121281_(); + this.parseSelector(); } else { - this.m_121304_(); + this.parseNameOrUUID(); @@ -470,12 +_,36 @@ - return this.m_121230_(); + return this.getSelector(); } + // CraftBukkit start + public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { + // CraftBukkit end -+ this.f_121174_ = this.f_121201_.getCursor(); -+ this.f_121176_ = this::m_121286_; -+ if (this.f_121201_.canRead() && this.f_121201_.peek() == '@') { -+ if (!this.f_121202_) { -+ throw f_121192_.createWithContext(this.f_121201_); ++ this.startPosition = this.reader.getCursor(); ++ this.suggestions = this::suggestNameOrSelector; ++ if (this.reader.canRead() && this.reader.peek() == '@') { ++ if (!this.allowSelectors) { ++ throw ERROR_SELECTORS_NOT_ALLOWED.createWithContext(this.reader); + } + -+ this.f_121201_.skip(); ++ this.reader.skip(); + EntitySelector forgeSelector = net.minecraftforge.common.command.EntitySelectorManager.parseSelector(this); + if (forgeSelector != null) + return forgeSelector; + this.parseSelector(overridePermissions); // CraftBukkit + } else { -+ this.m_121304_(); ++ this.parseNameOrUUID(); + } + -+ this.m_121229_(); -+ return this.m_121230_(); ++ this.finalizePredicates(); ++ return this.getSelector(); + } + - private static void m_121247_(SuggestionsBuilder p_121248_) { + private static void fillSelectorSuggestions(SuggestionsBuilder p_121248_) { p_121248_.suggest("@p", new TranslatableComponent("argument.entity.selector.nearestPlayer")); p_121248_.suggest("@a", new TranslatableComponent("argument.entity.selector.allPlayers")); p_121248_.suggest("@r", new TranslatableComponent("argument.entity.selector.randomPlayer")); @@ -104,4 +104,4 @@ + net.minecraftforge.common.command.EntitySelectorManager.fillSelectorSuggestions(p_121248_); } - private CompletableFuture m_121286_(SuggestionsBuilder p_121287_, Consumer p_121288_) { + private CompletableFuture suggestNameOrSelector(SuggestionsBuilder p_121287_, Consumer p_121288_) { diff --git a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch index 3d64baa8..72859372 100644 --- a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch +++ b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypes.java.patch @@ -3,28 +3,28 @@ @@ -64,7 +_,7 @@ public class ArgumentTypes { - private static final Logger f_121582_ = LogUtils.getLogger(); -- private static final Map, ArgumentTypes.Entry> f_121583_ = Maps.newHashMap(); -+ public static final Map, ArgumentTypes.Entry> f_121583_ = Maps.newHashMap(); - private static final Map> f_121584_ = Maps.newHashMap(); + private static final Logger LOGGER = LogUtils.getLogger(); +- private static final Map, ArgumentTypes.Entry> BY_CLASS = Maps.newHashMap(); ++ public static final Map, ArgumentTypes.Entry> BY_CLASS = Maps.newHashMap(); + private static final Map> BY_NAME = Maps.newHashMap(); - public static > void m_121601_(String p_121602_, Class p_121603_, ArgumentSerializer p_121604_) { + public static > void register(String p_121602_, Class p_121603_, ArgumentSerializer p_121604_) { @@ -122,7 +_,7 @@ - m_121601_("uuid", UuidArgument.class, new EmptyArgumentSerializer<>(UuidArgument::m_113850_)); - m_121601_("resource", m_211031_(ResourceKeyArgument.class), new ResourceKeyArgument.Serializer()); - m_121601_("resource_or_tag", m_211031_(ResourceOrTagLocationArgument.class), new ResourceOrTagLocationArgument.Serializer()); -- if (SharedConstants.f_136183_) { + register("uuid", UuidArgument.class, new EmptyArgumentSerializer<>(UuidArgument::uuid)); + register("resource", fixClassType(ResourceKeyArgument.class), new ResourceKeyArgument.Serializer()); + register("resource_or_tag", fixClassType(ResourceOrTagLocationArgument.class), new ResourceOrTagLocationArgument.Serializer()); +- if (SharedConstants.IS_RUNNING_IN_IDE) { + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { - m_121601_("test_argument", TestFunctionArgument.class, new EmptyArgumentSerializer<>(TestFunctionArgument::m_128088_)); - m_121601_("test_class", TestClassNameArgument.class, new EmptyArgumentSerializer<>(TestClassNameArgument::m_127917_)); + register("test_argument", TestFunctionArgument.class, new EmptyArgumentSerializer<>(TestFunctionArgument::testFunctionArgument)); + register("test_class", TestClassNameArgument.class, new EmptyArgumentSerializer<>(TestClassNameArgument::testClassName)); } @@ -139,7 +_,7 @@ } @Nullable -- private static ArgumentTypes.Entry m_121616_(ArgumentType p_121617_) { -+ public static ArgumentTypes.Entry m_121616_(ArgumentType p_121617_) { - return f_121583_.get(p_121617_.getClass()); +- private static ArgumentTypes.Entry get(ArgumentType p_121617_) { ++ public static ArgumentTypes.Entry get(ArgumentType p_121617_) { + return BY_CLASS.get(p_121617_.getClass()); } @@ -254,7 +_,7 @@ @@ -33,16 +33,16 @@ - static class Entry> { + public static class Entry> { - public final ArgumentSerializer f_121619_; - public final ResourceLocation f_121620_; + public final ArgumentSerializer serializer; + public final ResourceLocation name; @@ -262,5 +_,9 @@ - this.f_121619_ = p_211034_; - this.f_121620_ = p_211035_; + this.serializer = p_211034_; + this.name = p_211035_; } + } + @javax.annotation.Nullable public static ResourceLocation getId(ArgumentType type) { -+ Entry entry = m_121616_(type); -+ return entry == null ? null : entry.f_121620_; ++ Entry entry = get(type); ++ return entry == null ? null : entry.name; } } diff --git a/patches/minecraft/net/minecraft/core/Holder.java.patch b/patches/minecraft/net/minecraft/core/Holder.java.patch index b2cea0f8..64201765 100644 --- a/patches/minecraft/net/minecraft/core/Holder.java.patch +++ b/patches/minecraft/net/minecraft/core/Holder.java.patch @@ -9,24 +9,24 @@ + + @Override + default Stream> getTagKeys() { -+ return this.m_203616_(); ++ return this.tags(); + } + + - T m_203334_(); + T value(); - boolean m_203633_(); + boolean isBound(); @@ -43,6 +_,12 @@ } - public static record Direct(T f_205714_) implements Holder { + public static record Direct(T value) implements Holder { + + @Override + public boolean containsTag(TagKey key) { -+ return m_203656_(key); ++ return is(key); + } + - public boolean m_203633_() { + public boolean isBound() { return true; } @@ -98,6 +_,10 @@ @@ -35,19 +35,19 @@ public static class Reference implements Holder { + @Override + public boolean containsTag(TagKey key) { -+ return m_203656_(key); ++ return is(key); + } - private final Registry f_205748_; - private Set> f_205749_ = Set.of(); - private final Holder.Reference.Type f_205750_; + private final Registry registry; + private Set> tags = Set.of(); + private final Holder.Reference.Type type; @@ -192,6 +_,10 @@ - public Stream> m_203616_() { - return this.f_205749_.stream(); + public Stream> tags() { + return this.tags.stream(); + } + + public Type getType() { -+ return this.f_205750_; ++ return this.type; } public String toString() { diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index 851cccdb..191fca2a 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java @@ -90,7 +_,8 @@ - this.f_122672_.size(Math.max(this.f_122672_.size(), p_205858_ + 1)); - this.f_122673_.put(p_205860_, p_205858_); - this.f_211051_ = null; -- if (p_205862_ && this.f_205842_.containsKey(p_205859_)) { + this.byId.size(Math.max(this.byId.size(), p_205858_ + 1)); + this.toId.put(p_205860_, p_205858_); + this.holdersInOrder = null; +- if (p_205862_ && this.byKey.containsKey(p_205859_)) { + // Forge: Fix bug where a key is considered a duplicate if getOrCreateHolder was called before the entry was registered -+ if (p_205862_ && this.f_205842_.containsKey(p_205859_) && this.f_205842_.get(p_205859_).m_203633_()) { - Util.m_143785_("Adding duplicate key '" + p_205859_ + "' to registry"); ++ if (p_205862_ && this.byKey.containsKey(p_205859_) && this.byKey.get(p_205859_).isBound()) { + Util.logAndPauseIfInIde("Adding duplicate key '" + p_205859_ + "' to registry"); } @@ -277,6 +_,14 @@ - public boolean m_142003_(ResourceKey p_175392_) { - return this.f_205842_.containsKey(p_175392_); + public boolean containsKey(ResourceKey p_175392_) { + return this.byKey.containsKey(p_175392_); + } + + /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ + @Deprecated + public void unfreeze() { -+ this.f_205845_ = false; -+ if (this.f_205846_ != null && this.f_205847_ == null) -+ this.f_205847_ = new IdentityHashMap<>(); ++ this.frozen = false; ++ if (this.customHolderProvider != null && this.intrusiveHolderCache == null) ++ this.intrusiveHolderCache = new IdentityHashMap<>(); } - public Registry m_203521_() { + public Registry freeze() { diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch index 7d1e99ba..0e35421d 100644 --- a/patches/minecraft/net/minecraft/core/Registry.java.patch +++ b/patches/minecraft/net/minecraft/core/Registry.java.patch @@ -9,187 +9,187 @@ + * We will be wrapping all of these in our API as necessary for syncing and management. + */ public abstract class Registry implements Keyable, IdMap { - private static final Logger f_122894_ = LogUtils.getLogger(); - private static final Map> f_122834_ = Maps.newLinkedHashMap(); + private static final Logger LOGGER = LogUtils.getLogger(); + private static final Map> LOADERS = Maps.newLinkedHashMap(); @@ -163,43 +_,43 @@ - public static final DefaultedRegistry f_175412_ = m_206031_(f_175423_, "step", GameEvent::m_204530_, (p_206044_) -> { - return GameEvent.f_157785_; + public static final DefaultedRegistry GAME_EVENT = registerDefaulted(GAME_EVENT_REGISTRY, "step", GameEvent::builtInRegistryHolder, (p_206044_) -> { + return GameEvent.STEP; }); -- public static final Registry f_122821_ = m_206008_(f_122898_, (p_206042_) -> { -+ @Deprecated public static final Registry f_122821_ = forge(f_122898_, (registry) -> { - return SoundEvents.f_12019_; +- public static final Registry SOUND_EVENT = registerSimple(SOUND_EVENT_REGISTRY, (p_206042_) -> { ++ @Deprecated public static final Registry SOUND_EVENT = forge(SOUND_EVENT_REGISTRY, (registry) -> { + return SoundEvents.ITEM_PICKUP; }); -- public static final DefaultedRegistry f_122822_ = m_206031_(f_122899_, "empty", Fluid::m_205069_, (p_206040_) -> { -+ @Deprecated public static final DefaultedRegistry f_122822_ = forge(f_122899_, "empty", (registry) -> { - return Fluids.f_76191_; +- public static final DefaultedRegistry FLUID = registerDefaulted(FLUID_REGISTRY, "empty", Fluid::builtInRegistryHolder, (p_206040_) -> { ++ @Deprecated public static final DefaultedRegistry FLUID = forge(FLUID_REGISTRY, "empty", (registry) -> { + return Fluids.EMPTY; }); -- public static final Registry f_122823_ = m_206008_(f_122900_, (p_205982_) -> { -+ @Deprecated public static final Registry f_122823_ = forge(f_122900_, (registry) -> { - return MobEffects.f_19621_; +- public static final Registry MOB_EFFECT = registerSimple(MOB_EFFECT_REGISTRY, (p_205982_) -> { ++ @Deprecated public static final Registry MOB_EFFECT = forge(MOB_EFFECT_REGISTRY, (registry) -> { + return MobEffects.LUCK; }); -- public static final DefaultedRegistry f_122824_ = m_206031_(f_122901_, "air", Block::m_204297_, (p_205980_) -> { -+ @Deprecated public static final DefaultedRegistry f_122824_ = forge(f_122901_, "air", (registry) -> { - return Blocks.f_50016_; +- public static final DefaultedRegistry BLOCK = registerDefaulted(BLOCK_REGISTRY, "air", Block::builtInRegistryHolder, (p_205980_) -> { ++ @Deprecated public static final DefaultedRegistry BLOCK = forge(BLOCK_REGISTRY, "air", (registry) -> { + return Blocks.AIR; }); -- public static final Registry f_122825_ = m_206008_(f_122902_, (p_205978_) -> { -+ @Deprecated public static final Registry f_122825_ = forge(f_122902_, (registry) -> { - return Enchantments.f_44987_; +- public static final Registry ENCHANTMENT = registerSimple(ENCHANTMENT_REGISTRY, (p_205978_) -> { ++ @Deprecated public static final Registry ENCHANTMENT = forge(ENCHANTMENT_REGISTRY, (registry) -> { + return Enchantments.BLOCK_FORTUNE; }); -- public static final DefaultedRegistry> f_122826_ = m_206031_(f_122903_, "pig", EntityType::m_204041_, (p_205976_) -> { -+ @Deprecated public static final DefaultedRegistry> f_122826_ = forge(f_122903_, "pig", (registry) -> { - return EntityType.f_20510_; +- public static final DefaultedRegistry> ENTITY_TYPE = registerDefaulted(ENTITY_TYPE_REGISTRY, "pig", EntityType::builtInRegistryHolder, (p_205976_) -> { ++ @Deprecated public static final DefaultedRegistry> ENTITY_TYPE = forge(ENTITY_TYPE_REGISTRY, "pig", (registry) -> { + return EntityType.PIG; }); -- public static final DefaultedRegistry f_122827_ = m_206031_(f_122904_, "air", Item::m_204114_, (p_205974_) -> { -+ @Deprecated public static final DefaultedRegistry f_122827_ = forge(f_122904_, "air", (registry) -> { - return Items.f_41852_; +- public static final DefaultedRegistry ITEM = registerDefaulted(ITEM_REGISTRY, "air", Item::builtInRegistryHolder, (p_205974_) -> { ++ @Deprecated public static final DefaultedRegistry ITEM = forge(ITEM_REGISTRY, "air", (registry) -> { + return Items.AIR; }); -- public static final DefaultedRegistry f_122828_ = m_206027_(f_122905_, "empty", (p_205972_) -> { -+ @Deprecated public static final DefaultedRegistry f_122828_ = forge(f_122905_, "empty", (registry) -> { - return Potions.f_43598_; +- public static final DefaultedRegistry POTION = registerDefaulted(POTION_REGISTRY, "empty", (p_205972_) -> { ++ @Deprecated public static final DefaultedRegistry POTION = forge(POTION_REGISTRY, "empty", (registry) -> { + return Potions.EMPTY; }); -- public static final Registry> f_122829_ = m_206008_(f_122906_, (p_205970_) -> { -+ @Deprecated public static final Registry> f_122829_ = forge(f_122906_, (registry) -> { - return ParticleTypes.f_123794_; +- public static final Registry> PARTICLE_TYPE = registerSimple(PARTICLE_TYPE_REGISTRY, (p_205970_) -> { ++ @Deprecated public static final Registry> PARTICLE_TYPE = forge(PARTICLE_TYPE_REGISTRY, (registry) -> { + return ParticleTypes.BLOCK; }); -- public static final Registry> f_122830_ = m_206008_(f_122907_, (p_205968_) -> { -+ @Deprecated public static final Registry> f_122830_ = forge(f_122907_, (registry) -> { - return BlockEntityType.f_58917_; +- public static final Registry> BLOCK_ENTITY_TYPE = registerSimple(BLOCK_ENTITY_TYPE_REGISTRY, (p_205968_) -> { ++ @Deprecated public static final Registry> BLOCK_ENTITY_TYPE = forge(BLOCK_ENTITY_TYPE_REGISTRY, (registry) -> { + return BlockEntityType.FURNACE; }); -- public static final DefaultedRegistry f_122831_ = m_206027_(f_122908_, "kebab", (p_205966_) -> { -+ @Deprecated public static final DefaultedRegistry f_122831_ = forge(f_122908_, "kebab", (registry) -> { - return Motive.f_31866_; +- public static final DefaultedRegistry MOTIVE = registerDefaulted(MOTIVE_REGISTRY, "kebab", (p_205966_) -> { ++ @Deprecated public static final DefaultedRegistry MOTIVE = forge(MOTIVE_REGISTRY, "kebab", (registry) -> { + return Motive.KEBAB; }); - public static final Registry f_122832_ = m_206008_(f_122909_, (p_205964_) -> { - return Stats.f_12926_; + public static final Registry CUSTOM_STAT = registerSimple(CUSTOM_STAT_REGISTRY, (p_205964_) -> { + return Stats.JUMP; }); -- public static final DefaultedRegistry f_122833_ = m_206027_(f_122910_, "empty", (p_205962_) -> { -+ @Deprecated public static final DefaultedRegistry f_122833_ = forge(f_122910_, "empty", (registry) -> { - return ChunkStatus.f_62314_; +- public static final DefaultedRegistry CHUNK_STATUS = registerDefaulted(CHUNK_STATUS_REGISTRY, "empty", (p_205962_) -> { ++ @Deprecated public static final DefaultedRegistry CHUNK_STATUS = forge(CHUNK_STATUS_REGISTRY, "empty", (registry) -> { + return ChunkStatus.EMPTY; }); - public static final Registry> f_122861_ = m_206008_(f_122911_, (p_205960_) -> { + public static final Registry> RULE_TEST = registerSimple(RULE_TEST_REGISTRY, (p_205960_) -> { @@ -208,43 +_,43 @@ - public static final Registry> f_122862_ = m_206008_(f_122912_, (p_205958_) -> { - return PosRuleTestType.f_74205_; + public static final Registry> POS_RULE_TEST = registerSimple(POS_RULE_TEST_REGISTRY, (p_205958_) -> { + return PosRuleTestType.ALWAYS_TRUE_TEST; }); -- public static final Registry> f_122863_ = m_206008_(f_122913_, (p_205956_) -> { -+ @Deprecated public static final Registry> f_122863_ = forge(f_122913_, (registry) -> { - return MenuType.f_39964_; +- public static final Registry> MENU = registerSimple(MENU_REGISTRY, (p_205956_) -> { ++ @Deprecated public static final Registry> MENU = forge(MENU_REGISTRY, (registry) -> { + return MenuType.ANVIL; }); - public static final Registry> f_122864_ = m_206008_(f_122914_, (p_205954_) -> { - return RecipeType.f_44107_; + public static final Registry> RECIPE_TYPE = registerSimple(RECIPE_TYPE_REGISTRY, (p_205954_) -> { + return RecipeType.CRAFTING; }); -- public static final Registry> f_122865_ = m_206008_(f_122915_, (p_205952_) -> { -+ @Deprecated public static final Registry> f_122865_ = forge(f_122915_, (registry) -> { - return RecipeSerializer.f_44077_; +- public static final Registry> RECIPE_SERIALIZER = registerSimple(RECIPE_SERIALIZER_REGISTRY, (p_205952_) -> { ++ @Deprecated public static final Registry> RECIPE_SERIALIZER = forge(RECIPE_SERIALIZER_REGISTRY, (registry) -> { + return RecipeSerializer.SHAPELESS_RECIPE; }); -- public static final Registry f_122866_ = m_206008_(f_122916_, (p_205950_) -> { -+ @Deprecated public static final Registry f_122866_ = forge(f_122916_, (registry) -> { - return Attributes.f_22286_; +- public static final Registry ATTRIBUTE = registerSimple(ATTRIBUTE_REGISTRY, (p_205950_) -> { ++ @Deprecated public static final Registry ATTRIBUTE = forge(ATTRIBUTE_REGISTRY, (registry) -> { + return Attributes.LUCK; }); - public static final Registry> f_175420_ = m_206008_(f_175408_, (p_205948_) -> { - return PositionSourceType.f_157871_; + public static final Registry> POSITION_SOURCE_TYPE = registerSimple(POSITION_SOURCE_TYPE_REGISTRY, (p_205948_) -> { + return PositionSourceType.BLOCK; }); -- public static final Registry> f_122867_ = m_206008_(f_122917_, (p_205946_) -> { -+ @Deprecated public static final Registry> f_122867_ = forge(f_122917_, (registry) -> { - return Stats.f_12982_; +- public static final Registry> STAT_TYPE = registerSimple(STAT_TYPE_REGISTRY, (p_205946_) -> { ++ @Deprecated public static final Registry> STAT_TYPE = forge(STAT_TYPE_REGISTRY, (registry) -> { + return Stats.ITEM_USED; }); - public static final DefaultedRegistry f_122868_ = m_206027_(f_122808_, "plains", (p_205944_) -> { - return VillagerType.f_35821_; + public static final DefaultedRegistry VILLAGER_TYPE = registerDefaulted(VILLAGER_TYPE_REGISTRY, "plains", (p_205944_) -> { + return VillagerType.PLAINS; }); -- public static final DefaultedRegistry f_122869_ = m_206027_(f_122809_, "none", (p_205942_) -> { -+ @Deprecated public static final DefaultedRegistry f_122869_ = forge(f_122809_, "none", (registry) -> { - return VillagerProfession.f_35585_; +- public static final DefaultedRegistry VILLAGER_PROFESSION = registerDefaulted(VILLAGER_PROFESSION_REGISTRY, "none", (p_205942_) -> { ++ @Deprecated public static final DefaultedRegistry VILLAGER_PROFESSION = forge(VILLAGER_PROFESSION_REGISTRY, "none", (registry) -> { + return VillagerProfession.NONE; }); -- public static final DefaultedRegistry f_122870_ = m_206027_(f_122810_, "unemployed", (p_205940_) -> { -+ @Deprecated public static final DefaultedRegistry f_122870_ = forge(f_122810_, "unemployed", (registry) -> { - return PoiType.f_27331_; +- public static final DefaultedRegistry POINT_OF_INTEREST_TYPE = registerDefaulted(POINT_OF_INTEREST_TYPE_REGISTRY, "unemployed", (p_205940_) -> { ++ @Deprecated public static final DefaultedRegistry POINT_OF_INTEREST_TYPE = forge(POINT_OF_INTEREST_TYPE_REGISTRY, "unemployed", (registry) -> { + return PoiType.UNEMPLOYED; }); -- public static final DefaultedRegistry> f_122871_ = m_206027_(f_122811_, "dummy", (p_205938_) -> { -+ @Deprecated public static final DefaultedRegistry> f_122871_ = forge(f_122811_, "dummy", (registry) -> { - return MemoryModuleType.f_26349_; +- public static final DefaultedRegistry> MEMORY_MODULE_TYPE = registerDefaulted(MEMORY_MODULE_TYPE_REGISTRY, "dummy", (p_205938_) -> { ++ @Deprecated public static final DefaultedRegistry> MEMORY_MODULE_TYPE = forge(MEMORY_MODULE_TYPE_REGISTRY, "dummy", (registry) -> { + return MemoryModuleType.DUMMY; }); -- public static final DefaultedRegistry> f_122872_ = m_206027_(f_122812_, "dummy", (p_205936_) -> { -+ @Deprecated public static final DefaultedRegistry> f_122872_ = forge(f_122812_, "dummy", (registry) -> { - return SensorType.f_26809_; +- public static final DefaultedRegistry> SENSOR_TYPE = registerDefaulted(SENSOR_TYPE_REGISTRY, "dummy", (p_205936_) -> { ++ @Deprecated public static final DefaultedRegistry> SENSOR_TYPE = forge(SENSOR_TYPE_REGISTRY, "dummy", (registry) -> { + return SensorType.DUMMY; }); -- public static final Registry f_122873_ = m_206008_(f_122813_, (p_205934_) -> { -+ @Deprecated public static final Registry f_122873_ = forge(f_122813_, (registry) -> { - return Schedule.f_38012_; +- public static final Registry SCHEDULE = registerSimple(SCHEDULE_REGISTRY, (p_205934_) -> { ++ @Deprecated public static final Registry SCHEDULE = forge(SCHEDULE_REGISTRY, (registry) -> { + return Schedule.EMPTY; }); -- public static final Registry f_122874_ = m_206008_(f_122814_, (p_205932_) -> { -+ @Deprecated public static final Registry f_122874_ = forge(f_122814_, (registry) -> { - return Activity.f_37979_; +- public static final Registry ACTIVITY = registerSimple(ACTIVITY_REGISTRY, (p_205932_) -> { ++ @Deprecated public static final Registry ACTIVITY = forge(ACTIVITY_REGISTRY, (registry) -> { + return Activity.IDLE; }); - public static final Registry f_122875_ = m_206008_(f_122815_, (p_206133_) -> { + public static final Registry LOOT_POOL_ENTRY_TYPE = registerSimple(LOOT_ENTRY_REGISTRY, (p_206133_) -> { @@ -293,15 +_,15 @@ - public static final ResourceKey> f_194568_ = m_122978_("worldgen/noise"); - public static final ResourceKey> f_211074_ = m_122978_("worldgen/density_function"); - public static final ResourceKey>> f_122836_ = m_122978_("worldgen/carver"); -- public static final Registry> f_122837_ = m_206008_(f_122836_, (p_206112_) -> { -+ @Deprecated public static final Registry> f_122837_ = forge(f_122836_, (registry) -> { - return WorldCarver.f_64974_; - }); - public static final ResourceKey>> f_122838_ = m_122978_("worldgen/feature"); -- public static final Registry> f_122839_ = m_206008_(f_122838_, (p_206109_) -> { -+ @Deprecated public static final Registry> f_122839_ = forge(f_122838_, (registry) -> { - return Feature.f_65731_; - }); - public static final ResourceKey>> f_122840_ = m_122978_("worldgen/structure_feature"); -- public static final Registry> f_122841_ = m_206008_(f_122840_, (p_206107_) -> { -+ @Deprecated public static final Registry> f_122841_ = forge(f_122840_, (registry) -> { - return StructureFeature.f_67014_; - }); - public static final ResourceKey>> f_205929_ = m_122978_("worldgen/structure_placement"); + public static final ResourceKey> NOISE_REGISTRY = createRegistryKey("worldgen/noise"); + public static final ResourceKey> DENSITY_FUNCTION_REGISTRY = createRegistryKey("worldgen/density_function"); + public static final ResourceKey>> CARVER_REGISTRY = createRegistryKey("worldgen/carver"); +- public static final Registry> CARVER = registerSimple(CARVER_REGISTRY, (p_206112_) -> { ++ @Deprecated public static final Registry> CARVER = forge(CARVER_REGISTRY, (registry) -> { + return WorldCarver.CAVE; + }); + public static final ResourceKey>> FEATURE_REGISTRY = createRegistryKey("worldgen/feature"); +- public static final Registry> FEATURE = registerSimple(FEATURE_REGISTRY, (p_206109_) -> { ++ @Deprecated public static final Registry> FEATURE = forge(FEATURE_REGISTRY, (registry) -> { + return Feature.ORE; + }); + public static final ResourceKey>> STRUCTURE_FEATURE_REGISTRY = createRegistryKey("worldgen/structure_feature"); +- public static final Registry> STRUCTURE_FEATURE = registerSimple(STRUCTURE_FEATURE_REGISTRY, (p_206107_) -> { ++ @Deprecated public static final Registry> STRUCTURE_FEATURE = forge(STRUCTURE_FEATURE_REGISTRY, (registry) -> { + return StructureFeature.MINESHAFT; + }); + public static final ResourceKey>> STRUCTURE_PLACEMENT_TYPE_REGISTRY = createRegistryKey("worldgen/structure_placement"); @@ -328,16 +_,16 @@ - public static final ResourceKey>> f_211075_ = m_122978_("worldgen/density_function_type"); - public static final ResourceKey>> f_122854_ = m_122978_("worldgen/structure_processor"); - public static final ResourceKey>> f_122855_ = m_122978_("worldgen/structure_pool_element"); -- public static final Registry> f_122856_ = m_206008_(f_122846_, (p_206098_) -> { -+ @Deprecated public static final Registry> f_122856_ = forge(f_122846_, (registry) -> { - return BlockStateProviderType.f_68752_; + public static final ResourceKey>> DENSITY_FUNCTION_TYPE_REGISTRY = createRegistryKey("worldgen/density_function_type"); + public static final ResourceKey>> STRUCTURE_PROCESSOR_REGISTRY = createRegistryKey("worldgen/structure_processor"); + public static final ResourceKey>> STRUCTURE_POOL_ELEMENT_REGISTRY = createRegistryKey("worldgen/structure_pool_element"); +- public static final Registry> BLOCKSTATE_PROVIDER_TYPES = registerSimple(BLOCK_STATE_PROVIDER_TYPE_REGISTRY, (p_206098_) -> { ++ @Deprecated public static final Registry> BLOCKSTATE_PROVIDER_TYPES = forge(BLOCK_STATE_PROVIDER_TYPE_REGISTRY, (registry) -> { + return BlockStateProviderType.SIMPLE_STATE_PROVIDER; }); -- public static final Registry> f_122858_ = m_206008_(f_122848_, (p_206092_) -> { -+ @Deprecated public static final Registry> f_122858_ = forge(f_122848_, (registry) -> { - return FoliagePlacerType.f_68591_; +- public static final Registry> FOLIAGE_PLACER_TYPES = registerSimple(FOLIAGE_PLACER_TYPE_REGISTRY, (p_206092_) -> { ++ @Deprecated public static final Registry> FOLIAGE_PLACER_TYPES = forge(FOLIAGE_PLACER_TYPE_REGISTRY, (registry) -> { + return FoliagePlacerType.BLOB_FOLIAGE_PLACER; }); - public static final Registry> f_122859_ = m_206008_(f_122849_, (p_206086_) -> { - return TrunkPlacerType.f_70315_; + public static final Registry> TRUNK_PLACER_TYPES = registerSimple(TRUNK_PLACER_TYPE_REGISTRY, (p_206086_) -> { + return TrunkPlacerType.STRAIGHT_TRUNK_PLACER; }); -- public static final Registry> f_122860_ = m_206008_(f_122850_, (p_206078_) -> { -+ @Deprecated public static final Registry> f_122860_ = forge(f_122850_, (registry) -> { - return TreeDecoratorType.f_70043_; +- public static final Registry> TREE_DECORATOR_TYPES = registerSimple(TREE_DECORATOR_TYPE_REGISTRY, (p_206078_) -> { ++ @Deprecated public static final Registry> TREE_DECORATOR_TYPES = forge(TREE_DECORATOR_TYPE_REGISTRY, (registry) -> { + return TreeDecoratorType.LEAVE_VINE; }); - public static final Registry> f_122888_ = m_206008_(f_122851_, (p_206072_) -> { + public static final Registry> FEATURE_SIZE_TYPES = registerSimple(FEATURE_SIZE_TYPE_REGISTRY, (p_206072_) -> { @@ -383,16 +_,32 @@ - return m_205999_(p_206009_, Lifecycle.experimental(), p_206010_); + return registerSimple(p_206009_, Lifecycle.experimental(), p_206010_); } + private static > Registry forge(ResourceKey> key, Registry.RegistryBootstrap def) { + return forge(key, Lifecycle.experimental(), def); + } + - private static DefaultedRegistry m_206027_(ResourceKey> p_206028_, String p_206029_, Registry.RegistryBootstrap p_206030_) { - return m_206016_(p_206028_, p_206029_, Lifecycle.experimental(), p_206030_); + private static DefaultedRegistry registerDefaulted(ResourceKey> p_206028_, String p_206029_, Registry.RegistryBootstrap p_206030_) { + return registerDefaulted(p_206028_, p_206029_, Lifecycle.experimental(), p_206030_); } + private static > DefaultedRegistry forge(ResourceKey> key, String defKey, Registry.RegistryBootstrap def) { + return forge(key, defKey, Lifecycle.experimental(), def); + } + - private static DefaultedRegistry m_206031_(ResourceKey> p_206032_, String p_206033_, Function> p_206034_, Registry.RegistryBootstrap p_206035_) { - return m_206021_(p_206032_, p_206033_, Lifecycle.experimental(), p_206034_, p_206035_); + private static DefaultedRegistry registerDefaulted(ResourceKey> p_206032_, String p_206033_, Function> p_206034_, Registry.RegistryBootstrap p_206035_) { + return registerDefaulted(p_206032_, p_206033_, Lifecycle.experimental(), p_206034_, p_206035_); } + private static > Registry forge(ResourceKey> key, Lifecycle cycle, Registry.RegistryBootstrap def) { -+ return m_206011_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle), def, cycle); ++ return internalRegister(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle), def, cycle); + } + - private static Registry m_205999_(ResourceKey> p_206000_, Lifecycle p_206001_, Registry.RegistryBootstrap p_206002_) { - return m_206011_(p_206000_, new MappedRegistry<>(p_206000_, p_206001_, (Function>)null), p_206002_, p_206001_); + private static Registry registerSimple(ResourceKey> p_206000_, Lifecycle p_206001_, Registry.RegistryBootstrap p_206002_) { + return internalRegister(p_206000_, new MappedRegistry<>(p_206000_, p_206001_, (Function>)null), p_206002_, p_206001_); + } + + private static > DefaultedRegistry forge(ResourceKey> key, String defKey, Lifecycle cycle, Registry.RegistryBootstrap def) { -+ return m_206011_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle, defKey), def, cycle); ++ return internalRegister(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle, defKey), def, cycle); } - private static Registry m_206003_(ResourceKey> p_206004_, Lifecycle p_206005_, Function> p_206006_, Registry.RegistryBootstrap p_206007_) { + private static Registry registerSimple(ResourceKey> p_206004_, Lifecycle p_206005_, Function> p_206006_, Registry.RegistryBootstrap p_206007_) { diff --git a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch index 30430348..dc688226 100644 --- a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/core/RegistryAccess.java +++ b/net/minecraft/core/RegistryAccess.java @@ -58,7 +_,7 @@ - m_123053_(builder, Registry.f_122878_, NoiseGeneratorSettings.f_64430_); - m_123053_(builder, Registry.f_194568_, NormalNoise.NoiseParameters.f_192851_); - m_123053_(builder, Registry.f_211074_, DensityFunction.f_208216_); + put(builder, Registry.NOISE_GENERATOR_SETTINGS_REGISTRY, NoiseGeneratorSettings.DIRECT_CODEC); + put(builder, Registry.NOISE_REGISTRY, NormalNoise.NoiseParameters.DIRECT_CODEC); + put(builder, Registry.DENSITY_FUNCTION_REGISTRY, DensityFunction.DIRECT_CODEC); - return builder.build(); + return net.minecraftforge.registries.DataPackRegistriesHooks.grabBuiltinRegistries(builder); // FORGE: Keep the map so custom registries can be added later }); - Codec f_206151_ = m_206205_(); - Supplier f_123049_ = Suppliers.memoize(() -> { + Codec NETWORK_CODEC = makeNetworkCodec(); + Supplier BUILTIN = Suppliers.memoize(() -> { diff --git a/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch b/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch index aa101f2f..53e24fd8 100644 --- a/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch @@ -3,10 +3,10 @@ @@ -95,7 +_,8 @@ } - private static Codec, T>> m_206315_(ResourceKey> p_206316_, Codec p_206317_) { -- return Codec.unboundedMap(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_206316_), ResourceKey::m_135782_), p_206317_); + private static Codec, T>> directCodec(ResourceKey> p_206316_, Codec p_206317_) { +- return Codec.unboundedMap(ResourceLocation.CODEC.xmap(ResourceKey.elementKey(p_206316_), ResourceKey::location), p_206317_); + // FORGE: Fix MC-197860 -+ return new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_206316_), ResourceKey::m_135782_), p_206317_); ++ return new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceLocation.CODEC.xmap(ResourceKey.elementKey(p_206316_), ResourceKey::location), p_206317_); } - public static Codec> m_206279_(ResourceKey> p_206280_, Codec p_206281_) { + public static Codec> homogeneousList(ResourceKey> p_206280_, Codec p_206281_) { diff --git a/patches/minecraft/net/minecraft/core/cauldron/CauldronInteraction.java.patch b/patches/minecraft/net/minecraft/core/cauldron/CauldronInteraction.java.patch index 72ccc84c..2f268f19 100644 --- a/patches/minecraft/net/minecraft/core/cauldron/CauldronInteraction.java.patch +++ b/patches/minecraft/net/minecraft/core/cauldron/CauldronInteraction.java.patch @@ -3,126 +3,126 @@ @@ -49,6 +_,11 @@ return InteractionResult.PASS; } else { - if (!p_175663_.f_46443_) { + if (!p_175663_.isClientSide) { + //Craftbukkit start + if(!LayeredCauldronBlock.lowerFillLevel(p_175662_, p_175663_, p_175664_, p_175665_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)){ + return InteractionResult.SUCCESS; + } + //Craftbukkit end - ItemStack itemstack = new ItemStack(Blocks.f_50456_); - if (p_175667_.m_41782_()) { - itemstack.m_41751_(p_175667_.m_41783_().m_6426_()); + ItemStack itemstack = new ItemStack(Blocks.SHULKER_BOX); + if (p_175667_.hasTag()) { + itemstack.setTag(p_175667_.getTag().copy()); @@ -56,7 +_,7 @@ - p_175665_.m_21008_(p_175666_, itemstack); - p_175665_.m_36220_(Stats.f_12947_); -- LayeredCauldronBlock.m_153559_(p_175662_, p_175663_, p_175664_); + p_175665_.setItemInHand(p_175666_, itemstack); + p_175665_.awardStat(Stats.CLEAN_SHULKER_BOX); +- LayeredCauldronBlock.lowerFillLevel(p_175662_, p_175663_, p_175664_); + //LayeredCauldronBlock.lowerFillLevel(p_175662_, p_175663_, p_175664_); // CraftBukkit } - return InteractionResult.m_19078_(p_175663_.f_46443_); + return InteractionResult.sidedSuccess(p_175663_.isClientSide); @@ -99,9 +_,14 @@ return InteractionResult.PASS; } else { - if (!p_175630_.f_46443_) { + if (!p_175630_.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.lowerFillLevel(p_175629_, p_175630_, p_175631_, p_175632_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { + return InteractionResult.SUCCESS; + } + // CraftBukkit end - dyeableleatheritem.m_41123_(p_175634_); - p_175632_.m_36220_(Stats.f_12945_); -- LayeredCauldronBlock.m_153559_(p_175629_, p_175630_, p_175631_); + dyeableleatheritem.clearColor(p_175634_); + p_175632_.awardStat(Stats.CLEAN_ARMOR); +- LayeredCauldronBlock.lowerFillLevel(p_175629_, p_175630_, p_175631_); + //LayeredCauldronBlock.lowerFillLevel(p_175629_, p_175630_, p_175631_); // CraftBukkit } - return InteractionResult.m_19078_(p_175630_.f_46443_); + return InteractionResult.sidedSuccess(p_175630_.isClientSide); @@ -126,11 +_,16 @@ return InteractionResult.PASS; } else { - if (!p_175733_.f_46443_) { + if (!p_175733_.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(p_175732_, p_175733_, p_175734_, Blocks.f_152476_.m_49966_(), p_175735_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { ++ if (!LayeredCauldronBlock.changeLevel(p_175732_, p_175733_, p_175734_, Blocks.WATER_CAULDRON.defaultBlockState(), p_175735_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { + return InteractionResult.SUCCESS; + } + // CraftBukkit end - Item item = p_175737_.m_41720_(); - p_175735_.m_21008_(p_175736_, ItemUtils.m_41813_(p_175737_, p_175735_, new ItemStack(Items.f_42590_))); - p_175735_.m_36220_(Stats.f_12944_); - p_175735_.m_36246_(Stats.f_12982_.m_12902_(item)); -- p_175733_.m_46597_(p_175734_, Blocks.f_152476_.m_49966_()); + Item item = p_175737_.getItem(); + p_175735_.setItemInHand(p_175736_, ItemUtils.createFilledResult(p_175737_, p_175735_, new ItemStack(Items.GLASS_BOTTLE))); + p_175735_.awardStat(Stats.USE_CAULDRON); + p_175735_.awardStat(Stats.ITEM_USED.get(item)); +- p_175733_.setBlockAndUpdate(p_175734_, Blocks.WATER_CAULDRON.defaultBlockState()); + // p_175733_.setBlockAndUpdate(p_175734_, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit - p_175733_.m_5594_((Player)null, p_175734_, SoundEvents.f_11769_, SoundSource.BLOCKS, 1.0F, 1.0F); - p_175733_.m_142346_((Entity)null, GameEvent.f_157769_, p_175734_); + p_175733_.playSound((Player)null, p_175734_, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); + p_175733_.gameEvent((Entity)null, GameEvent.FLUID_PLACE, p_175734_); } @@ -146,11 +_,16 @@ }); - f_175607_.put(Items.f_42590_, (p_175718_, p_175719_, p_175720_, p_175721_, p_175722_, p_175723_) -> { - if (!p_175719_.f_46443_) { + WATER.put(Items.GLASS_BOTTLE, (p_175718_, p_175719_, p_175720_, p_175721_, p_175722_, p_175723_) -> { + if (!p_175719_.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.lowerFillLevel(p_175718_, p_175719_, p_175720_, p_175721_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { + return InteractionResult.SUCCESS; + } + // CraftBukkit end - Item item = p_175723_.m_41720_(); - p_175721_.m_21008_(p_175722_, ItemUtils.m_41813_(p_175723_, p_175721_, PotionUtils.m_43549_(new ItemStack(Items.f_42589_), Potions.f_43599_))); - p_175721_.m_36220_(Stats.f_12944_); - p_175721_.m_36246_(Stats.f_12982_.m_12902_(item)); -- LayeredCauldronBlock.m_153559_(p_175718_, p_175719_, p_175720_); + Item item = p_175723_.getItem(); + p_175721_.setItemInHand(p_175722_, ItemUtils.createFilledResult(p_175723_, p_175721_, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER))); + p_175721_.awardStat(Stats.USE_CAULDRON); + p_175721_.awardStat(Stats.ITEM_USED.get(item)); +- LayeredCauldronBlock.lowerFillLevel(p_175718_, p_175719_, p_175720_); + //LayeredCauldronBlock.lowerFillLevel(p_175718_, p_175719_, p_175720_); // CraftBukkit - p_175719_.m_5594_((Player)null, p_175720_, SoundEvents.f_11770_, SoundSource.BLOCKS, 1.0F, 1.0F); - p_175719_.m_142346_((Entity)null, GameEvent.f_157816_, p_175720_); + p_175719_.playSound((Player)null, p_175720_, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1.0F, 1.0F); + p_175719_.gameEvent((Entity)null, GameEvent.FLUID_PICKUP, p_175720_); } @@ -160,10 +_,15 @@ - f_175607_.put(Items.f_42589_, (p_175704_, p_175705_, p_175706_, p_175707_, p_175708_, p_175709_) -> { - if (p_175704_.m_61143_(LayeredCauldronBlock.f_153514_) != 3 && PotionUtils.m_43579_(p_175709_) == Potions.f_43599_) { - if (!p_175705_.f_46443_) { + WATER.put(Items.POTION, (p_175704_, p_175705_, p_175706_, p_175707_, p_175708_, p_175709_) -> { + if (p_175704_.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtils.getPotion(p_175709_) == Potions.WATER) { + if (!p_175705_.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(p_175704_, p_175705_, p_175706_, p_175704_.m_61122_(LayeredCauldronBlock.f_153514_), p_175707_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { ++ if (!LayeredCauldronBlock.changeLevel(p_175704_, p_175705_, p_175706_, p_175704_.cycle(LayeredCauldronBlock.LEVEL), p_175707_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { + return InteractionResult.SUCCESS; + } + // CraftBukkit end - p_175707_.m_21008_(p_175708_, ItemUtils.m_41813_(p_175709_, p_175707_, new ItemStack(Items.f_42590_))); - p_175707_.m_36220_(Stats.f_12944_); - p_175707_.m_36246_(Stats.f_12982_.m_12902_(p_175709_.m_41720_())); -- p_175705_.m_46597_(p_175706_, p_175704_.m_61122_(LayeredCauldronBlock.f_153514_)); + p_175707_.setItemInHand(p_175708_, ItemUtils.createFilledResult(p_175709_, p_175707_, new ItemStack(Items.GLASS_BOTTLE))); + p_175707_.awardStat(Stats.USE_CAULDRON); + p_175707_.awardStat(Stats.ITEM_USED.get(p_175709_.getItem())); +- p_175705_.setBlockAndUpdate(p_175706_, p_175704_.cycle(LayeredCauldronBlock.LEVEL)); + //p_175705_.setBlockAndUpdate(p_175706_, p_175704_.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit - p_175705_.m_5594_((Player)null, p_175706_, SoundEvents.f_11769_, SoundSource.BLOCKS, 1.0F, 1.0F); - p_175705_.m_142346_((Entity)null, GameEvent.f_157769_, p_175706_); + p_175705_.playSound((Player)null, p_175706_, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); + p_175705_.gameEvent((Entity)null, GameEvent.FLUID_PLACE, p_175706_); } @@ -235,11 +_,16 @@ return InteractionResult.PASS; } else { - if (!p_175637_.f_46443_) { + if (!p_175637_.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(p_175636_, p_175637_, p_175638_, Blocks.f_50256_.m_49966_(), p_175639_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { ++ if (!LayeredCauldronBlock.changeLevel(p_175636_, p_175637_, p_175638_, Blocks.CAULDRON.defaultBlockState(), p_175639_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { + return InteractionResult.SUCCESS; + } + // CraftBukkit end - Item item = p_175641_.m_41720_(); - p_175639_.m_21008_(p_175640_, ItemUtils.m_41813_(p_175641_, p_175639_, p_175642_)); - p_175639_.m_36220_(Stats.f_12944_); - p_175639_.m_36246_(Stats.f_12982_.m_12902_(item)); -- p_175637_.m_46597_(p_175638_, Blocks.f_50256_.m_49966_()); + Item item = p_175641_.getItem(); + p_175639_.setItemInHand(p_175640_, ItemUtils.createFilledResult(p_175641_, p_175639_, p_175642_)); + p_175639_.awardStat(Stats.USE_CAULDRON); + p_175639_.awardStat(Stats.ITEM_USED.get(item)); +- p_175637_.setBlockAndUpdate(p_175638_, Blocks.CAULDRON.defaultBlockState()); + // p_175637_.setBlockAndUpdate(p_175638_, Blocks.CAULDRON.defaultBlockState());// CraftBukkit - p_175637_.m_5594_((Player)null, p_175638_, p_175644_, SoundSource.BLOCKS, 1.0F, 1.0F); - p_175637_.m_142346_((Entity)null, GameEvent.f_157816_, p_175638_); + p_175637_.playSound((Player)null, p_175638_, p_175644_, SoundSource.BLOCKS, 1.0F, 1.0F); + p_175637_.gameEvent((Entity)null, GameEvent.FLUID_PICKUP, p_175638_); } @@ -250,11 +_,16 @@ - static InteractionResult m_175618_(Level p_175619_, BlockPos p_175620_, Player p_175621_, InteractionHand p_175622_, ItemStack p_175623_, BlockState p_175624_, SoundEvent p_175625_) { - if (!p_175619_.f_46443_) { + static InteractionResult emptyBucket(Level p_175619_, BlockPos p_175620_, Player p_175621_, InteractionHand p_175622_, ItemStack p_175623_, BlockState p_175624_, SoundEvent p_175625_) { + if (!p_175619_.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.changeLevel(p_175624_, p_175619_, p_175620_, p_175624_, p_175621_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) { + return InteractionResult.SUCCESS; + } + // CraftBukkit end - Item item = p_175623_.m_41720_(); - p_175621_.m_21008_(p_175622_, ItemUtils.m_41813_(p_175623_, p_175621_, new ItemStack(Items.f_42446_))); - p_175621_.m_36220_(Stats.f_12943_); - p_175621_.m_36246_(Stats.f_12982_.m_12902_(item)); -- p_175619_.m_46597_(p_175620_, p_175624_); + Item item = p_175623_.getItem(); + p_175621_.setItemInHand(p_175622_, ItemUtils.createFilledResult(p_175623_, p_175621_, new ItemStack(Items.BUCKET))); + p_175621_.awardStat(Stats.FILL_CAULDRON); + p_175621_.awardStat(Stats.ITEM_USED.get(item)); +- p_175619_.setBlockAndUpdate(p_175620_, p_175624_); + //p_175619_.setBlockAndUpdate(p_175620_, p_175624_); // CraftBukkit - p_175619_.m_5594_((Player)null, p_175620_, p_175625_, SoundSource.BLOCKS, 1.0F, 1.0F); - p_175619_.m_142346_((Entity)null, GameEvent.f_157769_, p_175620_); + p_175619_.playSound((Player)null, p_175620_, p_175625_, SoundSource.BLOCKS, 1.0F, 1.0F); + p_175619_.gameEvent((Entity)null, GameEvent.FLUID_PLACE, p_175620_); } diff --git a/patches/minecraft/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java.patch index 8deaacac..0fb969e4 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java.patch @@ -1,42 +1,42 @@ --- a/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java +++ b/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java @@ -14,9 +_,38 @@ - Position position = DispenserBlock.m_52720_(p_123366_); - Direction direction = p_123366_.m_6414_().m_61143_(DispenserBlock.f_52659_); - Projectile projectile = this.m_6895_(level, position, p_123367_); -- projectile.m_6686_((double)direction.m_122429_(), (double)((float)direction.m_122430_() + 0.1F), (double)direction.m_122431_(), this.m_7104_(), this.m_7101_()); + Position position = DispenserBlock.getDispensePosition(p_123366_); + Direction direction = p_123366_.getBlockState().getValue(DispenserBlock.FACING); + Projectile projectile = this.getProjectile(level, position, p_123367_); +- projectile.shoot((double)direction.getStepX(), (double)((float)direction.getStepY() + 0.1F), (double)direction.getStepZ(), this.getPower(), this.getUncertainty()); + // CraftBukkit start + // iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty()); -+ ItemStack itemstack1 = p_123367_.m_41620_(1); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123366_.m_7961_().m_123341_(), p_123366_.m_7961_().m_123342_(), p_123366_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123367_.split(1); ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123366_.getPos().getX(), p_123366_.getPos().getY(), p_123366_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) direction.m_122429_(), (double) ((float) direction.m_122430_() + 0.1F), (double) direction.m_122431_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) direction.getStepX(), (double) ((float) direction.getStepY() + 0.1F), (double) direction.getStepZ())); + if (!DispenserBlock.eventFired) { + level.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { -+ p_123367_.m_41769_(1); ++ p_123367_.grow(1); + return p_123367_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123367_.m_41769_(1); ++ p_123367_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123366_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123366_, eventStack); + return p_123367_; + } + } + -+ projectile.m_6686_(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.m_7104_(), this.m_7101_()); -+ ((net.minecraft.world.entity.Entity) projectile).projectileSource = new org.bukkit.craftbukkit.v1_18_R2.projectiles.CraftBlockProjectileSource((net.minecraft.world.level.block.entity.DispenserBlockEntity) p_123366_.m_8118_()); ++ projectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.getUncertainty()); ++ ((net.minecraft.world.entity.Entity) projectile).projectileSource = new org.bukkit.craftbukkit.v1_18_R2.projectiles.CraftBlockProjectileSource((net.minecraft.world.level.block.entity.DispenserBlockEntity) p_123366_.getEntity()); + // CraftBukkit end - level.m_7967_(projectile); -- p_123367_.m_41774_(1); + level.addFreshEntity(projectile); +- p_123367_.shrink(1); + // p_123367_.shrink(1); // CraftBukkit - Handled during event processing return p_123367_; } diff --git a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index c4606512..547e3ce5 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -8,8 +8,8 @@ - Boat boat = new Boat(level, d0, d1 + d3, d2); + // EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2); + // CraftBukkit start -+ ItemStack itemstack1 = p_123376_.m_41620_(1); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123375_.m_7961_().m_123341_(), p_123375_.m_7961_().m_123342_(), p_123375_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123376_.split(1); ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123375_.getPos().getX(), p_123375_.getPos().getY(), p_123375_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); @@ -18,28 +18,28 @@ + } + + if (event.isCancelled()) { -+ p_123376_.m_41769_(1); ++ p_123376_.grow(1); + return p_123376_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123376_.m_41769_(1); ++ p_123376_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123375_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123375_, eventStack); + return p_123376_; + } + } + + Boat boat = new Boat(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // CraftBukkit end - boat.m_38332_(this.f_123369_); - boat.m_146922_(direction.m_122435_()); -- level.m_7967_(boat); -- p_123376_.m_41774_(1); -+ if (!level.m_7967_(boat)) p_123376_.m_41769_(1); // CraftBukkit + boat.setType(this.type); + boat.setYRot(direction.toYRot()); +- level.addFreshEntity(boat); +- p_123376_.shrink(1); ++ if (!level.addFreshEntity(boat)) p_123376_.grow(1); // CraftBukkit + // itemstack.shrink(1); // CraftBukkit - handled during event processing return p_123376_; } diff --git a/patches/minecraft/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch index d333c7ea..54f49207 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch @@ -15,23 +15,23 @@ + + public DefaultDispenseItemBehavior() {} + - public final ItemStack m_6115_(BlockSource p_123391_, ItemStack p_123392_) { - ItemStack itemstack = this.m_7498_(p_123391_, p_123392_); - this.m_6823_(p_123391_); + public final ItemStack dispense(BlockSource p_123391_, ItemStack p_123392_) { + ItemStack itemstack = this.execute(p_123391_, p_123392_); + this.playSound(p_123391_); @@ -16,15 +_,31 @@ return itemstack; } + //Magma start - fix mixin inject - protected ItemStack m_7498_(BlockSource p_123385_, ItemStack p_123386_) { - Direction direction = p_123385_.m_6414_().m_61143_(DispenserBlock.f_52659_); - Position position = DispenserBlock.m_52720_(p_123385_); - ItemStack itemstack = p_123386_.m_41620_(1); + protected ItemStack execute(BlockSource p_123385_, ItemStack p_123386_) { + Direction direction = p_123385_.getBlockState().getValue(DispenserBlock.FACING); + Position position = DispenserBlock.getDispensePosition(p_123385_); + ItemStack itemstack = p_123386_.split(1); + // CraftBukkit start + spawnItem_source = p_123385_; - m_123378_(p_123385_.m_7727_(), itemstack, 6, direction, position); + spawnItem(p_123385_.getLevel(), itemstack, 6, direction, position); + if (!spawnItem_return) { -+ itemstack.m_41769_(1); ++ itemstack.grow(1); + } + // CraftBukkit end return p_123386_; @@ -40,30 +40,30 @@ + // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument + private static boolean spawnItem_return = true; + private static @org.jetbrains.annotations.Nullable BlockSource spawnItem_source = null; - public static void m_123378_(Level p_123379_, ItemStack p_123380_, int p_123381_, Direction p_123382_, Position p_123383_) { + public static void spawnItem(Level p_123379_, ItemStack p_123380_, int p_123381_, Direction p_123382_, Position p_123383_) { + spawnItem_return = true; //reset + -+ if (p_123380_.m_41619_()) ++ if (p_123380_.isEmpty()) + return; //return here, boolean is already true + + // CraftBukkit end - double d0 = p_123383_.m_7096_(); - double d1 = p_123383_.m_7098_(); - double d2 = p_123383_.m_7094_(); + double d0 = p_123383_.x(); + double d1 = p_123383_.y(); + double d2 = p_123383_.z(); @@ -36,9 +_,49 @@ ItemEntity itementity = new ItemEntity(p_123379_, d0, d1, d2, p_123380_); - double d3 = p_123379_.f_46441_.nextDouble() * 0.1D + 0.2D; -- itementity.m_20334_(p_123379_.f_46441_.nextGaussian() * (double)0.0075F * (double)p_123381_ + (double)p_123382_.m_122429_() * d3, p_123379_.f_46441_.nextGaussian() * (double)0.0075F * (double)p_123381_ + (double)0.2F, p_123379_.f_46441_.nextGaussian() * (double)0.0075F * (double)p_123381_ + (double)p_123382_.m_122431_() * d3); -+ itementity.m_20334_(p_123379_.f_46441_.nextGaussian() * (double) 0.0075F * (double) p_123381_ + (double) p_123382_.m_122429_() * d3, p_123379_.f_46441_.nextGaussian() * (double) 0.0075F * (double) p_123381_ + (double) 0.2F, p_123379_.f_46441_.nextGaussian() * (double) 0.0075F * (double) p_123381_ + (double) p_123382_.m_122431_() * d3); + double d3 = p_123379_.random.nextDouble() * 0.1D + 0.2D; +- itementity.setDeltaMovement(p_123379_.random.nextGaussian() * (double)0.0075F * (double)p_123381_ + (double)p_123382_.getStepX() * d3, p_123379_.random.nextGaussian() * (double)0.0075F * (double)p_123381_ + (double)0.2F, p_123379_.random.nextGaussian() * (double)0.0075F * (double)p_123381_ + (double)p_123382_.getStepZ() * d3); ++ itementity.setDeltaMovement(p_123379_.random.nextGaussian() * (double) 0.0075F * (double) p_123381_ + (double) p_123382_.getStepX() * d3, p_123379_.random.nextGaussian() * (double) 0.0075F * (double) p_123381_ + (double) 0.2F, p_123379_.random.nextGaussian() * (double) 0.0075F * (double) p_123381_ + (double) p_123382_.getStepZ() * d3); + + //Magma - add null check + if (spawnItem_source != null) { + // CraftBukkit start -+ org.bukkit.block.Block block = p_123379_.getWorld().getBlockAt(spawnItem_source.m_7961_().m_123341_(), spawnItem_source.m_7961_().m_123342_(), spawnItem_source.m_7961_().m_123343_()); ++ org.bukkit.block.Block block = p_123379_.getWorld().getBlockAt(spawnItem_source.getPos().getX(), spawnItem_source.getPos().getY(), spawnItem_source.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123380_); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), org.bukkit.craftbukkit.v1_18_R2.util.CraftVector.toBukkit(itementity.m_20184_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), org.bukkit.craftbukkit.v1_18_R2.util.CraftVector.toBukkit(itementity.getDeltaMovement())); + if (!DispenserBlock.eventFired) { + p_123379_.getCraftServer().getPluginManager().callEvent(event); + } @@ -73,24 +73,24 @@ + return; + } + -+ itementity.m_32045_(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); -+ itementity.m_20256_(org.bukkit.craftbukkit.v1_18_R2.util.CraftVector.toNMS(event.getVelocity())); ++ itementity.setItem(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ itementity.setDeltaMovement(org.bukkit.craftbukkit.v1_18_R2.util.CraftVector.toNMS(event.getVelocity())); + + if (!DefaultDispenseItemBehavior.dropper && !event.getItem().getType().equals(craftItem.getType())) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior.getClass() != DefaultDispenseItemBehavior.class) { -+ idispensebehavior.m_6115_(spawnItem_source, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior.getClass() != DefaultDispenseItemBehavior.class) { ++ idispensebehavior.dispense(spawnItem_source, eventStack); + } else { -+ p_123379_.m_7967_(itementity); ++ p_123379_.addFreshEntity(itementity); + } + spawnItem_return = false; + return; + } + } + - p_123379_.m_7967_(itementity); + p_123379_.addFreshEntity(itementity); + + spawnItem_return = true; + @@ -99,5 +99,5 @@ } + //Magma end - protected void m_6823_(BlockSource p_123384_) { - p_123384_.m_7727_().m_46796_(1000, p_123384_.m_7961_(), 0); + protected void playSound(BlockSource p_123384_) { + p_123384_.getLevel().levelEvent(1000, p_123384_.getPos(), 0); diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index d8e3d81f..098311d6 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java @@ -178,6 +_,34 @@ - Direction direction = p_123523_.m_6414_().m_61143_(DispenserBlock.f_52659_); - EntityType entitytype = ((SpawnEggItem)p_123524_.m_41720_()).m_43228_(p_123524_.m_41783_()); + Direction direction = p_123523_.getBlockState().getValue(DispenserBlock.FACING); + EntityType entitytype = ((SpawnEggItem)p_123524_.getItem()).getType(p_123524_.getTag()); + // CraftBukkit start -+ ServerLevel worldserver = p_123523_.m_7727_(); -+ ItemStack itemstack1 = p_123524_.m_41620_(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(p_123523_.m_7961_().m_123341_(), p_123523_.m_7961_().m_123342_(), p_123523_.m_7961_().m_123343_()); ++ ServerLevel worldserver = p_123523_.getLevel(); ++ ItemStack itemstack1 = p_123524_.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(p_123523_.getPos().getX(), p_123523_.getPos().getY(), p_123523_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -16,43 +16,43 @@ + } + + if (event.isCancelled()) { -+ p_123524_.m_41769_(1); ++ p_123524_.grow(1); + return p_123524_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123524_.m_41769_(1); ++ p_123524_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123523_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123523_, eventStack); + return p_123524_; + } + } + + try { - entitytype.m_20592_(p_123523_.m_7727_(), p_123524_, (Player)null, p_123523_.m_7961_().m_142300_(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false); + entitytype.spawn(p_123523_.getLevel(), p_123524_, (Player)null, p_123523_.getPos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false); } catch (Exception exception) { @@ -185,7 +_,8 @@ - return ItemStack.f_41583_; + return ItemStack.EMPTY; } -- p_123524_.m_41774_(1); +- p_123524_.shrink(1); + // p_123524_.shrink(1); // Handled during event processing + // CraftBukkit end - p_123523_.m_7727_().m_151555_(GameEvent.f_157810_, p_123523_.m_7961_()); + p_123523_.getLevel().gameEvent(GameEvent.ENTITY_PLACE, p_123523_.getPos()); return p_123524_; } @@ -200,11 +_,39 @@ - Direction direction = p_123461_.m_6414_().m_61143_(DispenserBlock.f_52659_); - BlockPos blockpos = p_123461_.m_7961_().m_142300_(direction); - Level level = p_123461_.m_7727_(); + Direction direction = p_123461_.getBlockState().getValue(DispenserBlock.FACING); + BlockPos blockpos = p_123461_.getPos().relative(direction); + Level level = p_123461_.getLevel(); + + // CraftBukkit start -+ ItemStack itemstack1 = p_123462_.m_41620_(1); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123461_.m_7961_().m_123341_(), p_123461_.m_7961_().m_123342_(), p_123461_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123462_.split(1); ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123461_.getPos().getX(), p_123461_.getPos().getY(), p_123461_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -61,27 +61,27 @@ + } + + if (event.isCancelled()) { -+ p_123462_.m_41769_(1); ++ p_123462_.grow(1); + return p_123462_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123462_.m_41769_(1); ++ p_123462_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123461_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123461_, eventStack); + return p_123462_; + } + } + // CraftBukkit end + - ArmorStand armorstand = new ArmorStand(level, (double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_(), (double)blockpos.m_123343_() + 0.5D); - EntityType.m_20620_(level, (Player)null, armorstand, p_123462_.m_41783_()); - armorstand.m_146922_(direction.m_122435_()); - level.m_7967_(armorstand); -- p_123462_.m_41774_(1); + ArmorStand armorstand = new ArmorStand(level, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D); + EntityType.updateCustomEntityTag(level, (Player)null, armorstand, p_123462_.getTag()); + armorstand.setYRot(direction.toYRot()); + level.addFreshEntity(armorstand); +- p_123462_.shrink(1); + // p_123462_.shrink(1); // CraftBukkit - Handled during event processing return p_123462_; } @@ -91,9 +91,9 @@ }); if (!list.isEmpty()) { + // CraftBukkit start -+ ItemStack itemstack1 = p_123530_.m_41620_(1); -+ Level world = p_123529_.m_7727_(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_123529_.m_7961_().m_123341_(), p_123529_.m_7961_().m_123342_(), p_123529_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123530_.split(1); ++ Level world = p_123529_.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_123529_.getPos().getX(), p_123529_.getPos().getY(), p_123529_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); @@ -102,36 +102,36 @@ + } + + if (event.isCancelled()) { -+ p_123530_.m_41769_(1); ++ p_123530_.grow(1); + return p_123530_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123530_.m_41769_(1); ++ p_123530_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != ArmorItem.f_40376_) { -+ idispensebehavior.m_6115_(p_123529_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != ArmorItem.DISPENSE_ITEM_BEHAVIOR) { ++ idispensebehavior.dispense(p_123529_, eventStack); + return p_123530_; + } + } + // CraftBukkit end - ((Saddleable)list.get(0)).m_5853_(SoundSource.BLOCKS); -- p_123530_.m_41774_(1); + ((Saddleable)list.get(0)).equipSaddle(SoundSource.BLOCKS); +- p_123530_.shrink(1); + //p_123530_.shrink(1);// CraftBukkit - handled above - this.m_123573_(true); + this.setSuccess(true); return p_123530_; } else { @@ -237,7 +_,35 @@ - return p_123533_.m_6084_() && p_123533_.m_7482_(); + return p_123533_.isAlive() && p_123533_.canWearArmor(); })) { - if (abstracthorse.m_6010_(p_123536_) && !abstracthorse.m_7481_() && abstracthorse.m_30614_()) { -- abstracthorse.m_141942_(401).m_142104_(p_123536_.m_41620_(1)); + if (abstracthorse.isArmor(p_123536_) && !abstracthorse.isWearingArmor() && abstracthorse.isTamed()) { +- abstracthorse.getSlot(401).set(p_123536_.split(1)); + // CraftBukkit start -+ ItemStack itemstack1 = p_123536_.m_41620_(1); -+ Level world = p_123535_.m_7727_(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_123535_.m_7961_().m_123341_(), p_123535_.m_7961_().m_123342_(), p_123535_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123536_.split(1); ++ Level world = p_123535_.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_123535_.getPos().getX(), p_123535_.getPos().getY(), p_123535_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) abstracthorse.getBukkitEntity()); @@ -140,36 +140,36 @@ + } + + if (event.isCancelled()) { -+ p_123536_.m_41769_(1); ++ p_123536_.grow(1); + return p_123536_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123536_.m_41769_(1); ++ p_123536_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != ArmorItem.f_40376_) { -+ idispensebehavior.m_6115_(p_123535_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != ArmorItem.DISPENSE_ITEM_BEHAVIOR) { ++ idispensebehavior.dispense(p_123535_, eventStack); + return p_123536_; + } + } + -+ abstracthorse.m_141942_(401).m_142104_(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ abstracthorse.getSlot(401).set(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end - this.m_123573_(true); + this.setSuccess(true); return p_123536_; } @@ -273,8 +_,33 @@ - for(AbstractChestedHorse abstractchestedhorse : p_123541_.m_7727_().m_6443_(AbstractChestedHorse.class, new AABB(blockpos), (p_123539_) -> { - return p_123539_.m_6084_() && !p_123539_.m_30502_(); + for(AbstractChestedHorse abstractchestedhorse : p_123541_.getLevel().getEntitiesOfClass(AbstractChestedHorse.class, new AABB(blockpos), (p_123539_) -> { + return p_123539_.isAlive() && !p_123539_.hasChest(); })) { -- if (abstractchestedhorse.m_30614_() && abstractchestedhorse.m_141942_(499).m_142104_(p_123542_)) { -- p_123542_.m_41774_(1); -+ if (abstractchestedhorse.m_30614_()) { -+ ItemStack itemstack1 = p_123542_.m_41620_(1); -+ Level world = p_123541_.m_7727_(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_123541_.m_7961_().m_123341_(), p_123541_.m_7961_().m_123342_(), p_123541_.m_7961_().m_123343_()); +- if (abstractchestedhorse.isTamed() && abstractchestedhorse.getSlot(499).set(p_123542_)) { +- p_123542_.shrink(1); ++ if (abstractchestedhorse.isTamed()) { ++ ItemStack itemstack1 = p_123542_.split(1); ++ Level world = p_123541_.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_123541_.getPos().getX(), p_123541_.getPos().getY(), p_123541_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) abstractchestedhorse.getBukkitEntity()); @@ -183,75 +183,75 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != ArmorItem.f_40376_) { -+ idispensebehavior.m_6115_(p_123541_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != ArmorItem.DISPENSE_ITEM_BEHAVIOR) { ++ idispensebehavior.dispense(p_123541_, eventStack); + return p_123542_; + } + } -+ abstractchestedhorse.m_141942_(499).m_142104_(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ abstractchestedhorse.getSlot(499).set(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end + + // p_123542_.shrink(1); // CraftBukkit - handled above - this.m_123573_(true); + this.setSuccess(true); return p_123542_; } @@ -286,11 +_,42 @@ - DispenserBlock.m_52672_(Items.f_42688_, new DefaultDispenseItemBehavior() { - public ItemStack m_7498_(BlockSource p_123547_, ItemStack p_123548_) { - Direction direction = p_123547_.m_6414_().m_61143_(DispenserBlock.f_52659_); + DispenserBlock.registerBehavior(Items.FIREWORK_ROCKET, new DefaultDispenseItemBehavior() { + public ItemStack execute(BlockSource p_123547_, ItemStack p_123548_) { + Direction direction = p_123547_.getBlockState().getValue(DispenserBlock.FACING); + + // CraftBukkit start -+ ServerLevel worldserver = p_123547_.m_7727_(); -+ ItemStack itemstack1 = p_123548_.m_41620_(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(p_123547_.m_7961_().m_123341_(), p_123547_.m_7961_().m_123342_(), p_123547_.m_7961_().m_123343_()); ++ ServerLevel worldserver = p_123547_.getLevel(); ++ ItemStack itemstack1 = p_123548_.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(p_123547_.getPos().getX(), p_123547_.getPos().getY(), p_123547_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(direction.m_122429_(), direction.m_122430_(), direction.m_122431_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(direction.getStepX(), direction.getStepY(), direction.getStepZ())); + if (!DispenserBlock.eventFired) { + worldserver.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { -+ p_123548_.m_41769_(1); ++ p_123548_.grow(1); + return p_123548_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123548_.m_41769_(1); ++ p_123548_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123547_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123547_, eventStack); + return p_123548_; + } + } + + itemstack1 = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); + - FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_123547_.m_7727_(), p_123548_, p_123547_.m_7096_(), p_123547_.m_7098_(), p_123547_.m_7096_(), true); - DispenseItemBehavior.m_123395_(p_123547_, fireworkrocketentity, direction); - fireworkrocketentity.m_6686_((double)direction.m_122429_(), (double)direction.m_122430_(), (double)direction.m_122431_(), 0.5F, 1.0F); - p_123547_.m_7727_().m_7967_(fireworkrocketentity); -- p_123548_.m_41774_(1); + FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_123547_.getLevel(), p_123548_, p_123547_.x(), p_123547_.y(), p_123547_.x(), true); + DispenseItemBehavior.setEntityPokingOutOfBlock(p_123547_, fireworkrocketentity, direction); + fireworkrocketentity.shoot((double)direction.getStepX(), (double)direction.getStepY(), (double)direction.getStepZ(), 0.5F, 1.0F); + p_123547_.getLevel().addFreshEntity(fireworkrocketentity); +- p_123548_.shrink(1); + //p_123548_.shrink(1); // Handled during event processing + // CraftBukkit end return p_123548_; } @@ -310,11 +_,39 @@ - double d3 = random.nextGaussian() * 0.05D + (double)direction.m_122429_(); - double d4 = random.nextGaussian() * 0.05D + (double)direction.m_122430_(); - double d5 = random.nextGaussian() * 0.05D + (double)direction.m_122431_(); + double d3 = random.nextGaussian() * 0.05D + (double)direction.getStepX(); + double d4 = random.nextGaussian() * 0.05D + (double)direction.getStepY(); + double d5 = random.nextGaussian() * 0.05D + (double)direction.getStepZ(); - SmallFireball smallfireball = new SmallFireball(level, d0, d1, d2, d3, d4, d5); -- level.m_7967_(Util.m_137469_(smallfireball, (p_123552_) -> { -- p_123552_.m_37010_(p_123557_); +- level.addFreshEntity(Util.make(smallfireball, (p_123552_) -> { +- p_123552_.setItem(p_123557_); - })); -- p_123557_.m_41774_(1); +- p_123557_.shrink(1); + // CraftBukkit start -+ ItemStack itemstack1 = p_123557_.m_41620_(1); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123556_.m_7961_().m_123341_(), p_123556_.m_7961_().m_123342_(), p_123556_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123557_.split(1); ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123556_.getPos().getX(), p_123556_.getPos().getY(), p_123556_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); @@ -260,45 +260,45 @@ + } + + if (event.isCancelled()) { -+ p_123557_.m_41769_(1); ++ p_123557_.grow(1); + return p_123557_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123557_.m_41769_(1); ++ p_123557_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123556_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123556_, eventStack); + return p_123557_; + } + } + + SmallFireball entitysmallfireball = new SmallFireball(level, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); -+ entitysmallfireball.m_37010_(itemstack1); -+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.v1_18_R2.projectiles.CraftBlockProjectileSource((DispenserBlockEntity) p_123556_.m_8118_()); ++ entitysmallfireball.setItem(itemstack1); ++ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.v1_18_R2.projectiles.CraftBlockProjectileSource((DispenserBlockEntity) p_123556_.getEntity()); + -+ level.m_7967_(entitysmallfireball); ++ level.addFreshEntity(entitysmallfireball); + // itemstack.shrink(1); // Handled during event processing + // CraftBukkit end return p_123557_; } @@ -335,9 +_,53 @@ - DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_123562_.m_41720_(); - BlockPos blockpos = p_123561_.m_7961_().m_142300_(p_123561_.m_6414_().m_61143_(DispenserBlock.f_52659_)); - Level level = p_123561_.m_7727_(); -- if (dispensiblecontaineritem.m_142073_((Player)null, level, blockpos, (BlockHitResult)null)) { + DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_123562_.getItem(); + BlockPos blockpos = p_123561_.getPos().relative(p_123561_.getBlockState().getValue(DispenserBlock.FACING)); + Level level = p_123561_.getLevel(); +- if (dispensiblecontaineritem.emptyContents((Player)null, level, blockpos, (BlockHitResult)null)) { + + // CraftBukkit start -+ int x = blockpos.m_123341_(); -+ int y = blockpos.m_123342_(); -+ int z = blockpos.m_123343_(); -+ BlockState iblockdata = level.m_8055_(blockpos); -+ net.minecraft.world.level.material.Material material = iblockdata.m_60767_(); -+ if (level.m_46859_(blockpos) || !material.m_76333_() || material.m_76336_() || (dispensiblecontaineritem instanceof net.minecraft.world.item.BucketItem && iblockdata.m_60734_() instanceof net.minecraft.world.level.block.LiquidBlockContainer && ((net.minecraft.world.level.block.LiquidBlockContainer) iblockdata.m_60734_()).m_6044_(level, blockpos, iblockdata, ((net.minecraft.world.item.BucketItem) dispensiblecontaineritem).getContent()))) { -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123561_.m_7961_().m_123341_(), p_123561_.m_7961_().m_123342_(), p_123561_.m_7961_().m_123343_()); ++ int x = blockpos.getX(); ++ int y = blockpos.getY(); ++ int z = blockpos.getZ(); ++ BlockState iblockdata = level.getBlockState(blockpos); ++ net.minecraft.world.level.material.Material material = iblockdata.getMaterial(); ++ if (level.isEmptyBlock(blockpos) || !material.isSolid() || material.isReplaceable() || (dispensiblecontaineritem instanceof net.minecraft.world.item.BucketItem && iblockdata.getBlock() instanceof net.minecraft.world.level.block.LiquidBlockContainer && ((net.minecraft.world.level.block.LiquidBlockContainer) iblockdata.getBlock()).canPlaceLiquid(level, blockpos, iblockdata, ((net.minecraft.world.item.BucketItem) dispensiblecontaineritem).getContent()))) { ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123561_.getPos().getX(), p_123561_.getPos().getY(), p_123561_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123562_); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); @@ -313,57 +313,57 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123561_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123561_, eventStack); + return p_123562_; + } + } + -+ dispensiblecontaineritem = (DispensibleContainerItem) org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()).m_41720_(); ++ dispensiblecontaineritem = (DispensibleContainerItem) org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()).getItem(); + } + // CraftBukkit end + + if (dispensiblecontaineritem.emptyContents((Player)null, level, blockpos, (BlockHitResult)null, p_123562_)) { - dispensiblecontaineritem.m_142131_((Player)null, level, p_123562_, blockpos); -- return new ItemStack(Items.f_42446_); + dispensiblecontaineritem.checkExtraContent((Player)null, level, p_123562_, blockpos); +- return new ItemStack(Items.BUCKET); + // CraftBukkit start - Handle stacked buckets -+ Item item = Items.f_42446_; -+ p_123562_.m_41774_(1); -+ if (p_123562_.m_41619_()) { -+ p_123562_.setItem(Items.f_42446_); -+ p_123562_.m_41764_(1); -+ } else if (((DispenserBlockEntity) p_123561_.m_8118_()).m_59237_(new ItemStack(item)) < 0) { -+ this.f_123558_.m_6115_(p_123561_, new ItemStack(item)); ++ Item item = Items.BUCKET; ++ p_123562_.shrink(1); ++ if (p_123562_.isEmpty()) { ++ p_123562_.setItem(Items.BUCKET); ++ p_123562_.setCount(1); ++ } else if (((DispenserBlockEntity) p_123561_.getEntity()).addItem(new ItemStack(item)) < 0) { ++ this.defaultDispenseItemBehavior.dispense(p_123561_, new ItemStack(item)); + } + return p_123562_; + // CraftBukkit end } else { - return this.f_123558_.m_6115_(p_123561_, p_123562_); + return this.defaultDispenseItemBehavior.dispense(p_123561_, p_123562_); } @@ -355,17 +_,44 @@ - private final DefaultDispenseItemBehavior f_123563_ = new DefaultDispenseItemBehavior(); + private final DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior(); - public ItemStack m_7498_(BlockSource p_123566_, ItemStack p_123567_) { -- LevelAccessor levelaccessor = p_123566_.m_7727_(); -+ Level levelaccessor = p_123566_.m_7727_(); - BlockPos blockpos = p_123566_.m_7961_().m_142300_(p_123566_.m_6414_().m_61143_(DispenserBlock.f_52659_)); - BlockState blockstate = levelaccessor.m_8055_(blockpos); - Block block = blockstate.m_60734_(); + public ItemStack execute(BlockSource p_123566_, ItemStack p_123567_) { +- LevelAccessor levelaccessor = p_123566_.getLevel(); ++ Level levelaccessor = p_123566_.getLevel(); + BlockPos blockpos = p_123566_.getPos().relative(p_123566_.getBlockState().getValue(DispenserBlock.FACING)); + BlockState blockstate = levelaccessor.getBlockState(blockpos); + Block block = blockstate.getBlock(); if (block instanceof BucketPickup) { -- ItemStack itemstack = ((BucketPickup)block).m_142598_(levelaccessor, blockpos, blockstate); -+ ItemStack itemstack = ((BucketPickup)block).m_142598_(org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, blockpos, blockstate); // CraftBukkit - if (itemstack.m_41619_()) { - return super.m_7498_(p_123566_, p_123567_); +- ItemStack itemstack = ((BucketPickup)block).pickupBlock(levelaccessor, blockpos, blockstate); ++ ItemStack itemstack = ((BucketPickup)block).pickupBlock(org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, blockpos, blockstate); // CraftBukkit + if (itemstack.isEmpty()) { + return super.execute(p_123566_, p_123567_); } else { - levelaccessor.m_142346_((Entity)null, GameEvent.f_157816_, blockpos); - Item item = itemstack.m_41720_(); + levelaccessor.gameEvent((Entity)null, GameEvent.FLUID_PICKUP, blockpos); + Item item = itemstack.getItem(); + + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = levelaccessor.getWorld().getBlockAt(p_123566_.m_7961_().m_123341_(), p_123566_.m_7961_().m_123342_(), p_123566_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = levelaccessor.getWorld().getBlockAt(p_123566_.getPos().getX(), p_123566_.getPos().getY(), p_123566_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.getX(), blockpos.getY(), blockpos.getZ())); + + if (!DispenserBlock.eventFired) { + levelaccessor.getCraftServer().getPluginManager().callEvent(event); @@ -376,25 +376,25 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123566_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123566_, eventStack); + return itemstack; + } + } + -+ itemstack = ((BucketPickup) block).m_142598_(levelaccessor, blockpos, blockstate); // From above ++ itemstack = ((BucketPickup) block).pickupBlock(levelaccessor, blockpos, blockstate); // From above + // CraftBukkit end - p_123567_.m_41774_(1); - if (p_123567_.m_41619_()) { + p_123567_.shrink(1); + if (p_123567_.isEmpty()) { return new ItemStack(item); @@ -385,17 +_,47 @@ - DispenserBlock.m_52672_(Items.f_42409_, new OptionalDispenseItemBehavior() { - protected ItemStack m_7498_(BlockSource p_123412_, ItemStack p_123413_) { - Level level = p_123412_.m_7727_(); + DispenserBlock.registerBehavior(Items.FLINT_AND_STEEL, new OptionalDispenseItemBehavior() { + protected ItemStack execute(BlockSource p_123412_, ItemStack p_123413_) { + Level level = p_123412_.getLevel(); + + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123412_.m_7961_().m_123341_(), p_123412_.m_7961_().m_123342_(), p_123412_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123412_.getPos().getX(), p_123412_.getPos().getY(), p_123412_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123413_); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -409,44 +409,44 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123412_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123412_, eventStack); + return p_123413_; + } + } + // CraftBukkit end + - this.m_123573_(true); - Direction direction = p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_); - BlockPos blockpos = p_123412_.m_7961_().m_142300_(direction); - BlockState blockstate = level.m_8055_(blockpos); - if (BaseFireBlock.m_49255_(level, blockpos, direction)) { -- level.m_46597_(blockpos, BaseFireBlock.m_49245_(level, blockpos)); -- level.m_142346_((Entity)null, GameEvent.f_157797_, blockpos); + this.setSuccess(true); + Direction direction = p_123412_.getBlockState().getValue(DispenserBlock.FACING); + BlockPos blockpos = p_123412_.getPos().relative(direction); + BlockState blockstate = level.getBlockState(blockpos); + if (BaseFireBlock.canBePlacedAt(level, blockpos, direction)) { +- level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(level, blockpos)); +- level.gameEvent((Entity)null, GameEvent.BLOCK_PLACE, blockpos); + // CraftBukkit start - Ignition by dispensing flint and steel -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, p_123412_.m_7961_()).isCancelled()) { -+ level.m_46597_(blockpos, net.minecraft.world.level.block.FireBlock.m_49245_(level, blockpos)); -+ level.m_142346_((Entity) null, GameEvent.f_157797_, blockpos); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, p_123412_.getPos()).isCancelled()) { ++ level.setBlockAndUpdate(blockpos, net.minecraft.world.level.block.FireBlock.getState(level, blockpos)); ++ level.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockpos); + } + // CraftBukkit end - } else if (!CampfireBlock.m_51321_(blockstate) && !CandleBlock.m_152845_(blockstate) && !CandleCakeBlock.m_152910_(blockstate)) { -- if (blockstate.m_60734_() instanceof TntBlock) { -- TntBlock.m_57433_(level, blockpos); -- level.m_7471_(blockpos, false); -+ if (blockstate.isFlammable(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_())) { -+ blockstate.onCaughtFire(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_(), null); -+ if (blockstate.m_60734_() instanceof TntBlock) -+ level.m_7471_(blockpos, false); + } else if (!CampfireBlock.canLight(blockstate) && !CandleBlock.canLight(blockstate) && !CandleCakeBlock.canLight(blockstate)) { +- if (blockstate.getBlock() instanceof TntBlock) { +- TntBlock.explode(level, blockpos); +- level.removeBlock(blockpos, false); ++ if (blockstate.isFlammable(level, blockpos, p_123412_.getBlockState().getValue(DispenserBlock.FACING).getOpposite())) { ++ blockstate.onCaughtFire(level, blockpos, p_123412_.getBlockState().getValue(DispenserBlock.FACING).getOpposite(), null); ++ if (blockstate.getBlock() instanceof TntBlock) ++ level.removeBlock(blockpos, false); } else { - this.m_123573_(false); + this.setSuccess(false); } @@ -416,12 +_,63 @@ - this.m_123573_(true); - Level level = p_123416_.m_7727_(); - BlockPos blockpos = p_123416_.m_7961_().m_142300_(p_123416_.m_6414_().m_61143_(DispenserBlock.f_52659_)); + this.setSuccess(true); + Level level = p_123416_.getLevel(); + BlockPos blockpos = p_123416_.getPos().relative(p_123416_.getBlockState().getValue(DispenserBlock.FACING)); + // CraftBukkit start -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123416_.m_7961_().m_123341_(), p_123416_.m_7961_().m_123342_(), p_123416_.m_7961_().m_123343_()); ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123416_.getPos().getX(), p_123416_.getPos().getY(), p_123416_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123417_); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -461,19 +461,19 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123416_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123416_, eventStack); + return p_123417_; + } + } + + level.captureTreeGeneration = true; + // CraftBukkit end - if (!BoneMealItem.m_40627_(p_123417_, level, blockpos) && !BoneMealItem.m_40631_(p_123417_, level, blockpos, (Direction)null)) { - this.m_123573_(false); - } else if (!level.f_46443_) { - level.m_46796_(1505, blockpos, 0); + if (!BoneMealItem.growCrop(p_123417_, level, blockpos) && !BoneMealItem.growWaterPlant(p_123417_, level, blockpos, (Direction)null)) { + this.setSuccess(false); + } else if (!level.isClientSide) { + level.levelEvent(1505, blockpos, 0); } + // CraftBukkit start @@ -481,7 +481,7 @@ + if (level.capturedBlockStates.size() > 0) { + org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; + net.minecraft.world.level.block.SaplingBlock.treeType = null; -+ org.bukkit.Location location = new org.bukkit.Location(level.getWorld(), blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ org.bukkit.Location location = new org.bukkit.Location(level.getWorld(), blockpos.getX(), blockpos.getY(), blockpos.getZ()); + List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); + level.capturedBlockStates.clear(); + org.bukkit.event.world.StructureGrowEvent structureEvent = null; @@ -506,58 +506,58 @@ } }); @@ -429,11 +_,40 @@ - protected ItemStack m_7498_(BlockSource p_123425_, ItemStack p_123426_) { - Level level = p_123425_.m_7727_(); - BlockPos blockpos = p_123425_.m_7961_().m_142300_(p_123425_.m_6414_().m_61143_(DispenserBlock.f_52659_)); -- PrimedTnt primedtnt = new PrimedTnt(level, (double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_(), (double)blockpos.m_123343_() + 0.5D, (LivingEntity)null); + protected ItemStack execute(BlockSource p_123425_, ItemStack p_123426_) { + Level level = p_123425_.getLevel(); + BlockPos blockpos = p_123425_.getPos().relative(p_123425_.getBlockState().getValue(DispenserBlock.FACING)); +- PrimedTnt primedtnt = new PrimedTnt(level, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, (LivingEntity)null); + // CraftBukkit start + // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); + -+ ItemStack itemstack1 = p_123426_.m_41620_(1); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123425_.m_7961_().m_123341_(), p_123425_.m_7961_().m_123342_(), p_123425_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_123426_.split(1); ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(p_123425_.getPos().getX(), p_123425_.getPos().getY(), p_123425_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockpos.m_123341_() + 0.5D, (double) blockpos.m_123342_(), (double) blockpos.m_123343_() + 0.5D)); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D)); + if (!DispenserBlock.eventFired) { + level.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { -+ p_123426_.m_41769_(1); ++ p_123426_.grow(1); + return p_123426_; + } + + if (!event.getItem().equals(craftItem)) { -+ p_123426_.m_41769_(1); ++ p_123426_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123425_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123425_, eventStack); + return p_123426_; + } + } + + PrimedTnt primedtnt = new PrimedTnt(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (LivingEntity) null); + // CraftBukkit end - level.m_7967_(primedtnt); - level.m_6263_((Player)null, primedtnt.m_20185_(), primedtnt.m_20186_(), primedtnt.m_20189_(), SoundEvents.f_12512_, SoundSource.BLOCKS, 1.0F, 1.0F); - level.m_142346_((Entity)null, GameEvent.f_157810_, blockpos); -- p_123426_.m_41774_(1); + level.addFreshEntity(primedtnt); + level.playSound((Player)null, primedtnt.getX(), primedtnt.getY(), primedtnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); + level.gameEvent((Entity)null, GameEvent.ENTITY_PLACE, blockpos); +- p_123426_.shrink(1); + // p_123426_.shrink(1); // CraftBukkit - handled above return p_123426_; } }); @@ -453,6 +_,31 @@ - Level level = p_123433_.m_7727_(); - Direction direction = p_123433_.m_6414_().m_61143_(DispenserBlock.f_52659_); - BlockPos blockpos = p_123433_.m_7961_().m_142300_(direction); + Level level = p_123433_.getLevel(); + Direction direction = p_123433_.getBlockState().getValue(DispenserBlock.FACING); + BlockPos blockpos = p_123433_.getPos().relative(direction); + + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123433_.m_7961_().m_123341_(), p_123433_.m_7961_().m_123342_(), p_123433_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123433_.getPos().getX(), p_123433_.getPos().getY(), p_123433_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123434_); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.getX(), blockpos.getY(), blockpos.getZ())); + if (!DispenserBlock.eventFired) { + level.getCraftServer().getPluginManager().callEvent(event); + } @@ -569,27 +569,27 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123433_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123433_, eventStack); + return p_123434_; + } + } + // CraftBukkit end + - if (level.m_46859_(blockpos) && WitherSkullBlock.m_58267_(level, blockpos, p_123434_)) { - level.m_7731_(blockpos, Blocks.f_50312_.m_49966_().m_61124_(SkullBlock.f_56314_, Integer.valueOf(direction.m_122434_() == Direction.Axis.Y ? 0 : direction.m_122424_().m_122416_() * 4)), 3); - level.m_142346_((Entity)null, GameEvent.f_157797_, blockpos); + if (level.isEmptyBlock(blockpos) && WitherSkullBlock.canSpawnMob(level, blockpos, p_123434_)) { + level.setBlock(blockpos, Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(SkullBlock.ROTATION, Integer.valueOf(direction.getAxis() == Direction.Axis.Y ? 0 : direction.getOpposite().get2DDataValue() * 4)), 3); + level.gameEvent((Entity)null, GameEvent.BLOCK_PLACE, blockpos); @@ -475,6 +_,32 @@ - Level level = p_123437_.m_7727_(); - BlockPos blockpos = p_123437_.m_7961_().m_142300_(p_123437_.m_6414_().m_61143_(DispenserBlock.f_52659_)); - CarvedPumpkinBlock carvedpumpkinblock = (CarvedPumpkinBlock)Blocks.f_50143_; + Level level = p_123437_.getLevel(); + BlockPos blockpos = p_123437_.getPos().relative(p_123437_.getBlockState().getValue(DispenserBlock.FACING)); + CarvedPumpkinBlock carvedpumpkinblock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; + + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123437_.m_7961_().m_123341_(), p_123437_.m_7961_().m_123342_(), p_123437_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123437_.getPos().getX(), p_123437_.getPos().getY(), p_123437_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123438_); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.getX(), blockpos.getY(), blockpos.getZ())); + if (!DispenserBlock.eventFired) { + level.getCraftServer().getPluginManager().callEvent(event); + } @@ -601,28 +601,28 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123437_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123437_, eventStack); + return p_123438_; + } + } + // CraftBukkit end + + - if (level.m_46859_(blockpos) && carvedpumpkinblock.m_51381_(level, blockpos)) { - if (!level.f_46443_) { - level.m_7731_(blockpos, carvedpumpkinblock.m_49966_(), 3); + if (level.isEmptyBlock(blockpos) && carvedpumpkinblock.canSpawnGolem(level, blockpos)) { + if (!level.isClientSide) { + level.setBlock(blockpos, carvedpumpkinblock.defaultBlockState(), 3); @@ -518,6 +_,31 @@ - ServerLevel serverlevel = p_123444_.m_7727_(); - BlockPos blockpos = p_123444_.m_7961_().m_142300_(p_123444_.m_6414_().m_61143_(DispenserBlock.f_52659_)); - BlockState blockstate = serverlevel.m_8055_(blockpos); + ServerLevel serverlevel = p_123444_.getLevel(); + BlockPos blockpos = p_123444_.getPos().relative(p_123444_.getBlockState().getValue(DispenserBlock.FACING)); + BlockState blockstate = serverlevel.getBlockState(blockpos); + + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = serverlevel.getWorld().getBlockAt(p_123444_.m_7961_().m_123341_(), p_123444_.m_7961_().m_123342_(), p_123444_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = serverlevel.getWorld().getBlockAt(p_123444_.getPos().getX(), p_123444_.getPos().getY(), p_123444_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123445_); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.getX(), blockpos.getY(), blockpos.getZ())); + if (!DispenserBlock.eventFired) { + serverlevel.getCraftServer().getPluginManager().callEvent(event); + } @@ -634,14 +634,14 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123444_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123444_, eventStack); + return p_123445_; + } + } + // CraftBukkit end + - if (blockstate.m_204338_(BlockTags.f_13072_, (p_123442_) -> { - return p_123442_.m_61138_(BeehiveBlock.f_49564_) && p_123442_.m_60734_() instanceof BeehiveBlock; - }) && blockstate.m_61143_(BeehiveBlock.f_49564_) >= 5) { + if (blockstate.is(BlockTags.BEEHIVES, (p_123442_) -> { + return p_123442_.hasProperty(BeehiveBlock.HONEY_LEVEL) && p_123442_.getBlock() instanceof BeehiveBlock; + }) && blockstate.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) { diff --git a/patches/minecraft/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch index 72d8e015..6ab28743 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java @@ -24,9 +_,33 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { - protected ItemStack m_7498_(BlockSource p_123580_, ItemStack p_123581_) { - Level level = p_123580_.m_7727_(); + protected ItemStack execute(BlockSource p_123580_, ItemStack p_123581_) { + Level level = p_123580_.getLevel(); + //CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123580_.m_7961_().m_123341_(), p_123580_.m_7961_().m_123342_(), p_123580_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(p_123580_.getPos().getX(), p_123580_.getPos().getY(), p_123580_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123581_); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -20,20 +20,20 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123580_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123580_, eventStack); + return p_123581_; + } + } + //CraftBukkit end + - if (!level.m_5776_()) { - BlockPos blockpos = p_123580_.m_7961_().m_142300_(p_123580_.m_6414_().m_61143_(DispenserBlock.f_52659_)); -- this.m_123573_(m_123576_((ServerLevel)level, blockpos) || m_123582_((ServerLevel)level, blockpos)); -+ this.m_123573_(m_123576_((ServerLevel)level, blockpos) || tryShearLivingEntity((ServerLevel)level, blockpos, bukkitBlock, craftItem)); //CraftBukkit - if (this.m_123570_() && p_123581_.m_41629_(1, level.m_5822_(), (ServerPlayer)null)) { - p_123581_.m_41764_(0); + if (!level.isClientSide()) { + BlockPos blockpos = p_123580_.getPos().relative(p_123580_.getBlockState().getValue(DispenserBlock.FACING)); +- this.setSuccess(tryShearBeehive((ServerLevel)level, blockpos) || tryShearLivingEntity((ServerLevel)level, blockpos)); ++ this.setSuccess(tryShearBeehive((ServerLevel)level, blockpos) || tryShearLivingEntity((ServerLevel)level, blockpos, bukkitBlock, craftItem)); //CraftBukkit + if (this.isSuccess() && p_123581_.hurt(1, level.getRandom(), (ServerPlayer)null)) { + p_123581_.setCount(0); } @@ -53,11 +_,28 @@ return false; @@ -45,15 +45,15 @@ + private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_, org.bukkit.block.Block bukkitBlock, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem) { + tryShearLivingEntity_bukkitBlock = bukkitBlock; + tryShearLivingEntity_craftItem = craftItem; -+ return m_123582_(p_123583_, p_123584_); ++ return tryShearLivingEntity(p_123583_, p_123584_); + } + //Magma end + - private static boolean m_123582_(ServerLevel p_123583_, BlockPos p_123584_) { - for(LivingEntity livingentity : p_123583_.m_6443_(LivingEntity.class, new AABB(p_123584_), EntitySelector.f_20408_)) { + private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_) { + for(LivingEntity livingentity : p_123583_.getEntitiesOfClass(LivingEntity.class, new AABB(p_123584_), EntitySelector.NO_SPECTATORS)) { if (livingentity instanceof Shearable) { Shearable shearable = (Shearable)livingentity; - if (shearable.m_6220_()) { + if (shearable.readyForShearing()) { + //CraftBukkit start + if (tryShearLivingEntity_bukkitBlock != null && tryShearLivingEntity_craftItem != null) { //Magma - null check + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockShearEntityEvent(livingentity, tryShearLivingEntity_bukkitBlock, tryShearLivingEntity_craftItem).isCancelled()) { @@ -61,6 +61,6 @@ + } + } + //CraftBukkit end - shearable.m_5851_(SoundSource.BLOCKS); - p_123583_.m_142346_((Entity)null, GameEvent.f_157781_, p_123584_); + shearable.shear(SoundSource.BLOCKS); + p_123583_.gameEvent((Entity)null, GameEvent.SHEAR, p_123584_); return true; diff --git a/patches/minecraft/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch index 59f9cc5f..8566fc14 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java @@ -22,6 +_,30 @@ - BlockPos blockpos = p_123587_.m_7961_().m_142300_(direction); - Direction direction1 = p_123587_.m_7727_().m_46859_(blockpos.m_7495_()) ? direction : Direction.UP; + BlockPos blockpos = p_123587_.getPos().relative(direction); + Direction direction1 = p_123587_.getLevel().isEmptyBlock(blockpos.below()) ? direction : Direction.UP; + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = p_123587_.m_7727_().getWorld().getBlockAt(p_123587_.m_7961_().m_123341_(), p_123587_.m_7961_().m_123342_(), p_123587_.m_7961_().m_123343_()); ++ org.bukkit.block.Block bukkitBlock = p_123587_.getLevel().getWorld().getBlockAt(p_123587_.getPos().getX(), p_123587_.getPos().getY(), p_123587_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_123588_); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockpos.getX(), blockpos.getY(), blockpos.getZ())); + if (!DispenserBlock.eventFired) { -+ p_123587_.m_7727_().getCraftServer().getPluginManager().callEvent(event); ++ p_123587_.getLevel().getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -20,14 +20,14 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_123587_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_123587_, eventStack); + return p_123588_; + } + } + // CraftBukkit end + try { - this.m_123573_(((BlockItem)item).m_40576_(new DirectionalPlaceContext(p_123587_.m_7727_(), blockpos, direction, p_123588_, direction1)).m_19077_()); + this.setSuccess(((BlockItem)item).place(new DirectionalPlaceContext(p_123587_.getLevel(), blockpos, direction, p_123588_, direction1)).consumesAction()); } catch (Exception exception) { diff --git a/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch b/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch index 8fa603e1..0a4f3c09 100644 --- a/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch +++ b/patches/minecraft/net/minecraft/core/particles/BlockParticleOption.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/particles/BlockParticleOption.java +++ b/net/minecraft/core/particles/BlockParticleOption.java @@ -51,4 +_,15 @@ - public BlockState m_123642_() { - return this.f_123626_; + public BlockState getState() { + return this.state; } + + //FORGE: Add a source pos property, so we can provide models with additional model data diff --git a/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch index 18398e3f..a35361bb 100644 --- a/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch +++ b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch @@ -3,9 +3,9 @@ @@ -35,7 +_,7 @@ public ItemParticleOption(ParticleType p_123705_, ItemStack p_123706_) { - this.f_123701_ = p_123705_; -- this.f_123702_ = p_123706_; -+ this.f_123702_ = p_123706_.m_41777_(); //Forge: Fix stack updating after the fact causing particle changes. + this.type = p_123705_; +- this.itemStack = p_123706_; ++ this.itemStack = p_123706_.copy(); //Forge: Fix stack updating after the fact causing particle changes. } - public void m_7711_(FriendlyByteBuf p_123716_) { + public void writeToNetwork(FriendlyByteBuf p_123716_) { diff --git a/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch b/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch index f024cbd6..ebca444b 100644 --- a/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch +++ b/patches/minecraft/net/minecraft/core/particles/ParticleType.java.patch @@ -6,6 +6,6 @@ -public abstract class ParticleType { +public abstract class ParticleType extends net.minecraftforge.registries.ForgeRegistryEntry> { - private final boolean f_123737_; - private final ParticleOptions.Deserializer f_123738_; + private final boolean overrideLimiter; + private final ParticleOptions.Deserializer deserializer; diff --git a/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch b/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch index 870126e6..6552e9b9 100644 --- a/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch +++ b/patches/minecraft/net/minecraft/core/particles/ParticleTypes.java.patch @@ -6,5 +6,5 @@ +@net.minecraftforge.registries.ObjectHolder("minecraft") public class ParticleTypes { - public static final SimpleParticleType f_123770_ = m_123824_("ambient_entity_effect", false); - public static final SimpleParticleType f_123792_ = m_123824_("angry_villager", false); + public static final SimpleParticleType AMBIENT_ENTITY_EFFECT = register("ambient_entity_effect", false); + public static final SimpleParticleType ANGRY_VILLAGER = register("angry_villager", false); diff --git a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch index 355a6362..55b3e660 100644 --- a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch +++ b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/data/BuiltinRegistries.java +++ b/net/minecraft/data/BuiltinRegistries.java @@ -52,7 +_,7 @@ - return ProcessorLists.f_127199_; + return ProcessorLists.ZOMBIE_PLAINS; }); - public static final Registry f_123864_ = m_123893_(Registry.f_122884_, Pools::m_206434_); -- public static final Registry f_123865_ = m_123893_(Registry.f_122885_, Biomes::m_206462_); -+ @Deprecated public static final Registry f_123865_ = forge(Registry.f_122885_, Biomes::m_206462_); - public static final Registry f_194654_ = m_123893_(Registry.f_194568_, NoiseData::m_206433_); - public static final Registry f_211085_ = m_123893_(Registry.f_211074_, NoiseRouterData::m_209468_); - public static final Registry f_123866_ = m_123893_(Registry.f_122878_, NoiseGeneratorSettings::m_204599_); + public static final Registry TEMPLATE_POOL = registerSimple(Registry.TEMPLATE_POOL_REGISTRY, Pools::bootstrap); +- public static final Registry BIOME = registerSimple(Registry.BIOME_REGISTRY, Biomes::bootstrap); ++ @Deprecated public static final Registry BIOME = forge(Registry.BIOME_REGISTRY, Biomes::bootstrap); + public static final Registry NOISE = registerSimple(Registry.NOISE_REGISTRY, NoiseData::bootstrap); + public static final Registry DENSITY_FUNCTION = registerSimple(Registry.DENSITY_FUNCTION_REGISTRY, NoiseRouterData::bootstrap); + public static final Registry NOISE_GENERATOR_SETTINGS = registerSimple(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY, NoiseGeneratorSettings::bootstrap); @@ -60,6 +_,10 @@ - private static Registry m_123893_(ResourceKey> p_123894_, Supplier> p_123895_) { - return m_123884_(p_123894_, Lifecycle.stable(), p_123895_); + private static Registry registerSimple(ResourceKey> p_123894_, Supplier> p_123895_) { + return registerSimple(p_123894_, Lifecycle.stable(), p_123895_); + } + + private static > Registry forge(ResourceKey> key, Supplier> holderSupplier) { -+ return m_123888_(key, net.minecraftforge.registries.GameData.getWrapper(key, Lifecycle.stable()), holderSupplier, Lifecycle.stable()); ++ return internalRegister(key, net.minecraftforge.registries.GameData.getWrapper(key, Lifecycle.stable()), holderSupplier, Lifecycle.stable()); } - private static Registry m_123884_(ResourceKey> p_123885_, Lifecycle p_123886_, Supplier> p_123887_) { + private static Registry registerSimple(ResourceKey> p_123885_, Lifecycle p_123886_, Supplier> p_123887_) { diff --git a/patches/minecraft/net/minecraft/data/DataGenerator.java.patch b/patches/minecraft/net/minecraft/data/DataGenerator.java.patch index 3c3f3695..2e56c090 100644 --- a/patches/minecraft/net/minecraft/data/DataGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/DataGenerator.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/data/DataGenerator.java +++ b/net/minecraft/data/DataGenerator.java @@ -16,10 +_,11 @@ - private final Collection f_123906_; - private final Path f_123907_; - private final List f_123908_ = Lists.newArrayList(); -+ private final List providerView = java.util.Collections.unmodifiableList(f_123908_); + private final Collection inputFolders; + private final Path outputFolder; + private final List providers = Lists.newArrayList(); ++ private final List providerView = java.util.Collections.unmodifiableList(providers); public DataGenerator(Path p_123911_, Collection p_123912_) { - this.f_123907_ = p_123911_; -- this.f_123906_ = p_123912_; -+ this.f_123906_ = Lists.newArrayList(p_123912_); + this.outputFolder = p_123911_; +- this.inputFolders = p_123912_; ++ this.inputFolders = Lists.newArrayList(p_123912_); } - public Collection m_123913_() { + public Collection getInputFolders() { @@ -38,6 +_,7 @@ - for(DataProvider dataprovider : this.f_123908_) { - f_123905_.info("Starting provider: {}", (Object)dataprovider.m_6055_()); -+ net.minecraftforge.fml.StartupMessageManager.addModMessage("Generating: " + dataprovider.m_6055_()); + for(DataProvider dataprovider : this.providers) { + LOGGER.info("Starting provider: {}", (Object)dataprovider.getName()); ++ net.minecraftforge.fml.StartupMessageManager.addModMessage("Generating: " + dataprovider.getName()); stopwatch1.start(); - dataprovider.m_6865_(hashcache); + dataprovider.run(hashcache); stopwatch1.stop(); @@ -51,6 +_,14 @@ - public void m_123914_(DataProvider p_123915_) { - this.f_123908_.add(p_123915_); + public void addProvider(DataProvider p_123915_) { + this.providers.add(p_123915_); + } + + public List getProviders() { @@ -32,7 +32,7 @@ + } + + public void addInput(Path value) { -+ this.f_123906_.add(value); ++ this.inputFolders.add(value); } static { diff --git a/patches/minecraft/net/minecraft/data/HashCache.java.patch b/patches/minecraft/net/minecraft/data/HashCache.java.patch index b17977f0..ae6aeecb 100644 --- a/patches/minecraft/net/minecraft/data/HashCache.java.patch +++ b/patches/minecraft/net/minecraft/data/HashCache.java.patch @@ -3,11 +3,11 @@ @@ -55,8 +_,8 @@ } - IOUtils.writeLines(this.f_123931_.entrySet().stream().map((p_123944_) -> { -- return (String)p_123944_.getValue() + " " + this.f_123927_.relativize(p_123944_.getKey()); + IOUtils.writeLines(this.newCache.entrySet().stream().map((p_123944_) -> { +- return (String)p_123944_.getValue() + " " + this.path.relativize(p_123944_.getKey()); - }).collect(Collectors.toList()), System.lineSeparator(), writer); -+ return (String)p_123944_.getValue() + ' ' + this.f_123927_.relativize(p_123944_.getKey()).toString().replace('\\', '/'); //Forge: Standardize file paths. ++ return (String)p_123944_.getValue() + ' ' + this.path.relativize(p_123944_.getKey()).toString().replace('\\', '/'); //Forge: Standardize file paths. + }).sorted(java.util.Comparator.comparing(a -> a.split(" ")[1])).collect(Collectors.toList()), System.lineSeparator(), writer); writer.close(); - f_123926_.debug("Caching: cache hits: {}, created: {} removed: {}", this.f_123929_, this.f_123931_.size() - this.f_123929_, this.f_123930_.size()); + LOGGER.debug("Caching: cache hits: {}, created: {} removed: {}", this.hits, this.newCache.size() - this.hits, this.oldCache.size()); } diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index 75cbbeb3..1614ada2 100644 --- a/patches/minecraft/net/minecraft/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/data/Main.java.patch @@ -21,10 +21,10 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); -- DataGenerator datagenerator = m_129660_(path, optionset.valuesOf(optionspec8).stream().map((p_129659_) -> { +- DataGenerator datagenerator = createStandardGenerator(path, optionset.valuesOf(optionspec8).stream().map((p_129659_) -> { - return Paths.get(p_129659_); - }).collect(Collectors.toList()), flag1, flag2, flag3, flag4, flag5); -- datagenerator.m_123917_(); +- datagenerator.run(); + Collection inputs = optionset.valuesOf(optionspec8).stream().map(Paths::get).collect(Collectors.toList()); + Collection existingPacks = optionset.valuesOf(existing).stream().map(Paths::get).collect(Collectors.toList()); + java.util.Set existingMods = new java.util.HashSet<>(optionset.valuesOf(existingMod)); @@ -32,7 +32,7 @@ + boolean isFlat = mods.isEmpty() || optionset.has(flat); + net.minecraftforge.data.loading.DatagenModLoader.begin(mods, path, inputs, existingPacks, existingMods, flag2, flag1, flag3, flag4, flag5, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir)); + if (mods.contains("minecraft") || mods.isEmpty()) -+ m_129660_(isFlat ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).m_123917_(); ++ createStandardGenerator(isFlat ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).run(); } else { optionparser.printHelpOn(System.out); } diff --git a/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch b/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch index d4f27651..0dde6aaf 100644 --- a/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/data/advancements/AdvancementProvider.java +++ b/net/minecraft/data/advancements/AdvancementProvider.java @@ -22,11 +_,18 @@ - private static final Gson f_123961_ = (new GsonBuilder()).setPrettyPrinting().create(); - private final DataGenerator f_123962_; - private final List>> f_123963_ = ImmutableList.of(new TheEndAdvancements(), new HusbandryAdvancements(), new AdventureAdvancements(), new NetherAdvancements(), new StoryAdvancements()); + private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); + private final DataGenerator generator; + private final List>> tabs = ImmutableList.of(new TheEndAdvancements(), new HusbandryAdvancements(), new AdventureAdvancements(), new NetherAdvancements(), new StoryAdvancements()); + protected net.minecraftforge.common.data.ExistingFileHelper fileHelper; + @Deprecated public AdvancementProvider(DataGenerator p_123966_) { - this.f_123962_ = p_123966_; + this.generator = p_123966_; } + public AdvancementProvider(DataGenerator generatorIn, net.minecraftforge.common.data.ExistingFileHelper fileHelperIn) { -+ this.f_123962_ = generatorIn; ++ this.generator = generatorIn; + this.fileHelper = fileHelperIn; + } + - public void m_6865_(HashCache p_123969_) { - Path path = this.f_123962_.m_123916_(); + public void run(HashCache p_123969_) { + Path path = this.generator.getOutputFolder(); Set set = Sets.newHashSet(); @@ -45,6 +_,16 @@ } @@ -33,6 +33,6 @@ + * @param fileHelper used for the register function from {@link Advancement.Builder} + */ + protected void registerAdvancements(Consumer consumer, net.minecraftforge.common.data.ExistingFileHelper fileHelper) { - for(Consumer> consumer1 : this.f_123963_) { + for(Consumer> consumer1 : this.tabs) { consumer1.accept(consumer); } diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch index 10ce7912..1ac05db6 100644 --- a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch @@ -1,37 +1,37 @@ --- a/net/minecraft/data/loot/BlockLoot.java +++ b/net/minecraft/data/loot/BlockLoot.java @@ -250,7 +_,7 @@ - return LootTable.m_79147_(); + return LootTable.lootTable(); } - public void accept(BiConsumer p_124179_) { + protected void addTables() { - this.m_124288_(Blocks.f_50122_); - this.m_124288_(Blocks.f_50175_); - this.m_124288_(Blocks.f_50228_); + this.dropSelf(Blocks.GRANITE); + this.dropSelf(Blocks.POLISHED_GRANITE); + this.dropSelf(Blocks.DIORITE); @@ -1252,9 +_,13 @@ - this.m_124165_(Blocks.f_50142_, m_124125_()); - this.m_124165_(Blocks.f_152491_, m_124125_()); - this.m_124165_(Blocks.f_152499_, m_124125_()); + this.add(Blocks.NETHER_PORTAL, noDrop()); + this.add(Blocks.BUDDING_AMETHYST, noDrop()); + this.add(Blocks.POWDER_SNOW, noDrop()); + } + + public void accept(BiConsumer p_124179_) { + this.addTables(); Set set = Sets.newHashSet(); -- for(Block block : Registry.f_122824_) { +- for(Block block : Registry.BLOCK) { + for(Block block : getKnownBlocks()) { - ResourceLocation resourcelocation = block.m_60589_(); - if (resourcelocation != BuiltInLootTables.f_78712_ && set.add(resourcelocation)) { - LootTable.Builder loottable$builder = this.f_124070_.remove(resourcelocation); + ResourceLocation resourcelocation = block.getLootTable(); + if (resourcelocation != BuiltInLootTables.EMPTY && set.add(resourcelocation)) { + LootTable.Builder loottable$builder = this.map.remove(resourcelocation); @@ -1279,6 +_,10 @@ - public static LootTable.Builder m_124137_(Block p_124138_) { - return m_124161_(p_124138_, DoorBlock.f_52730_, DoubleBlockHalf.LOWER); + public static LootTable.Builder createDoorTable(Block p_124138_) { + return createSinglePropConditionTable(p_124138_, DoorBlock.HALF, DoubleBlockHalf.LOWER); + } + + protected Iterable getKnownBlocks() { -+ return Registry.f_122824_; ++ return Registry.BLOCK; } - public void m_124252_(Block p_124253_) { + public void dropPottedContents(Block p_124253_) { diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch index 3d318b41..420a8c48 100644 --- a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch @@ -1,44 +1,44 @@ --- a/net/minecraft/data/loot/EntityLoot.java +++ b/net/minecraft/data/loot/EntityLoot.java @@ -49,7 +_,7 @@ - return LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(p_124375_))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootTableReference.m_79776_(EntityType.f_20520_.m_20677_()))); + return LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)).add(LootItem.lootTableItem(p_124375_))).withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)).add(LootTableReference.lootTableReference(EntityType.SHEEP.getDefaultLootTable()))); } - public void accept(BiConsumer p_124377_) { + protected void addTables() { - this.m_124371_(EntityType.f_20529_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_147039_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_20549_, LootTable.m_79147_()); + this.add(EntityType.ARMOR_STAND, LootTable.lootTable()); + this.add(EntityType.AXOLOTL, LootTable.lootTable()); + this.add(EntityType.BAT, LootTable.lootTable()); @@ -141,11 +_,15 @@ - this.m_124371_(EntityType.f_20511_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_20512_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_20530_, LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42583_).m_5577_(SetItemCountFunction.m_165412_(UniformGenerator.m_165780_(0.0F, 2.0F))).m_5577_(LootingEnchantFunction.m_165229_(UniformGenerator.m_165780_(0.0F, 1.0F))))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42416_)).m_79076_(LootItem.m_79579_(Items.f_42619_)).m_79076_(LootItem.m_79579_(Items.f_42620_).m_5577_(SmeltItemFunction.m_81271_().m_6509_(LootItemEntityPropertyCondition.m_81864_(LootContext.EntityTarget.THIS, f_124366_)))).m_6509_(LootItemKilledByPlayerCondition.m_81901_()).m_6509_(LootItemRandomChanceWithLootingCondition.m_81963_(0.025F, 0.01F)))); + this.add(EntityType.PIGLIN, LootTable.lootTable()); + this.add(EntityType.PIGLIN_BRUTE, LootTable.lootTable()); + this.add(EntityType.ZOMBIE_VILLAGER, LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)).add(LootItem.lootTableItem(Items.ROTTEN_FLESH).apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F))).apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(0.0F, 1.0F))))).withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)).add(LootItem.lootTableItem(Items.IRON_INGOT)).add(LootItem.lootTableItem(Items.CARROT)).add(LootItem.lootTableItem(Items.POTATO).apply(SmeltItemFunction.smelted().when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, ENTITY_ON_FIRE)))).when(LootItemKilledByPlayerCondition.killedByPlayer()).when(LootItemRandomChanceWithLootingCondition.randomChanceAndLootingBoost(0.025F, 0.01F)))); + } + + public void accept(BiConsumer p_124377_) { + this.addTables(); Set set = Sets.newHashSet(); -- for(EntityType entitytype : Registry.f_122826_) { +- for(EntityType entitytype : Registry.ENTITY_TYPE) { + for(EntityType entitytype : getKnownEntities()) { - ResourceLocation resourcelocation = entitytype.m_20677_(); -- if (!f_124367_.contains(entitytype) && entitytype.m_20674_() == MobCategory.MISC) { + ResourceLocation resourcelocation = entitytype.getDefaultLootTable(); +- if (!SPECIAL_LOOT_TABLE_TYPES.contains(entitytype) && entitytype.getCategory() == MobCategory.MISC) { + if (isNonLiving(entitytype)) { - if (resourcelocation != BuiltInLootTables.f_78712_ && this.f_124368_.remove(resourcelocation) != null) { - throw new IllegalStateException(String.format("Weird loottable '%s' for '%s', not a LivingEntity so should not have loot", resourcelocation, Registry.f_122826_.m_7981_(entitytype))); + if (resourcelocation != BuiltInLootTables.EMPTY && this.map.remove(resourcelocation) != null) { + throw new IllegalStateException(String.format("Weird loottable '%s' for '%s', not a LivingEntity so should not have loot", resourcelocation, Registry.ENTITY_TYPE.getKey(entitytype))); } @@ -160,6 +_,14 @@ } - this.f_124368_.forEach(p_124377_); + this.map.forEach(p_124377_); + } + + protected Iterable> getKnownEntities() { -+ return Registry.f_122826_; ++ return Registry.ENTITY_TYPE; + } + + protected boolean isNonLiving(EntityType entitytype) { -+ return !f_124367_.contains(entitytype) && entitytype.m_20674_() == MobCategory.MISC; ++ return !SPECIAL_LOOT_TABLE_TYPES.contains(entitytype) && entitytype.getCategory() == MobCategory.MISC; } - protected void m_124371_(EntityType p_124372_, LootTable.Builder p_124373_) { + protected void add(EntityType p_124372_, LootTable.Builder p_124373_) { diff --git a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch index a65a7b5f..fc97e3cb 100644 --- a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/data/loot/LootTableProvider.java +++ b/net/minecraft/data/loot/LootTableProvider.java @@ -40,7 +_,7 @@ - public void m_6865_(HashCache p_124444_) { - Path path = this.f_124433_.m_123916_(); + public void run(HashCache p_124444_) { + Path path = this.generator.getOutputFolder(); Map map = Maps.newHashMap(); -- this.f_124434_.forEach((p_124458_) -> { +- this.subProviders.forEach((p_124458_) -> { + this.getTables().forEach((p_124458_) -> { p_124458_.getFirst().get().accept((p_176077_, p_176078_) -> { - if (map.put(p_176077_, p_176078_.m_79165_(p_124458_.getSecond()).m_79167_()) != null) { + if (map.put(p_176077_, p_176078_.setParamSet(p_124458_.getSecond()).build()) != null) { throw new IllegalStateException("Duplicate loot table " + p_176077_); @@ -51,13 +_,8 @@ return null; }, map::get); -- for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.m_78766_(), map.keySet())) { -- validationcontext.m_79357_("Missing built-in table: " + resourcelocation); +- for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.all(), map.keySet())) { +- validationcontext.reportProblem("Missing built-in table: " + resourcelocation); - } + validate(map, validationcontext); - map.forEach((p_124441_, p_124442_) -> { -- LootTables.m_79202_(validationcontext, p_124441_, p_124442_); +- LootTables.validate(validationcontext, p_124441_, p_124442_); - }); - Multimap multimap = validationcontext.m_79352_(); + Multimap multimap = validationcontext.getProblems(); if (!multimap.isEmpty()) { multimap.forEach((p_124446_, p_124447_) -> { @@ -76,6 +_,20 @@ @@ -31,17 +31,17 @@ + } + + protected List>>, LootContextParamSet>> getTables() { -+ return f_124434_; ++ return subProviders; + } + + protected void validate(Map map, ValidationContext validationtracker) { -+ for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.m_78766_(), map.keySet())) { -+ validationtracker.m_79357_("Missing built-in table: " + resourcelocation); ++ for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.all(), map.keySet())) { ++ validationtracker.reportProblem("Missing built-in table: " + resourcelocation); + } + + map.forEach((p_218436_2_, p_218436_3_) -> { -+ LootTables.m_79202_(validationtracker, p_218436_2_, p_218436_3_); ++ LootTables.validate(validationtracker, p_218436_2_, p_218436_3_); + }); } - private static Path m_124453_(Path p_124454_, ResourceLocation p_124455_) { + private static Path createPath(Path p_124454_, ResourceLocation p_124455_) { diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index 022ce668..62b38ecc 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -2,349 +2,349 @@ +++ b/net/minecraft/data/recipes/RecipeProvider.java @@ -50,16 +_,16 @@ public class RecipeProvider implements DataProvider { - private static final Logger f_125968_ = LogUtils.getLogger(); - private static final Gson f_125969_ = (new GsonBuilder()).setPrettyPrinting().create(); -- protected static final ImmutableList f_176505_ = ImmutableList.of(Items.f_41835_, Items.f_150963_); -- protected static final ImmutableList f_176506_ = ImmutableList.of(Items.f_41834_, Items.f_150964_, Items.f_151050_); -- protected static final ImmutableList f_176507_ = ImmutableList.of(Items.f_150965_, Items.f_150966_, Items.f_151051_); -- protected static final ImmutableList f_176508_ = ImmutableList.of(Items.f_41833_, Items.f_150967_, Items.f_41836_, Items.f_151053_); -- protected static final ImmutableList f_176509_ = ImmutableList.of(Items.f_42010_, Items.f_150994_); -- protected static final ImmutableList f_176510_ = ImmutableList.of(Items.f_41853_, Items.f_150993_); -- protected static final ImmutableList f_176511_ = ImmutableList.of(Items.f_41977_, Items.f_150968_); -- protected static final ImmutableList f_176512_ = ImmutableList.of(Items.f_42107_, Items.f_150969_); -+ private static final ImmutableList f_176505_ = ImmutableList.of(Items.f_41835_, Items.f_150963_); -+ private static final ImmutableList f_176506_ = ImmutableList.of(Items.f_41834_, Items.f_150964_, Items.f_151050_); -+ private static final ImmutableList f_176507_ = ImmutableList.of(Items.f_150965_, Items.f_150966_, Items.f_151051_); -+ private static final ImmutableList f_176508_ = ImmutableList.of(Items.f_41833_, Items.f_150967_, Items.f_41836_, Items.f_151053_); -+ private static final ImmutableList f_176509_ = ImmutableList.of(Items.f_42010_, Items.f_150994_); -+ private static final ImmutableList f_176510_ = ImmutableList.of(Items.f_41853_, Items.f_150993_); -+ private static final ImmutableList f_176511_ = ImmutableList.of(Items.f_41977_, Items.f_150968_); -+ private static final ImmutableList f_176512_ = ImmutableList.of(Items.f_42107_, Items.f_150969_); - protected final DataGenerator f_125970_; -- protected static final Map> f_176513_ = ImmutableMap.>builder().put(BlockFamily.Variant.BUTTON, (p_176733_, p_176734_) -> { -+ private static final Map> f_176513_ = ImmutableMap.>builder().put(BlockFamily.Variant.BUTTON, (p_176733_, p_176734_) -> { - return m_176658_(p_176733_, Ingredient.m_43929_(p_176734_)); + private static final Logger LOGGER = LogUtils.getLogger(); + private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); +- protected static final ImmutableList COAL_SMELTABLES = ImmutableList.of(Items.COAL_ORE, Items.DEEPSLATE_COAL_ORE); +- protected static final ImmutableList IRON_SMELTABLES = ImmutableList.of(Items.IRON_ORE, Items.DEEPSLATE_IRON_ORE, Items.RAW_IRON); +- protected static final ImmutableList COPPER_SMELTABLES = ImmutableList.of(Items.COPPER_ORE, Items.DEEPSLATE_COPPER_ORE, Items.RAW_COPPER); +- protected static final ImmutableList GOLD_SMELTABLES = ImmutableList.of(Items.GOLD_ORE, Items.DEEPSLATE_GOLD_ORE, Items.NETHER_GOLD_ORE, Items.RAW_GOLD); +- protected static final ImmutableList DIAMOND_SMELTABLES = ImmutableList.of(Items.DIAMOND_ORE, Items.DEEPSLATE_DIAMOND_ORE); +- protected static final ImmutableList LAPIS_SMELTABLES = ImmutableList.of(Items.LAPIS_ORE, Items.DEEPSLATE_LAPIS_ORE); +- protected static final ImmutableList REDSTONE_SMELTABLES = ImmutableList.of(Items.REDSTONE_ORE, Items.DEEPSLATE_REDSTONE_ORE); +- protected static final ImmutableList EMERALD_SMELTABLES = ImmutableList.of(Items.EMERALD_ORE, Items.DEEPSLATE_EMERALD_ORE); ++ private static final ImmutableList COAL_SMELTABLES = ImmutableList.of(Items.COAL_ORE, Items.DEEPSLATE_COAL_ORE); ++ private static final ImmutableList IRON_SMELTABLES = ImmutableList.of(Items.IRON_ORE, Items.DEEPSLATE_IRON_ORE, Items.RAW_IRON); ++ private static final ImmutableList COPPER_SMELTABLES = ImmutableList.of(Items.COPPER_ORE, Items.DEEPSLATE_COPPER_ORE, Items.RAW_COPPER); ++ private static final ImmutableList GOLD_SMELTABLES = ImmutableList.of(Items.GOLD_ORE, Items.DEEPSLATE_GOLD_ORE, Items.NETHER_GOLD_ORE, Items.RAW_GOLD); ++ private static final ImmutableList DIAMOND_SMELTABLES = ImmutableList.of(Items.DIAMOND_ORE, Items.DEEPSLATE_DIAMOND_ORE); ++ private static final ImmutableList LAPIS_SMELTABLES = ImmutableList.of(Items.LAPIS_ORE, Items.DEEPSLATE_LAPIS_ORE); ++ private static final ImmutableList REDSTONE_SMELTABLES = ImmutableList.of(Items.REDSTONE_ORE, Items.DEEPSLATE_REDSTONE_ORE); ++ private static final ImmutableList EMERALD_SMELTABLES = ImmutableList.of(Items.EMERALD_ORE, Items.DEEPSLATE_EMERALD_ORE); + protected final DataGenerator generator; +- protected static final Map> shapeBuilders = ImmutableMap.>builder().put(BlockFamily.Variant.BUTTON, (p_176733_, p_176734_) -> { ++ private static final Map> shapeBuilders = ImmutableMap.>builder().put(BlockFamily.Variant.BUTTON, (p_176733_, p_176734_) -> { + return buttonBuilder(p_176733_, Ingredient.of(p_176734_)); }).put(BlockFamily.Variant.CHISELED, (p_176730_, p_176731_) -> { - return m_176646_(p_176730_, Ingredient.m_43929_(p_176731_)); + return chiseledBuilder(p_176730_, Ingredient.of(p_176731_)); @@ -106,6 +_,7 @@ } }); + if (this.getClass() == RecipeProvider.class) //Forge: Subclasses don't need this. - m_126013_(p_125982_, Advancement.Builder.m_138353_().m_138386_("impossible", new ImpossibleTrigger.TriggerInstance()).m_138400_(), path.resolve("data/minecraft/advancements/recipes/root.json")); + saveAdvancement(p_125982_, Advancement.Builder.advancement().addCriterion("impossible", new ImpossibleTrigger.TriggerInstance()).serializeToJson(), path.resolve("data/minecraft/advancements/recipes/root.json")); } @@ -143,7 +_,7 @@ } -- protected static void m_126013_(HashCache p_126014_, JsonObject p_126015_, Path p_126016_) { -+ protected void m_126013_(HashCache p_126014_, JsonObject p_126015_, Path p_126016_) { +- protected static void saveAdvancement(HashCache p_126014_, JsonObject p_126015_, Path p_126016_) { ++ protected void saveAdvancement(HashCache p_126014_, JsonObject p_126015_, Path p_126016_) { try { - String s = f_125969_.toJson((JsonElement)p_126015_); - String s1 = f_123918_.hashUnencodedChars(s).toString(); + String s = GSON.toJson((JsonElement)p_126015_); + String s1 = SHA1.hashUnencodedChars(s).toString(); @@ -177,7 +_,7 @@ } -- protected static void m_176531_(Consumer p_176532_) { -+ protected void m_176531_(Consumer p_176532_) { - BlockFamilies.m_175934_().filter(BlockFamily::m_175956_).forEach((p_176624_) -> { - m_176580_(p_176532_, p_176624_); +- protected static void buildCraftingRecipes(Consumer p_176532_) { ++ protected void buildCraftingRecipes(Consumer p_176532_) { + BlockFamilies.getAllFamilies().filter(BlockFamily::shouldGenerateRecipe).forEach((p_176624_) -> { + generateRecipes(p_176532_, p_176624_); }); @@ -981,136 +_,136 @@ - m_125994_(p_176532_, Items.f_42389_, Items.f_42394_); + netheriteSmithing(p_176532_, Items.DIAMOND_SHOVEL, Items.NETHERITE_SHOVEL); } -- protected static void m_176551_(Consumer p_176552_, ItemLike p_176553_, ItemLike p_176554_, @Nullable String p_176555_) { -+ private static void m_176551_(Consumer p_176552_, ItemLike p_176553_, ItemLike p_176554_, @Nullable String p_176555_) { - m_176556_(p_176552_, p_176553_, p_176554_, p_176555_, 1); +- protected static void oneToOneConversionRecipe(Consumer p_176552_, ItemLike p_176553_, ItemLike p_176554_, @Nullable String p_176555_) { ++ private static void oneToOneConversionRecipe(Consumer p_176552_, ItemLike p_176553_, ItemLike p_176554_, @Nullable String p_176555_) { + oneToOneConversionRecipe(p_176552_, p_176553_, p_176554_, p_176555_, 1); } -- protected static void m_176556_(Consumer p_176557_, ItemLike p_176558_, ItemLike p_176559_, @Nullable String p_176560_, int p_176561_) { -+ private static void m_176556_(Consumer p_176557_, ItemLike p_176558_, ItemLike p_176559_, @Nullable String p_176560_, int p_176561_) { - ShapelessRecipeBuilder.m_126191_(p_176558_, p_176561_).m_126209_(p_176559_).m_142409_(p_176560_).m_142284_(m_176602_(p_176559_), m_125977_(p_176559_)).m_176500_(p_176557_, m_176517_(p_176558_, p_176559_)); +- protected static void oneToOneConversionRecipe(Consumer p_176557_, ItemLike p_176558_, ItemLike p_176559_, @Nullable String p_176560_, int p_176561_) { ++ private static void oneToOneConversionRecipe(Consumer p_176557_, ItemLike p_176558_, ItemLike p_176559_, @Nullable String p_176560_, int p_176561_) { + ShapelessRecipeBuilder.shapeless(p_176558_, p_176561_).requires(p_176559_).group(p_176560_).unlockedBy(getHasName(p_176559_), has(p_176559_)).save(p_176557_, getConversionRecipeName(p_176558_, p_176559_)); } -- protected static void m_176591_(Consumer p_176592_, List p_176593_, ItemLike p_176594_, float p_176595_, int p_176596_, String p_176597_) { -+ private static void m_176591_(Consumer p_176592_, List p_176593_, ItemLike p_176594_, float p_176595_, int p_176596_, String p_176597_) { - m_176533_(p_176592_, RecipeSerializer.f_44091_, p_176593_, p_176594_, p_176595_, p_176596_, p_176597_, "_from_smelting"); +- protected static void oreSmelting(Consumer p_176592_, List p_176593_, ItemLike p_176594_, float p_176595_, int p_176596_, String p_176597_) { ++ private static void oreSmelting(Consumer p_176592_, List p_176593_, ItemLike p_176594_, float p_176595_, int p_176596_, String p_176597_) { + oreCooking(p_176592_, RecipeSerializer.SMELTING_RECIPE, p_176593_, p_176594_, p_176595_, p_176596_, p_176597_, "_from_smelting"); } -- protected static void m_176625_(Consumer p_176626_, List p_176627_, ItemLike p_176628_, float p_176629_, int p_176630_, String p_176631_) { -+ private static void m_176625_(Consumer p_176626_, List p_176627_, ItemLike p_176628_, float p_176629_, int p_176630_, String p_176631_) { - m_176533_(p_176626_, RecipeSerializer.f_44092_, p_176627_, p_176628_, p_176629_, p_176630_, p_176631_, "_from_blasting"); +- protected static void oreBlasting(Consumer p_176626_, List p_176627_, ItemLike p_176628_, float p_176629_, int p_176630_, String p_176631_) { ++ private static void oreBlasting(Consumer p_176626_, List p_176627_, ItemLike p_176628_, float p_176629_, int p_176630_, String p_176631_) { + oreCooking(p_176626_, RecipeSerializer.BLASTING_RECIPE, p_176627_, p_176628_, p_176629_, p_176630_, p_176631_, "_from_blasting"); } -- protected static void m_176533_(Consumer p_176534_, SimpleCookingSerializer p_176535_, List p_176536_, ItemLike p_176537_, float p_176538_, int p_176539_, String p_176540_, String p_176541_) { -+ private static void m_176533_(Consumer p_176534_, SimpleCookingSerializer p_176535_, List p_176536_, ItemLike p_176537_, float p_176538_, int p_176539_, String p_176540_, String p_176541_) { +- protected static void oreCooking(Consumer p_176534_, SimpleCookingSerializer p_176535_, List p_176536_, ItemLike p_176537_, float p_176538_, int p_176539_, String p_176540_, String p_176541_) { ++ private static void oreCooking(Consumer p_176534_, SimpleCookingSerializer p_176535_, List p_176536_, ItemLike p_176537_, float p_176538_, int p_176539_, String p_176540_, String p_176541_) { for(ItemLike itemlike : p_176536_) { - SimpleCookingRecipeBuilder.m_126248_(Ingredient.m_43929_(itemlike), p_176537_, p_176538_, p_176539_, p_176535_).m_142409_(p_176540_).m_142284_(m_176602_(itemlike), m_125977_(itemlike)).m_176500_(p_176534_, m_176632_(p_176537_) + p_176541_ + "_" + m_176632_(itemlike)); + SimpleCookingRecipeBuilder.cooking(Ingredient.of(itemlike), p_176537_, p_176538_, p_176539_, p_176535_).group(p_176540_).unlockedBy(getHasName(itemlike), has(itemlike)).save(p_176534_, getItemName(p_176537_) + p_176541_ + "_" + getItemName(itemlike)); } } -- protected static void m_125994_(Consumer p_125995_, Item p_125996_, Item p_125997_) { -+ private static void m_125994_(Consumer p_125995_, Item p_125996_, Item p_125997_) { - UpgradeRecipeBuilder.m_126385_(Ingredient.m_43929_(p_125996_), Ingredient.m_43929_(Items.f_42418_), p_125997_).m_126389_("has_netherite_ingot", m_125977_(Items.f_42418_)).m_126392_(p_125995_, m_176632_(p_125997_) + "_smithing"); +- protected static void netheriteSmithing(Consumer p_125995_, Item p_125996_, Item p_125997_) { ++ private static void netheriteSmithing(Consumer p_125995_, Item p_125996_, Item p_125997_) { + UpgradeRecipeBuilder.smithing(Ingredient.of(p_125996_), Ingredient.of(Items.NETHERITE_INGOT), p_125997_).unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT)).save(p_125995_, getItemName(p_125997_) + "_smithing"); } -- protected static void m_206408_(Consumer p_206409_, ItemLike p_206410_, TagKey p_206411_) { -+ private static void m_206408_(Consumer p_206409_, ItemLike p_206410_, TagKey p_206411_) { - ShapelessRecipeBuilder.m_126191_(p_206410_, 4).m_206419_(p_206411_).m_142409_("planks").m_142284_("has_log", m_206406_(p_206411_)).m_176498_(p_206409_); +- protected static void planksFromLog(Consumer p_206409_, ItemLike p_206410_, TagKey p_206411_) { ++ private static void planksFromLog(Consumer p_206409_, ItemLike p_206410_, TagKey p_206411_) { + ShapelessRecipeBuilder.shapeless(p_206410_, 4).requires(p_206411_).group("planks").unlockedBy("has_log", has(p_206411_)).save(p_206409_); } -- protected static void m_206412_(Consumer p_206413_, ItemLike p_206414_, TagKey p_206415_) { -+ private static void m_206412_(Consumer p_206413_, ItemLike p_206414_, TagKey p_206415_) { - ShapelessRecipeBuilder.m_126191_(p_206414_, 4).m_206419_(p_206415_).m_142409_("planks").m_142284_("has_logs", m_206406_(p_206415_)).m_176498_(p_206413_); +- protected static void planksFromLogs(Consumer p_206413_, ItemLike p_206414_, TagKey p_206415_) { ++ private static void planksFromLogs(Consumer p_206413_, ItemLike p_206414_, TagKey p_206415_) { + ShapelessRecipeBuilder.shapeless(p_206414_, 4).requires(p_206415_).group("planks").unlockedBy("has_logs", has(p_206415_)).save(p_206413_); } -- protected static void m_126002_(Consumer p_126003_, ItemLike p_126004_, ItemLike p_126005_) { -+ private static void m_126002_(Consumer p_126003_, ItemLike p_126004_, ItemLike p_126005_) { - ShapedRecipeBuilder.m_126118_(p_126004_, 3).m_126127_('#', p_126005_).m_126130_("##").m_126130_("##").m_142409_("bark").m_142284_("has_log", m_125977_(p_126005_)).m_176498_(p_126003_); +- protected static void woodFromLogs(Consumer p_126003_, ItemLike p_126004_, ItemLike p_126005_) { ++ private static void woodFromLogs(Consumer p_126003_, ItemLike p_126004_, ItemLike p_126005_) { + ShapedRecipeBuilder.shaped(p_126004_, 3).define('#', p_126005_).pattern("##").pattern("##").group("bark").unlockedBy("has_log", has(p_126005_)).save(p_126003_); } -- protected static void m_126021_(Consumer p_126022_, ItemLike p_126023_, ItemLike p_126024_) { -+ private static void m_126021_(Consumer p_126022_, ItemLike p_126023_, ItemLike p_126024_) { - ShapedRecipeBuilder.m_126116_(p_126023_).m_126127_('#', p_126024_).m_126130_("# #").m_126130_("###").m_142409_("boat").m_142284_("in_water", m_125979_(Blocks.f_49990_)).m_176498_(p_126022_); +- protected static void woodenBoat(Consumer p_126022_, ItemLike p_126023_, ItemLike p_126024_) { ++ private static void woodenBoat(Consumer p_126022_, ItemLike p_126023_, ItemLike p_126024_) { + ShapedRecipeBuilder.shaped(p_126023_).define('#', p_126024_).pattern("# #").pattern("###").group("boat").unlockedBy("in_water", insideOf(Blocks.WATER)).save(p_126022_); } -- protected static RecipeBuilder m_176658_(ItemLike p_176659_, Ingredient p_176660_) { -+ private static RecipeBuilder m_176658_(ItemLike p_176659_, Ingredient p_176660_) { - return ShapelessRecipeBuilder.m_126189_(p_176659_).m_126184_(p_176660_); +- protected static RecipeBuilder buttonBuilder(ItemLike p_176659_, Ingredient p_176660_) { ++ private static RecipeBuilder buttonBuilder(ItemLike p_176659_, Ingredient p_176660_) { + return ShapelessRecipeBuilder.shapeless(p_176659_).requires(p_176660_); } -- protected static RecipeBuilder m_176670_(ItemLike p_176671_, Ingredient p_176672_) { -+ private static RecipeBuilder m_176670_(ItemLike p_176671_, Ingredient p_176672_) { - return ShapedRecipeBuilder.m_126118_(p_176671_, 3).m_126124_('#', p_176672_).m_126130_("##").m_126130_("##").m_126130_("##"); +- protected static RecipeBuilder doorBuilder(ItemLike p_176671_, Ingredient p_176672_) { ++ private static RecipeBuilder doorBuilder(ItemLike p_176671_, Ingredient p_176672_) { + return ShapedRecipeBuilder.shaped(p_176671_, 3).define('#', p_176672_).pattern("##").pattern("##").pattern("##"); } -- protected static RecipeBuilder m_176678_(ItemLike p_176679_, Ingredient p_176680_) { -+ private static RecipeBuilder m_176678_(ItemLike p_176679_, Ingredient p_176680_) { - int i = p_176679_ == Blocks.f_50198_ ? 6 : 3; - Item item = p_176679_ == Blocks.f_50198_ ? Items.f_42691_ : Items.f_42398_; - return ShapedRecipeBuilder.m_126118_(p_176679_, i).m_126124_('W', p_176680_).m_126127_('#', item).m_126130_("W#W").m_126130_("W#W"); +- protected static RecipeBuilder fenceBuilder(ItemLike p_176679_, Ingredient p_176680_) { ++ private static RecipeBuilder fenceBuilder(ItemLike p_176679_, Ingredient p_176680_) { + int i = p_176679_ == Blocks.NETHER_BRICK_FENCE ? 6 : 3; + Item item = p_176679_ == Blocks.NETHER_BRICK_FENCE ? Items.NETHER_BRICK : Items.STICK; + return ShapedRecipeBuilder.shaped(p_176679_, i).define('W', p_176680_).define('#', item).pattern("W#W").pattern("W#W"); } -- protected static RecipeBuilder m_176684_(ItemLike p_176685_, Ingredient p_176686_) { -+ private static RecipeBuilder m_176684_(ItemLike p_176685_, Ingredient p_176686_) { - return ShapedRecipeBuilder.m_126116_(p_176685_).m_126127_('#', Items.f_42398_).m_126124_('W', p_176686_).m_126130_("#W#").m_126130_("#W#"); +- protected static RecipeBuilder fenceGateBuilder(ItemLike p_176685_, Ingredient p_176686_) { ++ private static RecipeBuilder fenceGateBuilder(ItemLike p_176685_, Ingredient p_176686_) { + return ShapedRecipeBuilder.shaped(p_176685_).define('#', Items.STICK).define('W', p_176686_).pattern("#W#").pattern("#W#"); } -- protected static void m_176690_(Consumer p_176691_, ItemLike p_176692_, ItemLike p_176693_) { -+ private static void m_176690_(Consumer p_176691_, ItemLike p_176692_, ItemLike p_176693_) { - m_176694_(p_176692_, Ingredient.m_43929_(p_176693_)).m_142284_(m_176602_(p_176693_), m_125977_(p_176693_)).m_176498_(p_176691_); +- protected static void pressurePlate(Consumer p_176691_, ItemLike p_176692_, ItemLike p_176693_) { ++ private static void pressurePlate(Consumer p_176691_, ItemLike p_176692_, ItemLike p_176693_) { + pressurePlateBuilder(p_176692_, Ingredient.of(p_176693_)).unlockedBy(getHasName(p_176693_), has(p_176693_)).save(p_176691_); } -- protected static RecipeBuilder m_176694_(ItemLike p_176695_, Ingredient p_176696_) { -+ private static RecipeBuilder m_176694_(ItemLike p_176695_, Ingredient p_176696_) { - return ShapedRecipeBuilder.m_126116_(p_176695_).m_126124_('#', p_176696_).m_126130_("##"); +- protected static RecipeBuilder pressurePlateBuilder(ItemLike p_176695_, Ingredient p_176696_) { ++ private static RecipeBuilder pressurePlateBuilder(ItemLike p_176695_, Ingredient p_176696_) { + return ShapedRecipeBuilder.shaped(p_176695_).define('#', p_176696_).pattern("##"); } -- protected static void m_176700_(Consumer p_176701_, ItemLike p_176702_, ItemLike p_176703_) { -+ private static void m_176700_(Consumer p_176701_, ItemLike p_176702_, ItemLike p_176703_) { - m_176704_(p_176702_, Ingredient.m_43929_(p_176703_)).m_142284_(m_176602_(p_176703_), m_125977_(p_176703_)).m_176498_(p_176701_); +- protected static void slab(Consumer p_176701_, ItemLike p_176702_, ItemLike p_176703_) { ++ private static void slab(Consumer p_176701_, ItemLike p_176702_, ItemLike p_176703_) { + slabBuilder(p_176702_, Ingredient.of(p_176703_)).unlockedBy(getHasName(p_176703_), has(p_176703_)).save(p_176701_); } -- protected static RecipeBuilder m_176704_(ItemLike p_176705_, Ingredient p_176706_) { -+ private static RecipeBuilder m_176704_(ItemLike p_176705_, Ingredient p_176706_) { - return ShapedRecipeBuilder.m_126118_(p_176705_, 6).m_126124_('#', p_176706_).m_126130_("###"); +- protected static RecipeBuilder slabBuilder(ItemLike p_176705_, Ingredient p_176706_) { ++ private static RecipeBuilder slabBuilder(ItemLike p_176705_, Ingredient p_176706_) { + return ShapedRecipeBuilder.shaped(p_176705_, 6).define('#', p_176706_).pattern("###"); } -- protected static RecipeBuilder m_176710_(ItemLike p_176711_, Ingredient p_176712_) { -+ private static RecipeBuilder m_176710_(ItemLike p_176711_, Ingredient p_176712_) { - return ShapedRecipeBuilder.m_126118_(p_176711_, 4).m_126124_('#', p_176712_).m_126130_("# ").m_126130_("## ").m_126130_("###"); +- protected static RecipeBuilder stairBuilder(ItemLike p_176711_, Ingredient p_176712_) { ++ private static RecipeBuilder stairBuilder(ItemLike p_176711_, Ingredient p_176712_) { + return ShapedRecipeBuilder.shaped(p_176711_, 4).define('#', p_176712_).pattern("# ").pattern("## ").pattern("###"); } -- protected static RecipeBuilder m_176720_(ItemLike p_176721_, Ingredient p_176722_) { -+ private static RecipeBuilder m_176720_(ItemLike p_176721_, Ingredient p_176722_) { - return ShapedRecipeBuilder.m_126118_(p_176721_, 2).m_126124_('#', p_176722_).m_126130_("###").m_126130_("###"); +- protected static RecipeBuilder trapdoorBuilder(ItemLike p_176721_, Ingredient p_176722_) { ++ private static RecipeBuilder trapdoorBuilder(ItemLike p_176721_, Ingredient p_176722_) { + return ShapedRecipeBuilder.shaped(p_176721_, 2).define('#', p_176722_).pattern("###").pattern("###"); } -- protected static RecipeBuilder m_176726_(ItemLike p_176727_, Ingredient p_176728_) { -+ private static RecipeBuilder m_176726_(ItemLike p_176727_, Ingredient p_176728_) { - return ShapedRecipeBuilder.m_126118_(p_176727_, 3).m_142409_("sign").m_126124_('#', p_176728_).m_126127_('X', Items.f_42398_).m_126130_("###").m_126130_("###").m_126130_(" X "); +- protected static RecipeBuilder signBuilder(ItemLike p_176727_, Ingredient p_176728_) { ++ private static RecipeBuilder signBuilder(ItemLike p_176727_, Ingredient p_176728_) { + return ShapedRecipeBuilder.shaped(p_176727_, 3).group("sign").define('#', p_176728_).define('X', Items.STICK).pattern("###").pattern("###").pattern(" X "); } -- protected static void m_126061_(Consumer p_126062_, ItemLike p_126063_, ItemLike p_126064_) { -+ private static void m_126061_(Consumer p_126062_, ItemLike p_126063_, ItemLike p_126064_) { - ShapelessRecipeBuilder.m_126189_(p_126063_).m_126209_(p_126064_).m_126209_(Blocks.f_50041_).m_142409_("wool").m_142284_("has_white_wool", m_125977_(Blocks.f_50041_)).m_176498_(p_126062_); +- protected static void coloredWoolFromWhiteWoolAndDye(Consumer p_126062_, ItemLike p_126063_, ItemLike p_126064_) { ++ private static void coloredWoolFromWhiteWoolAndDye(Consumer p_126062_, ItemLike p_126063_, ItemLike p_126064_) { + ShapelessRecipeBuilder.shapeless(p_126063_).requires(p_126064_).requires(Blocks.WHITE_WOOL).group("wool").unlockedBy("has_white_wool", has(Blocks.WHITE_WOOL)).save(p_126062_); } -- protected static void m_176716_(Consumer p_176717_, ItemLike p_176718_, ItemLike p_176719_) { -+ private static void m_176716_(Consumer p_176717_, ItemLike p_176718_, ItemLike p_176719_) { - ShapedRecipeBuilder.m_126118_(p_176718_, 3).m_126127_('#', p_176719_).m_126130_("##").m_142409_("carpet").m_142284_(m_176602_(p_176719_), m_125977_(p_176719_)).m_176498_(p_176717_); +- protected static void carpet(Consumer p_176717_, ItemLike p_176718_, ItemLike p_176719_) { ++ private static void carpet(Consumer p_176717_, ItemLike p_176718_, ItemLike p_176719_) { + ShapedRecipeBuilder.shaped(p_176718_, 3).define('#', p_176719_).pattern("##").group("carpet").unlockedBy(getHasName(p_176719_), has(p_176719_)).save(p_176717_); } -- protected static void m_126069_(Consumer p_126070_, ItemLike p_126071_, ItemLike p_126072_) { -+ private static void m_126069_(Consumer p_126070_, ItemLike p_126071_, ItemLike p_126072_) { - ShapedRecipeBuilder.m_126118_(p_126071_, 8).m_126127_('#', Blocks.f_50336_).m_126127_('$', p_126072_).m_126130_("###").m_126130_("#$#").m_126130_("###").m_142409_("carpet").m_142284_("has_white_carpet", m_125977_(Blocks.f_50336_)).m_142284_(m_176602_(p_126072_), m_125977_(p_126072_)).m_176500_(p_126070_, m_176517_(p_126071_, Blocks.f_50336_)); +- protected static void coloredCarpetFromWhiteCarpetAndDye(Consumer p_126070_, ItemLike p_126071_, ItemLike p_126072_) { ++ private static void coloredCarpetFromWhiteCarpetAndDye(Consumer p_126070_, ItemLike p_126071_, ItemLike p_126072_) { + ShapedRecipeBuilder.shaped(p_126071_, 8).define('#', Blocks.WHITE_CARPET).define('$', p_126072_).pattern("###").pattern("#$#").pattern("###").group("carpet").unlockedBy("has_white_carpet", has(Blocks.WHITE_CARPET)).unlockedBy(getHasName(p_126072_), has(p_126072_)).save(p_126070_, getConversionRecipeName(p_126071_, Blocks.WHITE_CARPET)); } -- protected static void m_126073_(Consumer p_126074_, ItemLike p_126075_, ItemLike p_126076_) { -+ private static void m_126073_(Consumer p_126074_, ItemLike p_126075_, ItemLike p_126076_) { - ShapedRecipeBuilder.m_126116_(p_126075_).m_126127_('#', p_126076_).m_206416_('X', ItemTags.f_13168_).m_126130_("###").m_126130_("XXX").m_142409_("bed").m_142284_(m_176602_(p_126076_), m_125977_(p_126076_)).m_176498_(p_126074_); +- protected static void bedFromPlanksAndWool(Consumer p_126074_, ItemLike p_126075_, ItemLike p_126076_) { ++ private static void bedFromPlanksAndWool(Consumer p_126074_, ItemLike p_126075_, ItemLike p_126076_) { + ShapedRecipeBuilder.shaped(p_126075_).define('#', p_126076_).define('X', ItemTags.PLANKS).pattern("###").pattern("XXX").group("bed").unlockedBy(getHasName(p_126076_), has(p_126076_)).save(p_126074_); } -- protected static void m_126077_(Consumer p_126078_, ItemLike p_126079_, ItemLike p_126080_) { -+ private static void m_126077_(Consumer p_126078_, ItemLike p_126079_, ItemLike p_126080_) { - ShapelessRecipeBuilder.m_126189_(p_126079_).m_126209_(Items.f_42503_).m_126209_(p_126080_).m_142409_("dyed_bed").m_142284_("has_bed", m_125977_(Items.f_42503_)).m_176500_(p_126078_, m_176517_(p_126079_, Items.f_42503_)); +- protected static void bedFromWhiteBedAndDye(Consumer p_126078_, ItemLike p_126079_, ItemLike p_126080_) { ++ private static void bedFromWhiteBedAndDye(Consumer p_126078_, ItemLike p_126079_, ItemLike p_126080_) { + ShapelessRecipeBuilder.shapeless(p_126079_).requires(Items.WHITE_BED).requires(p_126080_).group("dyed_bed").unlockedBy("has_bed", has(Items.WHITE_BED)).save(p_126078_, getConversionRecipeName(p_126079_, Items.WHITE_BED)); } -- protected static void m_126081_(Consumer p_126082_, ItemLike p_126083_, ItemLike p_126084_) { -+ private static void m_126081_(Consumer p_126082_, ItemLike p_126083_, ItemLike p_126084_) { - ShapedRecipeBuilder.m_126116_(p_126083_).m_126127_('#', p_126084_).m_126127_('|', Items.f_42398_).m_126130_("###").m_126130_("###").m_126130_(" | ").m_142409_("banner").m_142284_(m_176602_(p_126084_), m_125977_(p_126084_)).m_176498_(p_126082_); +- protected static void banner(Consumer p_126082_, ItemLike p_126083_, ItemLike p_126084_) { ++ private static void banner(Consumer p_126082_, ItemLike p_126083_, ItemLike p_126084_) { + ShapedRecipeBuilder.shaped(p_126083_).define('#', p_126084_).define('|', Items.STICK).pattern("###").pattern("###").pattern(" | ").group("banner").unlockedBy(getHasName(p_126084_), has(p_126084_)).save(p_126082_); } -- protected static void m_126085_(Consumer p_126086_, ItemLike p_126087_, ItemLike p_126088_) { -+ private static void m_126085_(Consumer p_126086_, ItemLike p_126087_, ItemLike p_126088_) { - ShapedRecipeBuilder.m_126118_(p_126087_, 8).m_126127_('#', Blocks.f_50058_).m_126127_('X', p_126088_).m_126130_("###").m_126130_("#X#").m_126130_("###").m_142409_("stained_glass").m_142284_("has_glass", m_125977_(Blocks.f_50058_)).m_176498_(p_126086_); +- protected static void stainedGlassFromGlassAndDye(Consumer p_126086_, ItemLike p_126087_, ItemLike p_126088_) { ++ private static void stainedGlassFromGlassAndDye(Consumer p_126086_, ItemLike p_126087_, ItemLike p_126088_) { + ShapedRecipeBuilder.shaped(p_126087_, 8).define('#', Blocks.GLASS).define('X', p_126088_).pattern("###").pattern("#X#").pattern("###").group("stained_glass").unlockedBy("has_glass", has(Blocks.GLASS)).save(p_126086_); } -- protected static void m_126089_(Consumer p_126090_, ItemLike p_126091_, ItemLike p_126092_) { -+ private static void m_126089_(Consumer p_126090_, ItemLike p_126091_, ItemLike p_126092_) { - ShapedRecipeBuilder.m_126118_(p_126091_, 16).m_126127_('#', p_126092_).m_126130_("###").m_126130_("###").m_142409_("stained_glass_pane").m_142284_("has_glass", m_125977_(p_126092_)).m_176498_(p_126090_); +- protected static void stainedGlassPaneFromStainedGlass(Consumer p_126090_, ItemLike p_126091_, ItemLike p_126092_) { ++ private static void stainedGlassPaneFromStainedGlass(Consumer p_126090_, ItemLike p_126091_, ItemLike p_126092_) { + ShapedRecipeBuilder.shaped(p_126091_, 16).define('#', p_126092_).pattern("###").pattern("###").group("stained_glass_pane").unlockedBy("has_glass", has(p_126092_)).save(p_126090_); } -- protected static void m_126093_(Consumer p_126094_, ItemLike p_126095_, ItemLike p_126096_) { -+ private static void m_126093_(Consumer p_126094_, ItemLike p_126095_, ItemLike p_126096_) { - ShapedRecipeBuilder.m_126118_(p_126095_, 8).m_126127_('#', Blocks.f_50185_).m_126127_('$', p_126096_).m_126130_("###").m_126130_("#$#").m_126130_("###").m_142409_("stained_glass_pane").m_142284_("has_glass_pane", m_125977_(Blocks.f_50185_)).m_142284_(m_176602_(p_126096_), m_125977_(p_126096_)).m_176500_(p_126094_, m_176517_(p_126095_, Blocks.f_50185_)); +- protected static void stainedGlassPaneFromGlassPaneAndDye(Consumer p_126094_, ItemLike p_126095_, ItemLike p_126096_) { ++ private static void stainedGlassPaneFromGlassPaneAndDye(Consumer p_126094_, ItemLike p_126095_, ItemLike p_126096_) { + ShapedRecipeBuilder.shaped(p_126095_, 8).define('#', Blocks.GLASS_PANE).define('$', p_126096_).pattern("###").pattern("#$#").pattern("###").group("stained_glass_pane").unlockedBy("has_glass_pane", has(Blocks.GLASS_PANE)).unlockedBy(getHasName(p_126096_), has(p_126096_)).save(p_126094_, getConversionRecipeName(p_126095_, Blocks.GLASS_PANE)); } -- protected static void m_126097_(Consumer p_126098_, ItemLike p_126099_, ItemLike p_126100_) { -+ private static void m_126097_(Consumer p_126098_, ItemLike p_126099_, ItemLike p_126100_) { - ShapedRecipeBuilder.m_126118_(p_126099_, 8).m_126127_('#', Blocks.f_50352_).m_126127_('X', p_126100_).m_126130_("###").m_126130_("#X#").m_126130_("###").m_142409_("stained_terracotta").m_142284_("has_terracotta", m_125977_(Blocks.f_50352_)).m_176498_(p_126098_); +- protected static void coloredTerracottaFromTerracottaAndDye(Consumer p_126098_, ItemLike p_126099_, ItemLike p_126100_) { ++ private static void coloredTerracottaFromTerracottaAndDye(Consumer p_126098_, ItemLike p_126099_, ItemLike p_126100_) { + ShapedRecipeBuilder.shaped(p_126099_, 8).define('#', Blocks.TERRACOTTA).define('X', p_126100_).pattern("###").pattern("#X#").pattern("###").group("stained_terracotta").unlockedBy("has_terracotta", has(Blocks.TERRACOTTA)).save(p_126098_); } -- protected static void m_126101_(Consumer p_126102_, ItemLike p_126103_, ItemLike p_126104_) { -+ private static void m_126101_(Consumer p_126102_, ItemLike p_126103_, ItemLike p_126104_) { - ShapelessRecipeBuilder.m_126191_(p_126103_, 8).m_126209_(p_126104_).m_126211_(Blocks.f_49992_, 4).m_126211_(Blocks.f_49994_, 4).m_142409_("concrete_powder").m_142284_("has_sand", m_125977_(Blocks.f_49992_)).m_142284_("has_gravel", m_125977_(Blocks.f_49994_)).m_176498_(p_126102_); +- protected static void concretePowder(Consumer p_126102_, ItemLike p_126103_, ItemLike p_126104_) { ++ private static void concretePowder(Consumer p_126102_, ItemLike p_126103_, ItemLike p_126104_) { + ShapelessRecipeBuilder.shapeless(p_126103_, 8).requires(p_126104_).requires(Blocks.SAND, 4).requires(Blocks.GRAVEL, 4).group("concrete_powder").unlockedBy("has_sand", has(Blocks.SAND)).unlockedBy("has_gravel", has(Blocks.GRAVEL)).save(p_126102_); } @@ -1150,36 +_,36 @@ - return ShapedRecipeBuilder.m_126116_(p_176647_).m_126124_('#', p_176648_).m_126130_("#").m_126130_("#"); + return ShapedRecipeBuilder.shaped(p_176647_).define('#', p_176648_).pattern("#").pattern("#"); } -- protected static void m_176735_(Consumer p_176736_, ItemLike p_176737_, ItemLike p_176738_) { -+ private static void m_176735_(Consumer p_176736_, ItemLike p_176737_, ItemLike p_176738_) { - m_176546_(p_176736_, p_176737_, p_176738_, 1); +- protected static void stonecutterResultFromBase(Consumer p_176736_, ItemLike p_176737_, ItemLike p_176738_) { ++ private static void stonecutterResultFromBase(Consumer p_176736_, ItemLike p_176737_, ItemLike p_176738_) { + stonecutterResultFromBase(p_176736_, p_176737_, p_176738_, 1); } -- protected static void m_176546_(Consumer p_176547_, ItemLike p_176548_, ItemLike p_176549_, int p_176550_) { -+ private static void m_176546_(Consumer p_176547_, ItemLike p_176548_, ItemLike p_176549_, int p_176550_) { - SingleItemRecipeBuilder.m_126316_(Ingredient.m_43929_(p_176549_), p_176548_, p_176550_).m_142284_(m_176602_(p_176549_), m_125977_(p_176549_)).m_176500_(p_176547_, m_176517_(p_176548_, p_176549_) + "_stonecutting"); +- protected static void stonecutterResultFromBase(Consumer p_176547_, ItemLike p_176548_, ItemLike p_176549_, int p_176550_) { ++ private static void stonecutterResultFromBase(Consumer p_176547_, ItemLike p_176548_, ItemLike p_176549_, int p_176550_) { + SingleItemRecipeBuilder.stonecutting(Ingredient.of(p_176549_), p_176548_, p_176550_).unlockedBy(getHasName(p_176549_), has(p_176549_)).save(p_176547_, getConversionRecipeName(p_176548_, p_176549_) + "_stonecutting"); } -- protected static void m_176739_(Consumer p_176740_, ItemLike p_176741_, ItemLike p_176742_) { -+ private static void m_176739_(Consumer p_176740_, ItemLike p_176741_, ItemLike p_176742_) { - SimpleCookingRecipeBuilder.m_126272_(Ingredient.m_43929_(p_176742_), p_176741_, 0.1F, 200).m_142284_(m_176602_(p_176742_), m_125977_(p_176742_)).m_176498_(p_176740_); +- protected static void smeltingResultFromBase(Consumer p_176740_, ItemLike p_176741_, ItemLike p_176742_) { ++ private static void smeltingResultFromBase(Consumer p_176740_, ItemLike p_176741_, ItemLike p_176742_) { + SimpleCookingRecipeBuilder.smelting(Ingredient.of(p_176742_), p_176741_, 0.1F, 200).unlockedBy(getHasName(p_176742_), has(p_176742_)).save(p_176740_); } -- protected static void m_176743_(Consumer p_176744_, ItemLike p_176745_, ItemLike p_176746_) { -+ private static void m_176743_(Consumer p_176744_, ItemLike p_176745_, ItemLike p_176746_) { - m_176568_(p_176744_, p_176745_, p_176746_, m_176644_(p_176746_), (String)null, m_176644_(p_176745_), (String)null); +- protected static void nineBlockStorageRecipes(Consumer p_176744_, ItemLike p_176745_, ItemLike p_176746_) { ++ private static void nineBlockStorageRecipes(Consumer p_176744_, ItemLike p_176745_, ItemLike p_176746_) { + nineBlockStorageRecipes(p_176744_, p_176745_, p_176746_, getSimpleRecipeName(p_176746_), (String)null, getSimpleRecipeName(p_176745_), (String)null); } -- protected static void m_176562_(Consumer p_176563_, ItemLike p_176564_, ItemLike p_176565_, String p_176566_, String p_176567_) { -+ private static void m_176562_(Consumer p_176563_, ItemLike p_176564_, ItemLike p_176565_, String p_176566_, String p_176567_) { - m_176568_(p_176563_, p_176564_, p_176565_, p_176566_, p_176567_, m_176644_(p_176564_), (String)null); +- protected static void nineBlockStorageRecipesWithCustomPacking(Consumer p_176563_, ItemLike p_176564_, ItemLike p_176565_, String p_176566_, String p_176567_) { ++ private static void nineBlockStorageRecipesWithCustomPacking(Consumer p_176563_, ItemLike p_176564_, ItemLike p_176565_, String p_176566_, String p_176567_) { + nineBlockStorageRecipes(p_176563_, p_176564_, p_176565_, p_176566_, p_176567_, getSimpleRecipeName(p_176564_), (String)null); } -- protected static void m_176616_(Consumer p_176617_, ItemLike p_176618_, ItemLike p_176619_, String p_176620_, String p_176621_) { -+ private static void m_176616_(Consumer p_176617_, ItemLike p_176618_, ItemLike p_176619_, String p_176620_, String p_176621_) { - m_176568_(p_176617_, p_176618_, p_176619_, m_176644_(p_176619_), (String)null, p_176620_, p_176621_); +- protected static void nineBlockStorageRecipesRecipesWithCustomUnpacking(Consumer p_176617_, ItemLike p_176618_, ItemLike p_176619_, String p_176620_, String p_176621_) { ++ private static void nineBlockStorageRecipesRecipesWithCustomUnpacking(Consumer p_176617_, ItemLike p_176618_, ItemLike p_176619_, String p_176620_, String p_176621_) { + nineBlockStorageRecipes(p_176617_, p_176618_, p_176619_, getSimpleRecipeName(p_176619_), (String)null, p_176620_, p_176621_); } -- protected static void m_176568_(Consumer p_176569_, ItemLike p_176570_, ItemLike p_176571_, String p_176572_, @Nullable String p_176573_, String p_176574_, @Nullable String p_176575_) { -+ private static void m_176568_(Consumer p_176569_, ItemLike p_176570_, ItemLike p_176571_, String p_176572_, @Nullable String p_176573_, String p_176574_, @Nullable String p_176575_) { - ShapelessRecipeBuilder.m_126191_(p_176570_, 9).m_126209_(p_176571_).m_142409_(p_176575_).m_142284_(m_176602_(p_176571_), m_125977_(p_176571_)).m_142700_(p_176569_, new ResourceLocation(p_176574_)); - ShapedRecipeBuilder.m_126116_(p_176571_).m_126127_('#', p_176570_).m_126130_("###").m_126130_("###").m_126130_("###").m_142409_(p_176573_).m_142284_(m_176602_(p_176570_), m_125977_(p_176570_)).m_142700_(p_176569_, new ResourceLocation(p_176572_)); +- protected static void nineBlockStorageRecipes(Consumer p_176569_, ItemLike p_176570_, ItemLike p_176571_, String p_176572_, @Nullable String p_176573_, String p_176574_, @Nullable String p_176575_) { ++ private static void nineBlockStorageRecipes(Consumer p_176569_, ItemLike p_176570_, ItemLike p_176571_, String p_176572_, @Nullable String p_176573_, String p_176574_, @Nullable String p_176575_) { + ShapelessRecipeBuilder.shapeless(p_176570_, 9).requires(p_176571_).group(p_176575_).unlockedBy(getHasName(p_176571_), has(p_176571_)).save(p_176569_, new ResourceLocation(p_176574_)); + ShapedRecipeBuilder.shaped(p_176571_).define('#', p_176570_).pattern("###").pattern("###").pattern("###").group(p_176573_).unlockedBy(getHasName(p_176570_), has(p_176570_)).save(p_176569_, new ResourceLocation(p_176572_)); } -- protected static void m_126006_(Consumer p_126007_, String p_126008_, SimpleCookingSerializer p_126009_, int p_126010_) { -+ private static void m_126006_(Consumer p_126007_, String p_126008_, SimpleCookingSerializer p_126009_, int p_126010_) { - m_176583_(p_126007_, p_126008_, p_126009_, p_126010_, Items.f_42579_, Items.f_42580_, 0.35F); - m_176583_(p_126007_, p_126008_, p_126009_, p_126010_, Items.f_42581_, Items.f_42582_, 0.35F); - m_176583_(p_126007_, p_126008_, p_126009_, p_126010_, Items.f_42526_, Items.f_42530_, 0.35F); +- protected static void cookRecipes(Consumer p_126007_, String p_126008_, SimpleCookingSerializer p_126009_, int p_126010_) { ++ private static void cookRecipes(Consumer p_126007_, String p_126008_, SimpleCookingSerializer p_126009_, int p_126010_) { + simpleCookingRecipe(p_126007_, p_126008_, p_126009_, p_126010_, Items.BEEF, Items.COOKED_BEEF, 0.35F); + simpleCookingRecipe(p_126007_, p_126008_, p_126009_, p_126010_, Items.CHICKEN, Items.COOKED_CHICKEN, 0.35F); + simpleCookingRecipe(p_126007_, p_126008_, p_126009_, p_126010_, Items.COD, Items.COOKED_COD, 0.35F); @@ -1191,17 +_,17 @@ - m_176583_(p_126007_, p_126008_, p_126009_, p_126010_, Items.f_42697_, Items.f_42698_, 0.35F); + simpleCookingRecipe(p_126007_, p_126008_, p_126009_, p_126010_, Items.RABBIT, Items.COOKED_RABBIT, 0.35F); } -- protected static void m_176583_(Consumer p_176584_, String p_176585_, SimpleCookingSerializer p_176586_, int p_176587_, ItemLike p_176588_, ItemLike p_176589_, float p_176590_) { -+ private static void m_176583_(Consumer p_176584_, String p_176585_, SimpleCookingSerializer p_176586_, int p_176587_, ItemLike p_176588_, ItemLike p_176589_, float p_176590_) { - SimpleCookingRecipeBuilder.m_126248_(Ingredient.m_43929_(p_176588_), p_176589_, p_176590_, p_176587_, p_176586_).m_142284_(m_176602_(p_176588_), m_125977_(p_176588_)).m_176500_(p_176584_, m_176632_(p_176589_) + "_from_" + p_176585_); +- protected static void simpleCookingRecipe(Consumer p_176584_, String p_176585_, SimpleCookingSerializer p_176586_, int p_176587_, ItemLike p_176588_, ItemLike p_176589_, float p_176590_) { ++ private static void simpleCookingRecipe(Consumer p_176584_, String p_176585_, SimpleCookingSerializer p_176586_, int p_176587_, ItemLike p_176588_, ItemLike p_176589_, float p_176590_) { + SimpleCookingRecipeBuilder.cooking(Ingredient.of(p_176588_), p_176589_, p_176590_, p_176587_, p_176586_).unlockedBy(getHasName(p_176588_), has(p_176588_)).save(p_176584_, getItemName(p_176589_) + "_from_" + p_176585_); } -- protected static void m_176610_(Consumer p_176611_) { -+ private static void m_176610_(Consumer p_176611_) { - HoneycombItem.f_150863_.get().forEach((p_176578_, p_176579_) -> { - ShapelessRecipeBuilder.m_126189_(p_176579_).m_126209_(p_176578_).m_126209_(Items.f_42784_).m_142409_(m_176632_(p_176579_)).m_142284_(m_176602_(p_176578_), m_125977_(p_176578_)).m_176500_(p_176611_, m_176517_(p_176579_, Items.f_42784_)); +- protected static void waxRecipes(Consumer p_176611_) { ++ private static void waxRecipes(Consumer p_176611_) { + HoneycombItem.WAXABLES.get().forEach((p_176578_, p_176579_) -> { + ShapelessRecipeBuilder.shapeless(p_176579_).requires(p_176578_).requires(Items.HONEYCOMB).group(getItemName(p_176579_)).unlockedBy(getHasName(p_176578_), has(p_176578_)).save(p_176611_, getConversionRecipeName(p_176579_, Items.HONEYCOMB)); }); } -- protected static void m_176580_(Consumer p_176581_, BlockFamily p_176582_) { -+ private static void m_176580_(Consumer p_176581_, BlockFamily p_176582_) { - p_176582_.m_175954_().forEach((p_176529_, p_176530_) -> { - BiFunction bifunction = f_176513_.get(p_176529_); - ItemLike itemlike = m_176523_(p_176582_, p_176529_); +- protected static void generateRecipes(Consumer p_176581_, BlockFamily p_176582_) { ++ private static void generateRecipes(Consumer p_176581_, BlockFamily p_176582_) { + p_176582_.getVariants().forEach((p_176529_, p_176530_) -> { + BiFunction bifunction = shapeBuilders.get(p_176529_); + ItemLike itemlike = getBaseBlock(p_176582_, p_176529_); @@ -1223,7 +_,7 @@ }); } -- protected static Block m_176523_(BlockFamily p_176524_, BlockFamily.Variant p_176525_) { -+ private static Block m_176523_(BlockFamily p_176524_, BlockFamily.Variant p_176525_) { +- protected static Block getBaseBlock(BlockFamily p_176524_, BlockFamily.Variant p_176525_) { ++ private static Block getBaseBlock(BlockFamily p_176524_, BlockFamily.Variant p_176525_) { if (p_176525_ == BlockFamily.Variant.CHISELED) { - if (!p_176524_.m_175954_().containsKey(BlockFamily.Variant.SLAB)) { + if (!p_176524_.getVariants().containsKey(BlockFamily.Variant.SLAB)) { throw new IllegalStateException("Slab is not defined for the family."); @@ -1239,7 +_,7 @@ - return new EnterBlockTrigger.TriggerInstance(EntityPredicate.Composite.f_36667_, p_125980_, StatePropertiesPredicate.f_67658_); + return new EnterBlockTrigger.TriggerInstance(EntityPredicate.Composite.ANY, p_125980_, StatePropertiesPredicate.ANY); } -- protected static InventoryChangeTrigger.TriggerInstance m_176520_(MinMaxBounds.Ints p_176521_, ItemLike p_176522_) { -+ private static InventoryChangeTrigger.TriggerInstance m_176520_(MinMaxBounds.Ints p_176521_, ItemLike p_176522_) { - return m_126011_(ItemPredicate.Builder.m_45068_().m_151445_(p_176522_).m_151443_(p_176521_).m_45077_()); +- protected static InventoryChangeTrigger.TriggerInstance has(MinMaxBounds.Ints p_176521_, ItemLike p_176522_) { ++ private static InventoryChangeTrigger.TriggerInstance has(MinMaxBounds.Ints p_176521_, ItemLike p_176522_) { + return inventoryTrigger(ItemPredicate.Builder.item().of(p_176522_).withCount(p_176521_).build()); } @@ -1247,7 +_,7 @@ - return m_126011_(ItemPredicate.Builder.m_45068_().m_151445_(p_125978_).m_45077_()); + return inventoryTrigger(ItemPredicate.Builder.item().of(p_125978_).build()); } -- protected static InventoryChangeTrigger.TriggerInstance m_206406_(TagKey p_206407_) { -+ private static InventoryChangeTrigger.TriggerInstance m_206406_(TagKey p_206407_) { - return m_126011_(ItemPredicate.Builder.m_45068_().m_204145_(p_206407_).m_45077_()); +- protected static InventoryChangeTrigger.TriggerInstance has(TagKey p_206407_) { ++ private static InventoryChangeTrigger.TriggerInstance has(TagKey p_206407_) { + return inventoryTrigger(ItemPredicate.Builder.item().of(p_206407_).build()); } @@ -1255,27 +_,27 @@ - return new InventoryChangeTrigger.TriggerInstance(EntityPredicate.Composite.f_36667_, MinMaxBounds.Ints.f_55364_, MinMaxBounds.Ints.f_55364_, MinMaxBounds.Ints.f_55364_, p_126012_); + return new InventoryChangeTrigger.TriggerInstance(EntityPredicate.Composite.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, p_126012_); } -- protected static String m_176602_(ItemLike p_176603_) { -+ private static String m_176602_(ItemLike p_176603_) { - return "has_" + m_176632_(p_176603_); +- protected static String getHasName(ItemLike p_176603_) { ++ private static String getHasName(ItemLike p_176603_) { + return "has_" + getItemName(p_176603_); } -- protected static String m_176632_(ItemLike p_176633_) { -+ private static String m_176632_(ItemLike p_176633_) { - return Registry.f_122827_.m_7981_(p_176633_.m_5456_()).m_135815_(); +- protected static String getItemName(ItemLike p_176633_) { ++ private static String getItemName(ItemLike p_176633_) { + return Registry.ITEM.getKey(p_176633_.asItem()).getPath(); } -- protected static String m_176644_(ItemLike p_176645_) { -+ private static String m_176644_(ItemLike p_176645_) { - return m_176632_(p_176645_); +- protected static String getSimpleRecipeName(ItemLike p_176645_) { ++ private static String getSimpleRecipeName(ItemLike p_176645_) { + return getItemName(p_176645_); } -- protected static String m_176517_(ItemLike p_176518_, ItemLike p_176519_) { -+ private static String m_176517_(ItemLike p_176518_, ItemLike p_176519_) { - return m_176632_(p_176518_) + "_from_" + m_176632_(p_176519_); +- protected static String getConversionRecipeName(ItemLike p_176518_, ItemLike p_176519_) { ++ private static String getConversionRecipeName(ItemLike p_176518_, ItemLike p_176519_) { + return getItemName(p_176518_) + "_from_" + getItemName(p_176519_); } -- protected static String m_176656_(ItemLike p_176657_) { -+ private static String m_176656_(ItemLike p_176657_) { - return m_176632_(p_176657_) + "_from_smelting"; +- protected static String getSmeltingRecipeName(ItemLike p_176657_) { ++ private static String getSmeltingRecipeName(ItemLike p_176657_) { + return getItemName(p_176657_) + "_from_smelting"; } -- protected static String m_176668_(ItemLike p_176669_) { -+ private static String m_176668_(ItemLike p_176669_) { - return m_176632_(p_176669_) + "_from_blasting"; +- protected static String getBlastingRecipeName(ItemLike p_176669_) { ++ private static String getBlastingRecipeName(ItemLike p_176669_) { + return getItemName(p_176669_) + "_from_blasting"; } diff --git a/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch index 85cbeb48..21e7f3ee 100644 --- a/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch @@ -8,11 +8,11 @@ + /** @deprecated Forge: Use the {@link #BiomeTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public BiomeTagsProvider(DataGenerator p_211094_) { - super(p_211094_, BuiltinRegistries.f_123865_); + super(p_211094_, BuiltinRegistries.BIOME); + } + + public BiomeTagsProvider(DataGenerator p_211094_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_211094_, BuiltinRegistries.f_123865_, modId, existingFileHelper); ++ super(p_211094_, BuiltinRegistries.BIOME, modId, existingFileHelper); } - protected void m_6577_() { + protected void addTags() { diff --git a/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch index ffbe425e..466de584 100644 --- a/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch @@ -7,11 +7,11 @@ + /** @deprecated Forge: Use the {@link #BlockTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public BlockTagsProvider(DataGenerator p_126511_) { - super(p_126511_, Registry.f_122824_); + super(p_126511_, Registry.BLOCK); + } + + public BlockTagsProvider(DataGenerator p_126511_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126511_, Registry.f_122824_, modId, existingFileHelper); ++ super(p_126511_, Registry.BLOCK, modId, existingFileHelper); } - protected void m_6577_() { + protected void addTags() { diff --git a/patches/minecraft/net/minecraft/data/tags/ConfiguredStructureTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/ConfiguredStructureTagsProvider.java.patch index 99f22735..206d3feb 100644 --- a/patches/minecraft/net/minecraft/data/tags/ConfiguredStructureTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/ConfiguredStructureTagsProvider.java.patch @@ -7,10 +7,10 @@ + /** @deprecated Forge: Use the {@link #ConfiguredStructureTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public ConfiguredStructureTagsProvider(DataGenerator p_211098_) { - super(p_211098_, BuiltinRegistries.f_123862_); + super(p_211098_, BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE); + } + public ConfiguredStructureTagsProvider(DataGenerator p_211098_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_211098_, BuiltinRegistries.f_123862_, modId, existingFileHelper); ++ super(p_211098_, BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, modId, existingFileHelper); } - protected void m_6577_() { + protected void addTags() { diff --git a/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch index 3bdce315..58f334a3 100644 --- a/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch @@ -7,10 +7,10 @@ + /** @deprecated Forge: Use the {@link #EntityTypeTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public EntityTypeTagsProvider(DataGenerator p_126517_) { - super(p_126517_, Registry.f_122826_); + super(p_126517_, Registry.ENTITY_TYPE); + } + public EntityTypeTagsProvider(DataGenerator p_126517_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126517_, Registry.f_122826_, modId, existingFileHelper); ++ super(p_126517_, Registry.ENTITY_TYPE, modId, existingFileHelper); } - protected void m_6577_() { + protected void addTags() { diff --git a/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch index e6c2f8d1..ad7376fe 100644 --- a/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch @@ -7,10 +7,10 @@ + /** @deprecated Forge: Use the {@link #FluidTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public FluidTagsProvider(DataGenerator p_126523_) { - super(p_126523_, Registry.f_122822_); + super(p_126523_, Registry.FLUID); + } + public FluidTagsProvider(DataGenerator p_126523_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126523_, Registry.f_122822_, modId, existingFileHelper); ++ super(p_126523_, Registry.FLUID, modId, existingFileHelper); } - protected void m_6577_() { + protected void addTags() { diff --git a/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch index 14b9900b..60d33b21 100644 --- a/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch @@ -7,10 +7,10 @@ + /** @deprecated Forge: Use the {@link #GameEventTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public GameEventTagsProvider(DataGenerator p_176826_) { - super(p_176826_, Registry.f_175412_); + super(p_176826_, Registry.GAME_EVENT); + } + public GameEventTagsProvider(DataGenerator p_176826_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_176826_, Registry.f_175412_, modId, existingFileHelper); ++ super(p_176826_, Registry.GAME_EVENT, modId, existingFileHelper); } - protected void m_6577_() { + protected void addTags() { diff --git a/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch index 30e5dd97..eb68ba97 100644 --- a/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/data/tags/ItemTagsProvider.java @@ -14,8 +_,14 @@ public class ItemTagsProvider extends TagsProvider { - private final Function, Tag.Builder> f_126528_; + private final Function, Tag.Builder> blockTags; + /** @deprecated Forge: Use the {@link #ItemTagsProvider(DataGenerator, BlockTagsProvider, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated public ItemTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_) { - super(p_126530_, Registry.f_122827_); -+ this.f_126528_ = p_126531_::m_206426_; + super(p_126530_, Registry.ITEM); ++ this.blockTags = p_126531_::getOrCreateRawBuilder; + } + public ItemTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126530_, Registry.f_122827_, modId, existingFileHelper); - this.f_126528_ = p_126531_::m_206426_; ++ super(p_126530_, Registry.ITEM, modId, existingFileHelper); + this.blockTags = p_126531_::getOrCreateRawBuilder; } diff --git a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch index a7e16497..83187416 100644 --- a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch @@ -4,36 +4,36 @@ import org.slf4j.Logger; public abstract class TagsProvider implements DataProvider { -- private static final Logger f_126541_ = LogUtils.getLogger(); -- private static final Gson f_126542_ = (new GsonBuilder()).setPrettyPrinting().create(); -- protected final DataGenerator f_126539_; -- protected final Registry f_126540_; -- protected final Map f_126543_ = Maps.newLinkedHashMap(); +- private static final Logger LOGGER = LogUtils.getLogger(); +- private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); +- protected final DataGenerator generator; +- protected final Registry registry; +- protected final Map builders = Maps.newLinkedHashMap(); - - protected TagsProvider(DataGenerator p_126546_, Registry p_126547_) { -- this.f_126539_ = p_126546_; -- this.f_126540_ = p_126547_; +- this.generator = p_126546_; +- this.registry = p_126547_; - } - -- protected abstract void m_6577_(); +- protected abstract void addTags(); - -- public void m_6865_(HashCache p_126554_) { -- this.f_126543_.clear(); -- this.m_6577_(); -- this.f_126543_.forEach((p_176835_, p_176836_) -> { -- List list = p_176836_.m_13330_().filter((p_176832_) -> { -- return !p_176832_.f_13338_().m_142746_(this.f_126540_::m_7804_, this.f_126543_::containsKey); +- public void run(HashCache p_126554_) { +- this.builders.clear(); +- this.addTags(); +- this.builders.forEach((p_176835_, p_176836_) -> { +- List list = p_176836_.getEntries().filter((p_176832_) -> { +- return !p_176832_.entry().verifyIfPresent(this.registry::containsKey, this.builders::containsKey); - }).toList(); - if (!list.isEmpty()) { - throw new IllegalArgumentException(String.format("Couldn't define tag %s as it is missing following references: %s", p_176835_, list.stream().map(Objects::toString).collect(Collectors.joining(",")))); - } else { -- JsonObject jsonobject = p_176836_.m_13334_(); -- Path path = this.m_6648_(p_176835_); +- JsonObject jsonobject = p_176836_.serializeToJson(); +- Path path = this.getPath(p_176835_); - - try { -- String s = f_126542_.toJson((JsonElement)jsonobject); -- String s1 = f_123918_.hashUnencodedChars(s).toString(); -- if (!Objects.equals(p_126554_.m_123938_(path), s1) || !Files.exists(path)) { +- String s = GSON.toJson((JsonElement)jsonobject); +- String s1 = SHA1.hashUnencodedChars(s).toString(); +- if (!Objects.equals(p_126554_.getHash(path), s1) || !Files.exists(path)) { - Files.createDirectories(path.getParent()); - BufferedWriter bufferedwriter = Files.newBufferedWriter(path); - @@ -41,11 +41,11 @@ - bufferedwriter.write(s); - } catch (Throwable throwable1) { - if (bufferedwriter != null) { -+ private static final Logger f_126541_ = LogUtils.getLogger(); -+ private static final Gson f_126542_ = (new GsonBuilder()).setPrettyPrinting().create(); -+ protected final DataGenerator f_126539_; -+ protected final Registry f_126540_; -+ protected final Map f_126543_ = Maps.newLinkedHashMap(); ++ private static final Logger LOGGER = LogUtils.getLogger(); ++ private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); ++ protected final DataGenerator generator; ++ protected final Registry registry; ++ protected final Map builders = Maps.newLinkedHashMap(); + protected final String modId; + protected final String folder; + protected final net.minecraftforge.common.data.ExistingFileHelper existingFileHelper; @@ -65,39 +65,39 @@ + } + + protected TagsProvider(DataGenerator p_126546_, Registry p_126547_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper, @javax.annotation.Nullable String folder) { -+ this.f_126539_ = p_126546_; -+ this.f_126540_ = p_126547_; ++ this.generator = p_126546_; ++ this.registry = p_126547_; + this.modId = modId; + this.existingFileHelper = existingFileHelper; + if (folder == null) { + //noinspection unchecked,rawtypes -+ folder = ((Registry) Registry.f_122897_).m_7981_(f_126540_).m_135815_() + "s"; ++ folder = ((Registry) Registry.REGISTRY).getKey(registry).getPath() + "s"; + } + this.folder = folder; + this.resourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.server.packs.PackType.SERVER_DATA, ".json", "tags/" + this.folder); + } + -+ protected abstract void m_6577_(); ++ protected abstract void addTags(); + -+ public void m_6865_(HashCache p_126554_) { -+ this.f_126543_.clear(); -+ this.m_6577_(); -+ this.f_126543_.forEach((p_176835_, p_176836_) -> { -+ List list = p_176836_.m_13330_().filter((p_176832_) -> { -+ return !p_176832_.f_13338_().m_142746_(this.f_126540_::m_7804_, this.f_126543_::containsKey); ++ public void run(HashCache p_126554_) { ++ this.builders.clear(); ++ this.addTags(); ++ this.builders.forEach((p_176835_, p_176836_) -> { ++ List list = p_176836_.getEntries().filter((p_176832_) -> { ++ return !p_176832_.entry().verifyIfPresent(this.registry::containsKey, this.builders::containsKey); + }).filter(this::missing).collect(Collectors.toList()); // Forge: Add validation via existing resources + if (!list.isEmpty()) { + throw new IllegalArgumentException(String.format("Couldn't define tag %s as it is missing following references: %s", p_176835_, list.stream().map(Objects::toString).collect(Collectors.joining(",")))); + } else { -+ JsonObject jsonobject = p_176836_.m_13334_(); -+ Path path = this.m_6648_(p_176835_); ++ JsonObject jsonobject = p_176836_.serializeToJson(); ++ Path path = this.getPath(p_176835_); + if (path == null) + return; // Forge: Allow running this data provider without writing it. Recipe provider needs valid tags. + + try { -+ String s = f_126542_.toJson((JsonElement) jsonobject); -+ String s1 = f_123918_.hashUnencodedChars(s).toString(); -+ if (!Objects.equals(p_126554_.m_123938_(path), s1) || !Files.exists(path)) { ++ String s = GSON.toJson((JsonElement) jsonobject); ++ String s1 = SHA1.hashUnencodedChars(s).toString(); ++ if (!Objects.equals(p_126554_.getHash(path), s1) || !Files.exists(path)) { + Files.createDirectories(path.getParent()); + BufferedWriter bufferedwriter = Files.newBufferedWriter(path); + @@ -116,75 +116,75 @@ - } - } - -- p_126554_.m_123940_(path, s1); +- p_126554_.putNew(path, s1); - } catch (IOException ioexception) { -- f_126541_.error("Couldn't save tags to {}", path, ioexception); +- LOGGER.error("Couldn't save tags to {}", path, ioexception); - } - - } - }); - } - -- protected Path m_6648_(ResourceLocation p_126561_) { -- ResourceKey> resourcekey = this.f_126540_.m_123023_(); -- return this.f_126539_.m_123916_().resolve("data/" + p_126561_.m_135827_() + "/" + TagManager.m_203918_(resourcekey) + "/" + p_126561_.m_135815_() + ".json"); +- protected Path getPath(ResourceLocation p_126561_) { +- ResourceKey> resourcekey = this.registry.key(); +- return this.generator.getOutputFolder().resolve("data/" + p_126561_.getNamespace() + "/" + TagManager.getTagDir(resourcekey) + "/" + p_126561_.getPath() + ".json"); - } - -- protected TagsProvider.TagAppender m_206424_(TagKey p_206425_) { -- Tag.Builder tag$builder = this.m_206426_(p_206425_); -- return new TagsProvider.TagAppender<>(tag$builder, this.f_126540_, "vanilla"); +- protected TagsProvider.TagAppender tag(TagKey p_206425_) { +- Tag.Builder tag$builder = this.getOrCreateRawBuilder(p_206425_); +- return new TagsProvider.TagAppender<>(tag$builder, this.registry, "vanilla"); - } - -- protected Tag.Builder m_206426_(TagKey p_206427_) { -- return this.f_126543_.computeIfAbsent(p_206427_.f_203868_(), (p_176838_) -> { +- protected Tag.Builder getOrCreateRawBuilder(TagKey p_206427_) { +- return this.builders.computeIfAbsent(p_206427_.location(), (p_176838_) -> { - return new Tag.Builder(); - }); - } - - protected static class TagAppender { -- private final Tag.Builder f_126568_; -- public final Registry f_126569_; -- private final String f_126570_; +- private final Tag.Builder builder; +- public final Registry registry; +- private final String source; - - TagAppender(Tag.Builder p_126572_, Registry p_126573_, String p_126574_) { -- this.f_126568_ = p_126572_; -- this.f_126569_ = p_126573_; -- this.f_126570_ = p_126574_; +- this.builder = p_126572_; +- this.registry = p_126573_; +- this.source = p_126574_; - } - -- public TagsProvider.TagAppender m_126582_(T p_126583_) { -- this.f_126568_.m_13327_(this.f_126569_.m_7981_(p_126583_), this.f_126570_); +- public TagsProvider.TagAppender add(T p_126583_) { +- this.builder.addElement(this.registry.getKey(p_126583_), this.source); - return this; - } - - @SafeVarargs -- public final TagsProvider.TagAppender m_211101_(ResourceKey... p_211102_) { +- public final TagsProvider.TagAppender add(ResourceKey... p_211102_) { - for(ResourceKey resourcekey : p_211102_) { -- this.f_126568_.m_13327_(resourcekey.m_135782_(), this.f_126570_); +- this.builder.addElement(resourcekey.location(), this.source); - } - - return this; - } - -- public TagsProvider.TagAppender m_176839_(ResourceLocation p_176840_) { -- this.f_126568_.m_144379_(p_176840_, this.f_126570_); +- public TagsProvider.TagAppender addOptional(ResourceLocation p_176840_) { +- this.builder.addOptionalElement(p_176840_, this.source); - return this; - } - -- public TagsProvider.TagAppender m_206428_(TagKey p_206429_) { -- this.f_126568_.m_13335_(p_206429_.f_203868_(), this.f_126570_); +- public TagsProvider.TagAppender addTag(TagKey p_206429_) { +- this.builder.addTag(p_206429_.location(), this.source); - return this; - } - -- public TagsProvider.TagAppender m_176841_(ResourceLocation p_176842_) { -- this.f_126568_.m_144382_(p_176842_, this.f_126570_); +- public TagsProvider.TagAppender addOptionalTag(ResourceLocation p_176842_) { +- this.builder.addOptionalTag(p_176842_, this.source); - return this; - } - - @SafeVarargs -- public final TagsProvider.TagAppender m_126584_(T... p_126585_) { -- Stream.of(p_126585_).map(this.f_126569_::m_7981_).forEach((p_126587_) -> { -- this.f_126568_.m_13327_(p_126587_, this.f_126570_); +- public final TagsProvider.TagAppender add(T... p_126585_) { +- Stream.of(p_126585_).map(this.registry::getKey).forEach((p_126587_) -> { +- this.builder.addElement(p_126587_, this.source); - }); - return this; - } @@ -207,9 +207,9 @@ + } + } + -+ p_126554_.m_123940_(path, s1); ++ p_126554_.putNew(path, s1); + } catch (IOException ioexception) { -+ f_126541_.error("Couldn't save tags to {}", path, ioexception); ++ LOGGER.error("Couldn't save tags to {}", path, ioexception); + } + + } @@ -217,7 +217,7 @@ + } + + private boolean missing(Tag.BuilderEntry reference) { -+ Tag.Entry entry = reference.f_13338_(); ++ Tag.Entry entry = reference.entry(); + // We only care about non-optional tag entries, this is the only type that can reference a resource and needs validation + // Optional tags should not be validated + @@ -228,82 +228,82 @@ + return false; + } + -+ protected Path m_6648_(ResourceLocation p_126561_) { -+ ResourceKey> resourcekey = this.f_126540_.m_123023_(); -+ return this.f_126539_.m_123916_().resolve("data/" + p_126561_.m_135827_() + "/" + TagManager.m_203918_(resourcekey) + "/" + p_126561_.m_135815_() + ".json"); ++ protected Path getPath(ResourceLocation p_126561_) { ++ ResourceKey> resourcekey = this.registry.key(); ++ return this.generator.getOutputFolder().resolve("data/" + p_126561_.getNamespace() + "/" + TagManager.getTagDir(resourcekey) + "/" + p_126561_.getPath() + ".json"); + } + -+ protected TagAppender m_206424_(TagKey p_206425_) { -+ Tag.Builder tag$builder = this.m_206426_(p_206425_); -+ return new TagAppender<>(tag$builder, this.f_126540_, modId); ++ protected TagAppender tag(TagKey p_206425_) { ++ Tag.Builder tag$builder = this.getOrCreateRawBuilder(p_206425_); ++ return new TagAppender<>(tag$builder, this.registry, modId); + } + -+ protected Tag.Builder m_206426_(TagKey p_206427_) { -+ return this.f_126543_.computeIfAbsent(p_206427_.f_203868_(), (p_176838_) -> { ++ protected Tag.Builder getOrCreateRawBuilder(TagKey p_206427_) { ++ return this.builders.computeIfAbsent(p_206427_.location(), (p_176838_) -> { + existingFileHelper.trackGenerated(p_176838_, resourceType); + return new Tag.Builder(); + }); + } + + public static class TagAppender implements net.minecraftforge.common.extensions.IForgeTagAppender { -+ private final Tag.Builder f_126568_; -+ public final Registry f_126569_; -+ private final String f_126570_; ++ private final Tag.Builder builder; ++ public final Registry registry; ++ private final String source; + + TagAppender(Tag.Builder p_126572_, Registry p_126573_, String p_126574_) { -+ this.f_126568_ = p_126572_; -+ this.f_126569_ = p_126573_; -+ this.f_126570_ = p_126574_; ++ this.builder = p_126572_; ++ this.registry = p_126573_; ++ this.source = p_126574_; + } + -+ public TagAppender m_126582_(T p_126583_) { -+ this.f_126568_.m_13327_(this.f_126569_.m_7981_(p_126583_), this.f_126570_); ++ public TagAppender add(T p_126583_) { ++ this.builder.addElement(this.registry.getKey(p_126583_), this.source); + return this; + } + + @SafeVarargs -+ public final TagAppender m_211101_(ResourceKey... p_211102_) { ++ public final TagAppender add(ResourceKey... p_211102_) { + for (ResourceKey resourcekey : p_211102_) { -+ this.f_126568_.m_13327_(resourcekey.m_135782_(), this.f_126570_); ++ this.builder.addElement(resourcekey.location(), this.source); + } + + return this; + } + -+ public TagAppender m_176839_(ResourceLocation p_176840_) { -+ this.f_126568_.m_144379_(p_176840_, this.f_126570_); ++ public TagAppender addOptional(ResourceLocation p_176840_) { ++ this.builder.addOptionalElement(p_176840_, this.source); + return this; + } + -+ public TagAppender m_206428_(TagKey p_206429_) { -+ this.f_126568_.m_13335_(p_206429_.f_203868_(), this.f_126570_); ++ public TagAppender addTag(TagKey p_206429_) { ++ this.builder.addTag(p_206429_.location(), this.source); + return this; + } + -+ public TagAppender m_176841_(ResourceLocation p_176842_) { -+ this.f_126568_.m_144382_(p_176842_, this.f_126570_); ++ public TagAppender addOptionalTag(ResourceLocation p_176842_) { ++ this.builder.addOptionalTag(p_176842_, this.source); + return this; + } + + @SafeVarargs -+ public final TagAppender m_126584_(T... p_126585_) { -+ Stream.of(p_126585_).map(this.f_126569_::m_7981_).forEach((p_126587_) -> { -+ this.f_126568_.m_13327_(p_126587_, this.f_126570_); ++ public final TagAppender add(T... p_126585_) { ++ Stream.of(p_126585_).map(this.registry::getKey).forEach((p_126587_) -> { ++ this.builder.addElement(p_126587_, this.source); + }); + return this; + } + + public TagAppender add(Tag.Entry tag) { -+ f_126568_.m_13307_(tag, f_126570_); ++ builder.add(tag, source); + return this; + } + + public Tag.Builder getInternalBuilder() { -+ return f_126568_; ++ return builder; + } + + public String getModID() { -+ return f_126570_; ++ return source; + } + } } diff --git a/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch b/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch index 74829db9..f9060820 100644 --- a/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch +++ b/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch @@ -6,6 +6,6 @@ public class OverworldBiomes { + // TODO: getAdditionalOverworldBiomes, likely in this class. -C + - protected static final int f_194836_ = 4159204; - protected static final int f_194837_ = 329011; - private static final int f_194838_ = 12638463; + protected static final int NORMAL_WATER_COLOR = 4159204; + protected static final int NORMAL_WATER_FOG_COLOR = 329011; + private static final int OVERWORLD_FOG_COLOR = 12638463; diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTest.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTest.java.patch index f5a2e8e4..930678b0 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTest.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTest.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/gametest/framework/GameTest.java @@ -16,6 +_,11 @@ - boolean m_177045_() default true; + boolean required() default true; + /** + * The namespace of where to grab the structure from, generally a mod id. + */ + String templateNamespace() default ""; + - String m_177046_() default ""; + String template() default ""; - long m_177047_() default 0L; + long setupTicks() default 0L; diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch index c665054b..cbb525f1 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/gametest/framework/GameTestRegistry.java +++ b/net/minecraft/gametest/framework/GameTestRegistry.java @@ -25,21 +_,33 @@ - private static final Map> f_177498_ = Maps.newHashMap(); - private static final Collection f_177499_ = Sets.newHashSet(); + private static final Map> AFTER_BATCH_FUNCTIONS = Maps.newHashMap(); + private static final Collection LAST_FAILED_TESTS = Sets.newHashSet(); + /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */ + @Deprecated - public static void m_177501_(Class p_177502_) { - Arrays.stream(p_177502_.getDeclaredMethods()).forEach(GameTestRegistry::m_177503_); + public static void register(Class p_177502_) { + Arrays.stream(p_177502_.getDeclaredMethods()).forEach(GameTestRegistry::register); } + /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */ + @Deprecated - public static void m_177503_(Method p_177504_) { + public static void register(Method p_177504_) { + register(p_177504_, java.util.Set.of()); + } + /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */ @@ -22,23 +22,23 @@ GameTest gametest = p_177504_.getAnnotation(GameTest.class); - if (gametest != null) { + if (gametest != null && (allowedNamespaces.isEmpty() || allowedNamespaces.contains(net.minecraftforge.gametest.ForgeGameTestHooks.getTemplateNamespace(p_177504_)))) { - f_177495_.add(m_177515_(p_177504_)); - f_177496_.add(s); + TEST_FUNCTIONS.add(turnMethodIntoTestFunction(p_177504_)); + TEST_CLASS_NAMES.add(s); } GameTestGenerator gametestgenerator = p_177504_.getAnnotation(GameTestGenerator.class); if (gametestgenerator != null) { -- f_177495_.addAll(m_177513_(p_177504_)); -+ Collection testFunctions = new java.util.ArrayList<>(m_177513_(p_177504_)); +- TEST_FUNCTIONS.addAll(useTestGeneratorMethod(p_177504_)); ++ Collection testFunctions = new java.util.ArrayList<>(useTestGeneratorMethod(p_177504_)); + if (!allowedNamespaces.isEmpty()) -+ testFunctions.removeIf(t -> !allowedNamespaces.contains(new net.minecraft.resources.ResourceLocation(t.m_128078_()).m_135827_())); -+ f_177495_.addAll(testFunctions); - f_177496_.add(s); ++ testFunctions.removeIf(t -> !allowedNamespaces.contains(new net.minecraft.resources.ResourceLocation(t.getStructureName()).getNamespace())); ++ TEST_FUNCTIONS.addAll(testFunctions); + TEST_CLASS_NAMES.add(s); } @@ -104,7 +_,9 @@ - private static Collection m_177513_(Method p_177514_) { + private static Collection useTestGeneratorMethod(Method p_177514_) { try { - Object object = p_177514_.getDeclaringClass().newInstance(); + Object object = null; @@ -52,15 +52,15 @@ String s = p_177516_.getDeclaringClass().getSimpleName(); String s1 = s.toLowerCase(); - String s2 = s1 + "." + p_177516_.getName().toLowerCase(); -- String s3 = gametest.m_177046_().isEmpty() ? s2 : s1 + "." + gametest.m_177046_(); +- String s3 = gametest.template().isEmpty() ? s2 : s1 + "." + gametest.template(); + boolean prefixGameTestTemplate = net.minecraftforge.gametest.ForgeGameTestHooks.prefixGameTestTemplate(p_177516_); + String s2 = (prefixGameTestTemplate ? s1 + "." : "") + p_177516_.getName().toLowerCase(); -+ String s3 = net.minecraftforge.gametest.ForgeGameTestHooks.getTemplateNamespace(p_177516_) + ":" + (gametest.m_177046_().isEmpty() ? s2 : (prefixGameTestTemplate ? s1 + "." : "") + gametest.m_177046_()); - String s4 = gametest.m_177043_(); - Rotation rotation = StructureUtils.m_127835_(gametest.m_177044_()); - return new TestFunction(s4, s2, s3, rotation, gametest.m_177042_(), gametest.m_177047_(), gametest.m_177045_(), gametest.m_177049_(), gametest.m_177048_(), (Consumer)m_177519_(p_177516_)); ++ String s3 = net.minecraftforge.gametest.ForgeGameTestHooks.getTemplateNamespace(p_177516_) + ":" + (gametest.template().isEmpty() ? s2 : (prefixGameTestTemplate ? s1 + "." : "") + gametest.template()); + String s4 = gametest.batch(); + Rotation rotation = StructureUtils.getRotationForRotationSteps(gametest.rotationSteps()); + return new TestFunction(s4, s2, s3, rotation, gametest.timeoutTicks(), gametest.setupTicks(), gametest.required(), gametest.requiredSuccesses(), gametest.attempts(), (Consumer)turnMethodIntoConsumer(p_177516_)); @@ -125,7 +_,9 @@ - private static Consumer m_177519_(Method p_177520_) { + private static Consumer turnMethodIntoConsumer(Method p_177520_) { return (p_177512_) -> { try { - Object object = p_177520_.getDeclaringClass().newInstance(); diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch index 384810ee..0b151149 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,33 +1,33 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java @@ -53,7 +_,7 @@ - p_177615_.m_46170_(GameRules.f_46134_).m_46246_(false, (MinecraftServer)null); - p_177615_.m_46170_(GameRules.f_46150_).m_46246_(false, (MinecraftServer)null); + p_177615_.getRule(GameRules.RULE_DOMOBSPAWNING).set(false, (MinecraftServer)null); + p_177615_.getRule(GameRules.RULE_WEATHER_CYCLE).set(false, (MinecraftServer)null); }); -- private static final LevelSettings f_177590_ = new LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.NORMAL, true, f_177589_, DataPackConfig.f_45842_); -+ private static final LevelSettings f_177590_ = new LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.NORMAL, true, f_177589_, DataPackConfig.f_45842_, Lifecycle.experimental()); +- private static final LevelSettings TEST_SETTINGS = new LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.NORMAL, true, TEST_GAME_RULES, DataPackConfig.DEFAULT); ++ private static final LevelSettings TEST_SETTINGS = new LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.NORMAL, true, TEST_GAME_RULES, DataPackConfig.DEFAULT, Lifecycle.experimental()); @Nullable - private MultipleTestTracker f_177591_; + private MultipleTestTracker testTracker; @@ -93,12 +_,13 @@ - public boolean m_7038_() { - this.m_129823_(new PlayerList(this, this.m_206579_(), this.f_129745_, 1) { + public boolean initServer() { + this.setPlayerList(new PlayerList(this, this.registryAccess(), this.playerDataStorage, 1) { }); -- this.m_130006_(); +- this.loadLevel(); + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; -+ this.m_130006_(); // Magma - ServerLevel serverlevel = this.m_129783_(); - serverlevel.m_8733_(this.f_177588_, 0.0F); ++ this.loadLevel(); // Magma + ServerLevel serverlevel = this.overworld(); + serverlevel.setDefaultSpawnPos(this.spawnPos, 0.0F); int i = 20000000; - serverlevel.m_8606_(20000000, 20000000, false, false); + serverlevel.setWeatherParameters(20000000, 20000000, false, false); - return true; + return net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(this); } - public void m_5705_(BooleanSupplier p_177619_) { + public void tickServer(BooleanSupplier p_177619_) { @@ -200,6 +_,11 @@ - public boolean m_6102_() { + public boolean shouldInformAdmins() { return false; + } + @@ -36,4 +36,4 @@ + return console; } - public boolean m_7779_(GameProfile p_177617_) { + public boolean isSingleplayerOwner(GameProfile p_177617_) { diff --git a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch index e56e9fde..f82339c1 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -5,7 +5,7 @@ return optional.get(); } else { - String s = p_127881_ + ".snbt"; -+ String s = new ResourceLocation(p_127881_).m_135815_() + ".snbt"; - Path path = Paths.get(f_127833_, s); - CompoundTag compoundtag = m_127902_(path); ++ String s = new ResourceLocation(p_127881_).getPath() + ".snbt"; + Path path = Paths.get(testStructuresDir, s); + CompoundTag compoundtag = tryLoadStructure(path); if (compoundtag == null) { diff --git a/patches/minecraft/net/minecraft/locale/Language.java.patch b/patches/minecraft/net/minecraft/locale/Language.java.patch index f82a97b8..9d6942cd 100644 --- a/patches/minecraft/net/minecraft/locale/Language.java.patch +++ b/patches/minecraft/net/minecraft/locale/Language.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/locale/Language.java +++ b/net/minecraft/locale/Language.java @@ -61,7 +_,8 @@ - f_128101_.error("Couldn't read strings from {}", "/assets/minecraft/lang/en_us.json", ioexception); + LOGGER.error("Couldn't read strings from {}", "/assets/minecraft/lang/en_us.json", ioexception); } - final Map map = builder.build(); + final Map map = new java.util.HashMap<>(builder.build()); + net.minecraftforge.server.LanguageHook.captureLanguageMap(map); return new Language() { - public String m_6834_(String p_128127_) { + public String getOrDefault(String p_128127_) { return map.getOrDefault(p_128127_, p_128127_); @@ -82,6 +_,11 @@ - }, Style.f_131099_).isPresent(); + }, Style.EMPTY).isPresent(); }; } + @@ -23,12 +23,12 @@ } @@ -102,6 +_,9 @@ - public static void m_128114_(Language p_128115_) { - f_128104_ = p_128115_; + public static void inject(Language p_128115_) { + instance = p_128115_; } + + // FORGE START + public Map getLanguageData() { return ImmutableMap.of(); } - public abstract String m_6834_(String p_128111_); + public abstract String getOrDefault(String p_128111_); diff --git a/patches/minecraft/net/minecraft/nbt/ByteArrayTag.java.patch b/patches/minecraft/net/minecraft/nbt/ByteArrayTag.java.patch index 615c90a6..534352dc 100644 --- a/patches/minecraft/net/minecraft/nbt/ByteArrayTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/ByteArrayTag.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/nbt/ByteArrayTag.java +++ b/net/minecraft/nbt/ByteArrayTag.java @@ -13,6 +_,7 @@ - public ByteArrayTag m_7300_(DataInput p_128247_, int p_128248_, NbtAccounter p_128249_) throws IOException { - p_128249_.m_6800_(192L); + public ByteArrayTag load(DataInput p_128247_, int p_128248_, NbtAccounter p_128249_) throws IOException { + p_128249_.accountBits(192L); int i = p_128247_.readInt(); + com.google.common.base.Preconditions.checkArgument( i < 1 << 24); // Spigot - p_128249_.m_6800_(8L * (long)i); + p_128249_.accountBits(8L * (long)i); byte[] abyte = new byte[i]; p_128247_.readFully(abyte); diff --git a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch index 4879f388..3a6317b1 100644 --- a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch @@ -1,59 +1,59 @@ --- a/net/minecraft/nbt/CompoundTag.java +++ b/net/minecraft/nbt/CompoundTag.java @@ -40,6 +_,7 @@ - while((b0 = CompoundTag.m_128420_(p_128485_, p_128487_)) != 0) { - String s = CompoundTag.m_128432_(p_128485_, p_128487_); - p_128487_.m_6800_((long)(224 + 16 * s.length())); -+ p_128487_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. - Tag tag = CompoundTag.m_128413_(TagTypes.m_129397_(b0), s, p_128485_, p_128486_ + 1, p_128487_); + while((b0 = CompoundTag.readNamedTagType(p_128485_, p_128487_)) != 0) { + String s = CompoundTag.readNamedTagName(p_128485_, p_128487_); + p_128487_.accountBits((long)(224 + 16 * s.length())); ++ p_128487_.accountBits(32); //Forge: 4 extra bytes for the object allocation. + Tag tag = CompoundTag.readNamedTagData(TagTypes.getType(b0), s, p_128485_, p_128486_ + 1, p_128487_); if (map.put(s, tag) != null) { - p_128487_.m_6800_(288L); + p_128487_.accountBits(288L); @@ -56,36 +_,36 @@ if ((b0 = p_197446_.readByte()) != 0) { - TagType tagtype = TagTypes.m_129397_(b0); - switch(p_197447_.m_196214_(tagtype)) { + TagType tagtype = TagTypes.getType(b0); + switch(p_197447_.visitEntry(tagtype)) { - case HALT: - return StreamTagVisitor.ValueResult.HALT; - case BREAK: -- StringTag.m_197563_(p_197446_); -- tagtype.m_196159_(p_197446_); +- StringTag.skipString(p_197446_); +- tagtype.skip(p_197446_); - break; - case SKIP: -- StringTag.m_197563_(p_197446_); -- tagtype.m_196159_(p_197446_); +- StringTag.skipString(p_197446_); +- tagtype.skip(p_197446_); - continue; - default: - String s = p_197446_.readUTF(); -- switch(p_197447_.m_196425_(tagtype, s)) { +- switch(p_197447_.visitEntry(tagtype, s)) { case HALT: return StreamTagVisitor.ValueResult.HALT; case BREAK: -+ StringTag.m_197563_(p_197446_); - tagtype.m_196159_(p_197446_); ++ StringTag.skipString(p_197446_); + tagtype.skip(p_197446_); break; case SKIP: -+ StringTag.m_197563_(p_197446_); - tagtype.m_196159_(p_197446_); ++ StringTag.skipString(p_197446_); + tagtype.skip(p_197446_); continue; default: -- switch(tagtype.m_196511_(p_197446_, p_197447_)) { +- switch(tagtype.parse(p_197446_, p_197447_)) { - case HALT: - return StreamTagVisitor.ValueResult.HALT; - case BREAK: - default: - continue; + String s = p_197446_.readUTF(); -+ switch(p_197447_.m_196425_(tagtype, s)) { ++ switch(p_197447_.visitEntry(tagtype, s)) { + case HALT: + return StreamTagVisitor.ValueResult.HALT; + case BREAK: -+ tagtype.m_196159_(p_197446_); ++ tagtype.skip(p_197446_); + break; + case SKIP: -+ tagtype.m_196159_(p_197446_); ++ tagtype.skip(p_197446_); + continue; + default: -+ switch(tagtype.m_196511_(p_197446_, p_197447_)) { ++ switch(tagtype.parse(p_197446_, p_197447_)) { + case HALT: + return StreamTagVisitor.ValueResult.HALT; + case BREAK: @@ -68,38 +68,38 @@ @@ -154,6 +_,8 @@ @Nullable - public Tag m_128365_(String p_128366_, Tag p_128367_) { + public Tag put(String p_128366_, Tag p_128367_) { + if (p_128367_ == null && org.magmafoundation.magma.configuration.MagmaConfig.instance.debugWarnOnNullNBT.getValues()) + org.magmafoundation.magma.Magma.LOGGER.warn("Tried to set key " + p_128366_ + " to null. This warning can be ignored if you know what you're doing."); // org.magmafoundation.magma.Magma - allow null nbt - return this.f_128329_.put(p_128366_, p_128367_); + return this.tags.put(p_128366_, p_128367_); } @@ -446,11 +_,12 @@ } - static byte m_128420_(DataInput p_128421_, NbtAccounter p_128422_) throws IOException { -+ p_128422_.m_6800_(8); + static byte readNamedTagType(DataInput p_128421_, NbtAccounter p_128422_) throws IOException { ++ p_128422_.accountBits(8); return p_128421_.readByte(); } - static String m_128432_(DataInput p_128433_, NbtAccounter p_128434_) throws IOException { + static String readNamedTagName(DataInput p_128433_, NbtAccounter p_128434_) throws IOException { - return p_128433_.readUTF(); + return p_128434_.readUTF(p_128433_.readUTF()); } - static Tag m_128413_(TagType p_128414_, String p_128415_, DataInput p_128416_, int p_128417_, NbtAccounter p_128418_) { + static Tag readNamedTagData(TagType p_128414_, String p_128415_, DataInput p_128416_, int p_128417_, NbtAccounter p_128418_) { @@ -497,15 +_,6 @@ - TagType tagtype = tag.m_6458_(); - StreamTagVisitor.EntryResult streamtagvisitor$entryresult = p_197442_.m_196214_(tagtype); + TagType tagtype = tag.getType(); + StreamTagVisitor.EntryResult streamtagvisitor$entryresult = p_197442_.visitEntry(tagtype); switch(streamtagvisitor$entryresult) { - case HALT: - return StreamTagVisitor.ValueResult.HALT; - case BREAK: -- return p_197442_.m_196527_(); +- return p_197442_.visitContainerEnd(); - case SKIP: - break; - default: -- streamtagvisitor$entryresult = p_197442_.m_196425_(tagtype, entry.getKey()); +- streamtagvisitor$entryresult = p_197442_.visitEntry(tagtype, entry.getKey()); - switch(streamtagvisitor$entryresult) { case HALT: return StreamTagVisitor.ValueResult.HALT; @@ -108,27 +108,27 @@ case SKIP: break; default: -- StreamTagVisitor.ValueResult streamtagvisitor$valueresult = tag.m_196533_(p_197442_); +- StreamTagVisitor.ValueResult streamtagvisitor$valueresult = tag.accept(p_197442_); - switch(streamtagvisitor$valueresult) { - case HALT: - return StreamTagVisitor.ValueResult.HALT; - case BREAK: -- return p_197442_.m_196527_(); -+ streamtagvisitor$entryresult = p_197442_.m_196425_(tagtype, entry.getKey()); +- return p_197442_.visitContainerEnd(); ++ streamtagvisitor$entryresult = p_197442_.visitEntry(tagtype, entry.getKey()); + switch(streamtagvisitor$entryresult) { + case HALT: + return StreamTagVisitor.ValueResult.HALT; + case BREAK: -+ return p_197442_.m_196527_(); ++ return p_197442_.visitContainerEnd(); + case SKIP: + break; + default: -+ StreamTagVisitor.ValueResult streamtagvisitor$valueresult = tag.m_196533_(p_197442_); ++ StreamTagVisitor.ValueResult streamtagvisitor$valueresult = tag.accept(p_197442_); + switch(streamtagvisitor$valueresult) { + case HALT: + return StreamTagVisitor.ValueResult.HALT; + case BREAK: -+ return p_197442_.m_196527_(); ++ return p_197442_.visitContainerEnd(); + } } - } diff --git a/patches/minecraft/net/minecraft/nbt/IntArrayTag.java.patch b/patches/minecraft/net/minecraft/nbt/IntArrayTag.java.patch index 0cb036a1..a75f1b85 100644 --- a/patches/minecraft/net/minecraft/nbt/IntArrayTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/IntArrayTag.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/nbt/IntArrayTag.java +++ b/net/minecraft/nbt/IntArrayTag.java @@ -13,6 +_,7 @@ - public IntArrayTag m_7300_(DataInput p_128662_, int p_128663_, NbtAccounter p_128664_) throws IOException { - p_128664_.m_6800_(192L); + public IntArrayTag load(DataInput p_128662_, int p_128663_, NbtAccounter p_128664_) throws IOException { + p_128664_.accountBits(192L); int i = p_128662_.readInt(); + com.google.common.base.Preconditions.checkArgument( i < 1 << 24); // Spigot - p_128664_.m_6800_(32L * (long)i); + p_128664_.accountBits(32L * (long)i); int[] aint = new int[i]; diff --git a/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch b/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch index 8f9fd462..519d2962 100644 --- a/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/nbt/NbtAccounter.java +++ b/net/minecraft/nbt/NbtAccounter.java @@ -18,4 +_,34 @@ - throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.f_128919_ + "bytes where max allowed: " + this.f_128918_); + throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.usage + "bytes where max allowed: " + this.quota); } } + @@ -17,7 +17,7 @@ + * This will accurately count the correct byte length to encode this string, plus the 2 bytes for it's length prefix. + */ + public String readUTF(String data) { -+ m_6800_(16); //Header length ++ accountBits(16); //Header length + if (data == null) + return data; + @@ -30,7 +30,7 @@ + else if (c > 0x07FF) utflen += 3; + else utflen += 2; + } -+ m_6800_(8 * utflen); ++ accountBits(8 * utflen); + + return data; + } diff --git a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch index 692c075d..44f29371 100644 --- a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch @@ -3,27 +3,27 @@ @@ -222,6 +_,12 @@ } - public static CompoundTag m_128934_(DataInput p_128935_, NbtAccounter p_128936_) throws IOException { + public static CompoundTag read(DataInput p_128935_, NbtAccounter p_128936_) throws IOException { + // Spigot start + if ( p_128935_ instanceof io.netty.buffer.ByteBufInputStream ) + { + p_128935_ = new DataInputStream(new org.spigotmc.LimitStream((InputStream) p_128935_, p_128936_)); + } + // Spigot end - Tag tag = m_128930_(p_128935_, 0, p_128936_); + Tag tag = readUnnamedTag(p_128935_, 0, p_128936_); if (tag instanceof CompoundTag) { return (CompoundTag)tag; @@ -268,10 +_,12 @@ - private static Tag m_128930_(DataInput p_128931_, int p_128932_, NbtAccounter p_128933_) throws IOException { + private static Tag readUnnamedTag(DataInput p_128931_, int p_128932_, NbtAccounter p_128933_) throws IOException { byte b0 = p_128931_.readByte(); -+ p_128933_.m_6800_(8); // Forge: Count everything! ++ p_128933_.accountBits(8); // Forge: Count everything! if (b0 == 0) { - return EndTag.f_128534_; + return EndTag.INSTANCE; } else { -- StringTag.m_197563_(p_128931_); +- StringTag.skipString(p_128931_); + p_128933_.readUTF(p_128931_.readUTF()); //Forge: Count this string. -+ p_128933_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. ++ p_128933_.accountBits(32); //Forge: 4 extra bytes for the object allocation. try { - return TagTypes.m_129397_(b0).m_7300_(p_128931_, p_128932_, p_128933_); + return TagTypes.getType(b0).load(p_128931_, p_128932_, p_128933_); diff --git a/patches/minecraft/net/minecraft/nbt/StringTag.java.patch b/patches/minecraft/net/minecraft/nbt/StringTag.java.patch index 28db75a0..364065ab 100644 --- a/patches/minecraft/net/minecraft/nbt/StringTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/StringTag.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/nbt/StringTag.java +++ b/net/minecraft/nbt/StringTag.java @@ -11,7 +_,7 @@ - public StringTag m_7300_(DataInput p_129315_, int p_129316_, NbtAccounter p_129317_) throws IOException { - p_129317_.m_6800_(288L); + public StringTag load(DataInput p_129315_, int p_129316_, NbtAccounter p_129317_) throws IOException { + p_129317_.accountBits(288L); String s = p_129315_.readUTF(); -- p_129317_.m_6800_((long)(16 * s.length())); +- p_129317_.accountBits((long)(16 * s.length())); + p_129317_.readUTF(s); - return StringTag.m_129297_(s); + return StringTag.valueOf(s); } @@ -52,7 +_,7 @@ } - public static StringTag m_129297_(String p_129298_) { -- return p_129298_.isEmpty() ? f_129289_ : new StringTag(p_129298_); -+ return (p_129298_ == null || p_129298_.isEmpty()) ? f_129289_ : new StringTag(p_129298_); + public static StringTag valueOf(String p_129298_) { +- return p_129298_.isEmpty() ? EMPTY : new StringTag(p_129298_); ++ return (p_129298_ == null || p_129298_.isEmpty()) ? EMPTY : new StringTag(p_129298_); } - public void m_6434_(DataOutput p_129296_) throws IOException { + public void write(DataOutput p_129296_) throws IOException { diff --git a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch index 8113c7ca..49f5f07d 100644 --- a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch +++ b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/network/CompressionEncoder.java +++ b/net/minecraft/network/CompressionEncoder.java @@ -9,6 +_,8 @@ - private final byte[] f_129444_ = new byte[8192]; - private final Deflater f_129445_; - private int f_129446_; + private final byte[] encodeBuf = new byte[8192]; + private final Deflater deflater; + private int threshold; + private static final boolean DISABLE_PACKET_DEBUG = Boolean.parseBoolean(System.getProperty("forge.disablePacketCompressionDebug", "false")); + private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); public CompressionEncoder(int p_129448_) { - this.f_129446_ = p_129448_; + this.threshold = p_129448_; @@ -22,6 +_,13 @@ - friendlybytebuf.m_130130_(0); + friendlybytebuf.writeVarInt(0); friendlybytebuf.writeBytes(p_129453_); } else { + int maxSize = org.magmafoundation.magma.configuration.MagmaConfig.instance.forgePacketCompressionThreshold.getValues(); @@ -22,4 +22,4 @@ + } byte[] abyte = new byte[i]; p_129453_.readBytes(abyte); - friendlybytebuf.m_130130_(abyte.length); + friendlybytebuf.writeVarInt(abyte.length); diff --git a/patches/minecraft/net/minecraft/network/Connection.java.patch b/patches/minecraft/net/minecraft/network/Connection.java.patch index 5bd935d3..059ebbfb 100644 --- a/patches/minecraft/net/minecraft/network/Connection.java.patch +++ b/patches/minecraft/net/minecraft/network/Connection.java.patch @@ -2,51 +2,51 @@ +++ b/net/minecraft/network/Connection.java @@ -65,18 +_,23 @@ }); - public static final AttributeKey f_129461_ = AttributeKey.valueOf("protocol"); - public static final LazyLoadedValue f_129462_ = new LazyLoadedValue<>(() -> { + public static final AttributeKey ATTRIBUTE_PROTOCOL = AttributeKey.valueOf("protocol"); + public static final LazyLoadedValue NETWORK_WORKER_GROUP = new LazyLoadedValue<>(() -> { - return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build()); -+ return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(f_129465_)).build()); // Paper ++ return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper }); - public static final LazyLoadedValue f_129463_ = new LazyLoadedValue<>(() -> { + public static final LazyLoadedValue NETWORK_EPOLL_WORKER_GROUP = new LazyLoadedValue<>(() -> { - return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build()); -+ return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(f_129465_)).build()); // Paper ++ return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper }); - public static final LazyLoadedValue f_129464_ = new LazyLoadedValue<>(() -> { + public static final LazyLoadedValue LOCAL_WORKER_GROUP = new LazyLoadedValue<>(() -> { - return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build()); -+ return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(f_129465_)).build()); // Paper ++ return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper }); - private final PacketFlow f_129466_; - private final Queue f_129467_ = Queues.newConcurrentLinkedQueue(); -- private Channel f_129468_; -+ public Channel f_129468_; //Magma - private -> public - public SocketAddress f_129469_; + private final PacketFlow receiving; + private final Queue queue = Queues.newConcurrentLinkedQueue(); +- private Channel channel; ++ public Channel channel; //Magma - private -> public + public SocketAddress address; + // Spigot Start + public java.util.UUID spoofedUUID; + public com.mojang.authlib.properties.Property[] spoofedProfile; + public boolean preparing = true; + // Spigot End - private PacketListener f_129470_; - private Component f_129471_; - private boolean f_129472_; + private PacketListener packetListener; + private Component disconnectedReason; + private boolean encrypted; @@ -87,6 +_,7 @@ - private float f_129477_; - private int f_129478_; - private boolean f_129479_; + private float averageSentPackets; + private int tickCount; + private boolean handlingFault; + private java.util.function.Consumer activationHandler; public Connection(PacketFlow p_129482_) { - this.f_129466_ = p_129482_; + this.receiving = p_129482_; @@ -96,6 +_,10 @@ super.channelActive(p_129525_); - this.f_129468_ = p_129525_.channel(); - this.f_129469_ = this.f_129468_.remoteAddress(); + this.channel = p_129525_.channel(); + this.address = this.channel.remoteAddress(); + // Spigot Start + this.preparing = false; + // Spigot End + if (activationHandler != null) activationHandler.accept(this); try { - this.m_129498_(ConnectionProtocol.HANDSHAKING); + this.setProtocol(ConnectionProtocol.HANDSHAKING); @@ -143,6 +_,7 @@ } @@ -56,27 +56,27 @@ protected void channelRead0(ChannelHandlerContext p_129487_, Packet p_129488_) { @@ -191,7 +_,7 @@ - ++this.f_129475_; + ++this.sentPackets; if (connectionprotocol1 != connectionprotocol) { - f_129465_.debug("Disabled auto read"); -- this.f_129468_.config().setAutoRead(false); -+ this.f_129468_.eventLoop().execute(()->this.f_129468_.config().setAutoRead(false)); + LOGGER.debug("Disabled auto read"); +- this.channel.config().setAutoRead(false); ++ this.channel.eventLoop().execute(()->this.channel.config().setAutoRead(false)); } - if (this.f_129468_.eventLoop().inEventLoop()) { + if (this.channel.eventLoop().inEventLoop()) { @@ -270,7 +_,7 @@ - public void m_129507_(Component p_129508_) { - if (this.f_129468_.isOpen()) { -- this.f_129468_.close().awaitUninterruptibly(); -+ this.f_129468_.close(); // We can't wait as this may be called from an event loop. - this.f_129471_ = p_129508_; + public void disconnect(Component p_129508_) { + if (this.channel.isOpen()) { +- this.channel.close().awaitUninterruptibly(); ++ this.channel.close(); // We can't wait as this may be called from an event loop. + this.disconnectedReason = p_129508_; } @@ -289,7 +_,10 @@ } - public static Connection m_178300_(InetSocketAddress p_178301_, boolean p_178302_) { + public static Connection connectToServer(InetSocketAddress p_178301_, boolean p_178302_) { + net.minecraftforge.network.DualStackUtils.checkIPv6(p_178301_.getAddress()); final Connection connection = new Connection(PacketFlow.CLIENTBOUND); + net.minecraftforge.network.DualStackUtils.checkIPv6(p_178301_.getAddress()); @@ -86,44 +86,44 @@ if (Epoll.isAvailable() && p_178302_) { @@ -315,6 +_,7 @@ - public static Connection m_129493_(SocketAddress p_129494_) { + public static Connection connectToLocalServer(SocketAddress p_129494_) { final Connection connection = new Connection(PacketFlow.CLIENTBOUND); + connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel; - (new Bootstrap()).group(f_129464_.m_13971_()).handler(new ChannelInitializer() { + (new Bootstrap()).group(LOCAL_WORKER_GROUP.get()).handler(new ChannelInitializer() { protected void initChannel(Channel p_129557_) { p_129557_.pipeline().addLast("packet_handler", connection); @@ -390,6 +_,7 @@ - } else if (this.m_129538_() != null) { - this.m_129538_().m_7026_(new TranslatableComponent("multiplayer.disconnect.generic")); + } else if (this.getPacketListener() != null) { + this.getPacketListener().onDisconnect(new TranslatableComponent("multiplayer.disconnect.generic")); } -+ this.f_129467_.clear(); // Free up packet queue. ++ this.queue.clear(); // Free up packet queue. } } @@ -403,6 +_,14 @@ - return this.f_129477_; + return this.averageSentPackets; } + public Channel channel() { -+ return f_129468_; ++ return channel; + } + + public PacketFlow getDirection() { -+ return this.f_129466_; ++ return this.receiving; + } + static class PacketHolder { - final Packet f_129558_; + final Packet packet; @Nullable @@ -413,4 +_,11 @@ - this.f_129559_ = p_129562_; + this.listener = p_129562_; } } + + // Spigot Start + public SocketAddress getRawAddress() + { -+ return this.f_129468_.remoteAddress(); ++ return this.channel.remoteAddress(); + } + // Spigot End } diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch index 4a2da236..314ec33d 100644 --- a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch @@ -6,14 +6,14 @@ -public class FriendlyByteBuf extends ByteBuf { +public class FriendlyByteBuf extends ByteBuf implements net.minecraftforge.common.extensions.IForgeFriendlyByteBuf { - private static final int f_178335_ = 5; - private static final int f_178336_ = 10; - private static final int f_178337_ = 2097152; + private static final int MAX_VARINT_SIZE = 5; + private static final int MAX_VARLONG_SIZE = 10; + private static final int DEFAULT_NBT_QUOTA = 2097152; @@ -439,7 +_,16 @@ } - public FriendlyByteBuf m_130055_(ItemStack p_130056_) { -- if (p_130056_.m_41619_()) { + public FriendlyByteBuf writeItem(ItemStack p_130056_) { +- if (p_130056_.isEmpty()) { + return writeItemStack(p_130056_, true); + } + @@ -23,33 +23,33 @@ + * If you want to send the FULL tag set limitedTag to false + */ + public FriendlyByteBuf writeItemStack(ItemStack p_130056_, boolean limitedTag) { -+ if (p_130056_.m_41619_() || p_130056_.m_41720_() == null) { // CraftBukkit - NPE fix itemstack.getItem() ++ if (p_130056_.isEmpty() || p_130056_.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() this.writeBoolean(false); } else { this.writeBoolean(true); @@ -447,8 +_,12 @@ - this.m_130130_(Item.m_41393_(item)); - this.writeByte(p_130056_.m_41613_()); + this.writeVarInt(Item.getId(item)); + this.writeByte(p_130056_.getCount()); CompoundTag compoundtag = null; -- if (item.m_41465_() || item.m_41468_()) { -- compoundtag = p_130056_.m_41783_(); -+ if (item.isDamageable(p_130056_) || item.m_41468_()) { +- if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) { +- compoundtag = p_130056_.getTag(); ++ if (item.isDamageable(p_130056_) || item.shouldOverrideMultiplayerNbt()) { + // Spigot start - filter -+ p_130056_ = p_130056_.m_41777_(); ++ p_130056_ = p_130056_.copy(); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.setItemMeta(p_130056_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.getItemMeta(p_130056_)); + // Spigot end -+ compoundtag = limitedTag ? p_130056_.getShareTag() : p_130056_.m_41783_(); ++ compoundtag = limitedTag ? p_130056_.getShareTag() : p_130056_.getTag(); } - this.m_130079_(compoundtag); + this.writeNbt(compoundtag); @@ -464,7 +_,12 @@ - int i = this.m_130242_(); + int i = this.readVarInt(); int j = this.readByte(); - ItemStack itemstack = new ItemStack(Item.m_41445_(i), j); -- itemstack.m_41751_(this.m_130260_()); -+ itemstack.readShareTag(this.m_130260_()); + ItemStack itemstack = new ItemStack(Item.byId(i), j); +- itemstack.setTag(this.readNbt()); ++ itemstack.readShareTag(this.readNbt()); + // CraftBukkit start -+ if (itemstack.m_41783_() != null) { ++ if (itemstack.getTag() != null) { + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.setItemMeta(itemstack, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.getItemMeta(itemstack)); + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch b/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch index af666147..81bdfcdb 100644 --- a/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch +++ b/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/network/PacketEncoder.java @@ -38,8 +_,8 @@ int i = friendlybytebuf.writerIndex(); - p_130546_.m_5779_(friendlybytebuf); + p_130546_.write(friendlybytebuf); int j = friendlybytebuf.writerIndex() - i; - if (j > 8388608) { - throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + p_130546_); + if (j > 8388608 && j > org.magmafoundation.magma.configuration.MagmaConfig.instance.forgeMaxPacketSize.getValues()) { + throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than "+org.magmafoundation.magma.configuration.MagmaConfig.instance.forgeMaxPacketSize.getValues()+"): " + p_130546_); } else { - int k = p_130545_.channel().attr(Connection.f_129461_).get().m_129582_(); - JvmProfiler.f_185340_.m_183508_(k, integer, p_130545_.channel().remoteAddress(), j); + int k = p_130545_.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId(); + JvmProfiler.INSTANCE.onPacketSent(k, integer, p_130545_.channel().remoteAddress(), j); diff --git a/patches/minecraft/net/minecraft/network/chat/Component.java.patch b/patches/minecraft/net/minecraft/network/chat/Component.java.patch index cc3f4761..ee58c9c6 100644 --- a/patches/minecraft/net/minecraft/network/chat/Component.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/Component.java.patch @@ -9,7 +9,7 @@ + + // CraftBukkit start + default java.util.stream.Stream stream() { -+ return com.google.common.collect.Streams.concat(new java.util.stream.Stream[]{java.util.stream.Stream.of(this), this.m_7360_().stream().flatMap(Component::stream)}); ++ return com.google.common.collect.Streams.concat(new java.util.stream.Stream[]{java.util.stream.Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)}); + } + + @Override @@ -18,6 +18,6 @@ + } + // CraftBukkit end + - Style m_7383_(); + Style getStyle(); - String m_6111_(); + String getContents(); diff --git a/patches/minecraft/net/minecraft/network/chat/Style.java.patch b/patches/minecraft/net/minecraft/network/chat/Style.java.patch index 68398e59..9a875c3c 100644 --- a/patches/minecraft/net/minecraft/network/chat/Style.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/Style.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/network/chat/Style.java +++ b/net/minecraft/network/chat/Style.java @@ -133,6 +_,30 @@ - return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, p_178525_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); + return new Style(this.color, this.bold, this.italic, this.underlined, this.strikethrough, p_178525_, this.clickEvent, this.hoverEvent, this.insertion, this.font); } + /** @@ -9,7 +9,7 @@ + */ + @Deprecated(forRemoval = true, since = "1.18.2") + public Style setUnderlined(@Nullable Boolean underlined) { -+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, underlined, this.f_131105_, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); ++ return new Style(this.color, this.bold, this.italic, underlined, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); + } + + /** @@ -17,7 +17,7 @@ + */ + @Deprecated(forRemoval = true, since = "1.18.2") + public Style setStrikethrough(@Nullable Boolean strikethrough) { -+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, strikethrough, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); ++ return new Style(this.color, this.bold, this.italic, this.underlined, strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); + } + + /** @@ -25,9 +25,9 @@ + */ + @Deprecated(forRemoval = true, since = "1.18.2") + public Style setObfuscated(@Nullable Boolean obfuscated) { -+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, obfuscated, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_); ++ return new Style(this.color, this.bold, this.italic, this.underlined, this.strikethrough, obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); + } + - public Style m_131142_(@Nullable ClickEvent p_131143_) { - return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, this.f_131106_, p_131143_, this.f_131108_, this.f_131109_, this.f_131110_); + public Style withClickEvent(@Nullable ClickEvent p_131143_) { + return new Style(this.color, this.bold, this.italic, this.underlined, this.strikethrough, this.obfuscated, p_131143_, this.hoverEvent, this.insertion, this.font); } diff --git a/patches/minecraft/net/minecraft/network/chat/TextColor.java.patch b/patches/minecraft/net/minecraft/network/chat/TextColor.java.patch index be4626ea..9fd1d1d9 100644 --- a/patches/minecraft/net/minecraft/network/chat/TextColor.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/TextColor.java.patch @@ -2,39 +2,39 @@ +++ b/net/minecraft/network/chat/TextColor.java @@ -11,7 +_,7 @@ public final class TextColor { - private static final String f_178538_ = "#"; - private static final Map f_131255_ = Stream.of(ChatFormatting.values()).filter(ChatFormatting::m_126664_).collect(ImmutableMap.toImmutableMap(Function.identity(), (p_131276_) -> { -- return new TextColor(p_131276_.m_126665_(), p_131276_.m_126666_()); -+ return new TextColor(p_131276_.m_126665_(), p_131276_.m_126666_(), p_131276_); // CraftBukkit + private static final String CUSTOM_COLOR_PREFIX = "#"; + private static final Map LEGACY_FORMAT_TO_COLOR = Stream.of(ChatFormatting.values()).filter(ChatFormatting::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (p_131276_) -> { +- return new TextColor(p_131276_.getColor(), p_131276_.getName()); ++ return new TextColor(p_131276_.getColor(), p_131276_.getName(), p_131276_); // CraftBukkit })); - private static final Map f_131256_ = f_131255_.values().stream().collect(ImmutableMap.toImmutableMap((p_131273_) -> { - return p_131273_.f_131258_; + private static final Map NAMED_COLORS = LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((p_131273_) -> { + return p_131273_.name; @@ -20,15 +_,28 @@ @Nullable - private final String f_131258_; + private final String name; + // CraftBukkit start + @Nullable + public final ChatFormatting format; + + private TextColor(int p_131263_, String p_131264_, ChatFormatting format) { -+ this.f_131257_ = p_131263_; -+ this.f_131258_ = p_131264_; ++ this.value = p_131263_; ++ this.name = p_131264_; + this.format = format; + } + private TextColor(int p_131263_, String p_131264_) { - this.f_131257_ = p_131263_; - this.f_131258_ = p_131264_; + this.value = p_131263_; + this.name = p_131264_; + this.format = null; } private TextColor(int p_131261_) { - this.f_131257_ = p_131261_; - this.f_131258_ = null; + this.value = p_131261_; + this.name = null; + this.format = null; } + // CraftBukkit end - public int m_131265_() { - return this.f_131257_; + public int getValue() { + return this.value; diff --git a/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch b/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch index d3f3f215..a622c18b 100644 --- a/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch @@ -6,7 +6,7 @@ + if (j == 0) { + // if we failed to match above, lets try the messageformat handler instead. -+ j = net.minecraftforge.internal.TextComponentMessageFormatHandler.handle(this, p_200007_, this.f_131299_, p_200006_); ++ j = net.minecraftforge.internal.TextComponentMessageFormatHandler.handle(this, p_200007_, this.args, p_200006_); + } if (j < p_200006_.length()) { String s3 = p_200006_.substring(j); diff --git a/patches/minecraft/net/minecraft/network/protocol/PacketUtils.java.patch b/patches/minecraft/net/minecraft/network/protocol/PacketUtils.java.patch index ac57400a..5757abaa 100644 --- a/patches/minecraft/net/minecraft/network/protocol/PacketUtils.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/PacketUtils.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/network/protocol/PacketUtils.java +++ b/net/minecraft/network/protocol/PacketUtils.java @@ -17,8 +_,10 @@ - public static void m_131363_(Packet p_131364_, T p_131365_, BlockableEventLoop p_131366_) throws RunningOnDifferentThreadException { - if (!p_131366_.m_18695_()) { - p_131366_.m_201446_(() -> { + public static void ensureRunningOnSameThread(Packet p_131364_, T p_131365_, BlockableEventLoop p_131366_) throws RunningOnDifferentThreadException { + if (!p_131366_.isSameThread()) { + p_131366_.executeIfPossible(() -> { + if (net.minecraft.server.MinecraftServer.getServer().hasStopped() || (p_131365_ instanceof net.minecraft.server.network.ServerGamePacketListenerImpl && ((net.minecraft.server.network.ServerGamePacketListenerImpl) p_131365_).processedDisconnect)) return; // CraftBukkit, MC-142590 - if (p_131365_.m_6198_().m_129536_()) { + if (p_131365_.getConnection().isConnected()) { - try { + co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(p_131364_); // Paper - timings + try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings - p_131364_.m_5797_(p_131365_); + p_131364_.handle(p_131365_); } catch (Exception exception) { - if (p_131365_.m_201767_()) { + if (p_131365_.shouldPropagateHandlingExceptions()) { @@ -33,6 +_,10 @@ }); - throw RunningOnDifferentThreadException.f_136017_; + throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; + // CraftBukkit start - SPIGOT-5477, MC-142590 + } else if (net.minecraft.server.MinecraftServer.getServer().hasStopped() || (p_131365_ instanceof net.minecraft.server.network.ServerGamePacketListenerImpl && ((net.minecraft.server.network.ServerGamePacketListenerImpl) p_131365_).processedDisconnect)) { -+ throw RunningOnDifferentThreadException.f_136017_; ++ throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; + // CraftBukkit end } } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundBlockUpdatePacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundBlockUpdatePacket.java.patch index b8a6fd40..2009f700 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundBlockUpdatePacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundBlockUpdatePacket.java.patch @@ -3,9 +3,9 @@ @@ -9,7 +_,7 @@ public class ClientboundBlockUpdatePacket implements Packet { - private final BlockPos f_131731_; -- private final BlockState f_131732_; -+ public final BlockState f_131732_; + private final BlockPos pos; +- private final BlockState blockState; ++ public final BlockState blockState; public ClientboundBlockUpdatePacket(BlockPos p_131738_, BlockState p_131739_) { - this.f_131731_ = p_131738_; + this.pos = p_131738_; diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundChatPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundChatPacket.java.patch index 8bd8fd37..cfa421cd 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundChatPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundChatPacket.java.patch @@ -3,23 +3,23 @@ @@ -8,6 +_,7 @@ public class ClientboundChatPacket implements Packet { - private final Component f_131821_; + private final Component message; + public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot - private final ChatType f_131822_; - private final UUID f_131823_; + private final ChatType type; + private final UUID sender; @@ -24,7 +_,13 @@ } - public void m_5779_(FriendlyByteBuf p_131838_) { -- p_131838_.m_130083_(this.f_131821_); + public void write(FriendlyByteBuf p_131838_) { +- p_131838_.writeComponent(this.message); + // Spigot start + if (components != null) { -+ p_131838_.m_130070_(net.md_5.bungee.chat.ComponentSerializer.toString(components)); ++ p_131838_.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components)); + } else { -+ p_131838_.m_130083_(this.f_131821_); ++ p_131838_.writeComponent(this.message); + } + // Spigot end - p_131838_.writeByte(this.f_131822_.m_130610_()); - p_131838_.m_130077_(this.f_131823_); + p_131838_.writeByte(this.type.getIndex()); + p_131838_.writeUUID(this.sender); } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCommandsPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCommandsPacket.java.patch index 24edb956..3d6c43c0 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCommandsPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCommandsPacket.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/network/protocol/game/ClientboundCommandsPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundCommandsPacket.java @@ -54,6 +_,96 @@ - p_131886_.m_130130_(object2intmap.get(this.f_131858_)); + p_131886_.writeVarInt(object2intmap.get(this.root)); } + //Magma - ambassador command support + public void write(FriendlyByteBuf byteBuf, boolean wrap) { -+ Object2IntMap> object2intmap = m_131862_(this.f_131858_); -+ List> list = m_178806_(object2intmap); -+ byteBuf.m_178352_(list, (p_178810_, p_178811_) -> { ++ Object2IntMap> object2intmap = enumerateNodes(this.root); ++ List> list = getNodesInIdOrder(object2intmap); ++ byteBuf.writeCollection(list, (p_178810_, p_178811_) -> { + writeNodeNoArgumentTypes(p_178810_, p_178811_, object2intmap); + if (p_178811_ instanceof ArgumentCommandNode argumentCommandNode) { + serialize(byteBuf, argumentCommandNode.getType(), wrap); + if (argumentCommandNode.getCustomSuggestions() != null) { -+ byteBuf.m_130085_(SuggestionProviders.m_121654_(argumentCommandNode.getCustomSuggestions())); ++ byteBuf.writeResourceLocation(SuggestionProviders.getName(argumentCommandNode.getCustomSuggestions())); + } + } + }); -+ byteBuf.m_130130_(object2intmap.get(this.f_131858_)); ++ byteBuf.writeVarInt(object2intmap.get(this.root)); + } + private static final List integratedArgumentTypes = java.util.Arrays.asList( + "brigadier:bool", @@ -75,17 +75,17 @@ + ); + + private static > void serialize(FriendlyByteBuf buf, T type, boolean wrap) { -+ ArgumentTypes.Entry entry = (ArgumentTypes.Entry)ArgumentTypes.m_121616_(type); ++ ArgumentTypes.Entry entry = (ArgumentTypes.Entry)ArgumentTypes.get(type); + + if (entry == null) { -+ buf.m_130085_(MOD_ARGUMENT_INDICATOR); -+ buf.m_130085_(new net.minecraft.resources.ResourceLocation("")); //"minecraft:" -+ buf.m_130130_(0); ++ buf.writeResourceLocation(MOD_ARGUMENT_INDICATOR); ++ buf.writeResourceLocation(new net.minecraft.resources.ResourceLocation("")); //"minecraft:" ++ buf.writeVarInt(0); + return; + } + -+ if (!wrap || integratedArgumentTypes.contains(entry.f_121620_.toString())) { -+ ArgumentTypes.m_121611_(buf, type); ++ if (!wrap || integratedArgumentTypes.contains(entry.name.toString())) { ++ ArgumentTypes.serialize(buf, type); + return; + } + @@ -94,14 +94,14 @@ + } + //Magma - end + - private static void m_178812_(List p_178813_) { + private static void resolveEntries(List p_178813_) { List list = Lists.newArrayList(p_178813_); @@ -128,54 +_,152 @@ } } -- private static void m_131871_(FriendlyByteBuf p_131872_, CommandNode p_131873_, Map, Integer> p_131874_) { +- private static void writeNode(FriendlyByteBuf p_131872_, CommandNode p_131873_, Map, Integer> p_131874_) { - byte b0 = 0; - if (p_131873_.getRedirect() != null) { - b0 = (byte)(b0 | 8); @@ -127,29 +127,29 @@ - } - - p_131872_.writeByte(b0); -- p_131872_.m_130130_(p_131873_.getChildren().size()); +- p_131872_.writeVarInt(p_131873_.getChildren().size()); - - for(CommandNode commandnode : p_131873_.getChildren()) { -- p_131872_.m_130130_(p_131874_.get(commandnode)); +- p_131872_.writeVarInt(p_131874_.get(commandnode)); - } - - if (p_131873_.getRedirect() != null) { -- p_131872_.m_130130_(p_131874_.get(p_131873_.getRedirect())); +- p_131872_.writeVarInt(p_131874_.get(p_131873_.getRedirect())); - } - - if (p_131873_ instanceof ArgumentCommandNode) { - ArgumentCommandNode argumentcommandnode = (ArgumentCommandNode)p_131873_; -- p_131872_.m_130070_(argumentcommandnode.getName()); -- ArgumentTypes.m_121611_(p_131872_, argumentcommandnode.getType()); +- p_131872_.writeUtf(argumentcommandnode.getName()); +- ArgumentTypes.serialize(p_131872_, argumentcommandnode.getType()); - if (argumentcommandnode.getCustomSuggestions() != null) { -- p_131872_.m_130085_(SuggestionProviders.m_121654_(argumentcommandnode.getCustomSuggestions())); +- p_131872_.writeResourceLocation(SuggestionProviders.getName(argumentcommandnode.getCustomSuggestions())); - } - } else if (p_131873_ instanceof LiteralCommandNode) { -- p_131872_.m_130070_(((LiteralCommandNode)p_131873_).getLiteral()); +- p_131872_.writeUtf(((LiteralCommandNode)p_131873_).getLiteral()); - } - - } -+ private static void m_131871_(FriendlyByteBuf p_131872_, CommandNode p_131873_, Map, Integer> p_131874_){ ++ private static void writeNode(FriendlyByteBuf p_131872_, CommandNode p_131873_, Map, Integer> p_131874_){ + byte b0 = 0; + if (p_131873_.getRedirect() != null) { + b0 = (byte)(b0 | 8); @@ -175,42 +175,42 @@ + } + + p_131872_.writeByte(b0); -+ p_131872_.m_130130_(p_131873_.getChildren().size()); ++ p_131872_.writeVarInt(p_131873_.getChildren().size()); + + for(CommandNode commandnode : p_131873_.getChildren()) { -+ p_131872_.m_130130_(p_131874_.get(commandnode)); ++ p_131872_.writeVarInt(p_131874_.get(commandnode)); + } + + if (p_131873_.getRedirect() != null) { -+ p_131872_.m_130130_(p_131874_.get(p_131873_.getRedirect())); ++ p_131872_.writeVarInt(p_131874_.get(p_131873_.getRedirect())); + } + + if (p_131873_ instanceof ArgumentCommandNode) { + ArgumentCommandNode argumentcommandnode = (ArgumentCommandNode)p_131873_; -+ p_131872_.m_130070_(argumentcommandnode.getName()); ++ p_131872_.writeUtf(argumentcommandnode.getName()); + //Magma start + if(org.spigotmc.SpigotConfig.bungee){ -+ ArgumentTypes.Entry entry = ArgumentTypes.f_121583_.get(argumentcommandnode.getType().getClass()); ++ ArgumentTypes.Entry entry = ArgumentTypes.BY_CLASS.get(argumentcommandnode.getType().getClass()); + if (entry == null) { -+ p_131872_.m_130085_(new net.minecraft.resources.ResourceLocation("")); ++ p_131872_.writeResourceLocation(new net.minecraft.resources.ResourceLocation("")); + return; + } -+ if (entry.f_121620_.m_135827_().equals("minecraft") || entry.f_121620_.m_135827_().equals("brigadier")) { -+ p_131872_.m_130085_(entry.f_121620_); -+ entry.f_121619_.m_6017_(argumentcommandnode.getType(), p_131872_); ++ if (entry.name.getNamespace().equals("minecraft") || entry.name.getNamespace().equals("brigadier")) { ++ p_131872_.writeResourceLocation(entry.name); ++ entry.serializer.serializeToNetwork(argumentcommandnode.getType(), p_131872_); + } else { + serializeWrappedArgumentType(p_131872_, argumentcommandnode.getType(), entry); + } + } else { -+ ArgumentTypes.m_121611_(p_131872_, argumentcommandnode.getType()); ++ ArgumentTypes.serialize(p_131872_, argumentcommandnode.getType()); + } + //Magma end + + if (argumentcommandnode.getCustomSuggestions() != null) { -+ p_131872_.m_130085_(SuggestionProviders.m_121654_(argumentcommandnode.getCustomSuggestions())); ++ p_131872_.writeResourceLocation(SuggestionProviders.getName(argumentcommandnode.getCustomSuggestions())); + } + } else if (p_131873_ instanceof LiteralCommandNode) { -+ p_131872_.m_130070_(((LiteralCommandNode)p_131873_).getLiteral()); ++ p_131872_.writeUtf(((LiteralCommandNode)p_131873_).getLiteral()); + } + } +//Magma start - ambassador command support @@ -240,29 +240,29 @@ + } + + p_131872_.writeByte(b0); -+ p_131872_.m_130130_(p_131873_.getChildren().size()); ++ p_131872_.writeVarInt(p_131873_.getChildren().size()); + + for(CommandNode commandnode : p_131873_.getChildren()) { -+ p_131872_.m_130130_(p_131874_.get(commandnode)); ++ p_131872_.writeVarInt(p_131874_.get(commandnode)); + } + + if (p_131873_.getRedirect() != null) { -+ p_131872_.m_130130_(p_131874_.get(p_131873_.getRedirect())); ++ p_131872_.writeVarInt(p_131874_.get(p_131873_.getRedirect())); + } + + if (p_131873_ instanceof ArgumentCommandNode) { + ArgumentCommandNode argumentcommandnode = (ArgumentCommandNode)p_131873_; -+ p_131872_.m_130070_(argumentcommandnode.getName()); ++ p_131872_.writeUtf(argumentcommandnode.getName()); + //Magma start + if(org.spigotmc.SpigotConfig.bungee){ -+ ArgumentTypes.Entry entry = ArgumentTypes.f_121583_.get(argumentcommandnode.getType().getClass()); ++ ArgumentTypes.Entry entry = ArgumentTypes.BY_CLASS.get(argumentcommandnode.getType().getClass()); + if (entry == null) { -+ p_131872_.m_130085_(new net.minecraft.resources.ResourceLocation("")); ++ p_131872_.writeResourceLocation(new net.minecraft.resources.ResourceLocation("")); + return; + } -+ if (entry.f_121620_.m_135827_().equals("minecraft") || entry.f_121620_.m_135827_().equals("brigadier")) { -+ p_131872_.m_130085_(entry.f_121620_); -+ entry.f_121619_.m_6017_(argumentcommandnode.getType(), p_131872_); ++ if (entry.name.getNamespace().equals("minecraft") || entry.name.getNamespace().equals("brigadier")) { ++ p_131872_.writeResourceLocation(entry.name); ++ entry.serializer.serializeToNetwork(argumentcommandnode.getType(), p_131872_); + } else { + serializeWrappedArgumentType(p_131872_, argumentcommandnode.getType(), entry); + } @@ -273,10 +273,10 @@ + //Magma end + + if (argumentcommandnode.getCustomSuggestions() != null) { -+ p_131872_.m_130085_(SuggestionProviders.m_121654_(argumentcommandnode.getCustomSuggestions())); ++ p_131872_.writeResourceLocation(SuggestionProviders.getName(argumentcommandnode.getCustomSuggestions())); + } + } else if (p_131873_ instanceof LiteralCommandNode) { -+ p_131872_.m_130070_(((LiteralCommandNode)p_131873_).getLiteral()); ++ p_131872_.writeUtf(((LiteralCommandNode)p_131873_).getLiteral()); + } + + } @@ -285,16 +285,16 @@ + private static final net.minecraft.resources.ResourceLocation MOD_ARGUMENT_INDICATOR = new net.minecraft.resources.ResourceLocation("crossstitch", "mod_argument"); + + private static void serializeWrappedArgumentType(FriendlyByteBuf packetByteBuf, ArgumentType argumentType, ArgumentTypes.Entry entry) { -+ packetByteBuf.m_130085_(MOD_ARGUMENT_INDICATOR); -+ packetByteBuf.m_130085_(entry.f_121620_); ++ packetByteBuf.writeResourceLocation(MOD_ARGUMENT_INDICATOR); ++ packetByteBuf.writeResourceLocation(entry.name); + + FriendlyByteBuf extraData = new FriendlyByteBuf(io.netty.buffer.Unpooled.buffer()); -+ entry.f_121619_.m_6017_(argumentType, extraData); ++ entry.serializer.serializeToNetwork(argumentType, extraData); + -+ packetByteBuf.m_130130_(extraData.readableBytes()); ++ packetByteBuf.writeVarInt(extraData.readableBytes()); + packetByteBuf.writeBytes(extraData); + } + //Magma end - public void m_5797_(ClientGamePacketListener p_131878_) { - p_131878_.m_7443_(this); + public void handle(ClientGamePacketListener p_131878_) { + p_131878_.handleCommands(this); diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch index ddc03d48..c4b78b1a 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch @@ -6,17 +6,17 @@ -public class ClientboundCustomPayloadPacket implements Packet { +public class ClientboundCustomPayloadPacket implements Packet, net.minecraftforge.network.ICustomPacket { - private static final int f_178834_ = 1048576; - public static final ResourceLocation f_132012_ = new ResourceLocation("brand"); - public static final ResourceLocation f_132013_ = new ResourceLocation("debug/path"); + private static final int MAX_PAYLOAD_SIZE = 1048576; + public static final ResourceLocation BRAND = new ResourceLocation("brand"); + public static final ResourceLocation DEBUG_PATHFINDING_PACKET = new ResourceLocation("debug/path"); @@ -26,6 +_,7 @@ - public static final ResourceLocation f_178833_ = new ResourceLocation("debug/game_event_listeners"); - private final ResourceLocation f_132029_; - private final FriendlyByteBuf f_132030_; + public static final ResourceLocation DEBUG_GAME_EVENT_LISTENER = new ResourceLocation("debug/game_event_listeners"); + private final ResourceLocation identifier; + private final FriendlyByteBuf data; + private final boolean shouldRelease; public ClientboundCustomPayloadPacket(ResourceLocation p_132034_, FriendlyByteBuf p_132035_) { - this.f_132029_ = p_132034_; + this.identifier = p_132034_; @@ -33,6 +_,7 @@ if (p_132035_.writerIndex() > 1048576) { throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes"); @@ -32,12 +32,12 @@ + this.shouldRelease = true; //We are the owner of the buffer, release it when we are done. } - public void m_5779_(FriendlyByteBuf p_132044_) { + public void write(FriendlyByteBuf p_132044_) { @@ -52,6 +_,7 @@ - public void m_5797_(ClientGamePacketListener p_132041_) { - p_132041_.m_7413_(this); -+ if (this.shouldRelease) this.f_132030_.release(); // FORGE: Fix impl buffer leaks (MC-121884), can only be fixed partially, because else you get problems in LAN-Worlds + public void handle(ClientGamePacketListener p_132041_) { + p_132041_.handleCustomPayload(this); ++ if (this.shouldRelease) this.data.release(); // FORGE: Fix impl buffer leaks (MC-121884), can only be fixed partially, because else you get problems in LAN-Worlds } - public ResourceLocation m_132042_() { + public ResourceLocation getIdentifier() { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch index 93230c3e..3e546d20 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch @@ -4,25 +4,25 @@ } public ClientboundInitializeBorderPacket(WorldBorder p_178877_) { -- this.f_178868_ = p_178877_.m_6347_(); -- this.f_178869_ = p_178877_.m_6345_(); +- this.newCenterX = p_178877_.getCenterX(); +- this.newCenterZ = p_178877_.getCenterZ(); + //Magma start + if (p_178877_.world == null) + p_178877_.world = org.magmafoundation.magma.helpers.BorderHelper.getLevelFromPlayer(this); + -+ double newCenterX = p_178877_.m_6347_(); -+ double newCenterZ = p_178877_.m_6345_(); ++ double newCenterX = p_178877_.getCenterX(); ++ double newCenterZ = p_178877_.getCenterZ(); + + if (p_178877_.world != null) { + // CraftBukkit start - multiply out nether border -+ newCenterX = newCenterX * p_178877_.world.m_6042_().m_63959_(); -+ newCenterZ = newCenterZ * p_178877_.world.m_6042_().m_63959_(); ++ newCenterX = newCenterX * p_178877_.world.dimensionType().coordinateScale(); ++ newCenterZ = newCenterZ * p_178877_.world.dimensionType().coordinateScale(); + // CraftBukkit end + } + -+ this.f_178868_ = newCenterX; -+ this.f_178869_ = newCenterZ; ++ this.newCenterX = newCenterX; ++ this.newCenterZ = newCenterZ; + //Magma end - this.f_178870_ = p_178877_.m_61959_(); - this.f_178871_ = p_178877_.m_61961_(); - this.f_178872_ = p_178877_.m_61960_(); + this.oldSize = p_178877_.getSize(); + this.newSize = p_178877_.getLerpTarget(); + this.lerpTime = p_178877_.getLerpRemainingTime(); diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch index 78268bfd..7f99d202 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch @@ -3,9 +3,9 @@ @@ -27,7 +_,7 @@ for(short short1 : p_132987_) { - this.f_132981_[j] = short1; -- this.f_132982_[j] = p_132988_.m_62982_(SectionPos.m_123204_(short1), SectionPos.m_123220_(short1), SectionPos.m_123227_(short1)); -+ this.f_132982_[j] = (p_132988_ != null) ? p_132988_.m_62982_(SectionPos.m_123204_(short1), SectionPos.m_123220_(short1), SectionPos.m_123227_(short1)) : net.minecraft.world.level.block.Blocks.f_50016_.m_49966_(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified + this.positions[j] = short1; +- this.states[j] = p_132988_.getBlockState(SectionPos.sectionRelativeX(short1), SectionPos.sectionRelativeY(short1), SectionPos.sectionRelativeZ(short1)); ++ this.states[j] = (p_132988_ != null) ? p_132988_.getBlockState(SectionPos.sectionRelativeX(short1), SectionPos.sectionRelativeY(short1), SectionPos.sectionRelativeZ(short1)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified ++j; } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch index 77c554ed..edd109b3 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java @@ -9,8 +_,10 @@ - private final double f_179212_; + private final double newCenterZ; public ClientboundSetBorderCenterPacket(WorldBorder p_179214_) { -- this.f_179211_ = p_179214_.m_6347_(); -- this.f_179212_ = p_179214_.m_6345_(); +- this.newCenterX = p_179214_.getCenterX(); +- this.newCenterZ = p_179214_.getCenterZ(); + // CraftBukkit start - multiply out nether border -+ this.f_179211_ = p_179214_.m_6347_() * (p_179214_.world != null ? p_179214_.world.m_6042_().m_63959_() : 1.0); -+ this.f_179212_ = p_179214_.m_6345_() * (p_179214_.world != null ? p_179214_.world.m_6042_().m_63959_() : 1.0); ++ this.newCenterX = p_179214_.getCenterX() * (p_179214_.world != null ? p_179214_.world.dimensionType().coordinateScale() : 1.0); ++ this.newCenterZ = p_179214_.getCenterZ() * (p_179214_.world != null ? p_179214_.world.dimensionType().coordinateScale() : 1.0); + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundChatPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundChatPacket.java.patch index bf186001..a1306364 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundChatPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundChatPacket.java.patch @@ -4,23 +4,23 @@ } public ServerboundChatPacket(FriendlyByteBuf p_179545_) { -- this.f_133827_ = p_179545_.m_130136_(256); -+ this.f_133827_ = org.apache.commons.lang3.StringUtils.normalizeSpace(p_179545_.m_130136_(256)); // CraftBukkit - see PlayerConnection +- this.message = p_179545_.readUtf(256); ++ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(p_179545_.readUtf(256)); // CraftBukkit - see PlayerConnection } - public void m_5779_(FriendlyByteBuf p_133839_) { - p_133839_.m_130070_(this.f_133827_); + public void write(FriendlyByteBuf p_133839_) { + p_133839_.writeUtf(this.message); } + // Spigot Start -+ private static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.f_129750_)).build()); ++ private static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); + - public void m_5797_(ServerGamePacketListener p_133836_) { -+ if (!f_133827_.startsWith("/")) { -+ executors.submit(() -> p_133836_.m_7388_(ServerboundChatPacket.this)); + public void handle(ServerGamePacketListener p_133836_) { ++ if (!message.startsWith("/")) { ++ executors.submit(() -> p_133836_.handleChat(ServerboundChatPacket.this)); + return; + } + // Spigot End - p_133836_.m_7388_(this); + p_133836_.handleChat(this); } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch index 68d3944f..fb7a7cfa 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java @@ -49,7 +_,7 @@ - p_133961_.writeByte(this.f_133941_); - p_133961_.m_130068_(this.f_133944_); - p_133961_.m_178355_(this.f_179569_, FriendlyByteBuf::writeShort, FriendlyByteBuf::m_130055_); -- p_133961_.m_130055_(this.f_179568_); -+ p_133961_.writeItemStack(this.f_179568_, false); //Forge: Include full tag for C->S + p_133961_.writeByte(this.buttonNum); + p_133961_.writeEnum(this.clickType); + p_133961_.writeMap(this.changedSlots, FriendlyByteBuf::writeShort, FriendlyByteBuf::writeItem); +- p_133961_.writeItem(this.carriedItem); ++ p_133961_.writeItemStack(this.carriedItem, false); //Forge: Include full tag for C->S } - public void m_5797_(ServerGamePacketListener p_133958_) { + public void handle(ServerGamePacketListener p_133958_) { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch index 17d6978d..07ffb9d6 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch @@ -6,15 +6,15 @@ -public class ServerboundCustomPayloadPacket implements Packet { +public class ServerboundCustomPayloadPacket implements Packet, net.minecraftforge.network.ICustomPacket { - private static final int f_179586_ = 32767; - public static final ResourceLocation f_133979_ = new ResourceLocation("brand"); - public final ResourceLocation f_133980_; + private static final int MAX_PAYLOAD_SIZE = 32767; + public static final ResourceLocation BRAND = new ResourceLocation("brand"); + public final ResourceLocation identifier; @@ -28,7 +_,7 @@ - public void m_5779_(FriendlyByteBuf p_133994_) { - p_133994_.m_130085_(this.f_133980_); -- p_133994_.writeBytes((ByteBuf)this.f_133981_); -+ p_133994_.writeBytes((ByteBuf)this.f_133981_.copy()); //This may be access multiple times, from multiple threads, lets be safe like the S->C packet + public void write(FriendlyByteBuf p_133994_) { + p_133994_.writeResourceLocation(this.identifier); +- p_133994_.writeBytes((ByteBuf)this.data); ++ p_133994_.writeBytes((ByteBuf)this.data.copy()); //This may be access multiple times, from multiple threads, lets be safe like the S->C packet } - public void m_5797_(ServerGamePacketListener p_133992_) { + public void handle(ServerGamePacketListener p_133992_) { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch index 2c33635a..e43ba89d 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java @@ -24,7 +_,7 @@ - public void m_5779_(FriendlyByteBuf p_134563_) { - p_134563_.writeShort(this.f_134549_); -- p_134563_.m_130055_(this.f_134550_); -+ p_134563_.writeItemStack(this.f_134550_, false); //Forge: Include full tag for C->S + public void write(FriendlyByteBuf p_134563_) { + p_134563_.writeShort(this.slotNum); +- p_134563_.writeItem(this.itemStack); ++ p_134563_.writeItemStack(this.itemStack, false); //Forge: Include full tag for C->S } - public int m_134561_() { + public int getSlotNum() { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch index d924c326..c5469e4c 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch @@ -2,17 +2,17 @@ +++ b/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java @@ -8,6 +_,7 @@ public class ServerboundUseItemOnPacket implements Packet { - private final BlockHitResult f_134691_; - private final InteractionHand f_134692_; + private final BlockHitResult blockHit; + private final InteractionHand hand; + public long timestamp; // Spigot public ServerboundUseItemOnPacket(InteractionHand p_134695_, BlockHitResult p_134696_) { - this.f_134692_ = p_134695_; + this.hand = p_134695_; @@ -15,6 +_,7 @@ } public ServerboundUseItemOnPacket(FriendlyByteBuf p_179796_) { + this.timestamp = System.currentTimeMillis(); // Spigot - this.f_134692_ = p_179796_.m_130066_(InteractionHand.class); - this.f_134691_ = p_179796_.m_130283_(); + this.hand = p_179796_.readEnum(InteractionHand.class); + this.blockHit = p_179796_.readBlockHitResult(); } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch index c7d6de5a..2c9dfde6 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch @@ -3,15 +3,15 @@ @@ -6,12 +_,14 @@ public class ServerboundUseItemPacket implements Packet { - private final InteractionHand f_134707_; + private final InteractionHand hand; + public long timestamp; // Spigot public ServerboundUseItemPacket(InteractionHand p_134710_) { - this.f_134707_ = p_134710_; + this.hand = p_134710_; } public ServerboundUseItemPacket(FriendlyByteBuf p_179798_) { + this.timestamp = System.currentTimeMillis(); // Spigot - this.f_134707_ = p_179798_.m_130066_(InteractionHand.class); + this.hand = p_179798_.readEnum(InteractionHand.class); } diff --git a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch index daae167f..d337ff43 100644 --- a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java +++ b/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java @@ -11,6 +_,10 @@ - public String f_134721_; - public final int f_134722_; - private final ConnectionProtocol f_134723_; + public String hostName; + public final int port; + private final ConnectionProtocol intention; + private String fmlVersion = net.minecraftforge.network.NetworkConstants.NETVERSION; + + private static final String EXTRA_DATA = "extraData"; + private static final com.google.gson.Gson GSON = new com.google.gson.GsonBuilder().registerTypeAdapter(com.mojang.authlib.properties.PropertyMap.class, new com.mojang.authlib.properties.PropertyMap.Serializer()).create(); public ClientIntentionPacket(String p_134726_, int p_134727_, ConnectionProtocol p_134728_) { - this.f_134720_ = SharedConstants.m_183709_().getProtocolVersion(); + this.protocolVersion = SharedConstants.getCurrentVersion().getProtocolVersion(); @@ -21,14 +_,36 @@ public ClientIntentionPacket(FriendlyByteBuf p_179801_) { - this.f_134720_ = p_179801_.m_130242_(); -- this.f_134721_ = p_179801_.m_130136_(255); -+ this.f_134721_ = p_179801_.m_130136_(Short.MAX_VALUE); // Spigot / Magma removed own init as var - this.f_134722_ = p_179801_.readUnsignedShort(); - this.f_134723_ = ConnectionProtocol.m_129583_(p_179801_.m_130242_()); -+ this.fmlVersion = net.minecraftforge.network.NetworkHooks.getFMLVersion(f_134721_); + this.protocolVersion = p_179801_.readVarInt(); +- this.hostName = p_179801_.readUtf(255); ++ this.hostName = p_179801_.readUtf(Short.MAX_VALUE); // Spigot / Magma removed own init as var + this.port = p_179801_.readUnsignedShort(); + this.intention = ConnectionProtocol.getById(p_179801_.readVarInt()); ++ this.fmlVersion = net.minecraftforge.network.NetworkHooks.getFMLVersion(hostName); + //this.hostName = hostName.split("\0")[0]; // Magma moved to [ServerHandshakePacketListenerImpl.java#L93] + //Magma start - add Velocity support + if (org.spigotmc.SpigotConfig.bungee && !java.util.Objects.equals(this.fmlVersion, net.minecraftforge.network.NetworkConstants.NETVERSION)) { -+ String[] split = this.f_134721_.split("\0"); ++ String[] split = this.hostName.split("\0"); + if (split.length == 4) { + com.mojang.authlib.properties.PropertyMap properties = GSON.fromJson(split[3], com.mojang.authlib.properties.PropertyMap.class); + for (java.util.Map.Entry property : properties.entries()) { @@ -43,17 +43,17 @@ + //Magma end } - public void m_5779_(FriendlyByteBuf p_134737_) { - p_134737_.m_130130_(this.f_134720_); -- p_134737_.m_130070_(this.f_134721_); -+ p_134737_.m_130070_(this.f_134721_ + "\0"+ net.minecraftforge.network.NetworkConstants.NETVERSION+"\0"); - p_134737_.writeShort(this.f_134722_); - p_134737_.m_130130_(this.f_134723_.m_129582_()); + public void write(FriendlyByteBuf p_134737_) { + p_134737_.writeVarInt(this.protocolVersion); +- p_134737_.writeUtf(this.hostName); ++ p_134737_.writeUtf(this.hostName + "\0"+ net.minecraftforge.network.NetworkConstants.NETVERSION+"\0"); + p_134737_.writeShort(this.port); + p_134737_.writeVarInt(this.intention.getId()); } @@ -51,5 +_,9 @@ - public int m_179803_() { - return this.f_134722_; + public int getPort() { + return this.port; + } + + public String getFMLVersion() { diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch index 1cfbdc6e..ae09fc73 100644 --- a/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -6,6 +6,6 @@ -public class ClientboundCustomQueryPacket implements Packet { +public class ClientboundCustomQueryPacket implements Packet, net.minecraftforge.network.ICustomPacket { - private static final int f_179804_ = 1048576; - private final int f_134745_; - private final ResourceLocation f_134746_; + private static final int MAX_PAYLOAD_SIZE = 1048576; + private final int transactionId; + private final ResourceLocation identifier; diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch index f52d6c54..cb6d86e9 100644 --- a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch @@ -7,6 +7,6 @@ -public class ServerboundCustomQueryPacket implements Packet { +public class ServerboundCustomQueryPacket implements Packet, net.minecraftforge.network.ICustomPacket +{ - private static final int f_179821_ = 1048576; - private final int f_134825_; + private static final int MAX_PAYLOAD_SIZE = 1048576; + private final int transactionId; @Nullable diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch index 60741335..30820d24 100644 --- a/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java.patch @@ -3,9 +3,9 @@ @@ -22,7 +_,7 @@ } - public void m_5779_(FriendlyByteBuf p_134899_) { -- p_134899_.m_130070_(f_134885_.toJson(this.f_134886_)); -+ p_134899_.m_130070_(this.f_134886_.getJson()); //Forge: Let the response cache the JSON + public void write(FriendlyByteBuf p_134899_) { +- p_134899_.writeUtf(GSON.toJson(this.status)); ++ p_134899_.writeUtf(this.status.getJson()); //Forge: Let the response cache the JSON } - public void m_5797_(ClientStatusPacketListener p_134896_) { + public void handle(ClientStatusPacketListener p_134896_) { diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch index 5d0b8bf0..766dac73 100644 --- a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/network/protocol/status/ServerStatus.java +++ b/net/minecraft/network/protocol/status/ServerStatus.java @@ -26,6 +_,16 @@ - private ServerStatus.Version f_134902_; + private ServerStatus.Version version; @Nullable - private String f_134903_; + private String favicon; + private transient net.minecraftforge.network.ServerStatusPing forgeData; + + public net.minecraftforge.network.ServerStatusPing getForgeData() { @@ -16,38 +16,38 @@ + } @Nullable - public Component m_134905_() { + public Component getDescription() { @@ -34,6 +_,7 @@ - public void m_134908_(Component p_134909_) { - this.f_134900_ = p_134909_; + public void setDescription(Component p_134909_) { + this.description = p_134909_; + invalidateJson(); } @Nullable @@ -43,6 +_,7 @@ - public void m_134910_(ServerStatus.Players p_134911_) { - this.f_134901_ = p_134911_; + public void setPlayers(ServerStatus.Players p_134911_) { + this.players = p_134911_; + invalidateJson(); } @Nullable @@ -52,10 +_,12 @@ - public void m_134912_(ServerStatus.Version p_134913_) { - this.f_134902_ = p_134913_; + public void setVersion(ServerStatus.Version p_134913_) { + this.version = p_134913_; + invalidateJson(); } - public void m_134906_(String p_134907_) { - this.f_134903_ = p_134907_; + public void setFavicon(String p_134907_) { + this.favicon = p_134907_; + invalidateJson(); } @Nullable @@ -63,6 +_,39 @@ - return this.f_134903_; + return this.favicon; } + private java.util.concurrent.Semaphore mutex = new java.util.concurrent.Semaphore(1); @@ -67,7 +67,7 @@ + mutex.acquireUninterruptibly(); + ret = this.json; + if (ret == null) { -+ ret = net.minecraft.network.protocol.status.ClientboundStatusResponsePacket.f_134885_.toJson(this); ++ ret = net.minecraft.network.protocol.status.ClientboundStatusResponsePacket.GSON.toJson(this); + this.json = ret; + } + mutex.release(); @@ -84,14 +84,14 @@ + } + public static class Players { - private final int f_134917_; - private final int f_134918_; + private final int maxPlayers; + private final int numPlayers; @@ -157,6 +_,10 @@ - serverstatus.m_134906_(GsonHelper.m_13906_(jsonobject, "favicon")); + serverstatus.setFavicon(GsonHelper.getAsString(jsonobject, "favicon")); } + if (jsonobject.has("forgeData")) { -+ serverstatus.setForgeData(net.minecraftforge.network.ServerStatusPing.Serializer.deserialize(GsonHelper.m_13930_(jsonobject, "forgeData"))); ++ serverstatus.setForgeData(net.minecraftforge.network.ServerStatusPing.Serializer.deserialize(GsonHelper.getAsJsonObject(jsonobject, "forgeData"))); + } + return serverstatus; @@ -99,8 +99,8 @@ @@ -176,6 +_,10 @@ - if (p_134951_.m_134916_() != null) { - jsonobject.addProperty("favicon", p_134951_.m_134916_()); + if (p_134951_.getFavicon() != null) { + jsonobject.addProperty("favicon", p_134951_.getFavicon()); + } + + if(p_134951_.getForgeData() != null){ diff --git a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch index eb1340bd..59a68218 100644 --- a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch +++ b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -3,20 +3,20 @@ @@ -301,16 +_,16 @@ }; - public static void m_135050_(EntityDataSerializer p_135051_) { -- f_135046_.m_13569_(p_135051_); -+ if (f_135046_.m_13569_(p_135051_) >= 256) throw new RuntimeException("Vanilla DataSerializer ID limit exceeded"); + public static void registerSerializer(EntityDataSerializer p_135051_) { +- SERIALIZERS.add(p_135051_); ++ if (SERIALIZERS.add(p_135051_) >= 256) throw new RuntimeException("Vanilla DataSerializer ID limit exceeded"); } @Nullable - public static EntityDataSerializer m_135048_(int p_135049_) { -- return f_135046_.m_7942_(p_135049_); -+ return net.minecraftforge.common.ForgeHooks.getSerializer(p_135049_, f_135046_); + public static EntityDataSerializer getSerializer(int p_135049_) { +- return SERIALIZERS.byId(p_135049_); ++ return net.minecraftforge.common.ForgeHooks.getSerializer(p_135049_, SERIALIZERS); } - public static int m_135052_(EntityDataSerializer p_135053_) { -- return f_135046_.m_7447_(p_135053_); -+ return net.minecraftforge.common.ForgeHooks.getSerializerId(p_135053_, f_135046_); + public static int getSerializedId(EntityDataSerializer p_135053_) { +- return SERIALIZERS.getId(p_135053_); ++ return net.minecraftforge.common.ForgeHooks.getSerializerId(p_135053_, SERIALIZERS); } private EntityDataSerializers() { diff --git a/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch index 517eb2bb..c163f2b1 100644 --- a/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -3,16 +3,16 @@ @@ -37,11 +_,13 @@ } - public static EntityDataAccessor m_135353_(Class p_135354_, EntityDataSerializer p_135355_) { -- if (f_135342_.isDebugEnabled()) { -+ if (true || f_135342_.isDebugEnabled()) { // Forge: This is very useful for mods that register keys on classes that are not their own + public static EntityDataAccessor defineId(Class p_135354_, EntityDataSerializer p_135355_) { +- if (LOGGER.isDebugEnabled()) { ++ if (true || LOGGER.isDebugEnabled()) { // Forge: This is very useful for mods that register keys on classes that are not their own try { Class oclass = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName()); if (!oclass.equals(p_135354_)) { -- f_135342_.debug("defineId called for: {} from {}", p_135354_, oclass, new RuntimeException()); +- LOGGER.debug("defineId called for: {} from {}", p_135354_, oclass, new RuntimeException()); + // Forge: log at warn, mods should not add to classes that they don't own, and only add stacktrace when in debug is enabled as it is mostly not needed and consumes time -+ if (f_135342_.isDebugEnabled()) f_135342_.warn("defineId called for: {} from {}", p_135354_, oclass, new RuntimeException()); -+ else f_135342_.warn("defineId called for: {} from {}", p_135354_, oclass); ++ if (LOGGER.isDebugEnabled()) LOGGER.warn("defineId called for: {} from {}", p_135354_, oclass, new RuntimeException()); ++ else LOGGER.warn("defineId called for: {} from {}", p_135354_, oclass); } } catch (ClassNotFoundException classnotfoundexception) { } @@ -23,10 +23,10 @@ + + // CraftBukkit start - add method from above + public void markDirty(EntityDataAccessor datawatcherobject) { -+ this.m_135379_(datawatcherobject).m_135401_(true); -+ this.f_135348_ = true; ++ this.getItem(datawatcherobject).setDirty(true); ++ this.isDirty = true; + } + // CraftBukkit end - public boolean m_135352_() { - return this.f_135348_; + public boolean isDirty() { + return this.isDirty; diff --git a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch index 193e21f3..51f7b931 100644 --- a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch +++ b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/recipebook/PlaceRecipe.java +++ b/net/minecraft/recipebook/PlaceRecipe.java @@ -9,10 +_,10 @@ - default void m_135408_(int p_135409_, int p_135410_, int p_135411_, Recipe p_135412_, Iterator p_135413_, int p_135414_) { + default void placeRecipe(int p_135409_, int p_135410_, int p_135411_, Recipe p_135412_, Iterator p_135413_, int p_135414_) { int i = p_135409_; int j = p_135410_; - if (p_135412_ instanceof ShapedRecipe) { - ShapedRecipe shapedrecipe = (ShapedRecipe)p_135412_; -- i = shapedrecipe.m_44220_(); -- j = shapedrecipe.m_44221_(); +- i = shapedrecipe.getWidth(); +- j = shapedrecipe.getHeight(); + if (p_135412_ instanceof net.minecraftforge.common.crafting.IShapedRecipe) { + net.minecraftforge.common.crafting.IShapedRecipe shapedrecipe = (net.minecraftforge.common.crafting.IShapedRecipe)p_135412_; + i = shapedrecipe.getRecipeWidth(); diff --git a/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch b/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch index 579f94e8..102694d0 100644 --- a/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch +++ b/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch @@ -4,25 +4,25 @@ try { JsonElement jsonelement = JsonParser.parseReader(reader); -+ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_195895_.m_135782_().toString()); - optional = Optional.of(p_195896_.parse(p_195893_, jsonelement).map(RegistryResourceAccess.ParsedEntry::m_195956_)); ++ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_195895_.location().toString()); + optional = Optional.of(p_195896_.parse(p_195893_, jsonelement).map(RegistryResourceAccess.ParsedEntry::createWithoutId)); } catch (Throwable throwable2) { try { @@ -102,6 +_,8 @@ } - private static String m_195909_(ResourceKey> p_195910_) { -+ if (net.minecraftforge.registries.RegistryManager.FROZEN.getRegistry(p_195910_.m_135782_()) != null && !(p_195910_.m_135782_().m_135827_().equals("minecraft"))) -+ return p_195910_.m_135782_().m_135827_() + "/" + p_195910_.m_135782_().m_135815_(); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey)) - return p_195910_.m_135782_().m_135815_(); + private static String registryDirPath(ResourceKey> p_195910_) { ++ if (net.minecraftforge.registries.RegistryManager.FROZEN.getRegistry(p_195910_.location()) != null && !(p_195910_.location().getNamespace().equals("minecraft"))) ++ return p_195910_.location().getNamespace() + "/" + p_195910_.location().getPath(); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey)) + return p_195910_.location().getPath(); } @@ -138,6 +_,8 @@ - public Optional>> m_183313_(DynamicOps p_195917_, ResourceKey> p_195918_, ResourceKey p_195919_, Decoder p_195920_) { - RegistryResourceAccess.InMemoryStorage.Entry registryresourceaccess$inmemorystorage$entry = this.f_195913_.get(p_195919_); -+ if (registryresourceaccess$inmemorystorage$entry != null && registryresourceaccess$inmemorystorage$entry.f_195936_ != null && registryresourceaccess$inmemorystorage$entry.f_195936_.isJsonObject()) -+ registryresourceaccess$inmemorystorage$entry.f_195936_.getAsJsonObject().addProperty("forge:registry_name", p_195919_.m_135782_().toString()); - return registryresourceaccess$inmemorystorage$entry == null ? Optional.of(DataResult.error("Unknown element: " + p_195919_)) : Optional.of(p_195920_.parse(p_195917_, registryresourceaccess$inmemorystorage$entry.f_195936_).setLifecycle(registryresourceaccess$inmemorystorage$entry.f_195938_).map((p_195930_) -> { - return RegistryResourceAccess.ParsedEntry.m_195958_(p_195930_, registryresourceaccess$inmemorystorage$entry.f_195937_); + public Optional>> parseElement(DynamicOps p_195917_, ResourceKey> p_195918_, ResourceKey p_195919_, Decoder p_195920_) { + RegistryResourceAccess.InMemoryStorage.Entry registryresourceaccess$inmemorystorage$entry = this.entries.get(p_195919_); ++ if (registryresourceaccess$inmemorystorage$entry != null && registryresourceaccess$inmemorystorage$entry.data != null && registryresourceaccess$inmemorystorage$entry.data.isJsonObject()) ++ registryresourceaccess$inmemorystorage$entry.data.getAsJsonObject().addProperty("forge:registry_name", p_195919_.location().toString()); + return registryresourceaccess$inmemorystorage$entry == null ? Optional.of(DataResult.error("Unknown element: " + p_195919_)) : Optional.of(p_195920_.parse(p_195917_, registryresourceaccess$inmemorystorage$entry.data).setLifecycle(registryresourceaccess$inmemorystorage$entry.lifecycle).map((p_195930_) -> { + return RegistryResourceAccess.ParsedEntry.createWithId(p_195930_, registryresourceaccess$inmemorystorage$entry.id); })); diff --git a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch index 126626bb..5d60a349 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch @@ -5,42 +5,42 @@ import net.minecraft.core.Registry; -public class ResourceKey { -- private static final Map> f_135775_ = Collections.synchronizedMap(Maps.newIdentityHashMap()); +- private static final Map> VALUES = Collections.synchronizedMap(Maps.newIdentityHashMap()); +public class ResourceKey implements Comparable> { -+ private static final Map> f_135775_ = Collections.synchronizedMap(Maps.newHashMap()); // CraftBukkit - SPIGOT-6973: remove costly intern - private final ResourceLocation f_135776_; - private final ResourceLocation f_135777_; ++ private static final Map> VALUES = Collections.synchronizedMap(Maps.newHashMap()); // CraftBukkit - SPIGOT-6973: remove costly intern + private final ResourceLocation registryName; + private final ResourceLocation location; @@ -28,7 +_,7 @@ } - private static ResourceKey m_135790_(ResourceLocation p_135791_, ResourceLocation p_135792_) { + private static ResourceKey create(ResourceLocation p_135791_, ResourceLocation p_135792_) { - String s = (p_135791_ + ":" + p_135792_).intern(); + String s = (p_135791_ + ":" + p_135792_); // CraftBukkit - SPIGOT-6973: remove costly intern - return (ResourceKey)f_135775_.computeIfAbsent(s, (p_195971_) -> { + return (ResourceKey)VALUES.computeIfAbsent(s, (p_195971_) -> { return new ResourceKey(p_135791_, p_135792_); }); @@ -63,5 +_,23 @@ return (p_195974_) -> { - return m_135785_(p_135798_, p_195974_); + return create(p_135798_, p_195974_); }; + } + + public ResourceLocation getRegistryName() { -+ return this.f_135776_; ++ return this.registryName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; -+ return f_135776_.equals(((ResourceKey) o).f_135776_) && f_135777_.equals(((ResourceKey) o).f_135777_); ++ return registryName.equals(((ResourceKey) o).registryName) && location.equals(((ResourceKey) o).location); + } + + @Override + public int compareTo(ResourceKey o) { + int ret = this.getRegistryName().compareTo(o.getRegistryName()); -+ if (ret == 0) ret = this.m_135782_().compareTo(o.m_135782_()); ++ if (ret == 0) ret = this.location().compareTo(o.location()); + return ret; } } diff --git a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch index ec4f2c2e..92e8ab7b 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch @@ -6,19 +6,19 @@ + // Normal compare sorts by path first, this compares namespace first. + public int compareNamespaced(ResourceLocation o) { -+ int ret = this.f_135804_.compareTo(o.f_135804_); -+ return ret != 0 ? ret : this.f_135805_.compareTo(o.f_135805_); ++ int ret = this.namespace.compareTo(o.namespace); ++ return ret != 0 ? ret : this.path.compareTo(o.path); + } + - public String m_179910_() { + public String toDebugFileName() { return this.toString().replace('/', '_').replace(':', '_'); } @@ -141,7 +_,7 @@ return p_135817_ >= '0' && p_135817_ <= '9' || p_135817_ >= 'a' && p_135817_ <= 'z' || p_135817_ == '_' || p_135817_ == ':' || p_135817_ == '/' || p_135817_ == '.' || p_135817_ == '-'; } -- private static boolean m_135841_(String p_135842_) { -+ public static boolean m_135841_(String p_135842_) { // Magma - private -> public +- private static boolean isValidPath(String p_135842_) { ++ public static boolean isValidPath(String p_135842_) { // Magma - private -> public for(int i = 0; i < p_135842_.length(); ++i) { - if (!m_135828_(p_135842_.charAt(i))) { + if (!validPathChar(p_135842_.charAt(i))) { return false; diff --git a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch index 78168a04..11235e83 100644 --- a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch +++ b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java @@ -55,6 +_,8 @@ - CauldronInteraction.m_175649_(); - ArgumentTypes.m_121586_(); - Registry.m_206101_(); + CauldronInteraction.bootStrap(); + ArgumentTypes.bootStrap(); + Registry.freezeBuiltins(); + net.minecraftforge.registries.GameData.vanillaSnapshot(); + if (false) // skip redirectOutputToLog, Forge already redirects stdout and stderr output to log so that they print with more context - m_135890_(); + wrapStreams(); } } @@ -128,7 +_,6 @@ - m_197757_(); + validateThatAllBiomeFeaturesHaveBiomeFilter(); } -- DefaultAttributes.m_22296_(); +- DefaultAttributes.validate(); } - private static void m_197757_() { + private static void validateThatAllBiomeFeaturesHaveBiomeFilter() { diff --git a/patches/minecraft/net/minecraft/server/Eula.java.patch b/patches/minecraft/net/minecraft/server/Eula.java.patch index f6c6662d..0b794be0 100644 --- a/patches/minecraft/net/minecraft/server/Eula.java.patch +++ b/patches/minecraft/net/minecraft/server/Eula.java.patch @@ -3,9 +3,9 @@ @@ -16,7 +_,7 @@ public Eula(Path p_135943_) { - this.f_135939_ = p_135943_; -- this.f_135940_ = SharedConstants.f_136183_ || this.m_135945_(); -+ this.f_135940_ = SharedConstants.f_136183_ || net.minecraftforge.gametest.ForgeGameTestHooks.isGametestServer() || this.m_135945_(); // Forge: Automatically agree to EULA for gametest servers to aid CI + this.file = p_135943_; +- this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readFile(); ++ this.agreed = SharedConstants.IS_RUNNING_IN_IDE || net.minecraftforge.gametest.ForgeGameTestHooks.isGametestServer() || this.readFile(); // Forge: Automatically agree to EULA for gametest servers to aid CI } - private boolean m_135945_() { + private boolean readFile() { diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index 26ee9af2..bef5331f 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -4,11 +4,11 @@ import org.slf4j.Logger; public class Main { -- private static final Logger f_129670_ = LogUtils.getLogger(); +- private static final Logger LOGGER = LogUtils.getLogger(); - - @DontObfuscate - public static void main(String[] p_129699_) { -- SharedConstants.m_142977_(); +- SharedConstants.tryDetectVersion(); - OptionParser optionparser = new OptionParser(); - OptionSpec optionspec = optionparser.accepts("nogui"); - OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); @@ -33,26 +33,26 @@ - return; - } - -- CrashReport.m_127529_(); +- CrashReport.preload(); - if (optionset.has(optionspec13)) { -- JvmProfiler.f_185340_.m_183425_(Environment.SERVER); +- JvmProfiler.INSTANCE.start(Environment.SERVER); - } - -- Bootstrap.m_135870_(); -- Bootstrap.m_135889_(); -- Util.m_137584_(); +- Bootstrap.bootStrap(); +- Bootstrap.validate(); +- Util.startTimerHackThread(); - Path path = Paths.get("server.properties"); - DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); -- dedicatedserversettings.m_139780_(); +- dedicatedserversettings.forceSave(); - Path path1 = Paths.get("eula.txt"); - Eula eula = new Eula(path1); - if (optionset.has(optionspec1)) { -- f_129670_.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); +- LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); - return; - } - -- if (!eula.m_135944_()) { -- f_129670_.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); +- if (!eula.hasAgreedToEULA()) { +- LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); - return; - } - @@ -60,93 +60,93 @@ - YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY); - MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); - GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); -- GameProfileCache gameprofilecache = new GameProfileCache(gameprofilerepository, new File(file1, MinecraftServer.f_129742_.getName())); -- String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.m_139777_().f_139741_); -- LevelStorageSource levelstoragesource = LevelStorageSource.m_78242_(file1.toPath()); -- LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.m_78260_(s); -- LevelSummary levelsummary = levelstoragesource$levelstorageaccess.m_78308_(); +- GameProfileCache gameprofilecache = new GameProfileCache(gameprofilerepository, new File(file1, MinecraftServer.USERID_CACHE_FILE.getName())); +- String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); +- LevelStorageSource levelstoragesource = LevelStorageSource.createDefault(file1.toPath()); +- LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.createAccess(s); +- LevelSummary levelsummary = levelstoragesource$levelstorageaccess.getSummary(); - if (levelsummary != null) { -- if (levelsummary.m_193020_()) { -- f_129670_.info("This world must be opened in an older version (like 1.6.4) to be safely converted"); +- if (levelsummary.requiresManualConversion()) { +- LOGGER.info("This world must be opened in an older version (like 1.6.4) to be safely converted"); - return; - } - -- if (!levelsummary.m_193021_()) { -- f_129670_.info("This world was created by an incompatible version."); +- if (!levelsummary.isCompatible()) { +- LOGGER.info("This world was created by an incompatible version."); - return; - } - } - - boolean flag = optionset.has(optionspec6); - if (flag) { -- f_129670_.warn("Safe mode active, only vanilla datapack will be loaded"); +- LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); - } - -- PackRepository packrepository = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(levelstoragesource$levelstorageaccess.m_78283_(LevelResource.f_78180_).toFile(), PackSource.f_10529_)); +- PackRepository packrepository = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(levelstoragesource$levelstorageaccess.getLevelPath(LevelResource.DATAPACK_DIR).toFile(), PackSource.WORLD)); - - WorldStem worldstem; - try { -- WorldStem.InitConfig worldstem$initconfig = new WorldStem.InitConfig(packrepository, Commands.CommandSelection.DEDICATED, dedicatedserversettings.m_139777_().f_139711_, flag); -- worldstem = WorldStem.m_206911_(worldstem$initconfig, () -> { -- DataPackConfig datapackconfig = levelstoragesource$levelstorageaccess.m_78309_(); -- return datapackconfig == null ? DataPackConfig.f_45842_ : datapackconfig; +- WorldStem.InitConfig worldstem$initconfig = new WorldStem.InitConfig(packrepository, Commands.CommandSelection.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, flag); +- worldstem = WorldStem.load(worldstem$initconfig, () -> { +- DataPackConfig datapackconfig = levelstoragesource$levelstorageaccess.getDataPacks(); +- return datapackconfig == null ? DataPackConfig.DEFAULT : datapackconfig; - }, (p_206543_, p_206544_) -> { -- RegistryAccess.Writable registryaccess$writable = RegistryAccess.m_206197_(); -- DynamicOps dynamicops = RegistryOps.m_206813_(NbtOps.f_128958_, registryaccess$writable, p_206543_); -- WorldData worlddata1 = levelstoragesource$levelstorageaccess.m_211747_(dynamicops, p_206544_, registryaccess$writable.m_211816_()); +- RegistryAccess.Writable registryaccess$writable = RegistryAccess.builtinCopy(); +- DynamicOps dynamicops = RegistryOps.createAndLoad(NbtOps.INSTANCE, registryaccess$writable, p_206543_); +- WorldData worlddata1 = levelstoragesource$levelstorageaccess.getDataTag(dynamicops, p_206544_, registryaccess$writable.allElementsLifecycle()); - if (worlddata1 != null) { -- return Pair.of(worlddata1, registryaccess$writable.m_203557_()); +- return Pair.of(worlddata1, registryaccess$writable.freeze()); - } else { - LevelSettings levelsettings; - WorldGenSettings worldgensettings; - if (optionset.has(optionspec2)) { -- levelsettings = MinecraftServer.f_129743_; -- worldgensettings = WorldGenSettings.m_64645_(registryaccess$writable); +- levelsettings = MinecraftServer.DEMO_SETTINGS; +- worldgensettings = WorldGenSettings.demoSettings(registryaccess$writable); - } else { -- DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.m_139777_(); -- levelsettings = new LevelSettings(dedicatedserverproperties.f_139741_, dedicatedserverproperties.f_139740_, dedicatedserverproperties.f_139752_, dedicatedserverproperties.f_139739_, false, new GameRules(), p_206544_); -- worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.m_180927_(registryaccess$writable).m_64671_() : dedicatedserverproperties.m_180927_(registryaccess$writable); +- DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); +- levelsettings = new LevelSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), p_206544_); +- worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.getWorldGenSettings(registryaccess$writable).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(registryaccess$writable); - } - - PrimaryLevelData primaryleveldata = new PrimaryLevelData(levelsettings, worldgensettings, Lifecycle.stable()); -- return Pair.of(primaryleveldata, registryaccess$writable.m_203557_()); +- return Pair.of(primaryleveldata, registryaccess$writable.freeze()); - } -- }, Util.m_183991_(), Runnable::run).get(); +- }, Util.backgroundExecutor(), Runnable::run).get(); - } catch (Exception exception) { -- f_129670_.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", (Throwable)exception); +- LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", (Throwable)exception); - packrepository.close(); - return; - } - -- worldstem.m_206901_(); -- RegistryAccess.Frozen registryaccess$frozen = worldstem.f_206894_(); -- dedicatedserversettings.m_139777_().m_180927_(registryaccess$frozen); -- WorldData worlddata = worldstem.f_206895_(); +- worldstem.updateGlobals(); +- RegistryAccess.Frozen registryaccess$frozen = worldstem.registryAccess(); +- dedicatedserversettings.getProperties().getWorldGenSettings(registryaccess$frozen); +- WorldData worlddata = worldstem.worldData(); - if (optionset.has(optionspec4)) { -- m_195488_(levelstoragesource$levelstorageaccess, DataFixers.m_14512_(), optionset.has(optionspec5), () -> { +- forceUpgrade(levelstoragesource$levelstorageaccess, DataFixers.getDataFixer(), optionset.has(optionspec5), () -> { - return true; -- }, worlddata.m_5961_()); +- }, worlddata.worldGenSettings()); - } - -- levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); -- final DedicatedServer dedicatedserver = MinecraftServer.m_129872_((p_206536_) -> { -- DedicatedServer dedicatedserver1 = new DedicatedServer(p_206536_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.m_14512_(), minecraftsessionservice, gameprofilerepository, gameprofilecache, LoggerChunkProgressListener::new); -- dedicatedserver1.m_129981_(optionset.valueOf(optionspec8)); -- dedicatedserver1.m_129801_(optionset.valueOf(optionspec11)); -- dedicatedserver1.m_129975_(optionset.has(optionspec2)); -- dedicatedserver1.m_129948_(optionset.valueOf(optionspec12)); +- levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); +- final DedicatedServer dedicatedserver = MinecraftServer.spin((p_206536_) -> { +- DedicatedServer dedicatedserver1 = new DedicatedServer(p_206536_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), minecraftsessionservice, gameprofilerepository, gameprofilecache, LoggerChunkProgressListener::new); +- dedicatedserver1.setSingleplayerName(optionset.valueOf(optionspec8)); +- dedicatedserver1.setPort(optionset.valueOf(optionspec11)); +- dedicatedserver1.setDemo(optionset.has(optionspec2)); +- dedicatedserver1.setId(optionset.valueOf(optionspec12)); - boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec14).contains("nogui"); - if (flag1 && !GraphicsEnvironment.isHeadless()) { -- dedicatedserver1.m_139667_(); +- dedicatedserver1.showGui(); - } - - return dedicatedserver1; - }); -+ private static final Logger f_129670_ = LogUtils.getLogger(); ++ private static final Logger LOGGER = LogUtils.getLogger(); + + @DontObfuscate + public static void main(String[] p_129699_) { -+ SharedConstants.m_142977_(); ++ SharedConstants.tryDetectVersion(); + OptionParser optionparser = new OptionParser(); + OptionSpec optionspec = optionparser.accepts("nogui"); + OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); @@ -221,41 +221,41 @@ + System.err.println( "If you do not agree to the above EULA please stop your server and remove this flag immediately." ); + } + // Spigot End -+ if (!eula.m_135944_() && !eulaAgreed) { // Spigot -+ f_129670_.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); ++ if (!eula.hasAgreedToEULA() && !eulaAgreed) { // Spigot ++ LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); + return; + } + -+ CrashReport.m_127529_(); ++ CrashReport.preload(); + if (optionset.has(optionspec13)) { -+ JvmProfiler.f_185340_.m_183425_(Environment.SERVER); ++ JvmProfiler.INSTANCE.start(Environment.SERVER); + } + + //Magma start - Boot Inject Protection + org.magmafoundation.magma.protect.InjectProtect.init(); + + try { -+ Bootstrap.m_135870_(); ++ Bootstrap.bootStrap(); + } catch (org.spongepowered.asm.mixin.throwables.MixinError e) { + org.magmafoundation.magma.protect.InjectProtect.onBootErrorCaught(e); + } + //Magma end + -+ Bootstrap.m_135889_(); -+ Util.m_137584_(); ++ Bootstrap.validate(); ++ Util.startTimerHackThread(); + if (!optionset.has(optionspec1)) + net.minecraftforge.server.loading.ServerModLoader.load(); // Load mods before we load almost anything else anymore. Single spot now. Only loads if they haven't passed the initserver param + //TODO-PATCHING: Figure out how to handle the delayed initialization. + Path path = Paths.get("server.properties"); + DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); -+ dedicatedserversettings.m_139780_(); ++ dedicatedserversettings.forceSave(); + // Paper start - load config files for access below if needed + org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = loadConfigFile((File) optionset.valueOf("bukkit-settings")); + org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = loadConfigFile((File) optionset.valueOf("spigot-settings")); + org.bukkit.configuration.file.YamlConfiguration paperConfiguration = loadConfigFile((File) optionset.valueOf("paper-settings")); + // Paper end + if (optionset.has(optionspec1)) { -+ f_129670_.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); ++ LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); + return; + } + @@ -263,39 +263,39 @@ + YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY); + MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); + GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); -+ GameProfileCache gameprofilecache = new GameProfileCache(gameprofilerepository, new File(file1, MinecraftServer.f_129742_.getName())); -+ String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.m_139777_().f_139741_); ++ GameProfileCache gameprofilecache = new GameProfileCache(gameprofilerepository, new File(file1, MinecraftServer.USERID_CACHE_FILE.getName())); ++ String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); + if (s == null || s.isEmpty() || new File(file1, s).getAbsolutePath().equals(new File(s).getAbsolutePath())) { -+ f_129670_.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s); ++ LOGGER.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s); + return; + } -+ LevelStorageSource levelstoragesource = LevelStorageSource.m_78242_(file1.toPath()); -+ LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.m_78260_(s); ++ LevelStorageSource levelstoragesource = LevelStorageSource.createDefault(file1.toPath()); ++ LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.createAccess(s); + levelstoragesource$levelstorageaccess.readAdditionalLevelSaveData(); -+ LevelSummary levelsummary = levelstoragesource$levelstorageaccess.m_78308_(); ++ LevelSummary levelsummary = levelstoragesource$levelstorageaccess.getSummary(); + if (levelsummary != null) { -+ if (levelsummary.m_193020_()) { -+ f_129670_.info("This world must be opened in an older version (like 1.6.4) to be safely converted"); ++ if (levelsummary.requiresManualConversion()) { ++ LOGGER.info("This world must be opened in an older version (like 1.6.4) to be safely converted"); + return; + } + -+ if (!levelsummary.m_193021_()) { -+ f_129670_.info("This world was created by an incompatible version."); ++ if (!levelsummary.isCompatible()) { ++ LOGGER.info("This world was created by an incompatible version."); + return; + } + } + + boolean flag = optionset.has(optionspec6); + if (flag) { -+ f_129670_.warn("Safe mode active, only vanilla datapack will be loaded"); ++ LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); + } + -+ DataPackConfig datapackconfig = levelstoragesource$levelstorageaccess.m_78309_(); ++ DataPackConfig datapackconfig = levelstoragesource$levelstorageaccess.getDataPacks(); + -+ PackRepository packrepository = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(levelstoragesource$levelstorageaccess.m_78283_(LevelResource.f_78180_).toFile(), PackSource.f_10529_)); ++ PackRepository packrepository = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(levelstoragesource$levelstorageaccess.getLevelPath(LevelResource.DATAPACK_DIR).toFile(), PackSource.WORLD)); + + // CraftBukkit start -+ File bukkitDataPackFolder = new File(levelstoragesource$levelstorageaccess.m_78283_(LevelResource.f_78180_).toFile(), "bukkit"); ++ File bukkitDataPackFolder = new File(levelstoragesource$levelstorageaccess.getLevelPath(LevelResource.DATAPACK_DIR).toFile(), "bukkit"); + if (!bukkitDataPackFolder.exists()) { + bukkitDataPackFolder.mkdirs(); + } @@ -304,7 +304,7 @@ + com.google.common.io.Files.write("{\n" + + " \"pack\": {\n" + + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.m_183709_().getPackVersion() + "\n" ++ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion() + "\n" + + " }\n" + + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); + } catch (java.io.IOException ex) { @@ -314,72 +314,72 @@ + java.util.concurrent.atomic.AtomicReference> ops = new java.util.concurrent.atomic.AtomicReference<>(); + // CraftBukkit end + -+ DataPackConfig datapackconfig1 = MinecraftServer.m_129819_(packrepository, datapackconfig == null ? DataPackConfig.f_45842_ : datapackconfig, flag); ++ DataPackConfig datapackconfig1 = MinecraftServer.configurePackRepository(packrepository, datapackconfig == null ? DataPackConfig.DEFAULT : datapackconfig, flag); + + WorldStem worldstem; + try { -+ WorldStem.InitConfig worldstem$initconfig = new WorldStem.InitConfig(packrepository, Commands.CommandSelection.DEDICATED, dedicatedserversettings.m_139777_().f_139711_, flag); -+ worldstem = WorldStem.m_206911_(worldstem$initconfig, () -> { -+ DataPackConfig datapackconfigd = levelstoragesource$levelstorageaccess.m_78309_(); -+ return datapackconfigd == null ? DataPackConfig.f_45842_ : datapackconfigd; ++ WorldStem.InitConfig worldstem$initconfig = new WorldStem.InitConfig(packrepository, Commands.CommandSelection.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, flag); ++ worldstem = WorldStem.load(worldstem$initconfig, () -> { ++ DataPackConfig datapackconfigd = levelstoragesource$levelstorageaccess.getDataPacks(); ++ return datapackconfigd == null ? DataPackConfig.DEFAULT : datapackconfigd; + }, (p_206543_, p_206544_) -> { -+ RegistryAccess.Writable registryaccess$writable = RegistryAccess.m_206197_(); -+ DynamicOps dynamicops = RegistryOps.m_206813_(NbtOps.f_128958_, registryaccess$writable, p_206543_); ++ RegistryAccess.Writable registryaccess$writable = RegistryAccess.builtinCopy(); ++ DynamicOps dynamicops = RegistryOps.createAndLoad(NbtOps.INSTANCE, registryaccess$writable, p_206543_); + config.set(p_206544_); + ops.set(dynamicops); -+ WorldData worlddata1 = levelstoragesource$levelstorageaccess.m_211747_(dynamicops, p_206544_, registryaccess$writable.m_211816_()); ++ WorldData worlddata1 = levelstoragesource$levelstorageaccess.getDataTag(dynamicops, p_206544_, registryaccess$writable.allElementsLifecycle()); + if (worlddata1 != null) { -+ return Pair.of(worlddata1, registryaccess$writable.m_203557_()); ++ return Pair.of(worlddata1, registryaccess$writable.freeze()); + } else { + LevelSettings levelsettings; + WorldGenSettings worldgensettings; + if (optionset.has(optionspec2)) { -+ levelsettings = MinecraftServer.f_129743_; -+ worldgensettings = WorldGenSettings.m_64645_(registryaccess$writable); ++ levelsettings = MinecraftServer.DEMO_SETTINGS; ++ worldgensettings = WorldGenSettings.demoSettings(registryaccess$writable); + } else { -+ DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.m_139777_(); -+ levelsettings = new LevelSettings(dedicatedserverproperties.f_139741_, dedicatedserverproperties.f_139740_, dedicatedserverproperties.f_139752_, dedicatedserverproperties.f_139739_, false, new GameRules(), p_206544_, Lifecycle.stable()); -+ worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.m_180927_(registryaccess$writable).m_64671_() : dedicatedserverproperties.m_180927_(registryaccess$writable); ++ DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); ++ levelsettings = new LevelSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), p_206544_, Lifecycle.stable()); ++ worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.getWorldGenSettings(registryaccess$writable).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(registryaccess$writable); + } + + // Forge: Deserialize the WorldGenSettings to ensure modded dims are loaded on first server load. Vanilla behavior only loads from the server.properties and deserializes only after the 2nd server load. -+ worldgensettings = WorldGenSettings.f_64600_.encodeStart(dynamicops, worldgensettings).flatMap(nbt -> WorldGenSettings.f_64600_.parse(dynamicops, nbt)).getOrThrow(false, errorMsg -> {}); ++ worldgensettings = WorldGenSettings.CODEC.encodeStart(dynamicops, worldgensettings).flatMap(nbt -> WorldGenSettings.CODEC.parse(dynamicops, nbt)).getOrThrow(false, errorMsg -> {}); + PrimaryLevelData primaryleveldata = new PrimaryLevelData(levelsettings, worldgensettings, Lifecycle.stable()); -+ return Pair.of(primaryleveldata, registryaccess$writable.m_203557_()); ++ return Pair.of(primaryleveldata, registryaccess$writable.freeze()); + } -+ }, Util.m_183991_(), Runnable::run).get(); ++ }, Util.backgroundExecutor(), Runnable::run).get(); + } catch (Exception exception) { -+ f_129670_.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", (Throwable) exception); ++ LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", (Throwable) exception); + packrepository.close(); + return; + } + -+ worldstem.m_206901_(); -+ RegistryAccess.Frozen registryaccess$frozen = worldstem.f_206894_(); -+ dedicatedserversettings.m_139777_().m_180927_(registryaccess$frozen); -+ WorldData worlddata = worldstem.f_206895_(); ++ worldstem.updateGlobals(); ++ RegistryAccess.Frozen registryaccess$frozen = worldstem.registryAccess(); ++ dedicatedserversettings.getProperties().getWorldGenSettings(registryaccess$frozen); ++ WorldData worlddata = worldstem.worldData(); + if (optionset.has(optionspec4)) { -+ m_195488_(levelstoragesource$levelstorageaccess, DataFixers.m_14512_(), optionset.has(optionspec5), () -> { ++ forceUpgrade(levelstoragesource$levelstorageaccess, DataFixers.getDataFixer(), optionset.has(optionspec5), () -> { + return true; -+ }, worlddata.m_5961_()); ++ }, worlddata.worldGenSettings()); + } + -+ levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); -+ final MinecraftServer dedicatedserver = MinecraftServer.m_129872_((p_129697_) -> { ++ levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); ++ final MinecraftServer dedicatedserver = MinecraftServer.spin((p_129697_) -> { + org.magmafoundation.magma.helpers.ServerInitHelper.init(optionset, config.get(), ops.get()); + MinecraftServer dedicatedserver1; + if (gametestEnabled) { + net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests(); -+ java.util.Collection testBatches = net.minecraft.gametest.framework.GameTestRunner.m_127724_(net.minecraft.gametest.framework.GameTestRegistry.m_127658_()); ++ java.util.Collection testBatches = net.minecraft.gametest.framework.GameTestRunner.groupTestsIntoBatches(net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions()); + net.minecraft.core.BlockPos spawnPos = optionset.valueOf(spawnPosOpt); + dedicatedserver1 = new net.minecraft.gametest.framework.GameTestServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, testBatches, spawnPos); + } else { -+ dedicatedserver1 = new DedicatedServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.m_14512_(), minecraftsessionservice, gameprofilerepository, gameprofilecache, LoggerChunkProgressListener::new); ++ dedicatedserver1 = new DedicatedServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), minecraftsessionservice, gameprofilerepository, gameprofilecache, LoggerChunkProgressListener::new); + } -+ dedicatedserver1.m_129981_(optionset.valueOf(optionspec8)); -+ dedicatedserver1.m_129801_(optionset.valueOf(optionspec11)); -+ dedicatedserver1.m_129975_(optionset.has(optionspec2)); -+ dedicatedserver1.m_129948_(optionset.valueOf(optionspec12)); ++ dedicatedserver1.setSingleplayerName(optionset.valueOf(optionspec8)); ++ dedicatedserver1.setPort(optionset.valueOf(optionspec11)); ++ dedicatedserver1.setDemo(optionset.has(optionspec2)); ++ dedicatedserver1.setId(optionset.valueOf(optionspec12)); + boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec14).contains("nogui"); + dedicatedserver1.options = optionset; + if (dedicatedserver1 instanceof DedicatedServer dedicatedServer && flag1 && !GraphicsEnvironment.isHeadless()) { @@ -389,7 +389,7 @@ + if (optionset.has("port")) { + int port = (Integer) optionset.valueOf("port"); + if (port > 0) { -+ dedicatedserver1.m_129801_(port); ++ dedicatedserver1.setPort(port); + } + } + @@ -400,43 +400,43 @@ + org.magmafoundation.magma.protect.InjectProtect.shutdownCalled(); //Magma - Mixin Inject protection + // FORGE: Halting as GameTestServer will cause issues as it always calls System#exit on both crash and normal exit, so skip it + if (!(dedicatedserver instanceof net.minecraft.gametest.framework.GameTestServer)) - dedicatedserver.m_7570_(true); + dedicatedserver.halt(true); + //TODO-PATCHING: Figure out what needs to be done here after the logging update. + //LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end. + org.apache.logging.log4j.LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end. } }; - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(f_129670_)); + thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(thread); - } catch (Exception exception1) { -- f_129670_.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)exception1); +- LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)exception1); - } - - } - -- public static void m_195488_(LevelStorageSource.LevelStorageAccess p_195489_, DataFixer p_195490_, boolean p_195491_, BooleanSupplier p_195492_, WorldGenSettings p_195493_) { -- f_129670_.info("Forcing world upgrade!"); +- public static void forceUpgrade(LevelStorageSource.LevelStorageAccess p_195489_, DataFixer p_195490_, boolean p_195491_, BooleanSupplier p_195492_, WorldGenSettings p_195493_) { +- LOGGER.info("Forcing world upgrade!"); - WorldUpgrader worldupgrader = new WorldUpgrader(p_195489_, p_195490_, p_195493_, p_195491_); - Component component = null; - -- while(!worldupgrader.m_18829_()) { -- Component component1 = worldupgrader.m_18837_(); +- while(!worldupgrader.isFinished()) { +- Component component1 = worldupgrader.getStatus(); - if (component != component1) { - component = component1; -- f_129670_.info(worldupgrader.m_18837_().getString()); +- LOGGER.info(worldupgrader.getStatus().getString()); - } - -- int i = worldupgrader.m_18834_(); +- int i = worldupgrader.getTotalChunks(); - if (i > 0) { -- int j = worldupgrader.m_18835_() + worldupgrader.m_18836_(); -- f_129670_.info("{}% completed ({} / {} chunks)...", Mth.m_14143_((float)j / (float)i * 100.0F), j, i); +- int j = worldupgrader.getConverted() + worldupgrader.getSkipped(); +- LOGGER.info("{}% completed ({} / {} chunks)...", Mth.floor((float)j / (float)i * 100.0F), j, i); - } - - if (!p_195492_.getAsBoolean()) { -- worldupgrader.m_18820_(); +- worldupgrader.cancel(); - } else { + } catch (Exception exception1) { -+ f_129670_.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable) exception1); ++ LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable) exception1); + } + + } @@ -462,26 +462,26 @@ + } + // Paper end + -+ public static void m_195488_(LevelStorageSource.LevelStorageAccess p_195489_, DataFixer p_195490_, boolean p_195491_, BooleanSupplier p_195492_, WorldGenSettings p_195493_) { -+ f_129670_.info("Forcing world upgrade! {}", p_195489_.m_78277_()); // CraftBukkit ++ public static void forceUpgrade(LevelStorageSource.LevelStorageAccess p_195489_, DataFixer p_195490_, boolean p_195491_, BooleanSupplier p_195492_, WorldGenSettings p_195493_) { ++ LOGGER.info("Forcing world upgrade! {}", p_195489_.getLevelId()); // CraftBukkit + WorldUpgrader worldupgrader = new WorldUpgrader(p_195489_, p_195490_, p_195493_, p_195491_); + net.minecraft.network.chat.Component component = null; + -+ while (!worldupgrader.m_18829_()) { -+ net.minecraft.network.chat.Component component1 = worldupgrader.m_18837_(); ++ while (!worldupgrader.isFinished()) { ++ net.minecraft.network.chat.Component component1 = worldupgrader.getStatus(); + if (component != component1) { + component = component1; -+ f_129670_.info(worldupgrader.m_18837_().getString()); ++ LOGGER.info(worldupgrader.getStatus().getString()); + } + -+ int i = worldupgrader.m_18834_(); ++ int i = worldupgrader.getTotalChunks(); + if (i > 0) { -+ int j = worldupgrader.m_18835_() + worldupgrader.m_18836_(); -+ f_129670_.info("{}% completed ({} / {} chunks)...", Mth.m_14143_((float) j / (float) i * 100.0F), j, i); ++ int j = worldupgrader.getConverted() + worldupgrader.getSkipped(); ++ LOGGER.info("{}% completed ({} / {} chunks)...", Mth.floor((float) j / (float) i * 100.0F), j, i); + } + + if (!p_195492_.getAsBoolean()) { -+ worldupgrader.m_18820_(); ++ worldupgrader.cancel(); + } else { + try { + Thread.sleep(1000L); diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 8be4a9fe..03d9e5c7 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -4,106 +4,106 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements CommandSource, AutoCloseable { -- public static final Logger f_129750_ = LogUtils.getLogger(); -- public static final String f_195495_ = "vanilla"; -- private static final float f_177884_ = 0.8F; -- private static final int f_177885_ = 100; -- public static final int f_177878_ = 50; -- private static final int f_177887_ = 2000; -- private static final int f_177888_ = 15000; -- public static final String f_177879_ = "level"; -- public static final String f_177880_ = "level://"; -- private static final long f_177889_ = 5000000000L; -- private static final int f_177890_ = 12; -- public static final String f_177881_ = "resources.zip"; -- public static final File f_129742_ = new File("usercache.json"); -- public static final int f_177882_ = 11; -- private static final int f_177891_ = 441; -- private static final int f_177892_ = 6000; -- private static final int f_177893_ = 3; -- public static final int f_177883_ = 29999984; -- public static final LevelSettings f_129743_ = new LevelSettings("Demo World", GameType.SURVIVAL, false, Difficulty.NORMAL, false, new GameRules(), DataPackConfig.f_45842_); -- private static final long f_177871_ = 50L; -- public static final GameProfile f_195496_ = new GameProfile(Util.f_137441_, "Anonymous Player"); -- public final LevelStorageSource.LevelStorageAccess f_129744_; -- public final PlayerDataStorage f_129745_; -- private final List f_129752_ = Lists.newArrayList(); -- private MetricsRecorder f_177872_ = InactiveMetricsRecorder.f_146153_; -- private ProfilerFiller f_129754_ = this.f_177872_.m_142610_(); -- private Consumer f_177873_ = (p_177903_) -> { -- this.m_177928_(); +- public static final Logger LOGGER = LogUtils.getLogger(); +- public static final String VANILLA_BRAND = "vanilla"; +- private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F; +- private static final int TICK_STATS_SPAN = 100; +- public static final int MS_PER_TICK = 50; +- private static final int OVERLOADED_THRESHOLD = 2000; +- private static final int OVERLOADED_WARNING_INTERVAL = 15000; +- public static final String LEVEL_STORAGE_PROTOCOL = "level"; +- public static final String LEVEL_STORAGE_SCHEMA = "level://"; +- private static final long STATUS_EXPIRE_TIME_NS = 5000000000L; +- private static final int MAX_STATUS_PLAYER_SAMPLE = 12; +- public static final String MAP_RESOURCE_FILE = "resources.zip"; +- public static final File USERID_CACHE_FILE = new File("usercache.json"); +- public static final int START_CHUNK_RADIUS = 11; +- private static final int START_TICKING_CHUNK_COUNT = 441; +- private static final int AUTOSAVE_INTERVAL = 6000; +- private static final int MAX_TICK_LATENCY = 3; +- public static final int ABSOLUTE_MAX_WORLD_SIZE = 29999984; +- public static final LevelSettings DEMO_SETTINGS = new LevelSettings("Demo World", GameType.SURVIVAL, false, Difficulty.NORMAL, false, new GameRules(), DataPackConfig.DEFAULT); +- private static final long DELAYED_TASKS_TICK_EXTENSION = 50L; +- public static final GameProfile ANONYMOUS_PLAYER_PROFILE = new GameProfile(Util.NIL_UUID, "Anonymous Player"); +- public final LevelStorageSource.LevelStorageAccess storageSource; +- public final PlayerDataStorage playerDataStorage; +- private final List tickables = Lists.newArrayList(); +- private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE; +- private ProfilerFiller profiler = this.metricsRecorder.getProfiler(); +- private Consumer onMetricsRecordingStopped = (p_177903_) -> { +- this.stopRecordingMetrics(); - }; -- private Consumer f_177874_ = (p_177954_) -> { +- private Consumer onMetricsRecordingFinished = (p_177954_) -> { - }; -- private boolean f_177875_; +- private boolean willStartRecordingMetrics; - @Nullable -- private MinecraftServer.TimeProfiler f_177876_; -- private boolean f_177877_; -- private final ServerConnectionListener f_129755_; -- public final ChunkProgressListenerFactory f_129756_; -- private final ServerStatus f_129757_ = new ServerStatus(); -- private final Random f_129758_ = new Random(); -- public final DataFixer f_129759_; -- private String f_129760_; -- private int f_129761_ = -1; -- public final RegistryAccess.Frozen f_129746_; -- public final Map, ServerLevel> f_129762_ = Maps.newLinkedHashMap(); -- private PlayerList f_129763_; -- private volatile boolean f_129764_ = true; -- private boolean f_129765_; -- private int f_129766_; -- protected final Proxy f_129747_; -- private boolean f_129705_; -- private boolean f_129706_; -- private boolean f_129707_; -- private boolean f_129708_; +- private MinecraftServer.TimeProfiler debugCommandProfiler; +- private boolean debugCommandProfilerDelayStart; +- private final ServerConnectionListener connection; +- public final ChunkProgressListenerFactory progressListenerFactory; +- private final ServerStatus status = new ServerStatus(); +- private final Random random = new Random(); +- public final DataFixer fixerUpper; +- private String localIp; +- private int port = -1; +- public final RegistryAccess.Frozen registryHolder; +- public final Map, ServerLevel> levels = Maps.newLinkedHashMap(); +- private PlayerList playerList; +- private volatile boolean running = true; +- private boolean stopped; +- private int tickCount; +- protected final Proxy proxy; +- private boolean onlineMode; +- private boolean preventProxyConnections; +- private boolean pvp; +- private boolean allowFlight; - @Nullable -- private String f_129709_; -- private int f_129711_; -- public final long[] f_129748_ = new long[100]; +- private String motd; +- private int playerIdleTimeout; +- public final long[] tickTimes = new long[100]; - @Nullable -- private KeyPair f_129712_; +- private KeyPair keyPair; - @Nullable -- private String f_129713_; -- private boolean f_129714_; -- private String f_129715_ = ""; -- private String f_129716_ = ""; -- private volatile boolean f_129717_; -- private long f_129718_; -- private final MinecraftSessionService f_129721_; +- private String singleplayerName; +- private boolean isDemo; +- private String resourcePack = ""; +- private String resourcePackHash = ""; +- private volatile boolean isReady; +- private long lastOverloadWarning; +- private final MinecraftSessionService sessionService; - @Nullable -- private final GameProfileRepository f_129722_; +- private final GameProfileRepository profileRepository; - @Nullable -- private final GameProfileCache f_129723_; -- private long f_129724_; -- public final Thread f_129725_; -- protected long f_129726_ = Util.m_137550_(); -- private long f_129727_; -- private boolean f_129728_; -- private final PackRepository f_129730_; -- private final ServerScoreboard f_129731_ = new ServerScoreboard(this); +- private final GameProfileCache profileCache; +- private long lastServerStatus; +- public final Thread serverThread; +- protected long nextTickTime = Util.getMillis(); +- private long delayedTasksMaxNextTickTime; +- private boolean mayHaveDelayedTasks; +- private final PackRepository packRepository; +- private final ServerScoreboard scoreboard = new ServerScoreboard(this); - @Nullable -- private CommandStorage f_129732_; -- private final CustomBossEvents f_129733_ = new CustomBossEvents(); -- private final ServerFunctionManager f_129734_; -- private final FrameTimer f_129735_ = new FrameTimer(); -- private boolean f_129736_; -- private float f_129737_; -- public final Executor f_129738_; +- private CommandStorage commandStorage; +- private final CustomBossEvents customBossEvents = new CustomBossEvents(); +- private final ServerFunctionManager functionManager; +- private final FrameTimer frameTimer = new FrameTimer(); +- private boolean enforceWhitelist; +- private float averageTickTime; +- public final Executor executor; - @Nullable -- private String f_129739_; -- public MinecraftServer.ReloadableResources f_129740_; -- private final StructureManager f_129741_; -- protected final WorldData f_129749_; -- private volatile boolean f_195494_; +- private String serverId; +- public MinecraftServer.ReloadableResources resources; +- private final StructureManager structureManager; +- protected final WorldData worldData; +- private volatile boolean isSaving; - -- public static S m_129872_(Function p_129873_) { +- public static S spin(Function p_129873_) { - AtomicReference atomicreference = new AtomicReference<>(); - Thread thread = new Thread(() -> { -- atomicreference.get().m_130011_(); +- atomicreference.get().runServer(); - }, "Server thread"); - thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> { -- f_129750_.error("Uncaught exception in server thread", p_177910_); +- LOGGER.error("Uncaught exception in server thread", p_177910_); - }); - if (Runtime.getRuntime().availableProcessors() > 4) { - thread.setPriority(8); @@ -117,184 +117,184 @@ - - public MinecraftServer(Thread p_206546_, LevelStorageSource.LevelStorageAccess p_206547_, PackRepository p_206548_, WorldStem p_206549_, Proxy p_206550_, DataFixer p_206551_, @Nullable MinecraftSessionService p_206552_, @Nullable GameProfileRepository p_206553_, @Nullable GameProfileCache p_206554_, ChunkProgressListenerFactory p_206555_) { - super("Server"); -- this.f_129746_ = p_206549_.f_206894_(); -- this.f_129749_ = p_206549_.f_206895_(); -- this.f_129747_ = p_206550_; -- this.f_129730_ = p_206548_; -- this.f_129740_ = new MinecraftServer.ReloadableResources(p_206549_.f_206892_(), p_206549_.f_206893_()); -- this.f_129721_ = p_206552_; -- this.f_129722_ = p_206553_; -- this.f_129723_ = p_206554_; +- this.registryHolder = p_206549_.registryAccess(); +- this.worldData = p_206549_.worldData(); +- this.proxy = p_206550_; +- this.packRepository = p_206548_; +- this.resources = new MinecraftServer.ReloadableResources(p_206549_.resourceManager(), p_206549_.dataPackResources()); +- this.sessionService = p_206552_; +- this.profileRepository = p_206553_; +- this.profileCache = p_206554_; - if (p_206554_ != null) { -- p_206554_.m_143974_(this); +- p_206554_.setExecutor(this); - } - -- this.f_129755_ = new ServerConnectionListener(this); -- this.f_129756_ = p_206555_; -- this.f_129744_ = p_206547_; -- this.f_129745_ = p_206547_.m_78301_(); -- this.f_129759_ = p_206551_; -- this.f_129734_ = new ServerFunctionManager(this, this.f_129740_.f_206585_.m_206860_()); -- this.f_129741_ = new StructureManager(p_206549_.f_206892_(), p_206547_, p_206551_); -- this.f_129725_ = p_206546_; -- this.f_129738_ = Util.m_183991_(); +- this.connection = new ServerConnectionListener(this); +- this.progressListenerFactory = p_206555_; +- this.storageSource = p_206547_; +- this.playerDataStorage = p_206547_.createPlayerStorage(); +- this.fixerUpper = p_206551_; +- this.functionManager = new ServerFunctionManager(this, this.resources.managers.getFunctionLibrary()); +- this.structureManager = new StructureManager(p_206549_.resourceManager(), p_206547_, p_206551_); +- this.serverThread = p_206546_; +- this.executor = Util.backgroundExecutor(); - } - -- private void m_129841_(DimensionDataStorage p_129842_) { -- p_129842_.m_164861_(this.m_129896_()::m_180013_, this.m_129896_()::m_180015_, "scoreboard"); +- private void readScoreboard(DimensionDataStorage p_129842_) { +- p_129842_.computeIfAbsent(this.getScoreboard()::createData, this.getScoreboard()::createData, "scoreboard"); - } - -- protected abstract boolean m_7038_() throws IOException; +- protected abstract boolean initServer() throws IOException; - -- protected void m_130006_() { -- if (!JvmProfiler.f_185340_.m_183608_()) { +- protected void loadLevel() { +- if (!JvmProfiler.INSTANCE.isRunning()) { - } - - boolean flag = false; -- ProfiledDuration profiledduration = JvmProfiler.f_185340_.m_183494_(); -- this.m_130007_(); -- this.f_129749_.m_7955_(this.m_130001_(), this.m_183471_().m_184597_()); -- ChunkProgressListener chunkprogresslistener = this.f_129756_.m_9620_(11); -- this.m_129815_(chunkprogresslistener); -- this.m_7044_(); -- this.m_129940_(chunkprogresslistener); +- ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); +- this.detectBundledResources(); +- this.worldData.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); +- ChunkProgressListener chunkprogresslistener = this.progressListenerFactory.create(11); +- this.createLevels(chunkprogresslistener); +- this.forceDifficulty(); +- this.prepareLevels(chunkprogresslistener); - if (profiledduration != null) { -- profiledduration.m_185413_(); +- profiledduration.finish(); - } - - if (flag) { - try { -- JvmProfiler.f_185340_.m_183243_(); +- JvmProfiler.INSTANCE.stop(); - } catch (Throwable throwable) { -- f_129750_.warn("Failed to stop JFR profiling", throwable); +- LOGGER.warn("Failed to stop JFR profiling", throwable); - } - } - - } - -- protected void m_7044_() { +- protected void forceDifficulty() { - } - -- protected void m_129815_(ChunkProgressListener p_129816_) { -- ServerLevelData serverleveldata = this.f_129749_.m_5996_(); -- WorldGenSettings worldgensettings = this.f_129749_.m_5961_(); -- boolean flag = worldgensettings.m_64668_(); -- long i = worldgensettings.m_64619_(); -- long j = BiomeManager.m_47877_(i); +- protected void createLevels(ChunkProgressListener p_129816_) { +- ServerLevelData serverleveldata = this.worldData.overworldData(); +- WorldGenSettings worldgensettings = this.worldData.worldGenSettings(); +- boolean flag = worldgensettings.isDebug(); +- long i = worldgensettings.seed(); +- long j = BiomeManager.obfuscateSeed(i); - List list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(serverleveldata)); -- Registry registry = worldgensettings.m_204655_(); -- LevelStem levelstem = registry.m_6246_(LevelStem.f_63971_); +- Registry registry = worldgensettings.dimensions(); +- LevelStem levelstem = registry.get(LevelStem.OVERWORLD); - ChunkGenerator chunkgenerator; - Holder holder; - if (levelstem == null) { -- holder = this.m_206579_().m_175515_(Registry.f_122818_).m_203538_(DimensionType.f_63845_); -- chunkgenerator = WorldGenSettings.m_190027_(this.m_206579_(), (new Random()).nextLong()); +- holder = this.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionType.OVERWORLD_LOCATION); +- chunkgenerator = WorldGenSettings.makeDefaultOverworld(this.registryAccess(), (new Random()).nextLong()); - } else { -- holder = levelstem.m_204521_(); -- chunkgenerator = levelstem.m_63990_(); +- holder = levelstem.typeHolder(); +- chunkgenerator = levelstem.generator(); - } - -- ServerLevel serverlevel = new ServerLevel(this, this.f_129738_, this.f_129744_, serverleveldata, Level.f_46428_, holder, p_129816_, chunkgenerator, flag, j, list, true); -- this.f_129762_.put(Level.f_46428_, serverlevel); -- DimensionDataStorage dimensiondatastorage = serverlevel.m_8895_(); -- this.m_129841_(dimensiondatastorage); -- this.f_129732_ = new CommandStorage(dimensiondatastorage); -- WorldBorder worldborder = serverlevel.m_6857_(); -- if (!serverleveldata.m_6535_()) { +- ServerLevel serverlevel = new ServerLevel(this, this.executor, this.storageSource, serverleveldata, Level.OVERWORLD, holder, p_129816_, chunkgenerator, flag, j, list, true); +- this.levels.put(Level.OVERWORLD, serverlevel); +- DimensionDataStorage dimensiondatastorage = serverlevel.getDataStorage(); +- this.readScoreboard(dimensiondatastorage); +- this.commandStorage = new CommandStorage(dimensiondatastorage); +- WorldBorder worldborder = serverlevel.getWorldBorder(); +- if (!serverleveldata.isInitialized()) { - try { -- m_177896_(serverlevel, serverleveldata, worldgensettings.m_64660_(), flag); -+ public static final Logger f_129750_ = LogUtils.getLogger(); -+ public static final String f_195495_ = "vanilla"; -+ private static final float f_177884_ = 0.8F; -+ private static final int f_177885_ = 100; -+ public static final int f_177878_ = 50; -+ private static final int f_177887_ = 2000; -+ private static final int f_177888_ = 15000; -+ public static final String f_177879_ = "level"; -+ public static final String f_177880_ = "level://"; -+ private static final long f_177889_ = 5000000000L; -+ private static final int f_177890_ = 12; -+ public static final String f_177881_ = "resources.zip"; -+ public static final File f_129742_ = new File("usercache.json"); -+ public static final int f_177882_ = 11; -+ private static final int f_177891_ = 441; -+ private static final int f_177892_ = 6000; -+ private static final int f_177893_ = 3; -+ public static final int f_177883_ = 29999984; -+ public static final LevelSettings f_129743_ = new LevelSettings("Demo World", GameType.SURVIVAL, false, Difficulty.NORMAL, false, new GameRules(), DataPackConfig.f_45842_, com.mojang.serialization.Lifecycle.experimental()); -+ private static final long f_177871_ = 50L; -+ public static final GameProfile f_195496_ = new GameProfile(Util.f_137441_, "Anonymous Player"); -+ public final LevelStorageSource.LevelStorageAccess f_129744_; -+ public final PlayerDataStorage f_129745_; -+ private final List f_129752_ = Lists.newArrayList(); -+ private MetricsRecorder f_177872_ = InactiveMetricsRecorder.f_146153_; -+ private ProfilerFiller f_129754_ = this.f_177872_.m_142610_(); -+ private Consumer f_177873_ = (p_177903_) -> { -+ this.m_177928_(); +- setInitialSpawn(serverlevel, serverleveldata, worldgensettings.generateBonusChest(), flag); ++ public static final Logger LOGGER = LogUtils.getLogger(); ++ public static final String VANILLA_BRAND = "vanilla"; ++ private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F; ++ private static final int TICK_STATS_SPAN = 100; ++ public static final int MS_PER_TICK = 50; ++ private static final int OVERLOADED_THRESHOLD = 2000; ++ private static final int OVERLOADED_WARNING_INTERVAL = 15000; ++ public static final String LEVEL_STORAGE_PROTOCOL = "level"; ++ public static final String LEVEL_STORAGE_SCHEMA = "level://"; ++ private static final long STATUS_EXPIRE_TIME_NS = 5000000000L; ++ private static final int MAX_STATUS_PLAYER_SAMPLE = 12; ++ public static final String MAP_RESOURCE_FILE = "resources.zip"; ++ public static final File USERID_CACHE_FILE = new File("usercache.json"); ++ public static final int START_CHUNK_RADIUS = 11; ++ private static final int START_TICKING_CHUNK_COUNT = 441; ++ private static final int AUTOSAVE_INTERVAL = 6000; ++ private static final int MAX_TICK_LATENCY = 3; ++ public static final int ABSOLUTE_MAX_WORLD_SIZE = 29999984; ++ public static final LevelSettings DEMO_SETTINGS = new LevelSettings("Demo World", GameType.SURVIVAL, false, Difficulty.NORMAL, false, new GameRules(), DataPackConfig.DEFAULT, com.mojang.serialization.Lifecycle.experimental()); ++ private static final long DELAYED_TASKS_TICK_EXTENSION = 50L; ++ public static final GameProfile ANONYMOUS_PLAYER_PROFILE = new GameProfile(Util.NIL_UUID, "Anonymous Player"); ++ public final LevelStorageSource.LevelStorageAccess storageSource; ++ public final PlayerDataStorage playerDataStorage; ++ private final List tickables = Lists.newArrayList(); ++ private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE; ++ private ProfilerFiller profiler = this.metricsRecorder.getProfiler(); ++ private Consumer onMetricsRecordingStopped = (p_177903_) -> { ++ this.stopRecordingMetrics(); + }; -+ private Consumer f_177874_ = (p_177954_) -> { ++ private Consumer onMetricsRecordingFinished = (p_177954_) -> { + }; -+ private boolean f_177875_; ++ private boolean willStartRecordingMetrics; + @Nullable -+ private MinecraftServer.TimeProfiler f_177876_; -+ private boolean f_177877_; -+ private ServerConnectionListener f_129755_; -+ public final ChunkProgressListenerFactory f_129756_; -+ private final ServerStatus f_129757_ = new ServerStatus(); -+ private final Random f_129758_ = new Random(); -+ public final DataFixer f_129759_; -+ private String f_129760_; -+ private int f_129761_ = -1; -+ public final RegistryAccess.Frozen f_129746_; -+ public final Map, ServerLevel> f_129762_ = Maps.newLinkedHashMap(); -+ private PlayerList f_129763_; -+ private volatile boolean f_129764_ = true; -+ private boolean f_129765_; -+ private int f_129766_; -+ protected final Proxy f_129747_; -+ private boolean f_129705_; -+ private boolean f_129706_; -+ private boolean f_129707_; -+ private boolean f_129708_; ++ private MinecraftServer.TimeProfiler debugCommandProfiler; ++ private boolean debugCommandProfilerDelayStart; ++ private ServerConnectionListener connection; ++ public final ChunkProgressListenerFactory progressListenerFactory; ++ private final ServerStatus status = new ServerStatus(); ++ private final Random random = new Random(); ++ public final DataFixer fixerUpper; ++ private String localIp; ++ private int port = -1; ++ public final RegistryAccess.Frozen registryHolder; ++ public final Map, ServerLevel> levels = Maps.newLinkedHashMap(); ++ private PlayerList playerList; ++ private volatile boolean running = true; ++ private boolean stopped; ++ private int tickCount; ++ protected final Proxy proxy; ++ private boolean onlineMode; ++ private boolean preventProxyConnections; ++ private boolean pvp; ++ private boolean allowFlight; + @Nullable -+ private String f_129709_; -+ private int f_129711_; -+ public final long[] f_129748_ = new long[100]; ++ private String motd; ++ private int playerIdleTimeout; ++ public final long[] tickTimes = new long[100]; + @Nullable -+ private KeyPair f_129712_; ++ private KeyPair keyPair; + @Nullable -+ private String f_129713_; -+ private boolean f_129714_; -+ private String f_129715_ = ""; -+ private String f_129716_ = ""; -+ private volatile boolean f_129717_; -+ private long f_129718_; -+ private final MinecraftSessionService f_129721_; ++ private String singleplayerName; ++ private boolean isDemo; ++ private String resourcePack = ""; ++ private String resourcePackHash = ""; ++ private volatile boolean isReady; ++ private long lastOverloadWarning; ++ private final MinecraftSessionService sessionService; + @Nullable -+ private final GameProfileRepository f_129722_; ++ private final GameProfileRepository profileRepository; + @Nullable -+ private final GameProfileCache f_129723_; -+ private long f_129724_; -+ public final Thread f_129725_; -+ protected long f_129726_ = Util.m_137550_(); -+ private long f_129727_; -+ private boolean f_129728_; -+ private final PackRepository f_129730_; -+ private final ServerScoreboard f_129731_ = new ServerScoreboard(this); ++ private final GameProfileCache profileCache; ++ private long lastServerStatus; ++ public final Thread serverThread; ++ protected long nextTickTime = Util.getMillis(); ++ private long delayedTasksMaxNextTickTime; ++ private boolean mayHaveDelayedTasks; ++ private final PackRepository packRepository; ++ private final ServerScoreboard scoreboard = new ServerScoreboard(this); + @Nullable -+ private CommandStorage f_129732_; -+ private final CustomBossEvents f_129733_ = new CustomBossEvents(); -+ private final ServerFunctionManager f_129734_; -+ private final FrameTimer f_129735_ = new FrameTimer(); -+ private boolean f_129736_; -+ private float f_129737_; -+ public final Executor f_129738_; ++ private CommandStorage commandStorage; ++ private final CustomBossEvents customBossEvents = new CustomBossEvents(); ++ private final ServerFunctionManager functionManager; ++ private final FrameTimer frameTimer = new FrameTimer(); ++ private boolean enforceWhitelist; ++ private float averageTickTime; ++ public final Executor executor; + @Nullable -+ private String f_129739_; -+ public MinecraftServer.ReloadableResources f_129740_; -+ private final StructureManager f_129741_; -+ protected final WorldData f_129749_; -+ private volatile boolean f_195494_; ++ private String serverId; ++ public MinecraftServer.ReloadableResources resources; ++ private final StructureManager structureManager; ++ protected final WorldData worldData; ++ private volatile boolean isSaving; + + // CraftBukkit start + public DataPackConfig datapackconfiguration; @@ -323,13 +323,13 @@ + private static org.magmafoundation.magma.metrics.Metrics metrics; + // org.magmafoundation.magma.Magma end + -+ public static S m_129872_(Function p_129873_) { ++ public static S spin(Function p_129873_) { + AtomicReference atomicreference = new AtomicReference<>(); + Thread thread = new Thread(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER, () -> { -+ atomicreference.get().m_130011_(); ++ atomicreference.get().runServer(); + }, "Server thread"); + thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> { -+ f_129750_.error("Uncaught exception in server thread", p_177910_); ++ LOGGER.error("Uncaught exception in server thread", p_177910_); + }); + if (Runtime.getRuntime().availableProcessors() > 4) { + thread.setPriority(8); @@ -352,29 +352,29 @@ + instance = this; // Magma + preInit(org.magmafoundation.magma.helpers.ServerInitHelper.getOptions(), org.magmafoundation.magma.helpers.ServerInitHelper.getDataPackConfig(), org.magmafoundation.magma.helpers.ServerInitHelper.getRegistryReadOps()); + -+ this.f_129746_ = p_206549_.f_206894_(); -+ this.f_129749_ = p_206549_.f_206895_(); -+ this.f_129747_ = p_206550_; -+ this.f_129730_ = p_206548_; -+ this.f_129740_ = new MinecraftServer.ReloadableResources(p_206549_.f_206892_(), p_206549_.f_206893_()); -+ this.f_129721_ = p_206552_; -+ this.f_129722_ = p_206553_; -+ this.f_129723_ = p_206554_; ++ this.registryHolder = p_206549_.registryAccess(); ++ this.worldData = p_206549_.worldData(); ++ this.proxy = p_206550_; ++ this.packRepository = p_206548_; ++ this.resources = new MinecraftServer.ReloadableResources(p_206549_.resourceManager(), p_206549_.dataPackResources()); ++ this.sessionService = p_206552_; ++ this.profileRepository = p_206553_; ++ this.profileCache = p_206554_; + if (p_206554_ != null) { -+ p_206554_.m_143974_(this); ++ p_206554_.setExecutor(this); + } + + // this.connection = new ServerConnectionListener(this); // Spigot -+ this.f_129756_ = p_206555_; -+ this.f_129744_ = p_206547_; -+ this.f_129745_ = p_206547_.m_78301_(); -+ this.f_129759_ = p_206551_; -+ this.f_129734_ = new ServerFunctionManager(this, this.f_129740_.f_206585_.m_206860_()); -+ this.f_129741_ = new StructureManager(p_206549_.f_206892_(), p_206547_, p_206551_); -+ this.f_129725_ = p_206546_; -+ this.f_129738_ = Util.m_183991_(); ++ this.progressListenerFactory = p_206555_; ++ this.storageSource = p_206547_; ++ this.playerDataStorage = p_206547_.createPlayerStorage(); ++ this.fixerUpper = p_206551_; ++ this.functionManager = new ServerFunctionManager(this, this.resources.managers.getFunctionLibrary()); ++ this.structureManager = new StructureManager(p_206549_.resourceManager(), p_206547_, p_206551_); ++ this.serverThread = p_206546_; ++ this.executor = Util.backgroundExecutor(); + // CraftBukkit start -+ this.vanillaCommandDispatcher = p_206549_.f_206893_().f_206847_; // CraftBukkit ++ this.vanillaCommandDispatcher = p_206549_.dataPackResources().commands; // CraftBukkit + // Try to see if we're actually running in a terminal, disable jline if not + if (System.console() == null && System.getProperty("jline.terminal") == null) { + System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); @@ -411,155 +411,155 @@ + reader = new jline.console.ConsoleReader(System.in, System.out); + reader.setExpandEvents(false); + } catch (IOException ex) { -+ f_129750_.warn((String) null, ex); ++ LOGGER.warn((String) null, ex); + } + } + Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.v1_18_R2.util.ServerShutdownThread(this)); + } + // CraftBukkit end + -+ private void m_129841_(DimensionDataStorage p_129842_) { -+ p_129842_.m_164861_(this.m_129896_()::m_180013_, this.m_129896_()::m_180015_, "scoreboard"); ++ private void readScoreboard(DimensionDataStorage p_129842_) { ++ p_129842_.computeIfAbsent(this.getScoreboard()::createData, this.getScoreboard()::createData, "scoreboard"); + } + -+ protected abstract boolean m_7038_() throws IOException; ++ protected abstract boolean initServer() throws IOException; + -+ protected void m_130006_() { // CraftBukkit - added argument //Magma - and we removed it again ;) -+ if (!JvmProfiler.f_185340_.m_183608_()) { ++ protected void loadLevel() { // CraftBukkit - added argument //Magma - and we removed it again ;) ++ if (!JvmProfiler.INSTANCE.isRunning()) { + } + + boolean flag = false; -+ ProfiledDuration profiledduration = JvmProfiler.f_185340_.m_183494_(); -+ this.m_130007_(); -+ this.f_129749_.m_7955_(this.m_130001_(), this.m_183471_().m_184597_()); -+ ChunkProgressListener chunkprogresslistener = this.f_129756_.m_9620_(11); -+ this.m_129815_(chunkprogresslistener); -+ this.m_7044_(); -+ this.m_129940_(chunkprogresslistener); ++ ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); ++ this.detectBundledResources(); ++ this.worldData.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); ++ ChunkProgressListener chunkprogresslistener = this.progressListenerFactory.create(11); ++ this.createLevels(chunkprogresslistener); ++ this.forceDifficulty(); ++ this.prepareLevels(chunkprogresslistener); + if (profiledduration != null) { -+ profiledduration.m_185413_(); ++ profiledduration.finish(); + } + + if (flag) { + try { -+ JvmProfiler.f_185340_.m_183243_(); ++ JvmProfiler.INSTANCE.stop(); + } catch (Throwable throwable) { -+ f_129750_.warn("Failed to stop JFR profiling", throwable); ++ LOGGER.warn("Failed to stop JFR profiling", throwable); + } + } + } + -+ protected void m_7044_() { ++ protected void forceDifficulty() { + } + -+ protected void m_129815_(ChunkProgressListener p_129816_) { -+ ServerLevelData serverleveldata = this.f_129749_.m_5996_(); -+ WorldGenSettings worldgensettings = this.f_129749_.m_5961_(); -+ boolean flag = worldgensettings.m_64668_(); -+ long i = worldgensettings.m_64619_(); -+ long j = BiomeManager.m_47877_(i); ++ protected void createLevels(ChunkProgressListener p_129816_) { ++ ServerLevelData serverleveldata = this.worldData.overworldData(); ++ WorldGenSettings worldgensettings = this.worldData.worldGenSettings(); ++ boolean flag = worldgensettings.isDebug(); ++ long i = worldgensettings.seed(); ++ long j = BiomeManager.obfuscateSeed(i); + List list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(serverleveldata)); -+ Registry registry = worldgensettings.m_204655_(); -+ LevelStem levelstem = registry.m_6246_(LevelStem.f_63971_); ++ Registry registry = worldgensettings.dimensions(); ++ LevelStem levelstem = registry.get(LevelStem.OVERWORLD); + ChunkGenerator chunkgenerator; + Holder holder; + if (levelstem == null) { -+ holder = this.m_206579_().m_175515_(Registry.f_122818_).m_203538_(DimensionType.f_63845_); -+ chunkgenerator = WorldGenSettings.m_190027_(this.m_206579_(), (new Random()).nextLong()); ++ holder = this.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionType.OVERWORLD_LOCATION); ++ chunkgenerator = WorldGenSettings.makeDefaultOverworld(this.registryAccess(), (new Random()).nextLong()); + } else { -+ holder = levelstem.m_204521_(); -+ chunkgenerator = levelstem.m_63990_(); -+ } -+ -+ ServerLevel serverlevel = new ServerLevel(this, this.f_129738_, this.f_129744_, serverleveldata, Level.f_46428_, holder, p_129816_, chunkgenerator, flag, j, list, true); -+ org.magmafoundation.magma.forge.ForgeInject.addForgeEnvironment(this.f_129749_.m_5961_().m_204655_()); -+ this.f_129762_.put(Level.f_46428_, bukkitInit(serverlevel)); //Magma - bukkitInit -+ DimensionDataStorage dimensiondatastorage = serverlevel.m_8895_(); -+ this.m_129841_(dimensiondatastorage); -+ this.f_129732_ = new CommandStorage(dimensiondatastorage); -+ WorldBorder worldborder = serverlevel.m_6857_(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(Level.f_46428_))); -+ if (!serverleveldata.m_6535_()) { ++ holder = levelstem.typeHolder(); ++ chunkgenerator = levelstem.generator(); ++ } ++ ++ ServerLevel serverlevel = new ServerLevel(this, this.executor, this.storageSource, serverleveldata, Level.OVERWORLD, holder, p_129816_, chunkgenerator, flag, j, list, true); ++ org.magmafoundation.magma.forge.ForgeInject.addForgeEnvironment(this.worldData.worldGenSettings().dimensions()); ++ this.levels.put(Level.OVERWORLD, bukkitInit(serverlevel)); //Magma - bukkitInit ++ DimensionDataStorage dimensiondatastorage = serverlevel.getDataStorage(); ++ this.readScoreboard(dimensiondatastorage); ++ this.commandStorage = new CommandStorage(dimensiondatastorage); ++ WorldBorder worldborder = serverlevel.getWorldBorder(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(levels.get(Level.OVERWORLD))); ++ if (!serverleveldata.isInitialized()) { + try { -+ m_177896_(serverlevel, serverleveldata, worldgensettings.m_64660_(), flag); -+ serverleveldata.m_5555_(true); ++ setInitialSpawn(serverlevel, serverleveldata, worldgensettings.generateBonusChest(), flag); ++ serverleveldata.setInitialized(true); + if (flag) { -+ this.m_129847_(this.f_129749_); ++ this.setupDebugLevel(this.worldData); + } + } catch (Throwable throwable1) { -+ CrashReport crashreport = CrashReport.m_127521_(throwable1, "Exception initializing level"); ++ CrashReport crashreport = CrashReport.forThrowable(throwable1, "Exception initializing level"); + + try { -+ serverlevel.m_6026_(crashreport); ++ serverlevel.fillReportDetails(crashreport); + } catch (Throwable throwable) { + } + + throw new ReportedException(crashreport); + } + - serverleveldata.m_5555_(true); + serverleveldata.setInitialized(true); - if (flag) { -- this.m_129847_(this.f_129749_); +- this.setupDebugLevel(this.worldData); - } - } catch (Throwable throwable1) { -- CrashReport crashreport = CrashReport.m_127521_(throwable1, "Exception initializing level"); +- CrashReport crashreport = CrashReport.forThrowable(throwable1, "Exception initializing level"); - - try { -- serverlevel.m_6026_(crashreport); +- serverlevel.fillReportDetails(crashreport); - } catch (Throwable throwable) { - } - - throw new ReportedException(crashreport); - } - -- serverleveldata.m_5555_(true); +- serverleveldata.setInitialized(true); - } - -- this.m_6846_().m_184209_(serverlevel); -- if (this.f_129749_.m_6587_() != null) { -- this.m_129901_().m_136295_(this.f_129749_.m_6587_()); +- this.getPlayerList().addWorldborderListener(serverlevel); +- if (this.worldData.getCustomBossEvents() != null) { +- this.getCustomBossEvents().load(this.worldData.getCustomBossEvents()); - } - -- for(Entry, LevelStem> entry : registry.m_6579_()) { +- for(Entry, LevelStem> entry : registry.entrySet()) { - ResourceKey resourcekey = entry.getKey(); -- if (resourcekey != LevelStem.f_63971_) { -- ResourceKey resourcekey1 = ResourceKey.m_135785_(Registry.f_122819_, resourcekey.m_135782_()); -- Holder holder1 = entry.getValue().m_204521_(); -- ChunkGenerator chunkgenerator1 = entry.getValue().m_63990_(); -- DerivedLevelData derivedleveldata = new DerivedLevelData(this.f_129749_, serverleveldata); -- ServerLevel serverlevel1 = new ServerLevel(this, this.f_129738_, this.f_129744_, derivedleveldata, resourcekey1, holder1, p_129816_, chunkgenerator1, flag, j, ImmutableList.of(), false); -- worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_())); -- this.f_129762_.put(resourcekey1, serverlevel1); +- if (resourcekey != LevelStem.OVERWORLD) { +- ResourceKey resourcekey1 = ResourceKey.create(Registry.DIMENSION_REGISTRY, resourcekey.location()); +- Holder holder1 = entry.getValue().typeHolder(); +- ChunkGenerator chunkgenerator1 = entry.getValue().generator(); +- DerivedLevelData derivedleveldata = new DerivedLevelData(this.worldData, serverleveldata); +- ServerLevel serverlevel1 = new ServerLevel(this, this.executor, this.storageSource, derivedleveldata, resourcekey1, holder1, p_129816_, chunkgenerator1, flag, j, ImmutableList.of(), false); +- worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); +- this.levels.put(resourcekey1, serverlevel1); - } - } - -- worldborder.m_61931_(serverleveldata.m_5813_()); +- worldborder.applySettings(serverleveldata.getWorldBorder()); - } - -- private static void m_177896_(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) { +- private static void setInitialSpawn(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) { - if (p_177900_) { -- p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F); +- p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); - } else { -- ChunkGenerator chunkgenerator = p_177897_.m_7726_().m_8481_(); -- ChunkPos chunkpos = new ChunkPos(chunkgenerator.m_183403_().m_183230_()); -- int i = chunkgenerator.m_142051_(p_177897_); -- if (i < p_177897_.m_141937_()) { -- BlockPos blockpos = chunkpos.m_45615_(); -- i = p_177897_.m_6924_(Heightmap.Types.WORLD_SURFACE, blockpos.m_123341_() + 8, blockpos.m_123343_() + 8); +- ChunkGenerator chunkgenerator = p_177897_.getChunkSource().getGenerator(); +- ChunkPos chunkpos = new ChunkPos(chunkgenerator.climateSampler().findSpawnPosition()); +- int i = chunkgenerator.getSpawnHeight(p_177897_); +- if (i < p_177897_.getMinBuildHeight()) { +- BlockPos blockpos = chunkpos.getWorldPosition(); +- i = p_177897_.getHeight(Heightmap.Types.WORLD_SURFACE, blockpos.getX() + 8, blockpos.getZ() + 8); - } - -- p_177898_.m_7250_(chunkpos.m_45615_().m_142082_(8, i, 8), 0.0F); +- p_177898_.setSpawn(chunkpos.getWorldPosition().offset(8, i, 8), 0.0F); - int k1 = 0; - int j = 0; - int k = 0; - int l = -1; - int i1 = 5; - -- for(int j1 = 0; j1 < Mth.m_144944_(11); ++j1) { +- for(int j1 = 0; j1 < Mth.square(11); ++j1) { - if (k1 >= -5 && k1 <= 5 && j >= -5 && j <= 5) { -- BlockPos blockpos1 = PlayerRespawnLogic.m_183932_(p_177897_, new ChunkPos(chunkpos.f_45578_ + k1, chunkpos.f_45579_ + j)); +- BlockPos blockpos1 = PlayerRespawnLogic.getSpawnPosInChunk(p_177897_, new ChunkPos(chunkpos.x + k1, chunkpos.z + j)); - if (blockpos1 != null) { -- p_177898_.m_7250_(blockpos1, 0.0F); +- p_177898_.setSpawn(blockpos1, 0.0F); - break; - } - } @@ -575,287 +575,287 @@ - } - - if (p_177899_) { -- ConfiguredFeature configuredfeature = MiscOverworldFeatures.f_195021_.m_203334_(); -- configuredfeature.m_65385_(p_177897_, chunkgenerator, p_177897_.f_46441_, new BlockPos(p_177898_.m_6789_(), p_177898_.m_6527_(), p_177898_.m_6526_())); +- ConfiguredFeature configuredfeature = MiscOverworldFeatures.BONUS_CHEST.value(); +- configuredfeature.place(p_177897_, chunkgenerator, p_177897_.random, new BlockPos(p_177898_.getXSpawn(), p_177898_.getYSpawn(), p_177898_.getZSpawn())); - } - - } - } - -- private void m_129847_(WorldData p_129848_) { -- p_129848_.m_6166_(Difficulty.PEACEFUL); -- p_129848_.m_5560_(true); -- ServerLevelData serverleveldata = p_129848_.m_5996_(); -- serverleveldata.m_5565_(false); -- serverleveldata.m_5557_(false); -- serverleveldata.m_6393_(1000000000); -- serverleveldata.m_6247_(6000L); -- serverleveldata.m_5458_(GameType.SPECTATOR); -- } -- -- public void m_129940_(ChunkProgressListener p_129941_) { -- ServerLevel serverlevel = this.m_129783_(); -- f_129750_.info("Preparing start region for dimension {}", (Object)serverlevel.m_46472_().m_135782_()); -- BlockPos blockpos = serverlevel.m_8900_(); -- p_129941_.m_7647_(new ChunkPos(blockpos)); -- ServerChunkCache serverchunkcache = serverlevel.m_7726_(); -- serverchunkcache.m_7827_().m_9310_(500); -- this.f_129726_ = Util.m_137550_(); -- serverchunkcache.m_8387_(TicketType.f_9442_, new ChunkPos(blockpos), 11, Unit.INSTANCE); -- -- while(serverchunkcache.m_8427_() != 441) { -- this.f_129726_ = Util.m_137550_() + 10L; -- this.m_130012_(); +- private void setupDebugLevel(WorldData p_129848_) { +- p_129848_.setDifficulty(Difficulty.PEACEFUL); +- p_129848_.setDifficultyLocked(true); +- ServerLevelData serverleveldata = p_129848_.overworldData(); +- serverleveldata.setRaining(false); +- serverleveldata.setThundering(false); +- serverleveldata.setClearWeatherTime(1000000000); +- serverleveldata.setDayTime(6000L); +- serverleveldata.setGameType(GameType.SPECTATOR); +- } +- +- public void prepareLevels(ChunkProgressListener p_129941_) { +- ServerLevel serverlevel = this.overworld(); +- LOGGER.info("Preparing start region for dimension {}", (Object)serverlevel.dimension().location()); +- BlockPos blockpos = serverlevel.getSharedSpawnPos(); +- p_129941_.updateSpawnPos(new ChunkPos(blockpos)); +- ServerChunkCache serverchunkcache = serverlevel.getChunkSource(); +- serverchunkcache.getLightEngine().setTaskPerBatch(500); +- this.nextTickTime = Util.getMillis(); +- serverchunkcache.addRegionTicket(TicketType.START, new ChunkPos(blockpos), 11, Unit.INSTANCE); +- +- while(serverchunkcache.getTickingGenerated() != 441) { +- this.nextTickTime = Util.getMillis() + 10L; +- this.waitUntilNextTick(); - } - -- this.f_129726_ = Util.m_137550_() + 10L; -- this.m_130012_(); +- this.nextTickTime = Util.getMillis() + 10L; +- this.waitUntilNextTick(); - -- for(ServerLevel serverlevel1 : this.f_129762_.values()) { -- ForcedChunksSavedData forcedchunkssaveddata = serverlevel1.m_8895_().m_164858_(ForcedChunksSavedData::m_151483_, "chunks"); +- for(ServerLevel serverlevel1 : this.levels.values()) { +- ForcedChunksSavedData forcedchunkssaveddata = serverlevel1.getDataStorage().get(ForcedChunksSavedData::load, "chunks"); - if (forcedchunkssaveddata != null) { -- LongIterator longiterator = forcedchunkssaveddata.m_46116_().iterator(); +- LongIterator longiterator = forcedchunkssaveddata.getChunks().iterator(); - - while(longiterator.hasNext()) { - long i = longiterator.nextLong(); - ChunkPos chunkpos = new ChunkPos(i); -- serverlevel1.m_7726_().m_6692_(chunkpos, true); +- serverlevel1.getChunkSource().updateChunkForced(chunkpos, true); - } - } - } - -- this.f_129726_ = Util.m_137550_() + 10L; -- this.m_130012_(); -- p_129941_.m_7646_(); -- serverchunkcache.m_7827_().m_9310_(5); -- this.m_129962_(); +- this.nextTickTime = Util.getMillis() + 10L; +- this.waitUntilNextTick(); +- p_129941_.stop(); +- serverchunkcache.getLightEngine().setTaskPerBatch(5); +- this.updateMobSpawningFlags(); - } - -- protected void m_130007_() { -- File file1 = this.f_129744_.m_78283_(LevelResource.f_78181_).toFile(); +- protected void detectBundledResources() { +- File file1 = this.storageSource.getLevelPath(LevelResource.MAP_RESOURCE_FILE).toFile(); - if (file1.isFile()) { -- String s = this.f_129744_.m_78277_(); +- String s = this.storageSource.getLevelId(); - - try { -- this.m_129853_("level://" + URLEncoder.encode(s, StandardCharsets.UTF_8.toString()) + "/resources.zip", ""); +- this.setResourcePack("level://" + URLEncoder.encode(s, StandardCharsets.UTF_8.toString()) + "/resources.zip", ""); - } catch (UnsupportedEncodingException unsupportedencodingexception) { -- f_129750_.warn("Something went wrong url encoding {}", (Object)s); +- LOGGER.warn("Something went wrong url encoding {}", (Object)s); - } - } - - } - -- public GameType m_130008_() { -- return this.f_129749_.m_5464_(); +- public GameType getDefaultGameType() { +- return this.worldData.getGameType(); - } - -- public boolean m_7035_() { -- return this.f_129749_.m_5466_(); +- public boolean isHardcore() { +- return this.worldData.isHardcore(); - } - -- public abstract int m_7022_(); +- public abstract int getOperatorUserPermissionLevel(); - -- public abstract int m_7034_(); +- public abstract int getFunctionCompilationLevel(); - -- public abstract boolean m_6983_(); +- public abstract boolean shouldRconBroadcast(); - -- public boolean m_129885_(boolean p_129886_, boolean p_129887_, boolean p_129888_) { +- public boolean saveAllChunks(boolean p_129886_, boolean p_129887_, boolean p_129888_) { - boolean flag = false; - -- for(ServerLevel serverlevel : this.m_129785_()) { +- for(ServerLevel serverlevel : this.getAllLevels()) { - if (!p_129886_) { -- f_129750_.info("Saving chunks for level '{}'/{}", serverlevel, serverlevel.m_46472_().m_135782_()); +- LOGGER.info("Saving chunks for level '{}'/{}", serverlevel, serverlevel.dimension().location()); - } - -- serverlevel.m_8643_((ProgressListener)null, p_129887_, serverlevel.f_8564_ && !p_129888_); +- serverlevel.save((ProgressListener)null, p_129887_, serverlevel.noSave && !p_129888_); - flag = true; - } - -- ServerLevel serverlevel2 = this.m_129783_(); -- ServerLevelData serverleveldata = this.f_129749_.m_5996_(); -- serverleveldata.m_7831_(serverlevel2.m_6857_().m_61970_()); -- this.f_129749_.m_5917_(this.m_129901_().m_136307_()); -- this.f_129744_.m_78290_(this.m_206579_(), this.f_129749_, this.m_6846_().m_6960_()); +- ServerLevel serverlevel2 = this.overworld(); +- ServerLevelData serverleveldata = this.worldData.overworldData(); +- serverleveldata.setWorldBorder(serverlevel2.getWorldBorder().createSettings()); +- this.worldData.setCustomBossEvents(this.getCustomBossEvents().save()); +- this.storageSource.saveDataTag(this.registryAccess(), this.worldData, this.getPlayerList().getSingleplayerData()); - if (p_129887_) { -- for(ServerLevel serverlevel1 : this.m_129785_()) { -- f_129750_.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", (Object)serverlevel1.m_7726_().f_8325_.m_182285_()); +- for(ServerLevel serverlevel1 : this.getAllLevels()) { +- LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", (Object)serverlevel1.getChunkSource().chunkMap.getStorageName()); - } - -- f_129750_.info("ThreadedAnvilChunkStorage: All dimensions are saved"); +- LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved"); - } - - return flag; - } - -- public boolean m_195514_(boolean p_195515_, boolean p_195516_, boolean p_195517_) { +- public boolean saveEverything(boolean p_195515_, boolean p_195516_, boolean p_195517_) { - boolean flag; - try { -- this.f_195494_ = true; -- this.m_6846_().m_11302_(); -- flag = this.m_129885_(p_195515_, p_195516_, p_195517_); +- this.isSaving = true; +- this.getPlayerList().saveAll(); +- flag = this.saveAllChunks(p_195515_, p_195516_, p_195517_); - } finally { -- this.f_195494_ = false; +- this.isSaving = false; - } - - return flag; - } - - public void close() { -- this.m_7041_(); +- this.stopServer(); - } - -- public void m_7041_() { -- f_129750_.info("Stopping server"); -- if (this.m_129919_() != null) { -- this.m_129919_().m_9718_(); +- public void stopServer() { +- LOGGER.info("Stopping server"); +- if (this.getConnection() != null) { +- this.getConnection().stop(); - } - -- this.f_195494_ = true; -- if (this.f_129763_ != null) { -- f_129750_.info("Saving players"); -- this.f_129763_.m_11302_(); -- this.f_129763_.m_11313_(); +- this.isSaving = true; +- if (this.playerList != null) { +- LOGGER.info("Saving players"); +- this.playerList.saveAll(); +- this.playerList.removeAll(); - } - -- f_129750_.info("Saving worlds"); +- LOGGER.info("Saving worlds"); - -- for(ServerLevel serverlevel : this.m_129785_()) { +- for(ServerLevel serverlevel : this.getAllLevels()) { - if (serverlevel != null) { -- serverlevel.f_8564_ = false; +- serverlevel.noSave = false; - } - } - -- while(this.f_129762_.values().stream().anyMatch((p_202480_) -> { -- return p_202480_.m_7726_().f_8325_.m_201907_(); +- while(this.levels.values().stream().anyMatch((p_202480_) -> { +- return p_202480_.getChunkSource().chunkMap.hasWork(); - })) { -- this.f_129726_ = Util.m_137550_() + 1L; +- this.nextTickTime = Util.getMillis() + 1L; - -- for(ServerLevel serverlevel1 : this.m_129785_()) { -- serverlevel1.m_7726_().m_201915_(); -- serverlevel1.m_7726_().m_201698_(() -> { +- for(ServerLevel serverlevel1 : this.getAllLevels()) { +- serverlevel1.getChunkSource().removeTicketsOnClosing(); +- serverlevel1.getChunkSource().tick(() -> { - return true; - }, false); - } - -- this.m_130012_(); +- this.waitUntilNextTick(); - } - -- this.m_129885_(false, true, false); +- this.saveAllChunks(false, true, false); - -- for(ServerLevel serverlevel2 : this.m_129785_()) { +- for(ServerLevel serverlevel2 : this.getAllLevels()) { - if (serverlevel2 != null) { - try { - serverlevel2.close(); - } catch (IOException ioexception1) { -- f_129750_.error("Exception closing the level", (Throwable)ioexception1); +- LOGGER.error("Exception closing the level", (Throwable)ioexception1); - } - } - } - -- this.f_195494_ = false; -- this.f_129740_.close(); +- this.isSaving = false; +- this.resources.close(); - - try { -- this.f_129744_.close(); +- this.storageSource.close(); - } catch (IOException ioexception) { -- f_129750_.error("Failed to unlock level {}", this.f_129744_.m_78277_(), ioexception); +- LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception); - } - - } - -- public String m_130009_() { -- return this.f_129760_; +- public String getLocalIp() { +- return this.localIp; - } - -- public void m_129913_(String p_129914_) { -- this.f_129760_ = p_129914_; +- public void setLocalIp(String p_129914_) { +- this.localIp = p_129914_; - } - -- public boolean m_130010_() { -- return this.f_129764_; +- public boolean isRunning() { +- return this.running; - } - -- public void m_7570_(boolean p_129884_) { -- this.f_129764_ = false; +- public void halt(boolean p_129884_) { +- this.running = false; - if (p_129884_) { - try { -- this.f_129725_.join(); +- this.serverThread.join(); - } catch (InterruptedException interruptedexception) { -- f_129750_.error("Error while shutting down", (Throwable)interruptedexception); +- LOGGER.error("Error while shutting down", (Throwable)interruptedexception); - } - } - - } - -- protected void m_130011_() { +- protected void runServer() { - try { -- if (this.m_7038_()) { -- this.f_129726_ = Util.m_137550_(); -- this.f_129757_.m_134908_(new TextComponent(this.f_129709_)); -- this.f_129757_.m_134912_(new ServerStatus.Version(SharedConstants.m_183709_().getName(), SharedConstants.m_183709_().getProtocolVersion())); -- this.m_129878_(this.f_129757_); -- -- while(this.f_129764_) { -- long i = Util.m_137550_() - this.f_129726_; -- if (i > 2000L && this.f_129726_ - this.f_129718_ >= 15000L) { +- if (this.initServer()) { +- this.nextTickTime = Util.getMillis(); +- this.status.setDescription(new TextComponent(this.motd)); +- this.status.setVersion(new ServerStatus.Version(SharedConstants.getCurrentVersion().getName(), SharedConstants.getCurrentVersion().getProtocolVersion())); +- this.updateStatusIcon(this.status); +- +- while(this.running) { +- long i = Util.getMillis() - this.nextTickTime; +- if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) { - long j = i / 50L; -- f_129750_.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); -- this.f_129726_ += j * 50L; -- this.f_129718_ = this.f_129726_; +- LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); +- this.nextTickTime += j * 50L; +- this.lastOverloadWarning = this.nextTickTime; - } - -- if (this.f_177877_) { -- this.f_177877_ = false; -- this.f_177876_ = new MinecraftServer.TimeProfiler(Util.m_137569_(), this.f_129766_); +- if (this.debugCommandProfilerDelayStart) { +- this.debugCommandProfilerDelayStart = false; +- this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); - } - -- this.f_129726_ += 50L; -- this.m_177945_(); -- this.f_129754_.m_6180_("tick"); -- this.m_5705_(this::m_129960_); -- this.f_129754_.m_6182_("nextTickWait"); -- this.f_129728_ = true; -- this.f_129727_ = Math.max(Util.m_137550_() + 50L, this.f_129726_); -- this.m_130012_(); -- this.f_129754_.m_7238_(); -- this.m_177946_(); -- this.f_129717_ = true; -- JvmProfiler.f_185340_.m_183597_(this.f_129737_); +- this.nextTickTime += 50L; +- this.startMetricsRecordingTick(); +- this.profiler.push("tick"); +- this.tickServer(this::haveTime); +- this.profiler.popPush("nextTickWait"); +- this.mayHaveDelayedTasks = true; +- this.delayedTasksMaxNextTickTime = Math.max(Util.getMillis() + 50L, this.nextTickTime); +- this.waitUntilNextTick(); +- this.profiler.pop(); +- this.endMetricsRecordingTick(); +- this.isReady = true; +- JvmProfiler.INSTANCE.onServerTick(this.averageTickTime); - } - } else { -- this.m_7268_((CrashReport)null); +- this.onServerCrash((CrashReport)null); - } - } catch (Throwable throwable1) { -- f_129750_.error("Encountered an unexpected exception", throwable1); -- CrashReport crashreport = m_206568_(throwable1); -- this.m_177935_(crashreport.m_178626_()); -- File file1 = new File(new File(this.m_6237_(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); -- if (crashreport.m_127512_(file1)) { -- f_129750_.error("This crash report has been saved to: {}", (Object)file1.getAbsolutePath()); +- LOGGER.error("Encountered an unexpected exception", throwable1); +- CrashReport crashreport = constructOrExtractCrashReport(throwable1); +- this.fillSystemReport(crashreport.getSystemReport()); +- File file1 = new File(new File(this.getServerDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); +- if (crashreport.saveToFile(file1)) { +- LOGGER.error("This crash report has been saved to: {}", (Object)file1.getAbsolutePath()); - } else { -- f_129750_.error("We were unable to save this crash report to disk."); +- LOGGER.error("We were unable to save this crash report to disk."); - } - -- this.m_7268_(crashreport); +- this.onServerCrash(crashreport); - } finally { - try { -- this.f_129765_ = true; -- this.m_7041_(); +- this.stopped = true; +- this.stopServer(); - } catch (Throwable throwable) { -- f_129750_.error("Exception stopping the server", throwable); +- LOGGER.error("Exception stopping the server", throwable); - } finally { -- if (this.f_129723_ != null) { -- this.f_129723_.m_196559_(); +- if (this.profileCache != null) { +- this.profileCache.clearExecutor(); - } - -- this.m_6988_(); +- this.onServerExit(); - } - - } - - } - -- private static CrashReport m_206568_(Throwable p_206569_) { +- private static CrashReport constructOrExtractCrashReport(Throwable p_206569_) { - ReportedException reportedexception = null; - - for(Throwable throwable = p_206569_; throwable != null; throwable = throwable.getCause()) { @@ -867,9 +867,9 @@ - - CrashReport crashreport; - if (reportedexception != null) { -- crashreport = reportedexception.m_134761_(); +- crashreport = reportedexception.getReport(); - if (reportedexception != p_206569_) { -- crashreport.m_127514_("Wrapped in").m_128162_("Wrapping exception", p_206569_); +- crashreport.addCategory("Wrapped in").setDetailError("Wrapping exception", p_206569_); - } - } else { - crashreport = new CrashReport("Exception in server tick loop", p_206569_); @@ -878,38 +878,38 @@ - return crashreport; - } - -- private boolean m_129960_() { -- return this.m_18767_() || Util.m_137550_() < (this.f_129728_ ? this.f_129727_ : this.f_129726_); +- private boolean haveTime() { +- return this.runningTask() || Util.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); - } - -- protected void m_130012_() { -- this.m_18699_(); -- this.m_18701_(() -> { -- return !this.m_129960_(); +- protected void waitUntilNextTick() { +- this.runAllTasks(); +- this.managedBlock(() -> { +- return !this.haveTime(); - }); - } - -- protected TickTask m_6681_(Runnable p_129852_) { -- return new TickTask(this.f_129766_, p_129852_); +- protected TickTask wrapRunnable(Runnable p_129852_) { +- return new TickTask(this.tickCount, p_129852_); - } - -- protected boolean m_6362_(TickTask p_129883_) { -- return p_129883_.m_136254_() + 3 < this.f_129766_ || this.m_129960_(); +- protected boolean shouldRun(TickTask p_129883_) { +- return p_129883_.getTick() + 3 < this.tickCount || this.haveTime(); - } - -- public boolean m_7245_() { -- boolean flag = this.m_129961_(); -- this.f_129728_ = flag; +- public boolean pollTask() { +- boolean flag = this.pollTaskInternal(); +- this.mayHaveDelayedTasks = flag; - return flag; - } - -- private boolean m_129961_() { -- if (super.m_7245_()) { +- private boolean pollTaskInternal() { +- if (super.pollTask()) { - return true; - } else { -- if (this.m_129960_()) { -- for(ServerLevel serverlevel : this.m_129785_()) { -- if (serverlevel.m_7726_().m_8466_()) { +- if (this.haveTime()) { +- for(ServerLevel serverlevel : this.getAllLevels()) { +- if (serverlevel.getChunkSource().pollTask()) { - return true; - } - } @@ -919,15 +919,15 @@ - } - } - -- public void m_6367_(TickTask p_129957_) { -- this.m_129905_().m_6174_("runTask"); -- super.m_6367_(p_129957_); +- public void doRunTask(TickTask p_129957_) { +- this.getProfiler().incrementCounter("runTask"); +- super.doRunTask(p_129957_); - } - -- private void m_129878_(ServerStatus p_129879_) { -- Optional optional = Optional.of(this.m_129971_("server-icon.png")).filter(File::isFile); +- private void updateStatusIcon(ServerStatus p_129879_) { +- Optional optional = Optional.of(this.getFile("server-icon.png")).filter(File::isFile); - if (!optional.isPresent()) { -- optional = this.f_129744_.m_182514_().map(Path::toFile).filter(File::isFile); +- optional = this.storageSource.getIconFile().map(Path::toFile).filter(File::isFile); - } - - optional.ifPresent((p_202470_) -> { @@ -938,503 +938,503 @@ - ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); - ImageIO.write(bufferedimage, "PNG", bytearrayoutputstream); - byte[] abyte = Base64.getEncoder().encode(bytearrayoutputstream.toByteArray()); -- p_129879_.m_134906_("data:image/png;base64," + new String(abyte, StandardCharsets.UTF_8)); +- p_129879_.setFavicon("data:image/png;base64," + new String(abyte, StandardCharsets.UTF_8)); - } catch (Exception exception) { -- f_129750_.error("Couldn't load server icon", (Throwable)exception); +- LOGGER.error("Couldn't load server icon", (Throwable)exception); - } - - }); - } - -- public Optional m_182649_() { -- return this.f_129744_.m_182514_(); +- public Optional getWorldScreenshotFile() { +- return this.storageSource.getIconFile(); - } - -- public File m_6237_() { +- public File getServerDirectory() { - return new File("."); - } - -- protected void m_7268_(CrashReport p_129874_) { +- protected void onServerCrash(CrashReport p_129874_) { - } - -- public void m_6988_() { +- public void onServerExit() { - } - -- public void m_5705_(BooleanSupplier p_129871_) { -- long i = Util.m_137569_(); -- ++this.f_129766_; -- this.m_5703_(p_129871_); -- if (i - this.f_129724_ >= 5000000000L) { -- this.f_129724_ = i; -- this.f_129757_.m_134910_(new ServerStatus.Players(this.m_7418_(), this.m_7416_())); -- if (!this.m_183306_()) { -- GameProfile[] agameprofile = new GameProfile[Math.min(this.m_7416_(), 12)]; -- int j = Mth.m_14072_(this.f_129758_, 0, this.m_7416_() - agameprofile.length); +- public void tickServer(BooleanSupplier p_129871_) { +- long i = Util.getNanos(); +- ++this.tickCount; +- this.tickChildren(p_129871_); +- if (i - this.lastServerStatus >= 5000000000L) { +- this.lastServerStatus = i; +- this.status.setPlayers(new ServerStatus.Players(this.getMaxPlayers(), this.getPlayerCount())); +- if (!this.hidesOnlinePlayers()) { +- GameProfile[] agameprofile = new GameProfile[Math.min(this.getPlayerCount(), 12)]; +- int j = Mth.nextInt(this.random, 0, this.getPlayerCount() - agameprofile.length); - - for(int k = 0; k < agameprofile.length; ++k) { -- ServerPlayer serverplayer = this.f_129763_.m_11314_().get(j + k); -- if (serverplayer.m_184128_()) { -- agameprofile[k] = serverplayer.m_36316_(); +- ServerPlayer serverplayer = this.playerList.getPlayers().get(j + k); +- if (serverplayer.allowsListing()) { +- agameprofile[k] = serverplayer.getGameProfile(); - } else { -- agameprofile[k] = f_195496_; +- agameprofile[k] = ANONYMOUS_PLAYER_PROFILE; - } - } - - Collections.shuffle(Arrays.asList(agameprofile)); -- this.f_129757_.m_134914_().m_134924_(agameprofile); +- this.status.getPlayers().setSample(agameprofile); - } - } - -- if (this.f_129766_ % 6000 == 0) { -- f_129750_.debug("Autosave started"); -- this.f_129754_.m_6180_("save"); -- this.m_195514_(true, false, false); -- this.f_129754_.m_7238_(); -- f_129750_.debug("Autosave finished"); +- if (this.tickCount % 6000 == 0) { +- LOGGER.debug("Autosave started"); +- this.profiler.push("save"); +- this.saveEverything(true, false, false); +- this.profiler.pop(); +- LOGGER.debug("Autosave finished"); - } - -- this.f_129754_.m_6180_("tallying"); -- long l = this.f_129748_[this.f_129766_ % 100] = Util.m_137569_() - i; -- this.f_129737_ = this.f_129737_ * 0.8F + (float)l / 1000000.0F * 0.19999999F; -- long i1 = Util.m_137569_(); -- this.f_129735_.m_13755_(i1 - i); -- this.f_129754_.m_7238_(); +- this.profiler.push("tallying"); +- long l = this.tickTimes[this.tickCount % 100] = Util.getNanos() - i; +- this.averageTickTime = this.averageTickTime * 0.8F + (float)l / 1000000.0F * 0.19999999F; +- long i1 = Util.getNanos(); +- this.frameTimer.logFrameDuration(i1 - i); +- this.profiler.pop(); - } - -- public void m_5703_(BooleanSupplier p_129954_) { -- this.f_129754_.m_6180_("commandFunctions"); -- this.m_129890_().m_136128_(); -- this.f_129754_.m_6182_("levels"); +- public void tickChildren(BooleanSupplier p_129954_) { +- this.profiler.push("commandFunctions"); +- this.getFunctions().tick(); +- this.profiler.popPush("levels"); - -- for(ServerLevel serverlevel : this.m_129785_()) { -- this.f_129754_.m_6521_(() -> { -- return serverlevel + " " + serverlevel.m_46472_().m_135782_(); +- for(ServerLevel serverlevel : this.getAllLevels()) { +- this.profiler.push(() -> { +- return serverlevel + " " + serverlevel.dimension().location(); - }); -- if (this.f_129766_ % 20 == 0) { -- this.f_129754_.m_6180_("timeSync"); -- this.f_129763_.m_11270_(new ClientboundSetTimePacket(serverlevel.m_46467_(), serverlevel.m_46468_(), serverlevel.m_46469_().m_46207_(GameRules.f_46140_)), serverlevel.m_46472_()); -- this.f_129754_.m_7238_(); +- if (this.tickCount % 20 == 0) { +- this.profiler.push("timeSync"); +- this.playerList.broadcastAll(new ClientboundSetTimePacket(serverlevel.getGameTime(), serverlevel.getDayTime(), serverlevel.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)), serverlevel.dimension()); +- this.profiler.pop(); - } - -- this.f_129754_.m_6180_("tick"); +- this.profiler.push("tick"); - - try { -- serverlevel.m_8793_(p_129954_); +- serverlevel.tick(p_129954_); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Exception ticking world"); -- serverlevel.m_6026_(crashreport); +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); +- serverlevel.fillReportDetails(crashreport); - throw new ReportedException(crashreport); - } - -- this.f_129754_.m_7238_(); -- this.f_129754_.m_7238_(); +- this.profiler.pop(); +- this.profiler.pop(); - } - -- this.f_129754_.m_6182_("connection"); -- this.m_129919_().m_9721_(); -- this.f_129754_.m_6182_("players"); -- this.f_129763_.m_11288_(); -- if (SharedConstants.f_136183_) { -- GameTestTicker.f_177648_.m_127790_(); +- this.profiler.popPush("connection"); +- this.getConnection().tick(); +- this.profiler.popPush("players"); +- this.playerList.tick(); +- if (SharedConstants.IS_RUNNING_IN_IDE) { +- GameTestTicker.SINGLETON.tick(); - } - -- this.f_129754_.m_6182_("server gui refresh"); +- this.profiler.popPush("server gui refresh"); - -- for(int i = 0; i < this.f_129752_.size(); ++i) { -- this.f_129752_.get(i).run(); +- for(int i = 0; i < this.tickables.size(); ++i) { +- this.tickables.get(i).run(); - } - -- this.f_129754_.m_7238_(); +- this.profiler.pop(); - } - -- public boolean m_7079_() { +- public boolean isNetherEnabled() { - return true; - } - -- public void m_129946_(Runnable p_129947_) { -- this.f_129752_.add(p_129947_); +- public void addTickable(Runnable p_129947_) { +- this.tickables.add(p_129947_); - } - -- protected void m_129948_(String p_129949_) { -- this.f_129739_ = p_129949_; +- protected void setId(String p_129949_) { +- this.serverId = p_129949_; - } - -- public boolean m_129782_() { -- return !this.f_129725_.isAlive(); +- public boolean isShutdown() { +- return !this.serverThread.isAlive(); - } - -- public File m_129971_(String p_129972_) { -- return new File(this.m_6237_(), p_129972_); +- public File getFile(String p_129972_) { +- return new File(this.getServerDirectory(), p_129972_); - } - -- public final ServerLevel m_129783_() { -- return this.f_129762_.get(Level.f_46428_); +- public final ServerLevel overworld() { +- return this.levels.get(Level.OVERWORLD); - } - - @Nullable -- public ServerLevel m_129880_(ResourceKey p_129881_) { -- return this.f_129762_.get(p_129881_); +- public ServerLevel getLevel(ResourceKey p_129881_) { +- return this.levels.get(p_129881_); - } - -- public Set> m_129784_() { -- return this.f_129762_.keySet(); +- public Set> levelKeys() { +- return this.levels.keySet(); - } - -- public Iterable m_129785_() { -- return this.f_129762_.values(); +- public Iterable getAllLevels() { +- return this.levels.values(); - } - -- public String m_7630_() { -- return SharedConstants.m_183709_().getName(); +- public String getServerVersion() { +- return SharedConstants.getCurrentVersion().getName(); - } - -- public int m_7416_() { -- return this.f_129763_.m_11309_(); +- public int getPlayerCount() { +- return this.playerList.getPlayerCount(); - } - -- public int m_7418_() { -- return this.f_129763_.m_11310_(); +- public int getMaxPlayers() { +- return this.playerList.getMaxPlayers(); - } - -- public String[] m_7641_() { -- return this.f_129763_.m_11291_(); +- public String[] getPlayerNames() { +- return this.playerList.getPlayerNamesArray(); - } - - @DontObfuscate -- public String m_130001_() { +- public String getServerModName() { - return "vanilla"; - } - -- public SystemReport m_177935_(SystemReport p_177936_) { -- p_177936_.m_143522_("Server Running", () -> { -- return Boolean.toString(this.f_129764_); +- public SystemReport fillSystemReport(SystemReport p_177936_) { +- p_177936_.setDetail("Server Running", () -> { +- return Boolean.toString(this.running); - }); -- if (this.f_129763_ != null) { -- p_177936_.m_143522_("Player Count", () -> { -- return this.f_129763_.m_11309_() + " / " + this.f_129763_.m_11310_() + "; " + this.f_129763_.m_11314_(); +- if (this.playerList != null) { +- p_177936_.setDetail("Player Count", () -> { +- return this.playerList.getPlayerCount() + " / " + this.playerList.getMaxPlayers() + "; " + this.playerList.getPlayers(); - }); - } - -- p_177936_.m_143522_("Data Packs", () -> { +- p_177936_.setDetail("Data Packs", () -> { - StringBuilder stringbuilder = new StringBuilder(); - -- for(Pack pack : this.f_129730_.m_10524_()) { +- for(Pack pack : this.packRepository.getSelectedPacks()) { - if (stringbuilder.length() > 0) { - stringbuilder.append(", "); - } - -- stringbuilder.append(pack.m_10446_()); -- if (!pack.m_10443_().m_10489_()) { +- stringbuilder.append(pack.getId()); +- if (!pack.getCompatibility().isCompatible()) { - stringbuilder.append(" (incompatible)"); - } - } - - return stringbuilder.toString(); - }); -- p_177936_.m_143522_("World Generation", () -> { -- return this.f_129749_.m_5754_().toString(); +- p_177936_.setDetail("World Generation", () -> { +- return this.worldData.worldGenSettingsLifecycle().toString(); - }); -- if (this.f_129739_ != null) { -- p_177936_.m_143522_("Server Id", () -> { -- return this.f_129739_; +- if (this.serverId != null) { +- p_177936_.setDetail("Server Id", () -> { +- return this.serverId; - }); - } - -- return this.m_142424_(p_177936_); +- return this.fillServerSystemReport(p_177936_); - } - -- public abstract SystemReport m_142424_(SystemReport p_177901_); +- public abstract SystemReport fillServerSystemReport(SystemReport p_177901_); - -- public ModCheck m_183471_() { -- return ModCheck.m_184600_("vanilla", this::m_130001_, "Server", MinecraftServer.class); +- public ModCheck getModdedStatus() { +- return ModCheck.identify("vanilla", this::getServerModName, "Server", MinecraftServer.class); - } - -- public void m_6352_(Component p_129876_, UUID p_129877_) { -- f_129750_.info(p_129876_.getString()); +- public void sendMessage(Component p_129876_, UUID p_129877_) { +- LOGGER.info(p_129876_.getString()); - } - -- public KeyPair m_129790_() { -- return this.f_129712_; +- public KeyPair getKeyPair() { +- return this.keyPair; - } - -- public int m_7010_() { -- return this.f_129761_; +- public int getPort() { +- return this.port; - } - -- public void m_129801_(int p_129802_) { -- this.f_129761_ = p_129802_; +- public void setPort(int p_129802_) { +- this.port = p_129802_; - } - -- public String m_129791_() { -- return this.f_129713_; +- public String getSingleplayerName() { +- return this.singleplayerName; - } - -- public void m_129981_(String p_129982_) { -- this.f_129713_ = p_129982_; +- public void setSingleplayerName(String p_129982_) { +- this.singleplayerName = p_129982_; - } - -- public boolean m_129792_() { -- return this.f_129713_ != null; +- public boolean isSingleplayer() { +- return this.singleplayerName != null; - } - -- protected void m_129793_() { -- f_129750_.info("Generating keypair"); +- protected void initializeKeyPair() { +- LOGGER.info("Generating keypair"); - - try { -- this.f_129712_ = Crypt.m_13604_(); +- this.keyPair = Crypt.generateKeyPair(); - } catch (CryptException cryptexception) { - throw new IllegalStateException("Failed to generate key pair", cryptexception); - } - } - -- public void m_129827_(Difficulty p_129828_, boolean p_129829_) { -- if (p_129829_ || !this.f_129749_.m_5474_()) { -- this.f_129749_.m_6166_(this.f_129749_.m_5466_() ? Difficulty.HARD : p_129828_); -- this.m_129962_(); -- this.m_6846_().m_11314_().forEach(this::m_129938_); +- public void setDifficulty(Difficulty p_129828_, boolean p_129829_) { +- if (p_129829_ || !this.worldData.isDifficultyLocked()) { +- this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : p_129828_); +- this.updateMobSpawningFlags(); +- this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); - } - } - -- public int m_7186_(int p_129935_) { +- public int getScaledTrackingDistance(int p_129935_) { - return p_129935_; - } - -- private void m_129962_() { -- for(ServerLevel serverlevel : this.m_129785_()) { -- serverlevel.m_46703_(this.m_7004_(), this.m_6998_()); +- private void updateMobSpawningFlags() { +- for(ServerLevel serverlevel : this.getAllLevels()) { +- serverlevel.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); - } - - } - -- public void m_129958_(boolean p_129959_) { -- this.f_129749_.m_5560_(p_129959_); -- this.m_6846_().m_11314_().forEach(this::m_129938_); +- public void setDifficultyLocked(boolean p_129959_) { +- this.worldData.setDifficultyLocked(p_129959_); +- this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); - } - -- private void m_129938_(ServerPlayer p_129939_) { -- LevelData leveldata = p_129939_.m_183503_().m_6106_(); -- p_129939_.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); +- private void sendDifficultyUpdate(ServerPlayer p_129939_) { +- LevelData leveldata = p_129939_.getLevel().getLevelData(); +- p_129939_.connection.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); - } - -- public boolean m_7004_() { -- return this.f_129749_.m_5472_() != Difficulty.PEACEFUL; +- public boolean isSpawningMonsters() { +- return this.worldData.getDifficulty() != Difficulty.PEACEFUL; - } - -- public boolean m_129794_() { -- return this.f_129714_; +- public boolean isDemo() { +- return this.isDemo; - } - -- public void m_129975_(boolean p_129976_) { -- this.f_129714_ = p_129976_; +- public void setDemo(boolean p_129976_) { +- this.isDemo = p_129976_; - } - -- public String m_129795_() { -- return this.f_129715_; +- public String getResourcePack() { +- return this.resourcePack; - } - -- public String m_129796_() { -- return this.f_129716_; +- public String getResourcePackHash() { +- return this.resourcePackHash; - } - -- public void m_129853_(String p_129854_, String p_129855_) { -- this.f_129715_ = p_129854_; -- this.f_129716_ = p_129855_; +- public void setResourcePack(String p_129854_, String p_129855_) { +- this.resourcePack = p_129854_; +- this.resourcePackHash = p_129855_; - } - -- public abstract boolean m_6982_(); +- public abstract boolean isDedicatedServer(); - -- public abstract int m_7032_(); +- public abstract int getRateLimitPacketsPerSecond(); - -- public boolean m_129797_() { -- return this.f_129705_; +- public boolean usesAuthentication() { +- return this.onlineMode; - } - -- public void m_129985_(boolean p_129986_) { -- this.f_129705_ = p_129986_; +- public void setUsesAuthentication(boolean p_129986_) { +- this.onlineMode = p_129986_; - } - -- public boolean m_129798_() { -- return this.f_129706_; +- public boolean getPreventProxyConnections() { +- return this.preventProxyConnections; - } - -- public void m_129993_(boolean p_129994_) { -- this.f_129706_ = p_129994_; +- public void setPreventProxyConnections(boolean p_129994_) { +- this.preventProxyConnections = p_129994_; - } - -- public boolean m_6998_() { +- public boolean isSpawningAnimals() { - return true; - } - -- public boolean m_6997_() { +- public boolean areNpcsEnabled() { - return true; - } - -- public abstract boolean m_6994_(); +- public abstract boolean isEpollEnabled(); - -- public boolean m_129799_() { -- return this.f_129707_; +- public boolean isPvpAllowed() { +- return this.pvp; - } - -- public void m_129997_(boolean p_129998_) { -- this.f_129707_ = p_129998_; +- public void setPvpAllowed(boolean p_129998_) { +- this.pvp = p_129998_; - } - -- public boolean m_129915_() { -- return this.f_129708_; +- public boolean isFlightAllowed() { +- return this.allowFlight; - } - -- public void m_129999_(boolean p_130000_) { -- this.f_129708_ = p_130000_; +- public void setFlightAllowed(boolean p_130000_) { +- this.allowFlight = p_130000_; - } - -- public abstract boolean m_6993_(); +- public abstract boolean isCommandBlockEnabled(); - -- public String m_129916_() { -- return this.f_129709_; +- public String getMotd() { +- return this.motd; - } - -- public void m_129989_(String p_129990_) { -- this.f_129709_ = p_129990_; +- public void setMotd(String p_129990_) { +- this.motd = p_129990_; - } - -- public boolean m_129918_() { -- return this.f_129765_; +- public boolean isStopped() { +- return this.stopped; - } - -- public PlayerList m_6846_() { -- return this.f_129763_; +- public PlayerList getPlayerList() { +- return this.playerList; - } - -- public void m_129823_(PlayerList p_129824_) { -- this.f_129763_ = p_129824_; +- public void setPlayerList(PlayerList p_129824_) { +- this.playerList = p_129824_; - } - -- public abstract boolean m_6992_(); +- public abstract boolean isPublished(); - -- public void m_7835_(GameType p_129832_) { -- this.f_129749_.m_5458_(p_129832_); +- public void setDefaultGameType(GameType p_129832_) { +- this.worldData.setGameType(p_129832_); - } - - @Nullable -- public ServerConnectionListener m_129919_() { -- return this.f_129755_; +- public ServerConnectionListener getConnection() { +- return this.connection; - } - -- public boolean m_129920_() { -- return this.f_129717_; +- public boolean isReady() { +- return this.isReady; - } - -- public boolean m_6370_() { +- public boolean hasGui() { - return false; - } - -- public boolean m_7386_(@Nullable GameType p_129833_, boolean p_129834_, int p_129835_) { +- public boolean publishServer(@Nullable GameType p_129833_, boolean p_129834_, int p_129835_) { - return false; - } - -- public int m_129921_() { -- return this.f_129766_; +- public int getTickCount() { +- return this.tickCount; - } - -- public int m_6396_() { +- public int getSpawnProtectionRadius() { - return 16; - } - -- public boolean m_7762_(ServerLevel p_129811_, BlockPos p_129812_, Player p_129813_) { +- public boolean isUnderSpawnProtection(ServerLevel p_129811_, BlockPos p_129812_, Player p_129813_) { - return false; - } - -- public boolean m_6373_() { +- public boolean repliesToStatus() { - return true; - } - -- public boolean m_183306_() { +- public boolean hidesOnlinePlayers() { - return false; - } - -- public Proxy m_177930_() { -- return this.f_129747_; +- public Proxy getProxy() { +- return this.proxy; - } - -- public int m_129924_() { -- return this.f_129711_; +- public int getPlayerIdleTimeout() { +- return this.playerIdleTimeout; - } - -- public void m_7196_(int p_129978_) { -- this.f_129711_ = p_129978_; +- public void setPlayerIdleTimeout(int p_129978_) { +- this.playerIdleTimeout = p_129978_; - } - -- public MinecraftSessionService m_129925_() { -- return this.f_129721_; +- public MinecraftSessionService getSessionService() { +- return this.sessionService; - } - -- public GameProfileRepository m_129926_() { -- return this.f_129722_; +- public GameProfileRepository getProfileRepository() { +- return this.profileRepository; - } - -- public GameProfileCache m_129927_() { -- return this.f_129723_; +- public GameProfileCache getProfileCache() { +- return this.profileCache; - } - -- public ServerStatus m_129928_() { -- return this.f_129757_; +- public ServerStatus getStatus() { +- return this.status; - } - -- public void m_129929_() { -- this.f_129724_ = 0L; +- public void invalidateStatus() { +- this.lastServerStatus = 0L; - } - -- public int m_6329_() { +- public int getAbsoluteMaxWorldSize() { - return 29999984; - } - -- public boolean m_5660_() { -- return super.m_5660_() && !this.m_129918_(); +- public boolean scheduleExecutables() { +- return super.scheduleExecutables() && !this.isStopped(); - } - -- public void m_201446_(Runnable p_202482_) { -- if (this.m_129918_()) { +- public void executeIfPossible(Runnable p_202482_) { +- if (this.isStopped()) { - throw new RejectedExecutionException("Server already shutting down"); - } else { -- super.m_201446_(p_202482_); +- super.executeIfPossible(p_202482_); - } - } - -- public Thread m_6304_() { -- return this.f_129725_; +- public Thread getRunningThread() { +- return this.serverThread; - } - -- public int m_6328_() { +- public int getCompressionThreshold() { - return 256; - } - -- public long m_129932_() { -- return this.f_129726_; +- public long getNextTickTime() { +- return this.nextTickTime; - } - -- public DataFixer m_129933_() { -- return this.f_129759_; +- public DataFixer getFixerUpper() { +- return this.fixerUpper; - } - -- public int m_129803_(@Nullable ServerLevel p_129804_) { -- return p_129804_ != null ? p_129804_.m_46469_().m_46215_(GameRules.f_46147_) : 10; +- public int getSpawnRadius(@Nullable ServerLevel p_129804_) { +- return p_129804_ != null ? p_129804_.getGameRules().getInt(GameRules.RULE_SPAWN_RADIUS) : 10; - } - -- public ServerAdvancementManager m_129889_() { -- return this.f_129740_.f_206585_.m_206889_(); +- public ServerAdvancementManager getAdvancements() { +- return this.resources.managers.getAdvancements(); - } - -- public ServerFunctionManager m_129890_() { -- return this.f_129734_; +- public ServerFunctionManager getFunctions() { +- return this.functionManager; - } - -- public CompletableFuture m_129861_(Collection p_129862_) { -- RegistryAccess.Frozen registryaccess$frozen = this.m_206579_(); +- public CompletableFuture reloadResources(Collection p_129862_) { +- RegistryAccess.Frozen registryaccess$frozen = this.registryAccess(); - CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { -- return p_129862_.stream().map(this.f_129730_::m_10507_).filter(Objects::nonNull).map(Pack::m_10445_).collect(ImmutableList.toImmutableList()); +- return p_129862_.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()); - }, this).thenCompose((p_212913_) -> { - CloseableResourceManager closeableresourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, p_212913_); -- return ReloadableServerResources.m_206861_(closeableresourcemanager, registryaccess$frozen, this.m_6982_() ? Commands.CommandSelection.DEDICATED : Commands.CommandSelection.INTEGRATED, this.m_7034_(), this.f_129738_, this).whenComplete((p_212907_, p_212908_) -> { +- return ReloadableServerResources.loadResources(closeableresourcemanager, registryaccess$frozen, this.isDedicatedServer() ? Commands.CommandSelection.DEDICATED : Commands.CommandSelection.INTEGRATED, this.getFunctionCompilationLevel(), this.executor, this).whenComplete((p_212907_, p_212908_) -> { - if (p_212908_ != null) { - closeableresourcemanager.close(); - } @@ -1443,212 +1443,212 @@ - return new MinecraftServer.ReloadableResources(closeableresourcemanager, p_212904_); - }); - }).thenAcceptAsync((p_212919_) -> { -- this.f_129740_.close(); -- this.f_129740_ = p_212919_; -- this.f_129730_.m_10509_(p_129862_); -- this.f_129749_.m_6645_(m_129817_(this.f_129730_)); -- this.f_129740_.f_206585_.m_206868_(this.m_206579_()); -- this.m_6846_().m_11302_(); -- this.m_6846_().m_11315_(); -- this.f_129734_.m_136120_(this.f_129740_.f_206585_.m_206860_()); -- this.f_129741_.m_74335_(this.f_129740_.f_206584_); +- this.resources.close(); +- this.resources = p_212919_; +- this.packRepository.setSelected(p_129862_); +- this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository)); +- this.resources.managers.updateRegistryTags(this.registryAccess()); +- this.getPlayerList().saveAll(); +- this.getPlayerList().reloadResources(); +- this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); +- this.structureManager.onResourceManagerReload(this.resources.resourceManager); - }, this); -- if (this.m_18695_()) { -- this.m_18701_(completablefuture::isDone); +- if (this.isSameThread()) { +- this.managedBlock(completablefuture::isDone); - } - - return completablefuture; - } - -- public static DataPackConfig m_129819_(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { -- p_129820_.m_10506_(); +- public static DataPackConfig configurePackRepository(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { +- p_129820_.reload(); - if (p_129822_) { -- p_129820_.m_10509_(Collections.singleton("vanilla")); +- p_129820_.setSelected(Collections.singleton("vanilla")); - return new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()); - } else { - Set set = Sets.newLinkedHashSet(); - -- for(String s : p_129821_.m_45850_()) { -- if (p_129820_.m_10515_(s)) { +- for(String s : p_129821_.getEnabled()) { +- if (p_129820_.isAvailable(s)) { - set.add(s); - } else { -- f_129750_.warn("Missing data pack {}", (Object)s); +- LOGGER.warn("Missing data pack {}", (Object)s); - } - } - -- for(Pack pack : p_129820_.m_10519_()) { -- String s1 = pack.m_10446_(); -- if (!p_129821_.m_45855_().contains(s1) && !set.contains(s1)) { -- f_129750_.info("Found new data pack {}, loading it automatically", (Object)s1); +- for(Pack pack : p_129820_.getAvailablePacks()) { +- String s1 = pack.getId(); +- if (!p_129821_.getDisabled().contains(s1) && !set.contains(s1)) { +- LOGGER.info("Found new data pack {}, loading it automatically", (Object)s1); - set.add(s1); - } - } - - if (set.isEmpty()) { -- f_129750_.info("No datapacks selected, forcing vanilla"); +- LOGGER.info("No datapacks selected, forcing vanilla"); - set.add("vanilla"); - } - -- p_129820_.m_10509_(set); -- return m_129817_(p_129820_); +- p_129820_.setSelected(set); +- return getSelectedPacks(p_129820_); - } - } - -- private static DataPackConfig m_129817_(PackRepository p_129818_) { -- Collection collection = p_129818_.m_10523_(); +- private static DataPackConfig getSelectedPacks(PackRepository p_129818_) { +- Collection collection = p_129818_.getSelectedIds(); - List list = ImmutableList.copyOf(collection); -- List list1 = p_129818_.m_10514_().stream().filter((p_212916_) -> { +- List list1 = p_129818_.getAvailableIds().stream().filter((p_212916_) -> { - return !collection.contains(p_212916_); - }).collect(ImmutableList.toImmutableList()); - return new DataPackConfig(list, list1); - } - -- public void m_129849_(CommandSourceStack p_129850_) { -- if (this.m_129902_()) { -- PlayerList playerlist = p_129850_.m_81377_().m_6846_(); -- UserWhiteList userwhitelist = playerlist.m_11305_(); +- public void kickUnlistedPlayers(CommandSourceStack p_129850_) { +- if (this.isEnforceWhitelist()) { +- PlayerList playerlist = p_129850_.getServer().getPlayerList(); +- UserWhiteList userwhitelist = playerlist.getWhiteList(); - -- for(ServerPlayer serverplayer : Lists.newArrayList(playerlist.m_11314_())) { -- if (!userwhitelist.m_11453_(serverplayer.m_36316_())) { -- serverplayer.f_8906_.m_9942_(new TranslatableComponent("multiplayer.disconnect.not_whitelisted")); +- for(ServerPlayer serverplayer : Lists.newArrayList(playerlist.getPlayers())) { +- if (!userwhitelist.isWhiteListed(serverplayer.getGameProfile())) { +- serverplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.not_whitelisted")); - } - } - - } - } - -- public PackRepository m_129891_() { -- return this.f_129730_; +- public PackRepository getPackRepository() { +- return this.packRepository; - } - -- public Commands m_129892_() { -- return this.f_129740_.f_206585_.m_206888_(); +- public Commands getCommands() { +- return this.resources.managers.getCommands(); - } - -- public CommandSourceStack m_129893_() { -- ServerLevel serverlevel = this.m_129783_(); -- return new CommandSourceStack(this, serverlevel == null ? Vec3.f_82478_ : Vec3.m_82528_(serverlevel.m_8900_()), Vec2.f_82462_, serverlevel, 4, "Server", new TextComponent("Server"), this, (Entity)null); +- public CommandSourceStack createCommandSourceStack() { +- ServerLevel serverlevel = this.overworld(); +- return new CommandSourceStack(this, serverlevel == null ? Vec3.ZERO : Vec3.atLowerCornerOf(serverlevel.getSharedSpawnPos()), Vec2.ZERO, serverlevel, 4, "Server", new TextComponent("Server"), this, (Entity)null); - } - -- public boolean m_6999_() { +- public boolean acceptsSuccess() { - return true; - } - -- public boolean m_7028_() { +- public boolean acceptsFailure() { - return true; - } - -- public abstract boolean m_6102_(); +- public abstract boolean shouldInformAdmins(); - -- public RecipeManager m_129894_() { -- return this.f_129740_.f_206585_.m_206887_(); +- public RecipeManager getRecipeManager() { +- return this.resources.managers.getRecipeManager(); - } - -- public ServerScoreboard m_129896_() { -- return this.f_129731_; +- public ServerScoreboard getScoreboard() { +- return this.scoreboard; - } - -- public CommandStorage m_129897_() { -- if (this.f_129732_ == null) { +- public CommandStorage getCommandStorage() { +- if (this.commandStorage == null) { - throw new NullPointerException("Called before server init"); - } else { -- return this.f_129732_; +- return this.commandStorage; - } - } - -- public LootTables m_129898_() { -- return this.f_129740_.f_206585_.m_206885_(); +- public LootTables getLootTables() { +- return this.resources.managers.getLootTables(); - } - -- public PredicateManager m_129899_() { -- return this.f_129740_.f_206585_.m_206881_(); +- public PredicateManager getPredicateManager() { +- return this.resources.managers.getPredicateManager(); - } - -- public ItemModifierManager m_177926_() { -- return this.f_129740_.f_206585_.m_206886_(); +- public ItemModifierManager getItemModifierManager() { +- return this.resources.managers.getItemModifierManager(); - } - -- public GameRules m_129900_() { -- return this.m_129783_().m_46469_(); +- public GameRules getGameRules() { +- return this.overworld().getGameRules(); - } - -- public CustomBossEvents m_129901_() { -- return this.f_129733_; +- public CustomBossEvents getCustomBossEvents() { +- return this.customBossEvents; - } - -- public boolean m_129902_() { -- return this.f_129736_; +- public boolean isEnforceWhitelist() { +- return this.enforceWhitelist; - } - -- public void m_130004_(boolean p_130005_) { -- this.f_129736_ = p_130005_; +- public void setEnforceWhitelist(boolean p_130005_) { +- this.enforceWhitelist = p_130005_; - } - -- public float m_129903_() { -- return this.f_129737_; +- public float getAverageTickTime() { +- return this.averageTickTime; - } - -- public int m_129944_(GameProfile p_129945_) { -- if (this.m_6846_().m_11303_(p_129945_)) { -- ServerOpListEntry serveroplistentry = this.m_6846_().m_11307_().m_11388_(p_129945_); +- public int getProfilePermissions(GameProfile p_129945_) { +- if (this.getPlayerList().isOp(p_129945_)) { +- ServerOpListEntry serveroplistentry = this.getPlayerList().getOps().get(p_129945_); - if (serveroplistentry != null) { -- return serveroplistentry.m_11363_(); -- } else if (this.m_7779_(p_129945_)) { +- return serveroplistentry.getLevel(); +- } else if (this.isSingleplayerOwner(p_129945_)) { - return 4; -- } else if (this.m_129792_()) { -- return this.m_6846_().m_11316_() ? 4 : 0; +- } else if (this.isSingleplayer()) { +- return this.getPlayerList().isAllowCheatsForAllPlayers() ? 4 : 0; - } else { -- return this.m_7022_(); +- return this.getOperatorUserPermissionLevel(); - } - } else { - return 0; - } - } - -- public FrameTimer m_129904_() { -- return this.f_129735_; +- public FrameTimer getFrameTimer() { +- return this.frameTimer; - } - -- public ProfilerFiller m_129905_() { -- return this.f_129754_; +- public ProfilerFiller getProfiler() { +- return this.profiler; - } - -- public abstract boolean m_7779_(GameProfile p_129840_); +- public abstract boolean isSingleplayerOwner(GameProfile p_129840_); - -- public void m_142116_(Path p_177911_) throws IOException { +- public void dumpServerProperties(Path p_177911_) throws IOException { - } - -- private void m_129859_(Path p_129860_) { +- private void saveDebugReport(Path p_129860_) { - Path path = p_129860_.resolve("levels"); - - try { -- for(Entry, ServerLevel> entry : this.f_129762_.entrySet()) { -- ResourceLocation resourcelocation = entry.getKey().m_135782_(); -- Path path1 = path.resolve(resourcelocation.m_135827_()).resolve(resourcelocation.m_135815_()); +- for(Entry, ServerLevel> entry : this.levels.entrySet()) { +- ResourceLocation resourcelocation = entry.getKey().location(); +- Path path1 = path.resolve(resourcelocation.getNamespace()).resolve(resourcelocation.getPath()); - Files.createDirectories(path1); -- entry.getValue().m_8786_(path1); +- entry.getValue().saveDebugReport(path1); - } - -- this.m_129983_(p_129860_.resolve("gamerules.txt")); -- this.m_129991_(p_129860_.resolve("classpath.txt")); -- this.m_129950_(p_129860_.resolve("stats.txt")); -- this.m_129995_(p_129860_.resolve("threads.txt")); -- this.m_142116_(p_129860_.resolve("server.properties.txt")); -- this.m_195521_(p_129860_.resolve("modules.txt")); +- this.dumpGameRules(p_129860_.resolve("gamerules.txt")); +- this.dumpClasspath(p_129860_.resolve("classpath.txt")); +- this.dumpMiscStats(p_129860_.resolve("stats.txt")); +- this.dumpThreads(p_129860_.resolve("threads.txt")); +- this.dumpServerProperties(p_129860_.resolve("server.properties.txt")); +- this.dumpNativeModules(p_129860_.resolve("modules.txt")); - } catch (IOException ioexception) { -- f_129750_.warn("Failed to save debug report", (Throwable)ioexception); +- LOGGER.warn("Failed to save debug report", (Throwable)ioexception); - } - - } - -- private void m_129950_(Path p_129951_) throws IOException { +- private void dumpMiscStats(Path p_129951_) throws IOException { - Writer writer = Files.newBufferedWriter(p_129951_); - - try { -- writer.write(String.format("pending_tasks: %d\n", this.m_18696_())); -- writer.write(String.format("average_tick_time: %f\n", this.m_129903_())); -- writer.write(String.format("tick_times: %s\n", Arrays.toString(this.f_129748_))); -- writer.write(String.format("queue: %s\n", Util.m_183991_())); +- writer.write(String.format("pending_tasks: %d\n", this.getPendingTasksCount())); +- writer.write(String.format("average_tick_time: %f\n", this.getAverageTickTime())); +- writer.write(String.format("tick_times: %s\n", Arrays.toString(this.tickTimes))); +- writer.write(String.format("queue: %s\n", Util.backgroundExecutor())); - } catch (Throwable throwable1) { - if (writer != null) { - try { @@ -1667,15 +1667,15 @@ - - } - -- private void m_129983_(Path p_129984_) throws IOException { +- private void dumpGameRules(Path p_129984_) throws IOException { - Writer writer = Files.newBufferedWriter(p_129984_); - - try { - final List list = Lists.newArrayList(); -- final GameRules gamerules = this.m_129900_(); -- GameRules.m_46164_(new GameRules.GameRuleTypeVisitor() { -- public > void m_6889_(GameRules.Key p_195531_, GameRules.Type p_195532_) { -- list.add(String.format("%s=%s\n", p_195531_.m_46328_(), gamerules.m_46170_(p_195531_))); +- final GameRules gamerules = this.getGameRules(); +- GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { +- public > void visit(GameRules.Key p_195531_, GameRules.Type p_195532_) { +- list.add(String.format("%s=%s\n", p_195531_.getId(), gamerules.getRule(p_195531_))); - } - }); - @@ -1700,7 +1700,7 @@ - - } - -- private void m_129991_(Path p_129992_) throws IOException { +- private void dumpClasspath(Path p_129992_) throws IOException { - Writer writer = Files.newBufferedWriter(p_129992_); - - try { @@ -1729,7 +1729,7 @@ - - } - -- private void m_129995_(Path p_129996_) throws IOException { +- private void dumpThreads(Path p_129996_) throws IOException { - ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); - ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); - Arrays.sort(athreadinfo, Comparator.comparing(ThreadInfo::getThreadName)); @@ -1758,7 +1758,7 @@ - - } - -- private void m_195521_(Path p_195522_) throws IOException { +- private void dumpNativeModules(Path p_195522_) throws IOException { - Writer writer = Files.newBufferedWriter(p_195522_); - - label49: { @@ -1766,14 +1766,14 @@ - label50: { - List list; - try { -- list = Lists.newArrayList(NativeModuleLister.m_184666_()); +- list = Lists.newArrayList(NativeModuleLister.listModules()); - } catch (Throwable throwable1) { -- f_129750_.warn("Failed to list native modules", throwable1); +- LOGGER.warn("Failed to list native modules", throwable1); - break label50; - } - - list.sort(Comparator.comparing((p_212910_) -> { -- return p_212910_.f_184690_; +- return p_212910_.name; - })); - Iterator $$3 = list.iterator(); - @@ -1812,158 +1812,158 @@ - - } - -- private void m_177945_() { -- if (this.f_177875_) { -- this.f_177872_ = ActiveMetricsRecorder.m_146132_(new ServerMetricsSamplersProvider(Util.f_137440_, this.m_6982_()), Util.f_137440_, Util.m_183992_(), new MetricsPersister("server"), this.f_177873_, (p_212927_) -> { -- this.m_18709_(() -> { -- this.m_129859_(p_212927_.resolve("server")); +- private void startMetricsRecordingTick() { +- if (this.willStartRecordingMetrics) { +- this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (p_212927_) -> { +- this.executeBlocking(() -> { +- this.saveDebugReport(p_212927_.resolve("server")); - }); -- this.f_177874_.accept(p_212927_); +- this.onMetricsRecordingFinished.accept(p_212927_); - }); -- this.f_177875_ = false; +- this.willStartRecordingMetrics = false; - } - -- this.f_129754_ = SingleTickProfiler.m_18629_(this.f_177872_.m_142610_(), SingleTickProfiler.m_18632_("Server")); -- this.f_177872_.m_142759_(); -- this.f_129754_.m_7242_(); +- this.profiler = SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server")); +- this.metricsRecorder.startTick(); +- this.profiler.startTick(); - } - -- private void m_177946_() { -- this.f_129754_.m_7241_(); -- this.f_177872_.m_142758_(); +- private void endMetricsRecordingTick() { +- this.profiler.endTick(); +- this.metricsRecorder.endTick(); - } - -- public boolean m_177927_() { -- return this.f_177872_.m_142763_(); +- public boolean isRecordingMetrics() { +- return this.metricsRecorder.isRecording(); - } - -- public void m_177923_(Consumer p_177924_, Consumer p_177925_) { -- this.f_177873_ = (p_212922_) -> { -- this.m_177928_(); +- public void startRecordingMetrics(Consumer p_177924_, Consumer p_177925_) { +- this.onMetricsRecordingStopped = (p_212922_) -> { +- this.stopRecordingMetrics(); - p_177924_.accept(p_212922_); - }; -- this.f_177874_ = p_177925_; -- this.f_177875_ = true; +- this.onMetricsRecordingFinished = p_177925_; +- this.willStartRecordingMetrics = true; - } - -- public void m_177928_() { -- this.f_177872_ = InactiveMetricsRecorder.f_146153_; +- public void stopRecordingMetrics() { +- this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; - } - -- public void m_177929_() { -- this.f_177872_.m_142760_(); +- public void finishRecordingMetrics() { +- this.metricsRecorder.end(); - } - -- public Path m_129843_(LevelResource p_129844_) { -- return this.f_129744_.m_78283_(p_129844_); +- public Path getWorldPath(LevelResource p_129844_) { +- return this.storageSource.getLevelPath(p_129844_); - } - -- public boolean m_6365_() { +- public boolean forceSynchronousWrites() { - return true; - } - -- public StructureManager m_129909_() { -- return this.f_129741_; +- public StructureManager getStructureManager() { +- return this.structureManager; - } - -- public WorldData m_129910_() { -- return this.f_129749_; +- public WorldData getWorldData() { +- return this.worldData; - } - -- public RegistryAccess.Frozen m_206579_() { -- return this.f_129746_; +- public RegistryAccess.Frozen registryAccess() { +- return this.registryHolder; - } - -- public TextFilter m_7950_(ServerPlayer p_129814_) { -- return TextFilter.f_143703_; +- public TextFilter createTextFilterForPlayer(ServerPlayer p_129814_) { +- return TextFilter.DUMMY; - } - -- public boolean m_142205_() { +- public boolean isResourcePackRequired() { - return false; - } - -- public ServerPlayerGameMode m_177933_(ServerPlayer p_177934_) { -- return (ServerPlayerGameMode)(this.m_129794_() ? new DemoMode(p_177934_) : new ServerPlayerGameMode(p_177934_)); +- public ServerPlayerGameMode createGameModeForPlayer(ServerPlayer p_177934_) { +- return (ServerPlayerGameMode)(this.isDemo() ? new DemoMode(p_177934_) : new ServerPlayerGameMode(p_177934_)); - } - - @Nullable -- public GameType m_142359_() { +- public GameType getForcedGameType() { - return null; - } - -- public ResourceManager m_177941_() { -- return this.f_129740_.f_206584_; +- public ResourceManager getResourceManager() { +- return this.resources.resourceManager; - } - - @Nullable -- public Component m_141958_() { +- public Component getResourcePackPrompt() { - return null; - } - -- public boolean m_195518_() { -- return this.f_195494_; +- public boolean isCurrentlySaving() { +- return this.isSaving; - } - -- public boolean m_177942_() { -- return this.f_177877_ || this.f_177876_ != null; +- public boolean isTimeProfilerRunning() { +- return this.debugCommandProfilerDelayStart || this.debugCommandProfiler != null; - } - -- public void m_177943_() { -- this.f_177877_ = true; +- public void startTimeProfiler() { +- this.debugCommandProfilerDelayStart = true; - } - -- public ProfileResults m_177944_() { -- if (this.f_177876_ == null) { -- return EmptyProfileResults.f_18441_; +- public ProfileResults stopTimeProfiler() { +- if (this.debugCommandProfiler == null) { +- return EmptyProfileResults.EMPTY; - } else { -- ProfileResults profileresults = this.f_177876_.m_177960_(Util.m_137569_(), this.f_129766_); -- this.f_177876_ = null; +- ProfileResults profileresults = this.debugCommandProfiler.stop(Util.getNanos(), this.tickCount); +- this.debugCommandProfiler = null; - return profileresults; - } - } - -- public static record ReloadableResources(CloseableResourceManager f_206584_, ReloadableServerResources f_206585_) implements AutoCloseable { +- public static record ReloadableResources(CloseableResourceManager resourceManager, ReloadableServerResources managers) implements AutoCloseable { - public void close() { -- this.f_206584_.close(); +- this.resourceManager.close(); - } - } - - static class TimeProfiler { -- final long f_177955_; -- final int f_177956_; +- final long startNanos; +- final int startTick; - - TimeProfiler(long p_177958_, int p_177959_) { -- this.f_177955_ = p_177958_; -- this.f_177956_ = p_177959_; +- this.startNanos = p_177958_; +- this.startTick = p_177959_; - } - -- ProfileResults m_177960_(final long p_177961_, final int p_177962_) { +- ProfileResults stop(final long p_177961_, final int p_177962_) { - return new ProfileResults() { -- public List m_6412_(String p_177972_) { +- public List getTimes(String p_177972_) { - return Collections.emptyList(); - } - -- public boolean m_142444_(Path p_177974_) { +- public boolean saveResults(Path p_177974_) { - return false; - } - -- public long m_7229_() { -- return TimeProfiler.this.f_177955_; +- public long getStartTimeNano() { +- return TimeProfiler.this.startNanos; - } - -- public int m_7230_() { -- return TimeProfiler.this.f_177956_; +- public int getStartTimeTicks() { +- return TimeProfiler.this.startTick; - } - -- public long m_7236_() { +- public long getEndTimeNano() { - return p_177961_; - } - -- public int m_7317_() { +- public int getEndTimeTicks() { - return p_177962_; - } - -- public String m_142368_() { +- public String getProfilerResults() { - return ""; - } - }; @@ -1971,40 +1971,40 @@ - } + } + -+ this.m_6846_().m_184209_(serverlevel); -+ if (this.f_129749_.m_6587_() != null) { -+ this.m_129901_().m_136295_(this.f_129749_.m_6587_()); ++ this.getPlayerList().addWorldborderListener(serverlevel); ++ if (this.worldData.getCustomBossEvents() != null) { ++ this.getCustomBossEvents().load(this.worldData.getCustomBossEvents()); + } + -+ for (Entry, LevelStem> entry : registry.m_6579_()) { ++ for (Entry, LevelStem> entry : registry.entrySet()) { + ResourceKey resourcekey = entry.getKey(); -+ if (resourcekey != LevelStem.f_63971_) { -+ ResourceKey resourcekey1 = ResourceKey.m_135785_(Registry.f_122819_, resourcekey.m_135782_()); -+ Holder holder1 = entry.getValue().m_204521_(); -+ ChunkGenerator chunkgenerator1 = entry.getValue().m_63990_(); -+ DerivedLevelData derivedleveldata = new DerivedLevelData(this.f_129749_, serverleveldata); ++ if (resourcekey != LevelStem.OVERWORLD) { ++ ResourceKey resourcekey1 = ResourceKey.create(Registry.DIMENSION_REGISTRY, resourcekey.location()); ++ Holder holder1 = entry.getValue().typeHolder(); ++ ChunkGenerator chunkgenerator1 = entry.getValue().generator(); ++ DerivedLevelData derivedleveldata = new DerivedLevelData(this.worldData, serverleveldata); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.forceRandomizedUUIDForDimensions.getValues()) -+ derivedleveldata.setLevelName(derivedleveldata.m_5462_() + "_" + resourcekey.m_135782_().m_135815_()); -+ ServerLevel serverlevel1 = new ServerLevel(this, this.f_129738_, this.f_129744_, derivedleveldata, resourcekey1, holder1, p_129816_, chunkgenerator1, flag, j, ImmutableList.of(), false); -+ worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_())); -+ this.f_129762_.put(resourcekey1, bukkitInit(serverlevel1)); //Magma - bukkitInit -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(resourcekey))); ++ derivedleveldata.setLevelName(derivedleveldata.getLevelName() + "_" + resourcekey.location().getPath()); ++ ServerLevel serverlevel1 = new ServerLevel(this, this.executor, this.storageSource, derivedleveldata, resourcekey1, holder1, p_129816_, chunkgenerator1, flag, j, ImmutableList.of(), false); ++ worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); ++ this.levels.put(resourcekey1, bukkitInit(serverlevel1)); //Magma - bukkitInit ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(levels.get(resourcekey))); + } + } + -+ worldborder.m_61931_(serverleveldata.m_5813_()); ++ worldborder.applySettings(serverleveldata.getWorldBorder()); + + // CraftBukkit start + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.getPluginManager().callEvent(new org.bukkit.event.server.ServerLoadEvent(org.bukkit.event.server.ServerLoadEvent.LoadType.STARTUP)); -+ this.f_129755_.acceptConnections(); ++ this.connection.acceptConnections(); + // CraftBukkit end + } + + private ServerLevel bukkitInit(ServerLevel level) { + org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboardManager manager = ((org.bukkit.craftbukkit.v1_18_R2.CraftServer) org.bukkit.Bukkit.getServer()).scoreboardManager; + if (manager == null) { -+ manager = new org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboardManager((MinecraftServer) (Object) this, level.m_6188_()); ++ manager = new org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboardManager((MinecraftServer) (Object) this, level.getScoreboard()); + ((org.bukkit.craftbukkit.v1_18_R2.CraftServer) org.bukkit.Bukkit.getServer()).scoreboardManager = manager; + } + @@ -2017,30 +2017,30 @@ + + //Magma start - bukkit methods + public void initWorld(ServerLevel level, net.minecraft.world.level.storage.PrimaryLevelData worldData, net.minecraft.world.level.storage.PrimaryLevelData worldData1, WorldGenSettings worldGenSettings) { -+ boolean flag = worldGenSettings.m_64668_(); ++ boolean flag = worldGenSettings.isDebug(); + org.bukkit.generator.ChunkGenerator generator = level.getWorld().getGenerator(); + if (generator != null) + level.getWorld().getPopulators().addAll(generator.getDefaultPopulators(level.getWorld())); + -+ WorldBorder worldborder = level.m_6857_(); -+ worldborder.m_61931_(worldData1.m_5813_()); -+ if (!worldData1.m_6535_()) { ++ WorldBorder worldborder = level.getWorldBorder(); ++ worldborder.applySettings(worldData1.getWorldBorder()); ++ if (!worldData1.isInitialized()) { + try { -+ m_177896_(level, worldData1, worldGenSettings.m_64660_(), flag); -+ worldData1.m_5555_(true); ++ setInitialSpawn(level, worldData1, worldGenSettings.generateBonusChest(), flag); ++ worldData1.setInitialized(true); + if (flag) -+ this.m_129847_(worldData); ++ this.setupDebugLevel(worldData); + } catch (Throwable throwable1) { -+ CrashReport crashreport = CrashReport.m_127521_(throwable1, "Exception initializing level"); ++ CrashReport crashreport = CrashReport.forThrowable(throwable1, "Exception initializing level"); + + try { -+ level.m_6026_(crashreport); ++ level.fillReportDetails(crashreport); + } catch (Throwable ignored) {} + + throw new ReportedException(crashreport); + } + -+ worldData1.m_5555_(true); ++ worldData1.setInitialized(true); + } + } + @@ -2050,35 +2050,35 @@ + if (!internal.getWorld().getKeepSpawnInMemory()) + return; + this.forceTicks = true; -+ f_129750_.info("Preparing start region for dimension {}", internal.m_46472_().m_135782_()); -+ BlockPos blockpos = internal.m_8900_(); -+ progressListener.m_7647_(new ChunkPos(blockpos)); -+ ServerChunkCache serverchunkprovider = internal.m_7726_(); -+ serverchunkprovider.m_7827_().m_9310_(500); -+ this.f_129726_ = Util.m_137550_(); -+ serverchunkprovider.m_8387_(TicketType.f_9442_, new ChunkPos(blockpos), 11, Unit.INSTANCE); -+ -+ while (serverchunkprovider.m_8427_() < 441) { ++ LOGGER.info("Preparing start region for dimension {}", internal.dimension().location()); ++ BlockPos blockpos = internal.getSharedSpawnPos(); ++ progressListener.updateSpawnPos(new ChunkPos(blockpos)); ++ ServerChunkCache serverchunkprovider = internal.getChunkSource(); ++ serverchunkprovider.getLightEngine().setTaskPerBatch(500); ++ this.nextTickTime = Util.getMillis(); ++ serverchunkprovider.addRegionTicket(TicketType.START, new ChunkPos(blockpos), 11, Unit.INSTANCE); ++ ++ while (serverchunkprovider.getTickingGenerated() < 441) { + this.executeModerately(); + } + + this.executeModerately(); + -+ ForcedChunksSavedData forcedchunkssavedata = internal.m_8895_().m_164858_(ForcedChunksSavedData::m_151483_, "chunks"); ++ ForcedChunksSavedData forcedchunkssavedata = internal.getDataStorage().get(ForcedChunksSavedData::load, "chunks"); + if (forcedchunkssavedata != null) { -+ LongIterator longiterator = forcedchunkssavedata.m_46116_().iterator(); ++ LongIterator longiterator = forcedchunkssavedata.getChunks().iterator(); + + while (longiterator.hasNext()) { + long i = longiterator.nextLong(); + ChunkPos chunkpos = new ChunkPos(i); -+ internal.m_7726_().m_6692_(chunkpos, true); ++ internal.getChunkSource().updateChunkForced(chunkpos, true); + } + net.minecraftforge.common.world.ForgeChunkManager.reinstatePersistentChunks(internal, forcedchunkssavedata); + } + this.executeModerately(); -+ progressListener.m_7646_(); -+ serverchunkprovider.m_7827_().m_9310_(5); -+ internal.m_46703_(this.m_7004_(), this.m_6998_()); ++ progressListener.stop(); ++ serverchunkprovider.getLightEngine().setTaskPerBatch(5); ++ internal.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); + this.forceTicks = false; + } + // org.magmafoundation.magma.Magma end @@ -2088,31 +2088,31 @@ + return console; + } + -+ private static void m_177896_(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) { ++ private static void setInitialSpawn(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) { + if (p_177900_) { -+ p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F); ++ p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); + } else { -+ ChunkGenerator chunkgenerator = p_177897_.m_7726_().m_8481_(); ++ ChunkGenerator chunkgenerator = p_177897_.getChunkSource().getGenerator(); + if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(p_177897_, p_177898_)) return; -+ ChunkPos chunkpos = new ChunkPos(chunkgenerator.m_183403_().m_183230_()); -+ int i = chunkgenerator.m_142051_(p_177897_); -+ if (i < p_177897_.m_141937_()) { -+ BlockPos blockpos = chunkpos.m_45615_(); -+ i = p_177897_.m_6924_(Heightmap.Types.WORLD_SURFACE, blockpos.m_123341_() + 8, blockpos.m_123343_() + 8); ++ ChunkPos chunkpos = new ChunkPos(chunkgenerator.climateSampler().findSpawnPosition()); ++ int i = chunkgenerator.getSpawnHeight(p_177897_); ++ if (i < p_177897_.getMinBuildHeight()) { ++ BlockPos blockpos = chunkpos.getWorldPosition(); ++ i = p_177897_.getHeight(Heightmap.Types.WORLD_SURFACE, blockpos.getX() + 8, blockpos.getZ() + 8); + } + -+ p_177898_.m_7250_(chunkpos.m_45615_().m_142082_(8, i, 8), 0.0F); ++ p_177898_.setSpawn(chunkpos.getWorldPosition().offset(8, i, 8), 0.0F); + int k1 = 0; + int j = 0; + int k = 0; + int l = -1; + int i1 = 5; + -+ for (int j1 = 0; j1 < Mth.m_144944_(11); ++j1) { ++ for (int j1 = 0; j1 < Mth.square(11); ++j1) { + if (k1 >= -5 && k1 <= 5 && j >= -5 && j <= 5) { -+ BlockPos blockpos1 = PlayerRespawnLogic.m_183932_(p_177897_, new ChunkPos(chunkpos.f_45578_ + k1, chunkpos.f_45579_ + j)); ++ BlockPos blockpos1 = PlayerRespawnLogic.getSpawnPosInChunk(p_177897_, new ChunkPos(chunkpos.x + k1, chunkpos.z + j)); + if (blockpos1 != null) { -+ p_177898_.m_7250_(blockpos1, 0.0F); ++ p_177898_.setSpawn(blockpos1, 0.0F); + break; + } + } @@ -2128,52 +2128,52 @@ + } + + if (p_177899_) { -+ ConfiguredFeature configuredfeature = MiscOverworldFeatures.f_195021_.m_203334_(); -+ configuredfeature.m_65385_(p_177897_, chunkgenerator, p_177897_.f_46441_, new BlockPos(p_177898_.m_6789_(), p_177898_.m_6527_(), p_177898_.m_6526_())); ++ ConfiguredFeature configuredfeature = MiscOverworldFeatures.BONUS_CHEST.value(); ++ configuredfeature.place(p_177897_, chunkgenerator, p_177897_.random, new BlockPos(p_177898_.getXSpawn(), p_177898_.getYSpawn(), p_177898_.getZSpawn())); + } + + } + } + -+ private void m_129847_(WorldData p_129848_) { -+ p_129848_.m_6166_(Difficulty.PEACEFUL); -+ p_129848_.m_5560_(true); -+ ServerLevelData serverleveldata = p_129848_.m_5996_(); -+ serverleveldata.m_5565_(false); -+ serverleveldata.m_5557_(false); -+ serverleveldata.m_6393_(1000000000); -+ serverleveldata.m_6247_(6000L); -+ serverleveldata.m_5458_(GameType.SPECTATOR); ++ private void setupDebugLevel(WorldData p_129848_) { ++ p_129848_.setDifficulty(Difficulty.PEACEFUL); ++ p_129848_.setDifficultyLocked(true); ++ ServerLevelData serverleveldata = p_129848_.overworldData(); ++ serverleveldata.setRaining(false); ++ serverleveldata.setThundering(false); ++ serverleveldata.setClearWeatherTime(1000000000); ++ serverleveldata.setDayTime(6000L); ++ serverleveldata.setGameType(GameType.SPECTATOR); + } + -+ public void m_129940_(ChunkProgressListener p_129941_) { -+ ServerLevel serverlevel = this.m_129783_(); ++ public void prepareLevels(ChunkProgressListener p_129941_) { ++ ServerLevel serverlevel = this.overworld(); + this.forceTicks = true; // CraftBukkit -+ f_129750_.info("Preparing start region for dimension {}", (Object) serverlevel.m_46472_().m_135782_()); -+ BlockPos blockpos = serverlevel.m_8900_(); -+ p_129941_.m_7647_(new ChunkPos(blockpos)); -+ ServerChunkCache serverchunkcache = serverlevel.m_7726_(); -+ serverchunkcache.m_7827_().m_9310_(500); -+ this.f_129726_ = Util.m_137550_(); -+ serverchunkcache.m_8387_(TicketType.f_9442_, new ChunkPos(blockpos), 11, Unit.INSTANCE); -+ -+ while (serverchunkcache.m_8427_() < 441) { ++ LOGGER.info("Preparing start region for dimension {}", (Object) serverlevel.dimension().location()); ++ BlockPos blockpos = serverlevel.getSharedSpawnPos(); ++ p_129941_.updateSpawnPos(new ChunkPos(blockpos)); ++ ServerChunkCache serverchunkcache = serverlevel.getChunkSource(); ++ serverchunkcache.getLightEngine().setTaskPerBatch(500); ++ this.nextTickTime = Util.getMillis(); ++ serverchunkcache.addRegionTicket(TicketType.START, new ChunkPos(blockpos), 11, Unit.INSTANCE); ++ ++ while (serverchunkcache.getTickingGenerated() < 441) { + this.executeModerately(); + } + + this.executeModerately(); + -+ for (ServerLevel serverlevel1 : this.f_129762_.values()) { ++ for (ServerLevel serverlevel1 : this.levels.values()) { + if (serverlevel1.getWorld().getKeepSpawnInMemory()) { + serverlevel1.paperConfig.removeOldValues(); // Paper - callback for clearing old config options, after any migrations have taken place -+ ForcedChunksSavedData forcedchunkssaveddata = serverlevel1.m_8895_().m_164858_(ForcedChunksSavedData::m_151483_, "chunks"); ++ ForcedChunksSavedData forcedchunkssaveddata = serverlevel1.getDataStorage().get(ForcedChunksSavedData::load, "chunks"); + if (forcedchunkssaveddata != null) { -+ LongIterator longiterator = forcedchunkssaveddata.m_46116_().iterator(); ++ LongIterator longiterator = forcedchunkssaveddata.getChunks().iterator(); + + while (longiterator.hasNext()) { + long i = longiterator.nextLong(); + ChunkPos chunkpos = new ChunkPos(i); -+ serverlevel1.m_7726_().m_6692_(chunkpos, true); ++ serverlevel1.getChunkSource().updateChunkForced(chunkpos, true); + } + net.minecraftforge.common.world.ForgeChunkManager.reinstatePersistentChunks(serverlevel1, forcedchunkssaveddata); + } @@ -2182,83 +2182,83 @@ + } + + this.executeModerately(); -+ p_129941_.m_7646_(); -+ serverchunkcache.m_7827_().m_9310_(5); -+ this.m_129962_(); ++ p_129941_.stop(); ++ serverchunkcache.getLightEngine().setTaskPerBatch(5); ++ this.updateMobSpawningFlags(); + this.forceTicks = false; // CraftBukkit + } + -+ protected void m_130007_() { -+ File file1 = this.f_129744_.m_78283_(LevelResource.f_78181_).toFile(); ++ protected void detectBundledResources() { ++ File file1 = this.storageSource.getLevelPath(LevelResource.MAP_RESOURCE_FILE).toFile(); + if (file1.isFile()) { -+ String s = this.f_129744_.m_78277_(); ++ String s = this.storageSource.getLevelId(); + + try { -+ this.m_129853_("level://" + URLEncoder.encode(s, StandardCharsets.UTF_8.toString()) + "/resources.zip", ""); ++ this.setResourcePack("level://" + URLEncoder.encode(s, StandardCharsets.UTF_8.toString()) + "/resources.zip", ""); + } catch (UnsupportedEncodingException unsupportedencodingexception) { -+ f_129750_.warn("Something went wrong url encoding {}", (Object) s); ++ LOGGER.warn("Something went wrong url encoding {}", (Object) s); + } + } + + } + -+ public GameType m_130008_() { -+ return this.f_129749_.m_5464_(); ++ public GameType getDefaultGameType() { ++ return this.worldData.getGameType(); + } + -+ public boolean m_7035_() { -+ return this.f_129749_.m_5466_(); ++ public boolean isHardcore() { ++ return this.worldData.isHardcore(); + } + -+ public abstract int m_7022_(); ++ public abstract int getOperatorUserPermissionLevel(); + -+ public abstract int m_7034_(); ++ public abstract int getFunctionCompilationLevel(); + -+ public abstract boolean m_6983_(); ++ public abstract boolean shouldRconBroadcast(); + -+ public boolean m_129885_(boolean p_129886_, boolean p_129887_, boolean p_129888_) { ++ public boolean saveAllChunks(boolean p_129886_, boolean p_129887_, boolean p_129888_) { + boolean flag = false; + -+ for (ServerLevel serverlevel : this.m_129785_()) { ++ for (ServerLevel serverlevel : this.getAllLevels()) { + if (!p_129886_) { -+ f_129750_.info("Saving chunks for level '{}'/{}", serverlevel, serverlevel.m_46472_().m_135782_()); ++ LOGGER.info("Saving chunks for level '{}'/{}", serverlevel, serverlevel.dimension().location()); + } + -+ serverlevel.m_8643_((ProgressListener) null, p_129887_, serverlevel.f_8564_ && !p_129888_); ++ serverlevel.save((ProgressListener) null, p_129887_, serverlevel.noSave && !p_129888_); + flag = true; + } + -+ ServerLevel serverlevel2 = this.m_129783_(); -+ ServerLevelData serverleveldata = this.f_129749_.m_5996_(); -+ serverleveldata.m_7831_(serverlevel2.m_6857_().m_61970_()); -+ this.f_129749_.m_5917_(this.m_129901_().m_136307_()); -+ this.f_129744_.m_78290_(this.m_206579_(), this.f_129749_, this.m_6846_().m_6960_()); ++ ServerLevel serverlevel2 = this.overworld(); ++ ServerLevelData serverleveldata = this.worldData.overworldData(); ++ serverleveldata.setWorldBorder(serverlevel2.getWorldBorder().createSettings()); ++ this.worldData.setCustomBossEvents(this.getCustomBossEvents().save()); ++ this.storageSource.saveDataTag(this.registryAccess(), this.worldData, this.getPlayerList().getSingleplayerData()); + if (p_129887_) { -+ for (ServerLevel serverlevel1 : this.m_129785_()) { -+ f_129750_.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", (Object) serverlevel1.m_7726_().f_8325_.m_182285_()); ++ for (ServerLevel serverlevel1 : this.getAllLevels()) { ++ LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", (Object) serverlevel1.getChunkSource().chunkMap.getStorageName()); + } + -+ f_129750_.info("ThreadedAnvilChunkStorage: All dimensions are saved"); ++ LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved"); + } + + return flag; + } + -+ public boolean m_195514_(boolean p_195515_, boolean p_195516_, boolean p_195517_) { ++ public boolean saveEverything(boolean p_195515_, boolean p_195516_, boolean p_195517_) { + boolean flag; + try { -+ this.f_195494_ = true; -+ this.m_6846_().m_11302_(); -+ flag = this.m_129885_(p_195515_, p_195516_, p_195517_); ++ this.isSaving = true; ++ this.getPlayerList().saveAll(); ++ flag = this.saveAllChunks(p_195515_, p_195516_, p_195517_); + } finally { -+ this.f_195494_ = false; ++ this.isSaving = false; + } + + return flag; + } + + public void close() { -+ this.m_7041_(); ++ this.stopServer(); + } + + // CraftBukkit start @@ -2272,112 +2272,112 @@ + } + // CraftBukkit end + -+ public void m_7041_() { ++ public void stopServer() { + // CraftBukkit start - prevent double stopping on multiple threads + synchronized(stopLock) { + if (hasStopped) return; + hasStopped = true; + } + // CraftBukkit end -+ if (this.f_177872_.m_142763_()) { -+ this.m_177928_(); ++ if (this.metricsRecorder.isRecording()) { ++ this.stopRecordingMetrics(); + } -+ f_129750_.info("Stopping server"); ++ LOGGER.info("Stopping server"); + co.aikar.timings.MinecraftTimings.stopServer(); // Paper + // CraftBukkit start + if (this.server != null) { + this.server.disablePlugins(); + } + // CraftBukkit end -+ if (this.m_129919_() != null) { -+ this.m_129919_().m_9718_(); ++ if (this.getConnection() != null) { ++ this.getConnection().stop(); + } + -+ this.f_195494_ = true; -+ if (this.f_129763_ != null) { -+ f_129750_.info("Saving players"); -+ this.f_129763_.m_11302_(); -+ this.f_129763_.m_11313_(); ++ this.isSaving = true; ++ if (this.playerList != null) { ++ LOGGER.info("Saving players"); ++ this.playerList.saveAll(); ++ this.playerList.removeAll(); + try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets + } + -+ f_129750_.info("Saving worlds"); ++ LOGGER.info("Saving worlds"); + -+ for (ServerLevel serverlevel : this.m_129785_()) { ++ for (ServerLevel serverlevel : this.getAllLevels()) { + if (serverlevel != null) { -+ serverlevel.f_8564_ = false; ++ serverlevel.noSave = false; + } + } + -+ while (this.f_129762_.values().stream().anyMatch((p_202480_) -> { -+ return p_202480_.m_7726_().f_8325_.m_201907_(); ++ while (this.levels.values().stream().anyMatch((p_202480_) -> { ++ return p_202480_.getChunkSource().chunkMap.hasWork(); + })) { -+ this.f_129726_ = Util.m_137550_() + 1L; ++ this.nextTickTime = Util.getMillis() + 1L; + -+ for (ServerLevel serverlevel1 : this.m_129785_()) { -+ serverlevel1.m_7726_().m_201915_(); -+ serverlevel1.m_7726_().m_201698_(() -> { ++ for (ServerLevel serverlevel1 : this.getAllLevels()) { ++ serverlevel1.getChunkSource().removeTicketsOnClosing(); ++ serverlevel1.getChunkSource().tick(() -> { + return true; + }, false); + } + -+ this.m_130012_(); ++ this.waitUntilNextTick(); + } + -+ this.m_129885_(false, true, false); ++ this.saveAllChunks(false, true, false); + -+ for (ServerLevel serverlevel2 : this.m_129785_()) { ++ for (ServerLevel serverlevel2 : this.getAllLevels()) { + if (serverlevel2 != null) { + try { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(serverlevel2)); + serverlevel2.close(); + } catch (IOException ioexception1) { -+ f_129750_.error("Exception closing the level", (Throwable) ioexception1); ++ LOGGER.error("Exception closing the level", (Throwable) ioexception1); + } + } + } + -+ this.f_195494_ = false; -+ this.f_129740_.close(); ++ this.isSaving = false; ++ this.resources.close(); + + try { -+ this.f_129744_.close(); ++ this.storageSource.close(); + } catch (IOException ioexception) { -+ f_129750_.error("Failed to unlock level {}", this.f_129744_.m_78277_(), ioexception); ++ LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception); + } + + // Spigot start + if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { -+ f_129750_.info("Saving usercache.json"); -+ this.m_129927_().m_11006_(); ++ LOGGER.info("Saving usercache.json"); ++ this.getProfileCache().save(); + } + // Spigot end + + } + -+ public String m_130009_() { -+ return this.f_129760_; ++ public String getLocalIp() { ++ return this.localIp; + } + -+ public void m_129913_(String p_129914_) { -+ this.f_129760_ = p_129914_; ++ public void setLocalIp(String p_129914_) { ++ this.localIp = p_129914_; + } + -+ public boolean m_130010_() { -+ return this.f_129764_; ++ public boolean isRunning() { ++ return this.running; + } + + public boolean v() { -+ return this.f_129764_; ++ return this.running; + } + -+ public void m_7570_(boolean p_129884_) { -+ this.f_129764_ = false; ++ public void halt(boolean p_129884_) { ++ this.running = false; + if (p_129884_) { + try { -+ this.f_129725_.join(); ++ this.serverThread.join(); + } catch (InterruptedException interruptedexception) { -+ f_129750_.error("Error while shutting down", (Throwable) interruptedexception); ++ LOGGER.error("Error while shutting down", (Throwable) interruptedexception); + } + } + @@ -2441,28 +2441,28 @@ + // Paper End + // Spigot End + -+ protected void m_130011_() { ++ protected void runServer() { + try { -+ if (this.m_7038_()) { ++ if (this.initServer()) { + net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(this); -+ this.server.checkForUnknownCommands(m_129892_()); //Magma - force a command sync -+ this.f_129726_ = Util.m_137550_(); -+ this.f_129757_.m_134908_(new TextComponent(this.f_129709_)); -+ this.f_129757_.m_134912_(new ServerStatus.Version(SharedConstants.m_183709_().getName(), SharedConstants.m_183709_().getProtocolVersion())); -+ this.m_129878_(this.f_129757_); ++ this.server.checkForUnknownCommands(getCommands()); //Magma - force a command sync ++ this.nextTickTime = Util.getMillis(); ++ this.status.setDescription(new TextComponent(this.motd)); ++ this.status.setVersion(new ServerStatus.Version(SharedConstants.getCurrentVersion().getName(), SharedConstants.getCurrentVersion().getProtocolVersion())); ++ this.updateStatusIcon(this.status); + + // Spigot start + Arrays.fill(recentTps, 20); + long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop + lastTick = start - TICK_TIME; // Paper -+ while (this.f_129764_) { -+ long i = ((curTime = System.nanoTime()) / (1000L * 1000L)) - this.f_129726_; // Paper -+ if (i > 5000L && this.f_129726_ - this.f_129718_ >= 30000L) { // CraftBukkit ++ while (this.running) { ++ long i = ((curTime = System.nanoTime()) / (1000L * 1000L)) - this.nextTickTime; // Paper ++ if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit + long j = i / 50L; + if (server.getWarnOnOverload()) // CraftBukkit -+ f_129750_.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); -+ this.f_129726_ += j * 50L; -+ this.f_129718_ = this.f_129726_; ++ LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); ++ this.nextTickTime += j * 50L; ++ this.lastOverloadWarning = this.nextTickTime; + } + + ++MinecraftServer.currentTickLong; // Paper @@ -2481,73 +2481,73 @@ + } + // Spigot end + -+ if (this.f_177877_) { -+ this.f_177877_ = false; -+ this.f_177876_ = new MinecraftServer.TimeProfiler(Util.m_137569_(), this.f_129766_); ++ if (this.debugCommandProfilerDelayStart) { ++ this.debugCommandProfilerDelayStart = false; ++ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); + } + + //MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time + lastTick = curTime; -+ this.f_129726_ += 50L; -+ this.m_177945_(); -+ this.f_129754_.m_6180_("tick"); -+ this.m_5705_(this::m_129960_); -+ this.f_129754_.m_6182_("nextTickWait"); -+ this.f_129728_ = true; -+ this.f_129727_ = Math.max(Util.m_137550_() + 50L, this.f_129726_); -+ this.m_130012_(); -+ this.f_129754_.m_7238_(); -+ this.m_177946_(); -+ this.f_129717_ = true; -+ JvmProfiler.f_185340_.m_183597_(this.f_129737_); ++ this.nextTickTime += 50L; ++ this.startMetricsRecordingTick(); ++ this.profiler.push("tick"); ++ this.tickServer(this::haveTime); ++ this.profiler.popPush("nextTickWait"); ++ this.mayHaveDelayedTasks = true; ++ this.delayedTasksMaxNextTickTime = Math.max(Util.getMillis() + 50L, this.nextTickTime); ++ this.waitUntilNextTick(); ++ this.profiler.pop(); ++ this.endMetricsRecordingTick(); ++ this.isReady = true; ++ JvmProfiler.INSTANCE.onServerTick(this.averageTickTime); + } + net.minecraftforge.server.ServerLifecycleHooks.handleServerStopping(this); + net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions + } else { + net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions -+ this.m_7268_((CrashReport) null); ++ this.onServerCrash((CrashReport) null); + } + } catch (org.spongepowered.asm.mixin.throwables.MixinError mixinerror) { + org.magmafoundation.magma.protect.InjectProtect.mixinInjectCaught(null, mixinerror); -+ CrashReport crashreport = m_206568_(mixinerror); -+ this.m_177935_(crashreport.m_178626_()); -+ File file1 = new File(new File(this.m_6237_(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); -+ if (crashreport.m_127512_(file1)) { -+ f_129750_.error("This crash report has been saved to: {}", (Object) file1.getAbsolutePath()); ++ CrashReport crashreport = constructOrExtractCrashReport(mixinerror); ++ this.fillSystemReport(crashreport.getSystemReport()); ++ File file1 = new File(new File(this.getServerDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); ++ if (crashreport.saveToFile(file1)) { ++ LOGGER.error("This crash report has been saved to: {}", (Object) file1.getAbsolutePath()); + } else { -+ f_129750_.error("We were unable to save this crash report to disk."); ++ LOGGER.error("We were unable to save this crash report to disk."); + } + + net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions -+ this.m_7268_(crashreport); ++ this.onServerCrash(crashreport); + } catch (Throwable throwable1) { -+ f_129750_.error("Encountered an unexpected exception", throwable1); ++ LOGGER.error("Encountered an unexpected exception", throwable1); + // Spigot Start + if ( throwable1.getCause() != null ) + { -+ MinecraftServer.f_129750_.error( "\tCause of unexpected exception was", throwable1.getCause() ); ++ MinecraftServer.LOGGER.error( "\tCause of unexpected exception was", throwable1.getCause() ); + } + // Spigot End -+ CrashReport crashreport = m_206568_(throwable1); -+ this.m_177935_(crashreport.m_178626_()); -+ File file1 = new File(new File(this.m_6237_(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); -+ if (crashreport.m_127512_(file1)) { -+ f_129750_.error("This crash report has been saved to: {}", (Object) file1.getAbsolutePath()); ++ CrashReport crashreport = constructOrExtractCrashReport(throwable1); ++ this.fillSystemReport(crashreport.getSystemReport()); ++ File file1 = new File(new File(this.getServerDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); ++ if (crashreport.saveToFile(file1)) { ++ LOGGER.error("This crash report has been saved to: {}", (Object) file1.getAbsolutePath()); + } else { -+ f_129750_.error("We were unable to save this crash report to disk."); ++ LOGGER.error("We were unable to save this crash report to disk."); + } + + net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions -+ this.m_7268_(crashreport); ++ this.onServerCrash(crashreport); + } finally { + try { -+ this.f_129765_ = true; -+ this.m_7041_(); ++ this.stopped = true; ++ this.stopServer(); + } catch (Throwable throwable) { -+ f_129750_.error("Exception stopping the server", throwable); ++ LOGGER.error("Exception stopping the server", throwable); + } finally { -+ if (this.f_129723_ != null) { -+ this.f_129723_.m_196559_(); ++ if (this.profileCache != null) { ++ this.profileCache.clearExecutor(); + } + + org.spigotmc.WatchdogThread.doStop(); // Spigot @@ -2558,14 +2558,14 @@ + } catch (Exception ignored) { + } + // CraftBukkit end -+ this.m_6988_(); ++ this.onServerExit(); + } + + } + + } + -+ private static CrashReport m_206568_(Throwable p_206569_) { ++ private static CrashReport constructOrExtractCrashReport(Throwable p_206569_) { + ReportedException reportedexception = null; + + for (Throwable throwable = p_206569_; throwable != null; throwable = throwable.getCause()) { @@ -2577,9 +2577,9 @@ + + CrashReport crashreport; + if (reportedexception != null) { -+ crashreport = reportedexception.m_134761_(); ++ crashreport = reportedexception.getReport(); + if (reportedexception != p_206569_) { -+ crashreport.m_127514_("Wrapped in").m_128162_("Wrapping exception", p_206569_); ++ crashreport.addCategory("Wrapped in").setDetailError("Wrapping exception", p_206569_); + } + } else { + crashreport = new CrashReport("Exception in server tick loop", p_206569_); @@ -2588,14 +2588,14 @@ + return crashreport; + } + -+ private boolean m_129960_() { ++ private boolean haveTime() { + if (this.forceTicks) + return true; -+ return this.m_18767_() || Util.m_137550_() < (this.f_129728_ ? this.f_129727_ : this.f_129726_); ++ return this.runningTask() || Util.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + } + + private void executeModerately() { -+ this.m_18699_(); ++ this.runAllTasks(); + this.drainQueuedTasks(); + java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L); + } @@ -2606,34 +2606,34 @@ + } + } + -+ protected void m_130012_() { -+ this.m_18699_(); -+ this.m_18701_(() -> { -+ return !this.m_129960_(); ++ protected void waitUntilNextTick() { ++ this.runAllTasks(); ++ this.managedBlock(() -> { ++ return !this.haveTime(); + }); + } + -+ public TickTask m_6681_(Runnable p_129852_) { -+ return new TickTask(this.f_129766_, p_129852_); ++ public TickTask wrapRunnable(Runnable p_129852_) { ++ return new TickTask(this.tickCount, p_129852_); + } + -+ protected boolean m_6362_(TickTask p_129883_) { -+ return p_129883_.m_136254_() + 3 < this.f_129766_ || this.m_129960_(); ++ protected boolean shouldRun(TickTask p_129883_) { ++ return p_129883_.getTick() + 3 < this.tickCount || this.haveTime(); + } + -+ public boolean m_7245_() { -+ boolean flag = this.m_129961_(); -+ this.f_129728_ = flag; ++ public boolean pollTask() { ++ boolean flag = this.pollTaskInternal(); ++ this.mayHaveDelayedTasks = flag; + return flag; + } + -+ private boolean m_129961_() { -+ if (super.m_7245_()) { ++ private boolean pollTaskInternal() { ++ if (super.pollTask()) { + return true; + } else { -+ if (this.m_129960_()) { -+ for (ServerLevel serverlevel : this.m_129785_()) { -+ if (serverlevel.m_7726_().m_8466_()) { ++ if (this.haveTime()) { ++ for (ServerLevel serverlevel : this.getAllLevels()) { ++ if (serverlevel.getChunkSource().pollTask()) { + return true; + } + } @@ -2643,15 +2643,15 @@ + } + } + -+ public void m_6367_(TickTask p_129957_) { -+ this.m_129905_().m_6174_("runTask"); -+ super.m_6367_(p_129957_); ++ public void doRunTask(TickTask p_129957_) { ++ this.getProfiler().incrementCounter("runTask"); ++ super.doRunTask(p_129957_); + } + -+ private void m_129878_(ServerStatus p_129879_) { -+ Optional optional = Optional.of(this.m_129971_("server-icon.png")).filter(File::isFile); ++ private void updateStatusIcon(ServerStatus p_129879_) { ++ Optional optional = Optional.of(this.getFile("server-icon.png")).filter(File::isFile); + if (!optional.isPresent()) { -+ optional = this.f_129744_.m_182514_().map(Path::toFile).filter(File::isFile); ++ optional = this.storageSource.getIconFile().map(Path::toFile).filter(File::isFile); + } + + optional.ifPresent((p_202470_) -> { @@ -2662,92 +2662,92 @@ + ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); + ImageIO.write(bufferedimage, "PNG", bytearrayoutputstream); + byte[] abyte = Base64.getEncoder().encode(bytearrayoutputstream.toByteArray()); -+ p_129879_.m_134906_("data:image/png;base64," + new String(abyte, StandardCharsets.UTF_8)); ++ p_129879_.setFavicon("data:image/png;base64," + new String(abyte, StandardCharsets.UTF_8)); + } catch (Exception exception) { -+ f_129750_.error("Couldn't load server icon", (Throwable) exception); ++ LOGGER.error("Couldn't load server icon", (Throwable) exception); + } + + }); + } + -+ public Optional m_182649_() { -+ return this.f_129744_.m_182514_(); ++ public Optional getWorldScreenshotFile() { ++ return this.storageSource.getIconFile(); + } + -+ public File m_6237_() { ++ public File getServerDirectory() { + return new File("."); + } + -+ protected void m_7268_(CrashReport p_129874_) { ++ protected void onServerCrash(CrashReport p_129874_) { + } + -+ public void m_6988_() { ++ public void onServerExit() { + System.exit(0); + } + -+ public void m_5705_(BooleanSupplier p_129871_) { ++ public void tickServer(BooleanSupplier p_129871_) { + co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper + -+ long i = Util.m_137569_(); ++ long i = Util.getNanos(); + + net.minecraftforge.event.ForgeEventFactory.onPreServerTick(p_129871_); -+ ++this.f_129766_; -+ this.m_5703_(p_129871_); -+ if (i - this.f_129724_ >= 5000000000L) { -+ this.f_129724_ = i; -+ this.f_129757_.m_134910_(new ServerStatus.Players(this.m_7418_(), this.m_7416_())); -+ if (!this.m_183306_()) { -+ GameProfile[] agameprofile = new GameProfile[Math.min(this.m_7416_(), 12)]; -+ int j = Mth.m_14072_(this.f_129758_, 0, this.m_7416_() - agameprofile.length); ++ ++this.tickCount; ++ this.tickChildren(p_129871_); ++ if (i - this.lastServerStatus >= 5000000000L) { ++ this.lastServerStatus = i; ++ this.status.setPlayers(new ServerStatus.Players(this.getMaxPlayers(), this.getPlayerCount())); ++ if (!this.hidesOnlinePlayers()) { ++ GameProfile[] agameprofile = new GameProfile[Math.min(this.getPlayerCount(), 12)]; ++ int j = Mth.nextInt(this.random, 0, this.getPlayerCount() - agameprofile.length); + + for (int k = 0; k < agameprofile.length; ++k) { -+ ServerPlayer serverplayer = this.f_129763_.m_11314_().get(j + k); -+ if (serverplayer.m_184128_()) { -+ agameprofile[k] = serverplayer.m_36316_(); ++ ServerPlayer serverplayer = this.playerList.getPlayers().get(j + k); ++ if (serverplayer.allowsListing()) { ++ agameprofile[k] = serverplayer.getGameProfile(); + } else { -+ agameprofile[k] = f_195496_; ++ agameprofile[k] = ANONYMOUS_PLAYER_PROFILE; + } + } + + Collections.shuffle(Arrays.asList(agameprofile)); -+ this.f_129757_.m_134914_().m_134924_(agameprofile); ++ this.status.getPlayers().setSample(agameprofile); + } -+ this.f_129757_.invalidateJson(); ++ this.status.invalidateJson(); + } + -+ if (autosavePeriod > 0 && this.f_129766_ % autosavePeriod == 0) { // CraftBukkit -+ f_129750_.debug("Autosave started"); -+ this.f_129754_.m_6180_("save"); -+ this.m_195514_(true, false, false); -+ this.f_129754_.m_7238_(); -+ f_129750_.debug("Autosave finished"); ++ if (autosavePeriod > 0 && this.tickCount % autosavePeriod == 0) { // CraftBukkit ++ LOGGER.debug("Autosave started"); ++ this.profiler.push("save"); ++ this.saveEverything(true, false, false); ++ this.profiler.pop(); ++ LOGGER.debug("Autosave finished"); + } + + // Paper start - move executeAll() into full server tick timing + try (co.aikar.timings.Timing ignored = co.aikar.timings.MinecraftTimings.processTasksTimer.startTiming()) { -+ this.m_18699_(); ++ this.runAllTasks(); + } + // Paper end -+ this.f_129754_.m_6180_("tallying"); -+ long l = this.f_129748_[this.f_129766_ % 100] = Util.m_137569_() - i; -+ this.f_129737_ = this.f_129737_ * 0.8F + (float) l / 1000000.0F * 0.19999999F; -+ long i1 = Util.m_137569_(); -+ this.f_129735_.m_13755_(i1 - i); -+ this.f_129754_.m_7238_(); ++ this.profiler.push("tallying"); ++ long l = this.tickTimes[this.tickCount % 100] = Util.getNanos() - i; ++ this.averageTickTime = this.averageTickTime * 0.8F + (float) l / 1000000.0F * 0.19999999F; ++ long i1 = Util.getNanos(); ++ this.frameTimer.logFrameDuration(i1 - i); ++ this.profiler.pop(); + org.spigotmc.WatchdogThread.tick(); // Spigot + net.minecraftforge.event.ForgeEventFactory.onPostServerTick(p_129871_); + co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper + } + -+ public void m_5703_(BooleanSupplier p_129954_) { ++ public void tickChildren(BooleanSupplier p_129954_) { + co.aikar.timings.MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper -+ this.server.getScheduler().mainThreadHeartbeat(this.f_129766_); // CraftBukkit ++ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit + co.aikar.timings.MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper -+ this.f_129754_.m_6180_("commandFunctions"); ++ this.profiler.push("commandFunctions"); + co.aikar.timings.MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper -+ this.m_129890_().m_136128_(); ++ this.getFunctions().tick(); + co.aikar.timings.MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper -+ this.f_129754_.m_6182_("levels"); ++ this.profiler.popPush("levels"); + + // CraftBukkit start + // Run tasks that are waiting on processing @@ -2758,456 +2758,456 @@ + co.aikar.timings.MinecraftTimings.processQueueTimer.stopTiming(); // Spigot + + for (ServerLevel serverlevel : this.getWorldArray()) { -+ long tickStart = Util.m_137569_(); -+ this.f_129754_.m_6521_(() -> { -+ return serverlevel + " " + serverlevel.m_46472_().m_135782_(); ++ long tickStart = Util.getNanos(); ++ this.profiler.push(() -> { ++ return serverlevel + " " + serverlevel.dimension().location(); + }); + co.aikar.timings.MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper -+ if (this.f_129766_ % 20 == 0) { -+ this.f_129754_.m_6180_("timeSync"); -+ this.f_129763_.m_11270_(new ClientboundSetTimePacket(serverlevel.m_46467_(), serverlevel.m_46468_(), serverlevel.m_46469_().m_46207_(GameRules.f_46140_)), serverlevel.m_46472_()); -+ this.f_129754_.m_7238_(); ++ if (this.tickCount % 20 == 0) { ++ this.profiler.push("timeSync"); ++ this.playerList.broadcastAll(new ClientboundSetTimePacket(serverlevel.getGameTime(), serverlevel.getDayTime(), serverlevel.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)), serverlevel.dimension()); ++ this.profiler.pop(); + } + co.aikar.timings.MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper + -+ this.f_129754_.m_6180_("tick"); ++ this.profiler.push("tick"); + net.minecraftforge.event.ForgeEventFactory.onPreWorldTick(serverlevel, p_129954_); + + try { + serverlevel.timings.doTick.startTiming(); // Spigot -+ serverlevel.m_8793_(p_129954_); ++ serverlevel.tick(p_129954_); + serverlevel.timings.doTick.stopTiming(); // Spigot + } catch (Throwable throwable) { + // Spigot Start + CrashReport crashreport; + try { -+ crashreport = CrashReport.m_127521_(throwable, "Exception ticking world"); ++ crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); + } catch (Throwable t) { + throw new RuntimeException("Error generating crash report", t); + } + // Spigot End -+ serverlevel.m_6026_(crashreport); ++ serverlevel.fillReportDetails(crashreport); + throw new ReportedException(crashreport); + } + net.minecraftforge.event.ForgeEventFactory.onPostWorldTick(serverlevel, p_129954_); + -+ this.f_129754_.m_7238_(); -+ this.f_129754_.m_7238_(); -+ perWorldTickTimes.computeIfAbsent(serverlevel.m_46472_(), k -> new long[100])[this.f_129766_ % 100] = Util.m_137569_() - tickStart; ++ this.profiler.pop(); ++ this.profiler.pop(); ++ perWorldTickTimes.computeIfAbsent(serverlevel.dimension(), k -> new long[100])[this.tickCount % 100] = Util.getNanos() - tickStart; + } + -+ this.f_129754_.m_6182_("connection"); ++ this.profiler.popPush("connection"); + co.aikar.timings.MinecraftTimings.connectionTimer.startTiming(); // Spigot -+ this.m_129919_().m_9721_(); ++ this.getConnection().tick(); + co.aikar.timings.MinecraftTimings.connectionTimer.stopTiming(); // Spigot -+ this.f_129754_.m_6182_("players"); ++ this.profiler.popPush("players"); + co.aikar.timings.MinecraftTimings.playerListTimer.startTiming(); // Spigot // Paper -+ this.f_129763_.m_11288_(); ++ this.playerList.tick(); + co.aikar.timings.MinecraftTimings.playerListTimer.stopTiming(); // Spigot // Paper + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { -+ GameTestTicker.f_177648_.m_127790_(); ++ GameTestTicker.SINGLETON.tick(); + } + -+ this.f_129754_.m_6182_("server gui refresh"); ++ this.profiler.popPush("server gui refresh"); + + co.aikar.timings.MinecraftTimings.tickablesTimer.startTiming(); // Spigot // Paper -+ for (int i = 0; i < this.f_129752_.size(); ++i) { -+ this.f_129752_.get(i).run(); ++ for (int i = 0; i < this.tickables.size(); ++i) { ++ this.tickables.get(i).run(); + } + co.aikar.timings.MinecraftTimings.tickablesTimer.stopTiming(); // Spigot // Paper + -+ this.f_129754_.m_7238_(); ++ this.profiler.pop(); + } + -+ public boolean m_7079_() { ++ public boolean isNetherEnabled() { + return true; + } + -+ public void m_129946_(Runnable p_129947_) { -+ this.f_129752_.add(p_129947_); ++ public void addTickable(Runnable p_129947_) { ++ this.tickables.add(p_129947_); + } + -+ protected void m_129948_(String p_129949_) { -+ this.f_129739_ = p_129949_; ++ protected void setId(String p_129949_) { ++ this.serverId = p_129949_; + } + -+ public boolean m_129782_() { -+ return !this.f_129725_.isAlive(); ++ public boolean isShutdown() { ++ return !this.serverThread.isAlive(); + } + -+ public File m_129971_(String p_129972_) { -+ return new File(this.m_6237_(), p_129972_); ++ public File getFile(String p_129972_) { ++ return new File(this.getServerDirectory(), p_129972_); + } + -+ public final ServerLevel m_129783_() { -+ return this.f_129762_.get(Level.f_46428_); ++ public final ServerLevel overworld() { ++ return this.levels.get(Level.OVERWORLD); + } + + @Nullable -+ public ServerLevel m_129880_(ResourceKey p_129881_) { -+ return this.f_129762_.get(p_129881_); ++ public ServerLevel getLevel(ResourceKey p_129881_) { ++ return this.levels.get(p_129881_); + } + -+ public Set> m_129784_() { -+ return this.f_129762_.keySet(); ++ public Set> levelKeys() { ++ return this.levels.keySet(); + } + -+ public Iterable m_129785_() { -+ return this.f_129762_.values(); ++ public Iterable getAllLevels() { ++ return this.levels.values(); + } + -+ public String m_7630_() { -+ return SharedConstants.m_183709_().getName(); ++ public String getServerVersion() { ++ return SharedConstants.getCurrentVersion().getName(); + } + -+ public int m_7416_() { -+ return this.f_129763_.m_11309_(); ++ public int getPlayerCount() { ++ return this.playerList.getPlayerCount(); + } + -+ public int m_7418_() { -+ return this.f_129763_.m_11310_(); ++ public int getMaxPlayers() { ++ return this.playerList.getMaxPlayers(); + } + -+ public String[] m_7641_() { -+ return this.f_129763_.m_11291_(); ++ public String[] getPlayerNames() { ++ return this.playerList.getPlayerNamesArray(); + } + + @DontObfuscate -+ public String m_130001_() { ++ public String getServerModName() { + return server.getName(); // Craftbukkit + } + -+ public SystemReport m_177935_(SystemReport p_177936_) { -+ p_177936_.m_143522_("Server Running", () -> { -+ return Boolean.toString(this.f_129764_); ++ public SystemReport fillSystemReport(SystemReport p_177936_) { ++ p_177936_.setDetail("Server Running", () -> { ++ return Boolean.toString(this.running); + }); -+ if (this.f_129763_ != null) { -+ p_177936_.m_143522_("Player Count", () -> { -+ return this.f_129763_.m_11309_() + " / " + this.f_129763_.m_11310_() + "; " + this.f_129763_.m_11314_(); ++ if (this.playerList != null) { ++ p_177936_.setDetail("Player Count", () -> { ++ return this.playerList.getPlayerCount() + " / " + this.playerList.getMaxPlayers() + "; " + this.playerList.getPlayers(); + }); + } + -+ p_177936_.m_143522_("Data Packs", () -> { ++ p_177936_.setDetail("Data Packs", () -> { + StringBuilder stringbuilder = new StringBuilder(); + + //TODO-PATCHING:Figure out how to stop the logger here. -+ for (Pack pack : this.f_129730_.m_10524_()) { ++ for (Pack pack : this.packRepository.getSelectedPacks()) { + if (stringbuilder.length() > 0) { + stringbuilder.append(", "); + } + -+ stringbuilder.append(pack.m_10446_()); -+ if (!pack.m_10443_().m_10489_()) { ++ stringbuilder.append(pack.getId()); ++ if (!pack.getCompatibility().isCompatible()) { + stringbuilder.append(" (incompatible)"); + } + } + + return stringbuilder.toString(); + }); -+ p_177936_.m_143522_("World Generation", () -> { -+ return this.f_129749_.m_5754_().toString(); ++ p_177936_.setDetail("World Generation", () -> { ++ return this.worldData.worldGenSettingsLifecycle().toString(); + }); -+ if (this.f_129739_ != null) { -+ p_177936_.m_143522_("Server Id", () -> { -+ return this.f_129739_; ++ if (this.serverId != null) { ++ p_177936_.setDetail("Server Id", () -> { ++ return this.serverId; + }); + } + -+ return this.m_142424_(p_177936_); ++ return this.fillServerSystemReport(p_177936_); + } + -+ public abstract SystemReport m_142424_(SystemReport p_177901_); ++ public abstract SystemReport fillServerSystemReport(SystemReport p_177901_); + -+ public ModCheck m_183471_() { -+ return ModCheck.m_184600_("vanilla", this::m_130001_, "Server", MinecraftServer.class); ++ public ModCheck getModdedStatus() { ++ return ModCheck.identify("vanilla", this::getServerModName, "Server", MinecraftServer.class); + } + -+ public void m_6352_(Component p_129876_, UUID p_129877_) { -+ f_129750_.info(p_129876_.getString()); ++ public void sendMessage(Component p_129876_, UUID p_129877_) { ++ LOGGER.info(p_129876_.getString()); + } + -+ public KeyPair m_129790_() { -+ return this.f_129712_; ++ public KeyPair getKeyPair() { ++ return this.keyPair; + } + -+ public int m_7010_() { -+ return this.f_129761_; ++ public int getPort() { ++ return this.port; + } + -+ public void m_129801_(int p_129802_) { -+ this.f_129761_ = p_129802_; ++ public void setPort(int p_129802_) { ++ this.port = p_129802_; + } + -+ public String m_129791_() { -+ return this.f_129713_; ++ public String getSingleplayerName() { ++ return this.singleplayerName; + } + -+ public void m_129981_(String p_129982_) { -+ this.f_129713_ = p_129982_; ++ public void setSingleplayerName(String p_129982_) { ++ this.singleplayerName = p_129982_; + } + -+ public boolean m_129792_() { -+ return this.f_129713_ != null; ++ public boolean isSingleplayer() { ++ return this.singleplayerName != null; + } + -+ protected void m_129793_() { -+ f_129750_.info("Generating keypair"); ++ protected void initializeKeyPair() { ++ LOGGER.info("Generating keypair"); + + try { -+ this.f_129712_ = Crypt.m_13604_(); ++ this.keyPair = Crypt.generateKeyPair(); + } catch (CryptException cryptexception) { + throw new IllegalStateException("Failed to generate key pair", cryptexception); + } + } + -+ public void m_129827_(Difficulty p_129828_, boolean p_129829_) { -+ if (p_129829_ || !this.f_129749_.m_5474_()) { -+ this.f_129749_.m_6166_(this.f_129749_.m_5466_() ? Difficulty.HARD : p_129828_); -+ this.m_129962_(); -+ this.m_6846_().m_11314_().forEach(this::m_129938_); ++ public void setDifficulty(Difficulty p_129828_, boolean p_129829_) { ++ if (p_129829_ || !this.worldData.isDifficultyLocked()) { ++ this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : p_129828_); ++ this.updateMobSpawningFlags(); ++ this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); + } + } + -+ public int m_7186_(int p_129935_) { ++ public int getScaledTrackingDistance(int p_129935_) { + return p_129935_; + } + -+ private void m_129962_() { -+ for (ServerLevel serverlevel : this.m_129785_()) { -+ serverlevel.m_46703_(this.m_7004_(), this.m_6998_()); ++ private void updateMobSpawningFlags() { ++ for (ServerLevel serverlevel : this.getAllLevels()) { ++ serverlevel.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); + } + + } + -+ public void m_129958_(boolean p_129959_) { -+ this.f_129749_.m_5560_(p_129959_); -+ this.m_6846_().m_11314_().forEach(this::m_129938_); ++ public void setDifficultyLocked(boolean p_129959_) { ++ this.worldData.setDifficultyLocked(p_129959_); ++ this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); + } + -+ private void m_129938_(ServerPlayer p_129939_) { -+ LevelData leveldata = p_129939_.m_183503_().m_6106_(); -+ p_129939_.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); ++ private void sendDifficultyUpdate(ServerPlayer p_129939_) { ++ LevelData leveldata = p_129939_.getLevel().getLevelData(); ++ p_129939_.connection.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); + } + -+ public boolean m_7004_() { -+ return this.f_129749_.m_5472_() != Difficulty.PEACEFUL; ++ public boolean isSpawningMonsters() { ++ return this.worldData.getDifficulty() != Difficulty.PEACEFUL; + } + -+ public boolean m_129794_() { -+ return this.f_129714_; ++ public boolean isDemo() { ++ return this.isDemo; + } + -+ public void m_129975_(boolean p_129976_) { -+ this.f_129714_ = p_129976_; ++ public void setDemo(boolean p_129976_) { ++ this.isDemo = p_129976_; + } + -+ public String m_129795_() { -+ return this.f_129715_; ++ public String getResourcePack() { ++ return this.resourcePack; + } + -+ public String m_129796_() { -+ return this.f_129716_; ++ public String getResourcePackHash() { ++ return this.resourcePackHash; + } + -+ public void m_129853_(String p_129854_, String p_129855_) { -+ this.f_129715_ = p_129854_; -+ this.f_129716_ = p_129855_; ++ public void setResourcePack(String p_129854_, String p_129855_) { ++ this.resourcePack = p_129854_; ++ this.resourcePackHash = p_129855_; + } + -+ public abstract boolean m_6982_(); ++ public abstract boolean isDedicatedServer(); + -+ public abstract int m_7032_(); ++ public abstract int getRateLimitPacketsPerSecond(); + -+ public boolean m_129797_() { -+ return this.f_129705_; ++ public boolean usesAuthentication() { ++ return this.onlineMode; + } + -+ public void m_129985_(boolean p_129986_) { -+ this.f_129705_ = p_129986_; ++ public void setUsesAuthentication(boolean p_129986_) { ++ this.onlineMode = p_129986_; + } + -+ public boolean m_129798_() { -+ return this.f_129706_; ++ public boolean getPreventProxyConnections() { ++ return this.preventProxyConnections; + } + -+ public void m_129993_(boolean p_129994_) { -+ this.f_129706_ = p_129994_; ++ public void setPreventProxyConnections(boolean p_129994_) { ++ this.preventProxyConnections = p_129994_; + } + -+ public boolean m_6998_() { ++ public boolean isSpawningAnimals() { + return true; + } + -+ public boolean m_6997_() { ++ public boolean areNpcsEnabled() { + return true; + } + -+ public abstract boolean m_6994_(); ++ public abstract boolean isEpollEnabled(); + -+ public boolean m_129799_() { -+ return this.f_129707_; ++ public boolean isPvpAllowed() { ++ return this.pvp; + } + -+ public void m_129997_(boolean p_129998_) { -+ this.f_129707_ = p_129998_; ++ public void setPvpAllowed(boolean p_129998_) { ++ this.pvp = p_129998_; + } + -+ public boolean m_129915_() { -+ return this.f_129708_; ++ public boolean isFlightAllowed() { ++ return this.allowFlight; + } + -+ public void m_129999_(boolean p_130000_) { -+ this.f_129708_ = p_130000_; ++ public void setFlightAllowed(boolean p_130000_) { ++ this.allowFlight = p_130000_; + } + -+ public abstract boolean m_6993_(); ++ public abstract boolean isCommandBlockEnabled(); + -+ public String m_129916_() { -+ return this.f_129709_; ++ public String getMotd() { ++ return this.motd; + } + -+ public void m_129989_(String p_129990_) { -+ this.f_129709_ = p_129990_; ++ public void setMotd(String p_129990_) { ++ this.motd = p_129990_; + } + -+ public boolean m_129918_() { -+ return this.f_129765_; ++ public boolean isStopped() { ++ return this.stopped; + } + -+ public PlayerList m_6846_() { -+ return this.f_129763_; ++ public PlayerList getPlayerList() { ++ return this.playerList; + } + -+ public void m_129823_(PlayerList p_129824_) { -+ this.f_129763_ = p_129824_; ++ public void setPlayerList(PlayerList p_129824_) { ++ this.playerList = p_129824_; + } + -+ public abstract boolean m_6992_(); ++ public abstract boolean isPublished(); + -+ public void m_7835_(GameType p_129832_) { -+ this.f_129749_.m_5458_(p_129832_); ++ public void setDefaultGameType(GameType p_129832_) { ++ this.worldData.setGameType(p_129832_); + } + + @Nullable -+ public ServerConnectionListener m_129919_() { -+ return this.f_129755_ == null ? this.f_129755_ = new ServerConnectionListener(this) : this.f_129755_; // Spigot ++ public ServerConnectionListener getConnection() { ++ return this.connection == null ? this.connection = new ServerConnectionListener(this) : this.connection; // Spigot + } + -+ public boolean m_129920_() { -+ return this.f_129717_; ++ public boolean isReady() { ++ return this.isReady; + } + -+ public boolean m_6370_() { ++ public boolean hasGui() { + return false; + } + -+ public boolean m_7386_(@Nullable GameType p_129833_, boolean p_129834_, int p_129835_) { ++ public boolean publishServer(@Nullable GameType p_129833_, boolean p_129834_, int p_129835_) { + return false; + } + -+ public int m_129921_() { -+ return this.f_129766_; ++ public int getTickCount() { ++ return this.tickCount; + } + -+ public int m_6396_() { ++ public int getSpawnProtectionRadius() { + return 16; + } + -+ public boolean m_7762_(ServerLevel p_129811_, BlockPos p_129812_, Player p_129813_) { ++ public boolean isUnderSpawnProtection(ServerLevel p_129811_, BlockPos p_129812_, Player p_129813_) { + return false; + } + -+ public boolean m_6373_() { ++ public boolean repliesToStatus() { + return true; + } + -+ public boolean m_183306_() { ++ public boolean hidesOnlinePlayers() { + return false; + } + -+ public Proxy m_177930_() { -+ return this.f_129747_; ++ public Proxy getProxy() { ++ return this.proxy; + } + -+ public int m_129924_() { -+ return this.f_129711_; ++ public int getPlayerIdleTimeout() { ++ return this.playerIdleTimeout; + } + -+ public void m_7196_(int p_129978_) { -+ this.f_129711_ = p_129978_; ++ public void setPlayerIdleTimeout(int p_129978_) { ++ this.playerIdleTimeout = p_129978_; + } + -+ public MinecraftSessionService m_129925_() { -+ return this.f_129721_; ++ public MinecraftSessionService getSessionService() { ++ return this.sessionService; + } + -+ public GameProfileRepository m_129926_() { -+ return this.f_129722_; ++ public GameProfileRepository getProfileRepository() { ++ return this.profileRepository; + } + -+ public GameProfileCache m_129927_() { -+ return this.f_129723_; ++ public GameProfileCache getProfileCache() { ++ return this.profileCache; + } + -+ public ServerStatus m_129928_() { -+ return this.f_129757_; ++ public ServerStatus getStatus() { ++ return this.status; + } + -+ public void m_129929_() { -+ this.f_129724_ = 0L; ++ public void invalidateStatus() { ++ this.lastServerStatus = 0L; + } + -+ public int m_6329_() { ++ public int getAbsoluteMaxWorldSize() { + return 29999984; + } + -+ public boolean m_5660_() { -+ return super.m_5660_() && !this.m_129918_(); ++ public boolean scheduleExecutables() { ++ return super.scheduleExecutables() && !this.isStopped(); + } + -+ public void m_201446_(Runnable p_202482_) { -+ if (this.m_129918_()) { ++ public void executeIfPossible(Runnable p_202482_) { ++ if (this.isStopped()) { + throw new RejectedExecutionException("Server already shutting down"); + } else { -+ super.m_201446_(p_202482_); ++ super.executeIfPossible(p_202482_); + } + } + -+ public Thread m_6304_() { -+ return this.f_129725_; ++ public Thread getRunningThread() { ++ return this.serverThread; + } + -+ public int m_6328_() { ++ public int getCompressionThreshold() { + return 256; + } + -+ public long m_129932_() { -+ return this.f_129726_; ++ public long getNextTickTime() { ++ return this.nextTickTime; + } + -+ public DataFixer m_129933_() { -+ return this.f_129759_; ++ public DataFixer getFixerUpper() { ++ return this.fixerUpper; + } + -+ public int m_129803_(@Nullable ServerLevel p_129804_) { -+ return p_129804_ != null ? p_129804_.m_46469_().m_46215_(GameRules.f_46147_) : 10; ++ public int getSpawnRadius(@Nullable ServerLevel p_129804_) { ++ return p_129804_ != null ? p_129804_.getGameRules().getInt(GameRules.RULE_SPAWN_RADIUS) : 10; + } + -+ public ServerAdvancementManager m_129889_() { -+ return this.f_129740_.f_206585_.m_206889_(); ++ public ServerAdvancementManager getAdvancements() { ++ return this.resources.managers.getAdvancements(); + } + -+ public ServerFunctionManager m_129890_() { -+ return this.f_129734_; ++ public ServerFunctionManager getFunctions() { ++ return this.functionManager; + } + -+ public CompletableFuture m_129861_(Collection p_129862_) { -+ RegistryAccess.Frozen registryaccess$frozen = this.m_206579_(); ++ public CompletableFuture reloadResources(Collection p_129862_) { ++ RegistryAccess.Frozen registryaccess$frozen = this.registryAccess(); + CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { -+ return p_129862_.stream().map(this.f_129730_::m_10507_).filter(Objects::nonNull).map(Pack::m_10445_).collect(ImmutableList.toImmutableList()); ++ return p_129862_.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()); + }, this).thenCompose((p_212913_) -> { + CloseableResourceManager closeableresourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, p_212913_); -+ return ReloadableServerResources.m_206861_(closeableresourcemanager, registryaccess$frozen, this.m_6982_() ? Commands.CommandSelection.DEDICATED : Commands.CommandSelection.INTEGRATED, this.m_7034_(), this.f_129738_, this).whenComplete((p_212907_, p_212908_) -> { ++ return ReloadableServerResources.loadResources(closeableresourcemanager, registryaccess$frozen, this.isDedicatedServer() ? Commands.CommandSelection.DEDICATED : Commands.CommandSelection.INTEGRATED, this.getFunctionCompilationLevel(), this.executor, this).whenComplete((p_212907_, p_212908_) -> { + if (p_212908_ != null) { + closeableresourcemanager.close(); + } @@ -3216,183 +3216,183 @@ + return new MinecraftServer.ReloadableResources(closeableresourcemanager, p_212904_); + }); + }).thenAcceptAsync((p_212919_) -> { -+ this.f_129740_.close(); -+ this.f_129740_ = p_212919_; ++ this.resources.close(); ++ this.resources = p_212919_; + org.magmafoundation.magma.craftbukkit.ItemMetaTransformer.loadPrefixes(); //Magma - reload prefixes -+ this.server.doSync(p_212919_.f_206585_().f_206847_); //Magma - sync forge commands -+ this.f_129730_.m_10509_(p_129862_); -+ this.f_129749_.m_6645_(m_129817_(this.f_129730_)); -+ this.f_129740_.f_206585_.m_206868_(this.m_206579_()); -+ this.m_6846_().m_11302_(); -+ this.m_6846_().m_11315_(); -+ this.f_129734_.m_136120_(this.f_129740_.f_206585_.m_206860_()); -+ this.f_129741_.m_74335_(this.f_129740_.f_206584_); -+ this.m_6846_().m_11314_().forEach(this.m_6846_()::m_11289_); //Forge: Fix newly added/modified commands not being sent to the client when commands reload. ++ this.server.doSync(p_212919_.managers().commands); //Magma - sync forge commands ++ this.packRepository.setSelected(p_129862_); ++ this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository)); ++ this.resources.managers.updateRegistryTags(this.registryAccess()); ++ this.getPlayerList().saveAll(); ++ this.getPlayerList().reloadResources(); ++ this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); ++ this.structureManager.onResourceManagerReload(this.resources.resourceManager); ++ 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.m_18695_()) { -+ this.m_18701_(completablefuture::isDone); ++ if (this.isSameThread()) { ++ this.managedBlock(completablefuture::isDone); + } + + return completablefuture; + } + -+ public static DataPackConfig m_129819_(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { ++ public static DataPackConfig configurePackRepository(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { + net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); -+ p_129820_.m_10506_(); -+ DataPackConfig.f_45842_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); ++ p_129820_.reload(); ++ DataPackConfig.DEFAULT.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); + p_129821_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); + if (p_129822_) { -+ p_129820_.m_10509_(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla()); ++ p_129820_.setSelected(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla()); + return new DataPackConfig(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla(), ImmutableList.of()); + } else { + Set set = Sets.newLinkedHashSet(); + -+ for (String s : p_129821_.m_45850_()) { -+ if (p_129820_.m_10515_(s)) { ++ for (String s : p_129821_.getEnabled()) { ++ if (p_129820_.isAvailable(s)) { + set.add(s); + } else { -+ f_129750_.warn("Missing data pack {}", (Object) s); ++ LOGGER.warn("Missing data pack {}", (Object) s); + } + } + -+ for (Pack pack : p_129820_.m_10519_()) { -+ String s1 = pack.m_10446_(); -+ if (!p_129821_.m_45855_().contains(s1) && !set.contains(s1)) { -+ f_129750_.info("Found new data pack {}, loading it automatically", (Object) s1); ++ for (Pack pack : p_129820_.getAvailablePacks()) { ++ String s1 = pack.getId(); ++ if (!p_129821_.getDisabled().contains(s1) && !set.contains(s1)) { ++ LOGGER.info("Found new data pack {}, loading it automatically", (Object) s1); + set.add(s1); + } + } + + if (set.isEmpty()) { -+ f_129750_.info("No datapacks selected, forcing vanilla"); ++ LOGGER.info("No datapacks selected, forcing vanilla"); + set.add("vanilla"); + } + -+ p_129820_.m_10509_(set); -+ return m_129817_(p_129820_); ++ p_129820_.setSelected(set); ++ return getSelectedPacks(p_129820_); + } + } + -+ private static DataPackConfig m_129817_(PackRepository p_129818_) { -+ Collection collection = p_129818_.m_10523_(); ++ private static DataPackConfig getSelectedPacks(PackRepository p_129818_) { ++ Collection collection = p_129818_.getSelectedIds(); + List list = ImmutableList.copyOf(collection); -+ List list1 = p_129818_.m_10514_().stream().filter((p_212916_) -> { ++ List list1 = p_129818_.getAvailableIds().stream().filter((p_212916_) -> { + return !collection.contains(p_212916_); + }).collect(ImmutableList.toImmutableList()); + return new DataPackConfig(list, list1); + } + -+ public void m_129849_(CommandSourceStack p_129850_) { -+ if (this.m_129902_()) { -+ PlayerList playerlist = p_129850_.m_81377_().m_6846_(); -+ UserWhiteList userwhitelist = playerlist.m_11305_(); ++ public void kickUnlistedPlayers(CommandSourceStack p_129850_) { ++ if (this.isEnforceWhitelist()) { ++ PlayerList playerlist = p_129850_.getServer().getPlayerList(); ++ UserWhiteList userwhitelist = playerlist.getWhiteList(); + -+ for (ServerPlayer serverplayer : Lists.newArrayList(playerlist.m_11314_())) { -+ if (!userwhitelist.m_11453_(serverplayer.m_36316_())) { -+ serverplayer.f_8906_.m_9942_(new TranslatableComponent("multiplayer.disconnect.not_whitelisted")); ++ for (ServerPlayer serverplayer : Lists.newArrayList(playerlist.getPlayers())) { ++ if (!userwhitelist.isWhiteListed(serverplayer.getGameProfile())) { ++ serverplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.not_whitelisted")); + } + } + + } + } + -+ public PackRepository m_129891_() { -+ return this.f_129730_; ++ public PackRepository getPackRepository() { ++ return this.packRepository; + } + -+ public Commands m_129892_() { -+ return this.f_129740_.f_206585_.m_206888_(); ++ public Commands getCommands() { ++ return this.resources.managers.getCommands(); + } + -+ public CommandSourceStack m_129893_() { -+ ServerLevel serverlevel = this.m_129783_(); -+ return new CommandSourceStack(this, serverlevel == null ? Vec3.f_82478_ : Vec3.m_82528_(serverlevel.m_8900_()), Vec2.f_82462_, serverlevel, 4, "Server", new TextComponent("Server"), this, (Entity) null); ++ public CommandSourceStack createCommandSourceStack() { ++ ServerLevel serverlevel = this.overworld(); ++ return new CommandSourceStack(this, serverlevel == null ? Vec3.ZERO : Vec3.atLowerCornerOf(serverlevel.getSharedSpawnPos()), Vec2.ZERO, serverlevel, 4, "Server", new TextComponent("Server"), this, (Entity) null); + } + -+ public boolean m_6999_() { ++ public boolean acceptsSuccess() { + return true; + } + -+ public boolean m_7028_() { ++ public boolean acceptsFailure() { + return true; + } + -+ public abstract boolean m_6102_(); ++ public abstract boolean shouldInformAdmins(); + -+ public RecipeManager m_129894_() { -+ return this.f_129740_.f_206585_.m_206887_(); ++ public RecipeManager getRecipeManager() { ++ return this.resources.managers.getRecipeManager(); + } + -+ public ServerScoreboard m_129896_() { -+ return this.f_129731_; ++ public ServerScoreboard getScoreboard() { ++ return this.scoreboard; + } + -+ public CommandStorage m_129897_() { -+ if (this.f_129732_ == null) { ++ public CommandStorage getCommandStorage() { ++ if (this.commandStorage == null) { + throw new NullPointerException("Called before server init"); + } else { -+ return this.f_129732_; ++ return this.commandStorage; + } + } + -+ public LootTables m_129898_() { -+ return this.f_129740_.f_206585_.m_206885_(); ++ public LootTables getLootTables() { ++ return this.resources.managers.getLootTables(); + } + -+ public PredicateManager m_129899_() { -+ return this.f_129740_.f_206585_.m_206881_(); ++ public PredicateManager getPredicateManager() { ++ return this.resources.managers.getPredicateManager(); + } + -+ public ItemModifierManager m_177926_() { -+ return this.f_129740_.f_206585_.m_206886_(); ++ public ItemModifierManager getItemModifierManager() { ++ return this.resources.managers.getItemModifierManager(); + } + -+ public GameRules m_129900_() { -+ return this.m_129783_().m_46469_(); ++ public GameRules getGameRules() { ++ return this.overworld().getGameRules(); + } + -+ public CustomBossEvents m_129901_() { -+ return this.f_129733_; ++ public CustomBossEvents getCustomBossEvents() { ++ return this.customBossEvents; + } + -+ public boolean m_129902_() { -+ return this.f_129736_; ++ public boolean isEnforceWhitelist() { ++ return this.enforceWhitelist; + } + -+ public void m_130004_(boolean p_130005_) { -+ this.f_129736_ = p_130005_; ++ public void setEnforceWhitelist(boolean p_130005_) { ++ this.enforceWhitelist = p_130005_; + } + -+ public float m_129903_() { -+ return this.f_129737_; ++ public float getAverageTickTime() { ++ return this.averageTickTime; + } + -+ public int m_129944_(GameProfile p_129945_) { -+ if (this.m_6846_().m_11303_(p_129945_)) { -+ ServerOpListEntry serveroplistentry = this.m_6846_().m_11307_().m_11388_(p_129945_); ++ public int getProfilePermissions(GameProfile p_129945_) { ++ if (this.getPlayerList().isOp(p_129945_)) { ++ ServerOpListEntry serveroplistentry = this.getPlayerList().getOps().get(p_129945_); + if (serveroplistentry != null) { -+ return serveroplistentry.m_11363_(); -+ } else if (this.m_7779_(p_129945_)) { ++ return serveroplistentry.getLevel(); ++ } else if (this.isSingleplayerOwner(p_129945_)) { + return 4; -+ } else if (this.m_129792_()) { -+ return this.m_6846_().m_11316_() ? 4 : 0; ++ } else if (this.isSingleplayer()) { ++ return this.getPlayerList().isAllowCheatsForAllPlayers() ? 4 : 0; + } else { -+ return this.m_7022_(); ++ return this.getOperatorUserPermissionLevel(); + } + } else { + return 0; + } + } + -+ public FrameTimer m_129904_() { -+ return this.f_129735_; ++ public FrameTimer getFrameTimer() { ++ return this.frameTimer; + } + -+ public ProfilerFiller m_129905_() { -+ return this.f_129754_; ++ public ProfilerFiller getProfiler() { ++ return this.profiler; + } + -+ public abstract boolean m_7779_(GameProfile p_129840_); ++ public abstract boolean isSingleplayerOwner(GameProfile p_129840_); + + private Map, long[]> perWorldTickTimes = Maps.newIdentityHashMap(); + @@ -3403,7 +3403,7 @@ + + @Deprecated //Forge Internal use Only, You can screw up a lot of things if you mess with this map. + public synchronized Map, ServerLevel> forgeGetWorldMap() { -+ return this.f_129762_; ++ return this.levels; + } + + private int worldArrayMarker = 0; @@ -3418,45 +3418,45 @@ + private ServerLevel[] getWorldArray() { + if (worldArrayMarker == worldArrayLast && worldArray != null) + return worldArray; -+ worldArray = this.f_129762_.values().stream().toArray(x -> new ServerLevel[x]); ++ worldArray = this.levels.values().stream().toArray(x -> new ServerLevel[x]); + worldArrayLast = worldArrayMarker; + return worldArray; + } + -+ public void m_142116_(Path p_177911_) throws IOException { ++ public void dumpServerProperties(Path p_177911_) throws IOException { + } + -+ private void m_129859_(Path p_129860_) { ++ private void saveDebugReport(Path p_129860_) { + Path path = p_129860_.resolve("levels"); + + try { -+ for (Entry, ServerLevel> entry : this.f_129762_.entrySet()) { -+ ResourceLocation resourcelocation = entry.getKey().m_135782_(); -+ Path path1 = path.resolve(resourcelocation.m_135827_()).resolve(resourcelocation.m_135815_()); ++ for (Entry, ServerLevel> entry : this.levels.entrySet()) { ++ ResourceLocation resourcelocation = entry.getKey().location(); ++ Path path1 = path.resolve(resourcelocation.getNamespace()).resolve(resourcelocation.getPath()); + Files.createDirectories(path1); -+ entry.getValue().m_8786_(path1); ++ entry.getValue().saveDebugReport(path1); + } + -+ this.m_129983_(p_129860_.resolve("gamerules.txt")); -+ this.m_129991_(p_129860_.resolve("classpath.txt")); -+ this.m_129950_(p_129860_.resolve("stats.txt")); -+ this.m_129995_(p_129860_.resolve("threads.txt")); -+ this.m_142116_(p_129860_.resolve("server.properties.txt")); -+ this.m_195521_(p_129860_.resolve("modules.txt")); ++ this.dumpGameRules(p_129860_.resolve("gamerules.txt")); ++ this.dumpClasspath(p_129860_.resolve("classpath.txt")); ++ this.dumpMiscStats(p_129860_.resolve("stats.txt")); ++ this.dumpThreads(p_129860_.resolve("threads.txt")); ++ this.dumpServerProperties(p_129860_.resolve("server.properties.txt")); ++ this.dumpNativeModules(p_129860_.resolve("modules.txt")); + } catch (IOException ioexception) { -+ f_129750_.warn("Failed to save debug report", (Throwable) ioexception); ++ LOGGER.warn("Failed to save debug report", (Throwable) ioexception); + } + + } + -+ private void m_129950_(Path p_129951_) throws IOException { ++ private void dumpMiscStats(Path p_129951_) throws IOException { + Writer writer = Files.newBufferedWriter(p_129951_); + + try { -+ writer.write(String.format("pending_tasks: %d\n", this.m_18696_())); -+ writer.write(String.format("average_tick_time: %f\n", this.m_129903_())); -+ writer.write(String.format("tick_times: %s\n", Arrays.toString(this.f_129748_))); -+ writer.write(String.format("queue: %s\n", Util.m_183991_())); ++ writer.write(String.format("pending_tasks: %d\n", this.getPendingTasksCount())); ++ writer.write(String.format("average_tick_time: %f\n", this.getAverageTickTime())); ++ writer.write(String.format("tick_times: %s\n", Arrays.toString(this.tickTimes))); ++ writer.write(String.format("queue: %s\n", Util.backgroundExecutor())); + } catch (Throwable throwable1) { + if (writer != null) { + try { @@ -3475,15 +3475,15 @@ + + } + -+ private void m_129983_(Path p_129984_) throws IOException { ++ private void dumpGameRules(Path p_129984_) throws IOException { + Writer writer = Files.newBufferedWriter(p_129984_); + + try { + final List list = Lists.newArrayList(); -+ final GameRules gamerules = this.m_129900_(); -+ GameRules.m_46164_(new GameRules.GameRuleTypeVisitor() { -+ public > void m_6889_(GameRules.Key p_195531_, GameRules.Type p_195532_) { -+ list.add(String.format("%s=%s\n", p_195531_.m_46328_(), gamerules.m_46170_(p_195531_))); ++ final GameRules gamerules = this.getGameRules(); ++ GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { ++ public > void visit(GameRules.Key p_195531_, GameRules.Type p_195532_) { ++ list.add(String.format("%s=%s\n", p_195531_.getId(), gamerules.getRule(p_195531_))); + } + }); + @@ -3508,7 +3508,7 @@ + + } + -+ private void m_129991_(Path p_129992_) throws IOException { ++ private void dumpClasspath(Path p_129992_) throws IOException { + Writer writer = Files.newBufferedWriter(p_129992_); + + try { @@ -3537,7 +3537,7 @@ + + } + -+ private void m_129995_(Path p_129996_) throws IOException { ++ private void dumpThreads(Path p_129996_) throws IOException { + ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); + ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); + Arrays.sort(athreadinfo, Comparator.comparing(ThreadInfo::getThreadName)); @@ -3566,7 +3566,7 @@ + + } + -+ private void m_195521_(Path p_195522_) throws IOException { ++ private void dumpNativeModules(Path p_195522_) throws IOException { + Writer writer = Files.newBufferedWriter(p_195522_); + + label49: @@ -3576,14 +3576,14 @@ + { + List list; + try { -+ list = Lists.newArrayList(NativeModuleLister.m_184666_()); ++ list = Lists.newArrayList(NativeModuleLister.listModules()); + } catch (Throwable throwable1) { -+ f_129750_.warn("Failed to list native modules", throwable1); ++ LOGGER.warn("Failed to list native modules", throwable1); + break label50; + } + + list.sort(Comparator.comparing((p_212910_) -> { -+ return p_212910_.f_184690_; ++ return p_212910_.name; + })); + Iterator $$3 = list.iterator(); + @@ -3624,8 +3624,8 @@ + + // CraftBukkit start + @Override -+ public boolean m_18695_() { -+ return super.m_18695_() || this.m_129918_(); // CraftBukkit - MC-142590 ++ public boolean isSameThread() { ++ return super.isSameThread() || this.isStopped(); // CraftBukkit - MC-142590 + } + + public boolean isDebugging() { @@ -3642,163 +3642,163 @@ + } + // CraftBukkit end + -+ private void m_177945_() { -+ if (this.f_177875_) { -+ this.f_177872_ = ActiveMetricsRecorder.m_146132_(new ServerMetricsSamplersProvider(Util.f_137440_, this.m_6982_()), Util.f_137440_, Util.m_183992_(), new MetricsPersister("server"), this.f_177873_, (p_212927_) -> { -+ this.m_18709_(() -> { -+ this.m_129859_(p_212927_.resolve("server")); ++ private void startMetricsRecordingTick() { ++ if (this.willStartRecordingMetrics) { ++ this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (p_212927_) -> { ++ this.executeBlocking(() -> { ++ this.saveDebugReport(p_212927_.resolve("server")); + }); -+ this.f_177874_.accept(p_212927_); ++ this.onMetricsRecordingFinished.accept(p_212927_); + }); -+ this.f_177875_ = false; ++ this.willStartRecordingMetrics = false; + } + -+ this.f_129754_ = SingleTickProfiler.m_18629_(this.f_177872_.m_142610_(), SingleTickProfiler.m_18632_("Server")); -+ this.f_177872_.m_142759_(); -+ this.f_129754_.m_7242_(); ++ this.profiler = SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server")); ++ this.metricsRecorder.startTick(); ++ this.profiler.startTick(); + } + -+ private void m_177946_() { -+ this.f_129754_.m_7241_(); -+ this.f_177872_.m_142758_(); ++ private void endMetricsRecordingTick() { ++ this.profiler.endTick(); ++ this.metricsRecorder.endTick(); + } + -+ public boolean m_177927_() { -+ return this.f_177872_.m_142763_(); ++ public boolean isRecordingMetrics() { ++ return this.metricsRecorder.isRecording(); + } + -+ public void m_177923_(Consumer p_177924_, Consumer p_177925_) { -+ this.f_177873_ = (p_212922_) -> { -+ this.m_177928_(); ++ public void startRecordingMetrics(Consumer p_177924_, Consumer p_177925_) { ++ this.onMetricsRecordingStopped = (p_212922_) -> { ++ this.stopRecordingMetrics(); + p_177924_.accept(p_212922_); + }; -+ this.f_177874_ = p_177925_; -+ this.f_177875_ = true; ++ this.onMetricsRecordingFinished = p_177925_; ++ this.willStartRecordingMetrics = true; + } + -+ public void m_177928_() { -+ this.f_177872_ = InactiveMetricsRecorder.f_146153_; ++ public void stopRecordingMetrics() { ++ this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; + } + -+ public void m_177929_() { -+ this.f_177872_.m_142760_(); ++ public void finishRecordingMetrics() { ++ this.metricsRecorder.end(); + } + -+ public Path m_129843_(LevelResource p_129844_) { -+ return this.f_129744_.m_78283_(p_129844_); ++ public Path getWorldPath(LevelResource p_129844_) { ++ return this.storageSource.getLevelPath(p_129844_); + } + -+ public boolean m_6365_() { ++ public boolean forceSynchronousWrites() { + return true; + } + -+ public StructureManager m_129909_() { -+ return this.f_129741_; ++ public StructureManager getStructureManager() { ++ return this.structureManager; + } + -+ public WorldData m_129910_() { -+ return this.f_129749_; ++ public WorldData getWorldData() { ++ return this.worldData; + } + + public MinecraftServer.ReloadableResources getServerResources() { -+ return f_129740_; ++ return resources; + } + -+ public RegistryAccess.Frozen m_206579_() { -+ return this.f_129746_; ++ public RegistryAccess.Frozen registryAccess() { ++ return this.registryHolder; + } + -+ public TextFilter m_7950_(ServerPlayer p_129814_) { -+ return TextFilter.f_143703_; ++ public TextFilter createTextFilterForPlayer(ServerPlayer p_129814_) { ++ return TextFilter.DUMMY; + } + -+ public boolean m_142205_() { ++ public boolean isResourcePackRequired() { + return false; + } + -+ public ServerPlayerGameMode m_177933_(ServerPlayer p_177934_) { -+ return (ServerPlayerGameMode) (this.m_129794_() ? new DemoMode(p_177934_) : new ServerPlayerGameMode(p_177934_)); ++ public ServerPlayerGameMode createGameModeForPlayer(ServerPlayer p_177934_) { ++ return (ServerPlayerGameMode) (this.isDemo() ? new DemoMode(p_177934_) : new ServerPlayerGameMode(p_177934_)); + } + + @Nullable -+ public GameType m_142359_() { ++ public GameType getForcedGameType() { + return null; + } + -+ public ResourceManager m_177941_() { -+ return this.f_129740_.f_206584_; ++ public ResourceManager getResourceManager() { ++ return this.resources.resourceManager; + } + + @Nullable -+ public Component m_141958_() { ++ public Component getResourcePackPrompt() { + return null; + } + -+ public boolean m_195518_() { -+ return this.f_195494_; ++ public boolean isCurrentlySaving() { ++ return this.isSaving; + } + -+ public boolean m_177942_() { -+ return this.f_177877_ || this.f_177876_ != null; ++ public boolean isTimeProfilerRunning() { ++ return this.debugCommandProfilerDelayStart || this.debugCommandProfiler != null; + } + -+ public void m_177943_() { -+ this.f_177877_ = true; ++ public void startTimeProfiler() { ++ this.debugCommandProfilerDelayStart = true; + } + -+ public ProfileResults m_177944_() { -+ if (this.f_177876_ == null) { -+ return EmptyProfileResults.f_18441_; ++ public ProfileResults stopTimeProfiler() { ++ if (this.debugCommandProfiler == null) { ++ return EmptyProfileResults.EMPTY; + } else { -+ ProfileResults profileresults = this.f_177876_.m_177960_(Util.m_137569_(), this.f_129766_); -+ this.f_177876_ = null; ++ ProfileResults profileresults = this.debugCommandProfiler.stop(Util.getNanos(), this.tickCount); ++ this.debugCommandProfiler = null; + return profileresults; + } + } + -+ public static record ReloadableResources(CloseableResourceManager f_206584_, -+ ReloadableServerResources f_206585_) implements AutoCloseable { ++ public static record ReloadableResources(CloseableResourceManager resourceManager, ++ ReloadableServerResources managers) implements AutoCloseable { + public void close() { -+ this.f_206584_.close(); ++ this.resourceManager.close(); + } + } + + static class TimeProfiler { -+ final long f_177955_; -+ final int f_177956_; ++ final long startNanos; ++ final int startTick; + + TimeProfiler(long p_177958_, int p_177959_) { -+ this.f_177955_ = p_177958_; -+ this.f_177956_ = p_177959_; ++ this.startNanos = p_177958_; ++ this.startTick = p_177959_; + } + -+ ProfileResults m_177960_(final long p_177961_, final int p_177962_) { ++ ProfileResults stop(final long p_177961_, final int p_177962_) { + return new ProfileResults() { -+ public List m_6412_(String p_177972_) { ++ public List getTimes(String p_177972_) { + return Collections.emptyList(); + } + -+ public boolean m_142444_(Path p_177974_) { ++ public boolean saveResults(Path p_177974_) { + return false; + } + -+ public long m_7229_() { -+ return TimeProfiler.this.f_177955_; ++ public long getStartTimeNano() { ++ return TimeProfiler.this.startNanos; + } + -+ public int m_7230_() { -+ return TimeProfiler.this.f_177956_; ++ public int getStartTimeTicks() { ++ return TimeProfiler.this.startTick; + } + -+ public long m_7236_() { ++ public long getEndTimeNano() { + return p_177961_; + } + -+ public int m_7317_() { ++ public int getEndTimeTicks() { + return p_177962_; + } + -+ public String m_142368_() { ++ public String getProfilerResults() { + return ""; + } + }; diff --git a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch index f91281cf..416e441a 100644 --- a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch @@ -1,63 +1,63 @@ --- a/net/minecraft/server/PlayerAdvancements.java +++ b/net/minecraft/server/PlayerAdvancements.java @@ -61,7 +_,7 @@ - private final DataFixer f_135961_; - private final PlayerList f_135962_; - private final File f_135963_; -- private final Map f_135964_ = Maps.newLinkedHashMap(); -+ public final Map f_135964_ = Maps.newLinkedHashMap(); //Magma - private -> public - private final Set f_135965_ = Sets.newLinkedHashSet(); - private final Set f_135966_ = Sets.newLinkedHashSet(); - private final Set f_135967_ = Sets.newLinkedHashSet(); + private final DataFixer dataFixer; + private final PlayerList playerList; + private final File file; +- private final Map advancements = Maps.newLinkedHashMap(); ++ public final Map advancements = Maps.newLinkedHashMap(); //Magma - private -> public + private final Set visible = Sets.newLinkedHashSet(); + private final Set visibilityChanged = Sets.newLinkedHashSet(); + private final Set progressChanged = Sets.newLinkedHashSet(); @@ -157,7 +_,11 @@ for(Entry entry : stream.collect(Collectors.toList())) { - Advancement advancement = p_136007_.m_136041_(entry.getKey()); + Advancement advancement = p_136007_.getAdvancement(entry.getKey()); if (advancement == null) { -- f_135958_.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f_135963_); +- LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); + // CraftBukkit start -+ if (entry.getKey().m_135827_().equals("minecraft")) { -+ PlayerAdvancements.f_135958_.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f_135963_); ++ if (entry.getKey().getNamespace().equals("minecraft")) { ++ PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); + } + // CraftBukkit end } else { - this.m_135985_(advancement, entry.getValue()); + this.startProgress(advancement, entry.getValue()); } @@ -181,11 +_,16 @@ } - this.m_136002_(p_136007_); + this.checkForAutomaticTriggers(p_136007_); + + if (net.minecraftforge.common.ForgeConfig.SERVER.fixAdvancementLoading.get()) -+ net.minecraftforge.common.AdvancementLoadFix.loadVisibility(this, this.f_135965_, this.f_135966_, this.f_135964_, this.f_135967_, this::m_136012_); ++ net.minecraftforge.common.AdvancementLoadFix.loadVisibility(this, this.visible, this.visibilityChanged, this.advancements, this.progressChanged, this::shouldBeVisible); + else - this.m_136001_(); - this.m_135994_(p_136007_); + this.ensureAllVisible(); + this.registerListeners(p_136007_); } - public void m_135991_() { + public void save() { + if (org.spigotmc.SpigotConfig.disableAdvancementSaving) return; // Spigot Map map = Maps.newHashMap(); - for(Entry entry : this.f_135964_.entrySet()) { + for(Entry entry : this.advancements.entrySet()) { @@ -239,6 +_,8 @@ } - public boolean m_135988_(Advancement p_135989_, String p_135990_) { + public boolean award(Advancement p_135989_, String p_135990_) { + // Forge: don't grant advancements for fake players -+ if (this.f_135968_ instanceof net.minecraftforge.common.util.FakePlayer) return false; ++ if (this.player instanceof net.minecraftforge.common.util.FakePlayer) return false; boolean flag = false; - AdvancementProgress advancementprogress = this.m_135996_(p_135989_); - boolean flag1 = advancementprogress.m_8193_(); + AdvancementProgress advancementprogress = this.getOrStartProgress(p_135989_); + boolean flag1 = advancementprogress.isDone(); @@ -247,10 +_,12 @@ - this.f_135967_.add(p_135989_); + this.progressChanged.add(p_135989_); flag = true; - if (!flag1 && advancementprogress.m_8193_()) { -+ this.f_135968_.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.f_135968_.getBukkitEntity(), p_135989_.bukkit)); // CraftBukkit - p_135989_.m_138321_().m_9989_(this.f_135968_); - if (p_135989_.m_138320_() != null && p_135989_.m_138320_().m_14996_() && this.f_135968_.f_19853_.m_46469_().m_46207_(GameRules.f_46153_)) { - this.f_135962_.m_11264_(new TranslatableComponent("chat.type.advancement." + p_135989_.m_138320_().m_14992_().m_15548_(), this.f_135968_.m_5446_(), p_135989_.m_138330_()), ChatType.SYSTEM, Util.f_137441_); + if (!flag1 && advancementprogress.isDone()) { ++ this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), p_135989_.bukkit)); // CraftBukkit + p_135989_.getRewards().grant(this.player); + if (p_135989_.getDisplay() != null && p_135989_.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { + this.playerList.broadcastMessage(new TranslatableComponent("chat.type.advancement." + p_135989_.getDisplay().getFrame().getName(), this.player.getDisplayName(), p_135989_.getChatComponent()), ChatType.SYSTEM, Util.NIL_UUID); } -+ net.minecraftforge.common.ForgeHooks.onAdvancement(this.f_135968_, p_135989_); ++ net.minecraftforge.common.ForgeHooks.onAdvancement(this.player, p_135989_); } } diff --git a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch index 962df672..b82ef090 100644 --- a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,53 +1,53 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java @@ -28,18 +_,22 @@ - private static final Logger f_206845_ = LogUtils.getLogger(); - private static final CompletableFuture f_206846_ = CompletableFuture.completedFuture(Unit.INSTANCE); - public Commands f_206847_; -- private final RecipeManager f_206848_ = new RecipeManager(); -+ private final RecipeManager f_206848_; - private final TagManager f_206849_; - private final PredicateManager f_206850_ = new PredicateManager(); - private final LootTables f_206851_ = new LootTables(this.f_206850_); - private final ItemModifierManager f_206852_ = new ItemModifierManager(this.f_206850_, this.f_206851_); -- private final ServerAdvancementManager f_206853_ = new ServerAdvancementManager(this.f_206850_); -+ private final ServerAdvancementManager f_206853_; - private final ServerFunctionLibrary f_206854_; + private static final Logger LOGGER = LogUtils.getLogger(); + private static final CompletableFuture DATA_RELOAD_INITIAL_TASK = CompletableFuture.completedFuture(Unit.INSTANCE); + public Commands commands; +- private final RecipeManager recipes = new RecipeManager(); ++ private final RecipeManager recipes; + private final TagManager tagManager; + private final PredicateManager predicateManager = new PredicateManager(); + private final LootTables lootTables = new LootTables(this.predicateManager); + private final ItemModifierManager itemModifierManager = new ItemModifierManager(this.predicateManager, this.lootTables); +- private final ServerAdvancementManager advancements = new ServerAdvancementManager(this.predicateManager); ++ private final ServerAdvancementManager advancements; + private final ServerFunctionLibrary functionLibrary; public ReloadableServerResources(RegistryAccess.Frozen p_206857_, Commands.CommandSelection p_206858_, int p_206859_) { - this.f_206849_ = new TagManager(p_206857_); - this.f_206847_ = new Commands(p_206858_); - this.f_206854_ = new ServerFunctionLibrary(p_206859_, this.f_206847_.m_82094_()); + this.tagManager = new TagManager(p_206857_); + this.commands = new Commands(p_206858_); + this.functionLibrary = new ServerFunctionLibrary(p_206859_, this.commands.getDispatcher()); + // Forge: Create context object and pass it to the recipe manager. -+ this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.f_206849_); -+ this.f_206848_ = new RecipeManager(context); -+ this.f_206853_ = new ServerAdvancementManager(this.f_206850_, context); ++ this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.tagManager); ++ this.recipes = new RecipeManager(context); ++ this.advancements = new ServerAdvancementManager(this.predicateManager, context); } - public ServerFunctionLibrary m_206860_() { + public ServerFunctionLibrary getFunctionLibrary() { @@ -76,7 +_,9 @@ - public static CompletableFuture m_206861_(ResourceManager p_206862_, RegistryAccess.Frozen p_206863_, Commands.CommandSelection p_206864_, int p_206865_, Executor p_206866_, Executor p_206867_) { + public static CompletableFuture loadResources(ResourceManager p_206862_, RegistryAccess.Frozen p_206863_, Commands.CommandSelection p_206864_, int p_206865_, Executor p_206866_, Executor p_206867_) { ReloadableServerResources reloadableserverresources = new ReloadableServerResources(p_206863_, p_206864_, p_206865_); -- return SimpleReloadInstance.m_203834_(p_206862_, reloadableserverresources.m_206890_(), p_206866_, p_206867_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().thenApply((p_206880_) -> { -+ List listeners = new java.util.ArrayList<>(reloadableserverresources.m_206890_()); +- return SimpleReloadInstance.create(p_206862_, reloadableserverresources.listeners(), p_206866_, p_206867_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled()).done().thenApply((p_206880_) -> { ++ List listeners = new java.util.ArrayList<>(reloadableserverresources.listeners()); + listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources)); -+ return SimpleReloadInstance.m_203834_(p_206862_, listeners, p_206866_, p_206867_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().thenApply((p_206880_) -> { ++ return SimpleReloadInstance.create(p_206862_, listeners, p_206866_, p_206867_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled()).done().thenApply((p_206880_) -> { return reloadableserverresources; }); } @@ -86,6 +_,7 @@ - m_206870_(p_206869_, p_206884_); + updateRegistryTags(p_206869_, p_206884_); }); - Blocks.m_50758_(); + Blocks.rebuildCache(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(p_206869_, false, false)); } - private static void m_206870_(RegistryAccess p_206871_, TagManager.LoadResult p_206872_) { + private static void updateRegistryTags(RegistryAccess p_206871_, TagManager.LoadResult p_206872_) { @@ -96,5 +_,16 @@ - return p_206874_.getValue().m_6497_(); + return p_206874_.getValue().getValues(); })); - p_206871_.m_175515_(resourcekey).m_203652_(map); + p_206871_.registryOrThrow(resourcekey).bindTags(map); + } + + private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; diff --git a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch index 7ddee0a4..67cce518 100644 --- a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch +++ b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/ServerAdvancementManager.java +++ b/net/minecraft/server/ServerAdvancementManager.java @@ -26,18 +_,36 @@ - public static final Gson f_136022_ = (new GsonBuilder()).create(); - public AdvancementList f_136023_ = new AdvancementList(); - private final PredicateManager f_136024_; + public static final Gson GSON = (new GsonBuilder()).create(); + public AdvancementList advancements = new AdvancementList(); + private final PredicateManager predicateManager; + private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; //Forge: add context + /** @deprecated Forge: use {@linkplain ServerAdvancementManager#ServerAdvancementManager(PredicateManager, net.minecraftforge.common.crafting.conditions.ICondition.IContext) constructor with context}. */ @@ -13,28 +13,28 @@ + } + + public ServerAdvancementManager(PredicateManager p_136027_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { - super(f_136022_, "advancements"); - this.f_136024_ = p_136027_; + super(GSON, "advancements"); + this.predicateManager = p_136027_; + this.context = context; } - protected void m_5787_(Map p_136034_, ResourceManager p_136035_, ProfilerFiller p_136036_) { + protected void apply(Map p_136034_, ResourceManager p_136035_, ProfilerFiller p_136036_) { Map map = Maps.newHashMap(); p_136034_.forEach((p_136039_, p_136040_) -> { + // Spigot start -+ if (org.spigotmc.SpigotConfig.disabledAdvancements != null && (org.spigotmc.SpigotConfig.disabledAdvancements.contains("*") || org.spigotmc.SpigotConfig.disabledAdvancements.contains(p_136039_.toString()) || org.spigotmc.SpigotConfig.disabledAdvancements.contains(p_136039_.m_135827_()))) { ++ if (org.spigotmc.SpigotConfig.disabledAdvancements != null && (org.spigotmc.SpigotConfig.disabledAdvancements.contains("*") || org.spigotmc.SpigotConfig.disabledAdvancements.contains(p_136039_.toString()) || org.spigotmc.SpigotConfig.disabledAdvancements.contains(p_136039_.getNamespace()))) { + return; + } + // Spigot end + try { - JsonObject jsonobject = GsonHelper.m_13918_(p_136040_, "advancement"); -- Advancement.Builder advancement$builder = Advancement.Builder.m_138380_(jsonobject, new DeserializationContext(p_136039_, this.f_136024_)); -+ Advancement.Builder advancement$builder = Advancement.Builder.fromJson(jsonobject, new DeserializationContext(p_136039_, this.f_136024_), this.context); + JsonObject jsonobject = GsonHelper.convertToJsonObject(p_136040_, "advancement"); +- Advancement.Builder advancement$builder = Advancement.Builder.fromJson(jsonobject, new DeserializationContext(p_136039_, this.predicateManager)); ++ Advancement.Builder advancement$builder = Advancement.Builder.fromJson(jsonobject, new DeserializationContext(p_136039_, this.predicateManager), this.context); + if (advancement$builder == null) { -+ f_136021_.debug("Skipping loading advancement {} as it's conditions were not met", p_136039_); ++ LOGGER.debug("Skipping loading advancement {} as it's conditions were not met", p_136039_); + return; + } map.put(p_136039_, advancement$builder); } catch (Exception exception) { - f_136021_.error("Parsing error loading custom advancement {}: {}", p_136039_, exception.getMessage()); + LOGGER.error("Parsing error loading custom advancement {}: {}", p_136039_, exception.getMessage()); diff --git a/patches/minecraft/net/minecraft/server/ServerFunctionManager.java.patch b/patches/minecraft/net/minecraft/server/ServerFunctionManager.java.patch index 1fddcc2c..69b7d99d 100644 --- a/patches/minecraft/net/minecraft/server/ServerFunctionManager.java.patch +++ b/patches/minecraft/net/minecraft/server/ServerFunctionManager.java.patch @@ -6,6 +6,6 @@ int i; - try { + try (co.aikar.timings.Timing timing = p_179961_.getTiming().startTiming()) { // Paper - this.f_179959_ = new ServerFunctionManager.ExecutionContext(p_179963_); - i = this.f_179959_.m_179977_(p_179961_, p_179962_); + this.context = new ServerFunctionManager.ExecutionContext(p_179963_); + i = this.context.runTopCommand(p_179961_, p_179962_); } finally { diff --git a/patches/minecraft/net/minecraft/server/ServerScoreboard.java.patch b/patches/minecraft/net/minecraft/server/ServerScoreboard.java.patch index b3391564..df98fa5e 100644 --- a/patches/minecraft/net/minecraft/server/ServerScoreboard.java.patch +++ b/patches/minecraft/net/minecraft/server/ServerScoreboard.java.patch @@ -1,125 +1,125 @@ --- a/net/minecraft/server/ServerScoreboard.java +++ b/net/minecraft/server/ServerScoreboard.java @@ -30,7 +_,7 @@ - public void m_5734_(Score p_136206_) { - super.m_5734_(p_136206_); - if (this.f_136194_.contains(p_136206_.m_83404_())) { -- this.f_136193_.m_6846_().m_11268_(new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, p_136206_.m_83404_().m_83320_(), p_136206_.m_83405_(), p_136206_.m_83400_())); -+ this.broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, p_136206_.m_83404_().m_83320_(), p_136206_.m_83405_(), p_136206_.m_83400_())); + public void onScoreChanged(Score p_136206_) { + super.onScoreChanged(p_136206_); + if (this.trackedObjectives.contains(p_136206_.getObjective())) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, p_136206_.getObjective().getName(), p_136206_.getOwner(), p_136206_.getScore())); ++ this.broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, p_136206_.getObjective().getName(), p_136206_.getOwner(), p_136206_.getScore())); } - this.m_136217_(); + this.setDirty(); @@ -38,14 +_,14 @@ - public void m_7182_(String p_136210_) { - super.m_7182_(p_136210_); -- this.f_136193_.m_6846_().m_11268_(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, (String)null, p_136210_, 0)); + public void onPlayerRemoved(String p_136210_) { + super.onPlayerRemoved(p_136210_); +- this.server.getPlayerList().broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, (String)null, p_136210_, 0)); + this.broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, (String)null, p_136210_, 0)); // CraftBukkit - this.m_136217_(); + this.setDirty(); } - public void m_5973_(String p_136212_, Objective p_136213_) { - super.m_5973_(p_136212_, p_136213_); - if (this.f_136194_.contains(p_136213_)) { -- this.f_136193_.m_6846_().m_11268_(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, p_136213_.m_83320_(), p_136212_, 0)); -+ this.broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, p_136213_.m_83320_(), p_136212_, 0)); // CraftBukkit + public void onPlayerScoreRemoved(String p_136212_, Objective p_136213_) { + super.onPlayerScoreRemoved(p_136212_, p_136213_); + if (this.trackedObjectives.contains(p_136213_)) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, p_136213_.getName(), p_136212_, 0)); ++ this.broadcastAll(new ClientboundSetScorePacket(ServerScoreboard.Method.REMOVE, p_136213_.getName(), p_136212_, 0)); // CraftBukkit } - this.m_136217_(); + this.setDirty(); @@ -56,7 +_,7 @@ - super.m_7136_(p_136199_, p_136200_); + super.setDisplayObjective(p_136199_, p_136200_); if (objective != p_136200_ && objective != null) { - if (this.m_136237_(objective) > 0) { -- this.f_136193_.m_6846_().m_11268_(new ClientboundSetDisplayObjectivePacket(p_136199_, p_136200_)); + if (this.getObjectiveDisplaySlotCount(objective) > 0) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetDisplayObjectivePacket(p_136199_, p_136200_)); + this.broadcastAll(new ClientboundSetDisplayObjectivePacket(p_136199_, p_136200_)); // CraftBukkit } else { - this.m_136235_(objective); + this.stopTrackingObjective(objective); } @@ -64,7 +_,7 @@ if (p_136200_ != null) { - if (this.f_136194_.contains(p_136200_)) { -- this.f_136193_.m_6846_().m_11268_(new ClientboundSetDisplayObjectivePacket(p_136199_, p_136200_)); + if (this.trackedObjectives.contains(p_136200_)) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetDisplayObjectivePacket(p_136199_, p_136200_)); + this.broadcastAll(new ClientboundSetDisplayObjectivePacket(p_136199_, p_136200_)); // CraftBukkit } else { - this.m_136231_(p_136200_); + this.startTrackingObjective(p_136200_); } @@ -75,7 +_,7 @@ - public boolean m_6546_(String p_136215_, PlayerTeam p_136216_) { - if (super.m_6546_(p_136215_, p_136216_)) { -- this.f_136193_.m_6846_().m_11268_(ClientboundSetPlayerTeamPacket.m_179328_(p_136216_, p_136215_, ClientboundSetPlayerTeamPacket.Action.ADD)); -+ this.broadcastAll(ClientboundSetPlayerTeamPacket.m_179328_(p_136216_, p_136215_, ClientboundSetPlayerTeamPacket.Action.ADD)); // CraftBukkit - this.m_136217_(); + public boolean addPlayerToTeam(String p_136215_, PlayerTeam p_136216_) { + if (super.addPlayerToTeam(p_136215_, p_136216_)) { +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(p_136216_, p_136215_, ClientboundSetPlayerTeamPacket.Action.ADD)); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(p_136216_, p_136215_, ClientboundSetPlayerTeamPacket.Action.ADD)); // CraftBukkit + this.setDirty(); return true; } else { @@ -85,7 +_,7 @@ - public void m_6519_(String p_136223_, PlayerTeam p_136224_) { - super.m_6519_(p_136223_, p_136224_); -- this.f_136193_.m_6846_().m_11268_(ClientboundSetPlayerTeamPacket.m_179328_(p_136224_, p_136223_, ClientboundSetPlayerTeamPacket.Action.REMOVE)); -+ this.broadcastAll(ClientboundSetPlayerTeamPacket.m_179328_(p_136224_, p_136223_, ClientboundSetPlayerTeamPacket.Action.REMOVE)); // CraftBukkit - this.m_136217_(); + public void removePlayerFromTeam(String p_136223_, PlayerTeam p_136224_) { + super.removePlayerFromTeam(p_136223_, p_136224_); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(p_136224_, p_136223_, ClientboundSetPlayerTeamPacket.Action.REMOVE)); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(p_136224_, p_136223_, ClientboundSetPlayerTeamPacket.Action.REMOVE)); // CraftBukkit + this.setDirty(); } @@ -97,7 +_,7 @@ - public void m_7091_(Objective p_136219_) { - super.m_7091_(p_136219_); - if (this.f_136194_.contains(p_136219_)) { -- this.f_136193_.m_6846_().m_11268_(new ClientboundSetObjectivePacket(p_136219_, 2)); + public void onObjectiveChanged(Objective p_136219_) { + super.onObjectiveChanged(p_136219_); + if (this.trackedObjectives.contains(p_136219_)) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetObjectivePacket(p_136219_, 2)); + this.broadcastAll(new ClientboundSetObjectivePacket(p_136219_, 2)); // CraftBukkit } - this.m_136217_(); + this.setDirty(); @@ -114,19 +_,19 @@ - public void m_7650_(PlayerTeam p_136204_) { - super.m_7650_(p_136204_); -- this.f_136193_.m_6846_().m_11268_(ClientboundSetPlayerTeamPacket.m_179332_(p_136204_, true)); -+ this.broadcastAll(ClientboundSetPlayerTeamPacket.m_179332_(p_136204_, true)); // CraftBukkit - this.m_136217_(); + public void onTeamAdded(PlayerTeam p_136204_) { + super.onTeamAdded(p_136204_); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(p_136204_, true)); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(p_136204_, true)); // CraftBukkit + this.setDirty(); } - public void m_7645_(PlayerTeam p_136221_) { - super.m_7645_(p_136221_); -- this.f_136193_.m_6846_().m_11268_(ClientboundSetPlayerTeamPacket.m_179332_(p_136221_, false)); -+ this.broadcastAll(ClientboundSetPlayerTeamPacket.m_179332_(p_136221_, false)); // CraftBukkit - this.m_136217_(); + public void onTeamChanged(PlayerTeam p_136221_) { + super.onTeamChanged(p_136221_); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(p_136221_, false)); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(p_136221_, false)); // CraftBukkit + this.setDirty(); } - public void m_7644_(PlayerTeam p_136228_) { - super.m_7644_(p_136228_); -- this.f_136193_.m_6846_().m_11268_(ClientboundSetPlayerTeamPacket.m_179326_(p_136228_)); -+ this.broadcastAll(ClientboundSetPlayerTeamPacket.m_179326_(p_136228_)); // CraftBukkit - this.m_136217_(); + public void onTeamRemoved(PlayerTeam p_136228_) { + super.onTeamRemoved(p_136228_); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createRemovePacket(p_136228_)); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createRemovePacket(p_136228_)); // CraftBukkit + this.setDirty(); } @@ -162,6 +_,7 @@ - List> list = this.m_136229_(p_136232_); + List> list = this.getStartTrackingPackets(p_136232_); - for(ServerPlayer serverplayer : this.f_136193_.m_6846_().m_11314_()) { + for(ServerPlayer serverplayer : this.server.getPlayerList().getPlayers()) { + if (serverplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board for(Packet packet : list) { - serverplayer.f_8906_.m_141995_(packet); + serverplayer.connection.send(packet); } @@ -187,6 +_,7 @@ - List> list = this.m_136233_(p_136236_); + List> list = this.getStopTrackingPackets(p_136236_); - for(ServerPlayer serverplayer : this.f_136193_.m_6846_().m_11314_()) { + for(ServerPlayer serverplayer : this.server.getPlayerList().getPlayers()) { + if (serverplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board for(Packet packet : list) { - serverplayer.f_8906_.m_141995_(packet); + serverplayer.connection.send(packet); } @@ -216,6 +_,16 @@ - public ScoreboardSaveData m_180013_(CompoundTag p_180014_) { - return this.m_180015_().m_166102_(p_180014_); + public ScoreboardSaveData createData(CompoundTag p_180014_) { + return this.createData().load(p_180014_); } + + // CraftBukkit start - Send to players + private void broadcastAll(Packet packet) { -+ for (ServerPlayer entityplayer : (List) this.f_136193_.m_6846_().f_11196_) { ++ for (ServerPlayer entityplayer : (List) this.server.getPlayerList().players) { + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) { -+ entityplayer.f_8906_.m_141995_(packet); ++ entityplayer.connection.send(packet); + } + } + } diff --git a/patches/minecraft/net/minecraft/server/bossevents/CustomBossEvent.java.patch b/patches/minecraft/net/minecraft/server/bossevents/CustomBossEvent.java.patch index c0e55efa..2e5b6e0f 100644 --- a/patches/minecraft/net/minecraft/server/bossevents/CustomBossEvent.java.patch +++ b/patches/minecraft/net/minecraft/server/bossevents/CustomBossEvent.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/bossevents/CustomBossEvent.java +++ b/net/minecraft/server/bossevents/CustomBossEvent.java @@ -22,6 +_,16 @@ - private final Set f_136257_ = Sets.newHashSet(); - private int f_136258_; - private int f_136259_ = 100; + private final Set players = Sets.newHashSet(); + private int value; + private int max = 100; + // CraftBukkit start + private org.bukkit.boss.KeyedBossBar bossBar; + diff --git a/patches/minecraft/net/minecraft/server/commands/AdvancementCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/AdvancementCommands.java.patch index 4443a52e..63b4a9b3 100644 --- a/patches/minecraft/net/minecraft/server/commands/AdvancementCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/AdvancementCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/AdvancementCommands.java @@ -25,7 +_,7 @@ - public static void m_136310_(CommandDispatcher p_136311_) { - p_136311_.register(Commands.m_82127_("advancement").requires((p_136318_) -> { -- return p_136318_.m_6761_(2); + public static void register(CommandDispatcher p_136311_) { + p_136311_.register(Commands.literal("advancement").requires((p_136318_) -> { +- return p_136318_.hasPermission(2); + return p_136318_.hasPermission(2,"minecraft.command.advancement"); - }).then(Commands.m_82127_("grant").then(Commands.m_82129_("targets", EntityArgument.m_91470_()).then(Commands.m_82127_("only").then(Commands.m_82129_("advancement", ResourceLocationArgument.m_106984_()).suggests(f_136308_).executes((p_136363_) -> { - return m_136319_(p_136363_.getSource(), EntityArgument.m_91477_(p_136363_, "targets"), AdvancementCommands.Action.GRANT, m_136333_(ResourceLocationArgument.m_106987_(p_136363_, "advancement"), AdvancementCommands.Mode.ONLY)); - }).then(Commands.m_82129_("criterion", StringArgumentType.greedyString()).suggests((p_136339_, p_136340_) -> { + }).then(Commands.literal("grant").then(Commands.argument("targets", EntityArgument.players()).then(Commands.literal("only").then(Commands.argument("advancement", ResourceLocationArgument.id()).suggests(SUGGEST_ADVANCEMENTS).executes((p_136363_) -> { + return perform(p_136363_.getSource(), EntityArgument.getPlayers(p_136363_, "targets"), AdvancementCommands.Action.GRANT, getAdvancements(ResourceLocationArgument.getAdvancement(p_136363_, "advancement"), AdvancementCommands.Mode.ONLY)); + }).then(Commands.argument("criterion", StringArgumentType.greedyString()).suggests((p_136339_, p_136340_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/BanIpCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/BanIpCommands.java.patch index 1180045c..2dcd8285 100644 --- a/patches/minecraft/net/minecraft/server/commands/BanIpCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/BanIpCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/BanIpCommands.java @@ -26,7 +_,7 @@ - public static void m_136527_(CommandDispatcher p_136528_) { - p_136528_.register(Commands.m_82127_("ban-ip").requires((p_136532_) -> { -- return p_136532_.m_6761_(3); + public static void register(CommandDispatcher p_136528_) { + p_136528_.register(Commands.literal("ban-ip").requires((p_136532_) -> { +- return p_136532_.hasPermission(3); + return p_136532_.hasPermission(3,"minecraft.command.ban-ip"); - }).then(Commands.m_82129_("target", StringArgumentType.word()).executes((p_136538_) -> { - return m_136533_(p_136538_.getSource(), StringArgumentType.getString(p_136538_, "target"), (Component)null); - }).then(Commands.m_82129_("reason", MessageArgument.m_96832_()).executes((p_136530_) -> { + }).then(Commands.argument("target", StringArgumentType.word()).executes((p_136538_) -> { + return banIpOrName(p_136538_.getSource(), StringArgumentType.getString(p_136538_, "target"), (Component)null); + }).then(Commands.argument("reason", MessageArgument.message()).executes((p_136530_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/BanListCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/BanListCommands.java.patch index d076d514..75c0582a 100644 --- a/patches/minecraft/net/minecraft/server/commands/BanListCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/BanListCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/BanListCommands.java @@ -13,7 +_,7 @@ public class BanListCommands { - public static void m_136543_(CommandDispatcher p_136544_) { - p_136544_.register(Commands.m_82127_("banlist").requires((p_136548_) -> { -- return p_136548_.m_6761_(3); + public static void register(CommandDispatcher p_136544_) { + p_136544_.register(Commands.literal("banlist").requires((p_136548_) -> { +- return p_136548_.hasPermission(3); + return p_136548_.hasPermission(3,"minecraft.command.banlist"); }).executes((p_136555_) -> { - PlayerList playerlist = p_136555_.getSource().m_81377_().m_6846_(); - return m_136549_(p_136555_.getSource(), Lists.newArrayList(Iterables.concat(playerlist.m_11295_().m_11395_(), playerlist.m_11299_().m_11395_()))); + PlayerList playerlist = p_136555_.getSource().getServer().getPlayerList(); + return showList(p_136555_.getSource(), Lists.newArrayList(Iterables.concat(playerlist.getBans().getEntries(), playerlist.getIpBans().getEntries()))); diff --git a/patches/minecraft/net/minecraft/server/commands/BanPlayerCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/BanPlayerCommands.java.patch index 4f1e3cba..301de120 100644 --- a/patches/minecraft/net/minecraft/server/commands/BanPlayerCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/BanPlayerCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/BanPlayerCommands.java @@ -23,7 +_,7 @@ - public static void m_136558_(CommandDispatcher p_136559_) { - p_136559_.register(Commands.m_82127_("ban").requires((p_136563_) -> { -- return p_136563_.m_6761_(3); + public static void register(CommandDispatcher p_136559_) { + p_136559_.register(Commands.literal("ban").requires((p_136563_) -> { +- return p_136563_.hasPermission(3); + return p_136563_.hasPermission(3,"minecraft.command.ban"); - }).then(Commands.m_82129_("targets", GameProfileArgument.m_94584_()).executes((p_136569_) -> { - return m_136564_(p_136569_.getSource(), GameProfileArgument.m_94590_(p_136569_, "targets"), (Component)null); - }).then(Commands.m_82129_("reason", MessageArgument.m_96832_()).executes((p_136561_) -> { + }).then(Commands.argument("targets", GameProfileArgument.gameProfile()).executes((p_136569_) -> { + return banPlayers(p_136569_.getSource(), GameProfileArgument.getGameProfiles(p_136569_, "targets"), (Component)null); + }).then(Commands.argument("reason", MessageArgument.message()).executes((p_136561_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/ClearInventoryCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/ClearInventoryCommands.java.patch index 26889def..1baae74f 100644 --- a/patches/minecraft/net/minecraft/server/commands/ClearInventoryCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/ClearInventoryCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/ClearInventoryCommands.java @@ -25,7 +_,7 @@ - public static void m_136699_(CommandDispatcher p_136700_) { - p_136700_.register(Commands.m_82127_("clear").requires((p_136704_) -> { -- return p_136704_.m_6761_(2); + public static void register(CommandDispatcher p_136700_) { + p_136700_.register(Commands.literal("clear").requires((p_136704_) -> { +- return p_136704_.hasPermission(2); + return p_136704_.hasPermission(2,"minecraft.command.clear"); }).executes((p_136721_) -> { - return m_136705_(p_136721_.getSource(), Collections.singleton(p_136721_.getSource().m_81375_()), (p_180029_) -> { + return clearInventory(p_136721_.getSource(), Collections.singleton(p_136721_.getSource().getPlayerOrException()), (p_180029_) -> { return true; diff --git a/patches/minecraft/net/minecraft/server/commands/DeOpCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/DeOpCommands.java.patch index 8670922b..53dc7997 100644 --- a/patches/minecraft/net/minecraft/server/commands/DeOpCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/DeOpCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/DeOpCommands.java @@ -17,7 +_,7 @@ - public static void m_136888_(CommandDispatcher p_136889_) { - p_136889_.register(Commands.m_82127_("deop").requires((p_136896_) -> { -- return p_136896_.m_6761_(3); + public static void register(CommandDispatcher p_136889_) { + p_136889_.register(Commands.literal("deop").requires((p_136896_) -> { +- return p_136896_.hasPermission(3); + return p_136896_.hasPermission(3,"minecraft.command.deop"); - }).then(Commands.m_82129_("targets", GameProfileArgument.m_94584_()).suggests((p_136893_, p_136894_) -> { - return SharedSuggestionProvider.m_82967_(p_136893_.getSource().m_81377_().m_6846_().m_11308_(), p_136894_); + }).then(Commands.argument("targets", GameProfileArgument.gameProfile()).suggests((p_136893_, p_136894_) -> { + return SharedSuggestionProvider.suggest(p_136893_.getSource().getServer().getPlayerList().getOpNames(), p_136894_); }).executes((p_136891_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/DebugCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/DebugCommand.java.patch index eb541289..f94c270f 100644 --- a/patches/minecraft/net/minecraft/server/commands/DebugCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/DebugCommand.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/server/commands/DebugCommand.java @@ -38,7 +_,7 @@ - public static void m_136905_(CommandDispatcher p_136906_) { - p_136906_.register(Commands.m_82127_("debug").requires((p_180073_) -> { -- return p_180073_.m_6761_(3); + public static void register(CommandDispatcher p_136906_) { + p_136906_.register(Commands.literal("debug").requires((p_180073_) -> { +- return p_180073_.hasPermission(3); + return p_180073_.hasPermission(3,"minecraft.command.debug"); - }).then(Commands.m_82127_("start").executes((p_180069_) -> { - return m_136909_(p_180069_.getSource()); - })).then(Commands.m_82127_("stop").executes((p_136918_) -> { + }).then(Commands.literal("start").executes((p_180069_) -> { + return start(p_180069_.getSource()); + })).then(Commands.literal("stop").executes((p_136918_) -> { @@ -216,6 +_,11 @@ - public boolean m_142559_() { + public boolean alwaysAccepts() { return true; + } + diff --git a/patches/minecraft/net/minecraft/server/commands/DefaultGameModeCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/DefaultGameModeCommands.java.patch index 68d2c42a..c3551fca 100644 --- a/patches/minecraft/net/minecraft/server/commands/DefaultGameModeCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/DefaultGameModeCommands.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/server/commands/DefaultGameModeCommands.java @@ -12,7 +_,7 @@ public class DefaultGameModeCommands { - public static void m_136926_(CommandDispatcher p_136927_) { - LiteralArgumentBuilder literalargumentbuilder = Commands.m_82127_("defaultgamemode").requires((p_136929_) -> { -- return p_136929_.m_6761_(2); + public static void register(CommandDispatcher p_136927_) { + LiteralArgumentBuilder literalargumentbuilder = Commands.literal("defaultgamemode").requires((p_136929_) -> { +- return p_136929_.hasPermission(2); + return p_136929_.hasPermission(2,"minecraft.command.defaultgamemode"); }); diff --git a/patches/minecraft/net/minecraft/server/commands/DifficultyCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/DifficultyCommand.java.patch index a9253a89..2baa45d8 100644 --- a/patches/minecraft/net/minecraft/server/commands/DifficultyCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/DifficultyCommand.java.patch @@ -4,8 +4,8 @@ } p_136939_.register(literalargumentbuilder.requires((p_136943_) -> { -- return p_136943_.m_6761_(2); +- return p_136943_.hasPermission(2); + return p_136943_.hasPermission(2,"minecraft.command.difficulty"); }).executes((p_136941_) -> { - Difficulty difficulty1 = p_136941_.getSource().m_81372_().m_46791_(); - p_136941_.getSource().m_81354_(new TranslatableComponent("commands.difficulty.query", difficulty1.m_19033_()), false); + Difficulty difficulty1 = p_136941_.getSource().getLevel().getDifficulty(); + p_136941_.getSource().sendSuccess(new TranslatableComponent("commands.difficulty.query", difficulty1.getDisplayName()), false); diff --git a/patches/minecraft/net/minecraft/server/commands/EffectCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/EffectCommands.java.patch index 78b06f09..9fc21036 100644 --- a/patches/minecraft/net/minecraft/server/commands/EffectCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/EffectCommands.java.patch @@ -2,20 +2,20 @@ +++ b/net/minecraft/server/commands/EffectCommands.java @@ -25,7 +_,7 @@ - public static void m_136953_(CommandDispatcher p_136954_) { - p_136954_.register(Commands.m_82127_("effect").requires((p_136958_) -> { -- return p_136958_.m_6761_(2); + public static void register(CommandDispatcher p_136954_) { + p_136954_.register(Commands.literal("effect").requires((p_136958_) -> { +- return p_136958_.hasPermission(2); + return p_136958_.hasPermission(2,"minecraft.command.effect"); - }).then(Commands.m_82127_("clear").executes((p_136984_) -> { - return m_136959_(p_136984_.getSource(), ImmutableList.of(p_136984_.getSource().m_81374_())); - }).then(Commands.m_82129_("targets", EntityArgument.m_91460_()).executes((p_136982_) -> { + }).then(Commands.literal("clear").executes((p_136984_) -> { + return clearEffects(p_136984_.getSource(), ImmutableList.of(p_136984_.getSource().getEntityOrException())); + }).then(Commands.argument("targets", EntityArgument.entities()).executes((p_136982_) -> { @@ -61,7 +_,8 @@ for(Entity entity : p_136968_) { if (entity instanceof LivingEntity) { MobEffectInstance mobeffectinstance = new MobEffectInstance(p_136969_, j, p_136971_, false, p_136972_); -- if (((LivingEntity)entity).m_147207_(mobeffectinstance, p_136967_.m_81373_())) { +- if (((LivingEntity)entity).addEffect(mobeffectinstance, p_136967_.getEntity())) { + ((LivingEntity) entity).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND); //Magma -+ if (((LivingEntity)entity).m_147207_(mobeffectinstance, p_136967_.m_81373_())) { // CraftBukkit ++ if (((LivingEntity)entity).addEffect(mobeffectinstance, p_136967_.getEntity())) { // CraftBukkit ++i; } } @@ -23,7 +23,7 @@ int i = 0; for(Entity entity : p_136961_) { -- if (entity instanceof LivingEntity && ((LivingEntity)entity).m_21219_()) { +- if (entity instanceof LivingEntity && ((LivingEntity)entity).removeAllEffects()) { + if (entity instanceof LivingEntity && ((LivingEntity)entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++i; } @@ -32,7 +32,7 @@ int i = 0; for(Entity entity : p_136964_) { -- if (entity instanceof LivingEntity && ((LivingEntity)entity).m_21195_(p_136965_)) { +- if (entity instanceof LivingEntity && ((LivingEntity)entity).removeEffect(p_136965_)) { + if (entity instanceof LivingEntity && ((LivingEntity)entity).removeEffect(p_136965_, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++i; } diff --git a/patches/minecraft/net/minecraft/server/commands/EmoteCommands.java.patch b/patches/minecraft/net/minecraft/server/commands/EmoteCommands.java.patch index 6b5d8311..87acb533 100644 --- a/patches/minecraft/net/minecraft/server/commands/EmoteCommands.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/EmoteCommands.java.patch @@ -3,11 +3,11 @@ @@ -15,7 +_,9 @@ public class EmoteCommands { - public static void m_136985_(CommandDispatcher p_136986_) { -- p_136986_.register(Commands.m_82127_("me").then(Commands.m_82129_("action", StringArgumentType.greedyString()).executes((p_136988_) -> { -+ p_136986_.register(Commands.m_82127_("me") + public static void register(CommandDispatcher p_136986_) { +- p_136986_.register(Commands.literal("me").then(Commands.argument("action", StringArgumentType.greedyString()).executes((p_136988_) -> { ++ p_136986_.register(Commands.literal("me") + .requires(commandSourceStack -> commandSourceStack.hasPermission(0,"minecraft.command.me")) -+ .then(Commands.m_82129_("action", StringArgumentType.greedyString()).executes((p_136988_) -> { ++ .then(Commands.argument("action", StringArgumentType.greedyString()).executes((p_136988_) -> { String s = StringArgumentType.getString(p_136988_, "action"); - Entity entity = p_136988_.getSource().m_81373_(); - MinecraftServer minecraftserver = p_136988_.getSource().m_81377_(); + Entity entity = p_136988_.getSource().getEntity(); + MinecraftServer minecraftserver = p_136988_.getSource().getServer(); diff --git a/patches/minecraft/net/minecraft/server/commands/EnchantCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/EnchantCommand.java.patch index fa671566..cf57ba7b 100644 --- a/patches/minecraft/net/minecraft/server/commands/EnchantCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/EnchantCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/EnchantCommand.java @@ -35,7 +_,7 @@ - public static void m_137008_(CommandDispatcher p_137009_) { - p_137009_.register(Commands.m_82127_("enchant").requires((p_137013_) -> { -- return p_137013_.m_6761_(2); + public static void register(CommandDispatcher p_137009_) { + p_137009_.register(Commands.literal("enchant").requires((p_137013_) -> { +- return p_137013_.hasPermission(2); + return p_137013_.hasPermission(2,"minecraft.command.enchant"); - }).then(Commands.m_82129_("targets", EntityArgument.m_91460_()).then(Commands.m_82129_("enchantment", ItemEnchantmentArgument.m_95260_()).executes((p_137025_) -> { - return m_137014_(p_137025_.getSource(), EntityArgument.m_91461_(p_137025_, "targets"), ItemEnchantmentArgument.m_95263_(p_137025_, "enchantment"), 1); - }).then(Commands.m_82129_("level", IntegerArgumentType.integer(0)).executes((p_137011_) -> { + }).then(Commands.argument("targets", EntityArgument.entities()).then(Commands.argument("enchantment", ItemEnchantmentArgument.enchantment()).executes((p_137025_) -> { + return enchant(p_137025_.getSource(), EntityArgument.getEntities(p_137025_, "targets"), ItemEnchantmentArgument.getEnchantment(p_137025_, "enchantment"), 1); + }).then(Commands.argument("level", IntegerArgumentType.integer(0)).executes((p_137011_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/ExperienceCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/ExperienceCommand.java.patch index 2cdfb370..42d430bf 100644 --- a/patches/minecraft/net/minecraft/server/commands/ExperienceCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/ExperienceCommand.java.patch @@ -2,18 +2,18 @@ +++ b/net/minecraft/server/commands/ExperienceCommand.java @@ -22,7 +_,7 @@ - public static void m_137306_(CommandDispatcher p_137307_) { - LiteralCommandNode literalcommandnode = p_137307_.register(Commands.m_82127_("experience").requires((p_137324_) -> { -- return p_137324_.m_6761_(2); + public static void register(CommandDispatcher p_137307_) { + LiteralCommandNode literalcommandnode = p_137307_.register(Commands.literal("experience").requires((p_137324_) -> { +- return p_137324_.hasPermission(2); + return p_137324_.hasPermission(2,"minecraft.command.xp"); - }).then(Commands.m_82127_("add").then(Commands.m_82129_("targets", EntityArgument.m_91470_()).then(Commands.m_82129_("amount", IntegerArgumentType.integer()).executes((p_137341_) -> { - return m_137316_(p_137341_.getSource(), EntityArgument.m_91477_(p_137341_, "targets"), IntegerArgumentType.getInteger(p_137341_, "amount"), ExperienceCommand.Type.POINTS); - }).then(Commands.m_82127_("points").executes((p_137339_) -> { + }).then(Commands.literal("add").then(Commands.argument("targets", EntityArgument.players()).then(Commands.argument("amount", IntegerArgumentType.integer()).executes((p_137341_) -> { + return addExperience(p_137341_.getSource(), EntityArgument.getPlayers(p_137341_, "targets"), IntegerArgumentType.getInteger(p_137341_, "amount"), ExperienceCommand.Type.POINTS); + }).then(Commands.literal("points").executes((p_137339_) -> { @@ -41,7 +_,7 @@ - return m_137312_(p_137309_.getSource(), EntityArgument.m_91474_(p_137309_, "targets"), ExperienceCommand.Type.LEVELS); + return queryExperience(p_137309_.getSource(), EntityArgument.getPlayer(p_137309_, "targets"), ExperienceCommand.Type.LEVELS); }))))); - p_137307_.register(Commands.m_82127_("xp").requires((p_137311_) -> { -- return p_137311_.m_6761_(2); + p_137307_.register(Commands.literal("xp").requires((p_137311_) -> { +- return p_137311_.hasPermission(2); + return p_137311_.hasPermission(2,"minecraft.command.xp"); }).redirect(literalcommandnode)); } diff --git a/patches/minecraft/net/minecraft/server/commands/FillCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/FillCommand.java.patch index 48e36067..ff91e0c2 100644 --- a/patches/minecraft/net/minecraft/server/commands/FillCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/FillCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/FillCommand.java @@ -36,7 +_,7 @@ - public static void m_137379_(CommandDispatcher p_137380_) { - p_137380_.register(Commands.m_82127_("fill").requires((p_137384_) -> { -- return p_137384_.m_6761_(2); + public static void register(CommandDispatcher p_137380_) { + p_137380_.register(Commands.literal("fill").requires((p_137384_) -> { +- return p_137384_.hasPermission(2); + return p_137384_.hasPermission(2,"minecraft.command.fill"); - }).then(Commands.m_82129_("from", BlockPosArgument.m_118239_()).then(Commands.m_82129_("to", BlockPosArgument.m_118239_()).then(Commands.m_82129_("block", BlockStateArgument.m_116120_()).executes((p_137405_) -> { - return m_137385_(p_137405_.getSource(), BoundingBox.m_162375_(BlockPosArgument.m_118242_(p_137405_, "from"), BlockPosArgument.m_118242_(p_137405_, "to")), BlockStateArgument.m_116123_(p_137405_, "block"), FillCommand.Mode.REPLACE, (Predicate)null); - }).then(Commands.m_82127_("replace").executes((p_137403_) -> { + }).then(Commands.argument("from", BlockPosArgument.blockPos()).then(Commands.argument("to", BlockPosArgument.blockPos()).then(Commands.argument("block", BlockStateArgument.block()).executes((p_137405_) -> { + return fillBlocks(p_137405_.getSource(), BoundingBox.fromCorners(BlockPosArgument.getLoadedBlockPos(p_137405_, "from"), BlockPosArgument.getLoadedBlockPos(p_137405_, "to")), BlockStateArgument.getBlock(p_137405_, "block"), FillCommand.Mode.REPLACE, (Predicate)null); + }).then(Commands.literal("replace").executes((p_137403_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/GameModeCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/GameModeCommand.java.patch index 52bc34e8..e852446d 100644 --- a/patches/minecraft/net/minecraft/server/commands/GameModeCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/GameModeCommand.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/server/commands/GameModeCommand.java @@ -20,7 +_,7 @@ - public static void m_137729_(CommandDispatcher p_137730_) { - LiteralArgumentBuilder literalargumentbuilder = Commands.m_82127_("gamemode").requires((p_137736_) -> { -- return p_137736_.m_6761_(2); + public static void register(CommandDispatcher p_137730_) { + LiteralArgumentBuilder literalargumentbuilder = Commands.literal("gamemode").requires((p_137736_) -> { +- return p_137736_.hasPermission(2); + return p_137736_.hasPermission(2,"minecraft.command.gamemode"); }); diff --git a/patches/minecraft/net/minecraft/server/commands/GameRuleCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/GameRuleCommand.java.patch index 6cd8a93c..7c327a18 100644 --- a/patches/minecraft/net/minecraft/server/commands/GameRuleCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -2,27 +2,27 @@ +++ b/net/minecraft/server/commands/GameRuleCommand.java @@ -11,7 +_,7 @@ public class GameRuleCommand { - public static void m_137744_(CommandDispatcher p_137745_) { - final LiteralArgumentBuilder literalargumentbuilder = Commands.m_82127_("gamerule").requires((p_137750_) -> { -- return p_137750_.m_6761_(2); + public static void register(CommandDispatcher p_137745_) { + final LiteralArgumentBuilder literalargumentbuilder = Commands.literal("gamerule").requires((p_137750_) -> { +- return p_137750_.hasPermission(2); + return p_137750_.hasPermission(2,"minecraft.command.gamerule"); }); - GameRules.m_46164_(new GameRules.GameRuleTypeVisitor() { - public > void m_6889_(GameRules.Key p_137764_, GameRules.Type p_137765_) { + GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { + public > void visit(GameRules.Key p_137764_, GameRules.Type p_137765_) { @@ -27,14 +_,14 @@ - static > int m_137754_(CommandContext p_137755_, GameRules.Key p_137756_) { + static > int setRule(CommandContext p_137755_, GameRules.Key p_137756_) { CommandSourceStack commandsourcestack = p_137755_.getSource(); -- T t = commandsourcestack.m_81377_().m_129900_().m_46170_(p_137756_); -+ T t = commandsourcestack.m_81372_().m_46469_().m_46170_(p_137756_); // CraftBukkit - t.m_46370_(p_137755_, "value"); - commandsourcestack.m_81354_(new TranslatableComponent("commands.gamerule.set", p_137756_.m_46328_(), t.toString()), true); - return t.m_6855_(); +- T t = commandsourcestack.getServer().getGameRules().getRule(p_137756_); ++ T t = commandsourcestack.getLevel().getGameRules().getRule(p_137756_); // CraftBukkit + t.setFromArgument(p_137755_, "value"); + commandsourcestack.sendSuccess(new TranslatableComponent("commands.gamerule.set", p_137756_.getId(), t.toString()), true); + return t.getCommandResult(); } - static > int m_137757_(CommandSourceStack p_137758_, GameRules.Key p_137759_) { -- T t = p_137758_.m_81377_().m_129900_().m_46170_(p_137759_); -+ T t = p_137758_.m_81372_().m_46469_().m_46170_(p_137759_); // CraftBukkit - p_137758_.m_81354_(new TranslatableComponent("commands.gamerule.query", p_137759_.m_46328_(), t.toString()), false); - return t.m_6855_(); + static > int queryRule(CommandSourceStack p_137758_, GameRules.Key p_137759_) { +- T t = p_137758_.getServer().getGameRules().getRule(p_137759_); ++ T t = p_137758_.getLevel().getGameRules().getRule(p_137759_); // CraftBukkit + p_137758_.sendSuccess(new TranslatableComponent("commands.gamerule.query", p_137759_.getId(), t.toString()), false); + return t.getCommandResult(); } diff --git a/patches/minecraft/net/minecraft/server/commands/GiveCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/GiveCommand.java.patch index a05718ac..63ab20e5 100644 --- a/patches/minecraft/net/minecraft/server/commands/GiveCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/GiveCommand.java.patch @@ -2,19 +2,19 @@ +++ b/net/minecraft/server/commands/GiveCommand.java @@ -22,7 +_,7 @@ - public static void m_137772_(CommandDispatcher p_137773_) { - p_137773_.register(Commands.m_82127_("give").requires((p_137777_) -> { -- return p_137777_.m_6761_(2); + public static void register(CommandDispatcher p_137773_) { + p_137773_.register(Commands.literal("give").requires((p_137777_) -> { +- return p_137777_.hasPermission(2); + return p_137777_.hasPermission(2,"minecraft.command.give"); - }).then(Commands.m_82129_("targets", EntityArgument.m_91470_()).then(Commands.m_82129_("item", ItemArgument.m_120960_()).executes((p_137784_) -> { - return m_137778_(p_137784_.getSource(), ItemArgument.m_120963_(p_137784_, "item"), EntityArgument.m_91477_(p_137784_, "targets"), 1); - }).then(Commands.m_82129_("count", IntegerArgumentType.integer(1)).executes((p_137775_) -> { + }).then(Commands.argument("targets", EntityArgument.players()).then(Commands.argument("item", ItemArgument.item()).executes((p_137784_) -> { + return giveItem(p_137784_.getSource(), ItemArgument.getItem(p_137784_, "item"), EntityArgument.getPlayers(p_137784_, "targets"), 1); + }).then(Commands.argument("count", IntegerArgumentType.integer(1)).executes((p_137775_) -> { @@ -47,7 +_,7 @@ - boolean flag = serverplayer.m_150109_().m_36054_(itemstack); - if (flag && itemstack.m_41619_()) { - itemstack.m_41764_(1); -- ItemEntity itementity1 = serverplayer.m_36176_(itemstack, false); + boolean flag = serverplayer.getInventory().add(itemstack); + if (flag && itemstack.isEmpty()) { + itemstack.setCount(1); +- ItemEntity itementity1 = serverplayer.drop(itemstack, false); + ItemEntity itementity1 = serverplayer.drop(itemstack, false, false, false); // SPIGOT-2942: Add boolean to call event if (itementity1 != null) { - itementity1.m_32065_(); + itementity1.makeFakeItem(); } diff --git a/patches/minecraft/net/minecraft/server/commands/HelpCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/HelpCommand.java.patch index cedc214e..28f831c1 100644 --- a/patches/minecraft/net/minecraft/server/commands/HelpCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/HelpCommand.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/HelpCommand.java +++ b/net/minecraft/server/commands/HelpCommand.java @@ -16,7 +_,10 @@ - private static final SimpleCommandExceptionType f_137785_ = new SimpleCommandExceptionType(new TranslatableComponent("commands.help.failed")); + private static final SimpleCommandExceptionType ERROR_FAILED = new SimpleCommandExceptionType(new TranslatableComponent("commands.help.failed")); - public static void m_137787_(CommandDispatcher p_137788_) { -- p_137788_.register(Commands.m_82127_("help").executes((p_137794_) -> { -+ p_137788_.register(Commands.m_82127_("help") + public static void register(CommandDispatcher p_137788_) { +- p_137788_.register(Commands.literal("help").executes((p_137794_) -> { ++ p_137788_.register(Commands.literal("help") + .requires(commandSourceStack -> { + return commandSourceStack.hasPermission(0, "minecraft.command.help"); + }).executes((p_137794_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/KickCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/KickCommand.java.patch index e6749914..46005ad5 100644 --- a/patches/minecraft/net/minecraft/server/commands/KickCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/KickCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/KickCommand.java @@ -13,7 +_,7 @@ public class KickCommand { - public static void m_137795_(CommandDispatcher p_137796_) { - p_137796_.register(Commands.m_82127_("kick").requires((p_137800_) -> { -- return p_137800_.m_6761_(3); + public static void register(CommandDispatcher p_137796_) { + p_137796_.register(Commands.literal("kick").requires((p_137800_) -> { +- return p_137800_.hasPermission(3); + return p_137800_.hasPermission(3,"minecraft.command.kick"); - }).then(Commands.m_82129_("targets", EntityArgument.m_91470_()).executes((p_137806_) -> { - return m_137801_(p_137806_.getSource(), EntityArgument.m_91477_(p_137806_, "targets"), new TranslatableComponent("multiplayer.disconnect.kicked")); - }).then(Commands.m_82129_("reason", MessageArgument.m_96832_()).executes((p_137798_) -> { + }).then(Commands.argument("targets", EntityArgument.players()).executes((p_137806_) -> { + return kickPlayers(p_137806_.getSource(), EntityArgument.getPlayers(p_137806_, "targets"), new TranslatableComponent("multiplayer.disconnect.kicked")); + }).then(Commands.argument("reason", MessageArgument.message()).executes((p_137798_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/KillCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/KillCommand.java.patch index efc73ba8..713134ee 100644 --- a/patches/minecraft/net/minecraft/server/commands/KillCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/KillCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/KillCommand.java @@ -12,7 +_,7 @@ public class KillCommand { - public static void m_137807_(CommandDispatcher p_137808_) { - p_137808_.register(Commands.m_82127_("kill").requires((p_137812_) -> { -- return p_137812_.m_6761_(2); + public static void register(CommandDispatcher p_137808_) { + p_137808_.register(Commands.literal("kill").requires((p_137812_) -> { +- return p_137812_.hasPermission(2); + return p_137812_.hasPermission(2,"minecraft.command.kill"); }).executes((p_137817_) -> { - return m_137813_(p_137817_.getSource(), ImmutableList.of(p_137817_.getSource().m_81374_())); - }).then(Commands.m_82129_("targets", EntityArgument.m_91460_()).executes((p_137810_) -> { + return kill(p_137817_.getSource(), ImmutableList.of(p_137817_.getSource().getEntityOrException())); + }).then(Commands.argument("targets", EntityArgument.entities()).executes((p_137810_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/ListPlayersCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/ListPlayersCommand.java.patch index 7a379eff..5044377a 100644 --- a/patches/minecraft/net/minecraft/server/commands/ListPlayersCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/ListPlayersCommand.java.patch @@ -3,26 +3,26 @@ @@ -14,7 +_,11 @@ public class ListPlayersCommand { - public static void m_137820_(CommandDispatcher p_137821_) { -- p_137821_.register(Commands.m_82127_("list").executes((p_137830_) -> { -+ p_137821_.register(Commands.m_82127_("list") + public static void register(CommandDispatcher p_137821_) { +- p_137821_.register(Commands.literal("list").executes((p_137830_) -> { ++ p_137821_.register(Commands.literal("list") + .requires(commandSourceStack -> { + return commandSourceStack.hasPermission(0,"minecraft.command.list"); + }) + .executes((p_137830_) -> { - return m_137824_(p_137830_.getSource()); - }).then(Commands.m_82127_("uuids").executes((p_137823_) -> { - return m_137831_(p_137823_.getSource()); + return listPlayers(p_137830_.getSource()); + }).then(Commands.literal("uuids").executes((p_137823_) -> { + return listPlayersWithUuids(p_137823_.getSource()); @@ -34,6 +_,12 @@ - private static int m_137826_(CommandSourceStack p_137827_, Function p_137828_) { - PlayerList playerlist = p_137827_.m_81377_().m_6846_(); - List list = playerlist.m_11314_(); + private static int format(CommandSourceStack p_137827_, Function p_137828_) { + PlayerList playerlist = p_137827_.getServer().getPlayerList(); + List list = playerlist.getPlayers(); + // CraftBukkit start + if (p_137827_.getBukkitSender() instanceof org.bukkit.entity.Player) { + org.bukkit.entity.Player sender = (org.bukkit.entity.Player) p_137827_.getBukkitSender(); + list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList()); + } + // CraftBukkit end - Component component = ComponentUtils.m_178440_(list, p_137828_); - p_137827_.m_81354_(new TranslatableComponent("commands.list.players", list.size(), playerlist.m_11310_(), component), false); + Component component = ComponentUtils.formatList(list, p_137828_); + p_137827_.sendSuccess(new TranslatableComponent("commands.list.players", list.size(), playerlist.getMaxPlayers(), component), false); return list.size(); diff --git a/patches/minecraft/net/minecraft/server/commands/LootCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/LootCommand.java.patch index 2963af00..1d7fb982 100644 --- a/patches/minecraft/net/minecraft/server/commands/LootCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/LootCommand.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/server/commands/LootCommand.java @@ -221,6 +_,7 @@ - private static int m_137945_(CommandSourceStack p_137946_, Vec3 p_137947_, List p_137948_, LootCommand.Callback p_137949_) throws CommandSyntaxException { - ServerLevel serverlevel = p_137946_.m_81372_(); -+ p_137948_.removeIf(ItemStack::m_41619_); // CraftBukkit - SPIGOT-6959 Remove empty items for avoid throw an error in new EntityItem + private static int dropInWorld(CommandSourceStack p_137946_, Vec3 p_137947_, List p_137948_, LootCommand.Callback p_137949_) throws CommandSyntaxException { + ServerLevel serverlevel = p_137946_.getLevel(); ++ p_137948_.removeIf(ItemStack::isEmpty); // CraftBukkit - SPIGOT-6959 Remove empty items for avoid throw an error in new EntityItem p_137948_.forEach((p_137884_) -> { - ItemEntity itementity = new ItemEntity(serverlevel, p_137947_.f_82479_, p_137947_.f_82480_, p_137947_.f_82481_, p_137884_.m_41777_()); - itementity.m_32060_(); + ItemEntity itementity = new ItemEntity(serverlevel, p_137947_.x, p_137947_.y, p_137947_.z, p_137884_.copy()); + itementity.setDefaultPickUpDelay(); diff --git a/patches/minecraft/net/minecraft/server/commands/MsgCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/MsgCommand.java.patch index 377c8a87..09fa6428 100644 --- a/patches/minecraft/net/minecraft/server/commands/MsgCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/MsgCommand.java.patch @@ -3,21 +3,21 @@ @@ -18,11 +_,17 @@ public class MsgCommand { - public static void m_138060_(CommandDispatcher p_138061_) { -- LiteralCommandNode literalcommandnode = p_138061_.register(Commands.m_82127_("msg").then(Commands.m_82129_("targets", EntityArgument.m_91470_()).then(Commands.m_82129_("message", MessageArgument.m_96832_()).executes((p_138063_) -> { -+ LiteralCommandNode literalcommandnode = p_138061_.register(Commands.m_82127_("msg") + public static void register(CommandDispatcher p_138061_) { +- LiteralCommandNode literalcommandnode = p_138061_.register(Commands.literal("msg").then(Commands.argument("targets", EntityArgument.players()).then(Commands.argument("message", MessageArgument.message()).executes((p_138063_) -> { ++ LiteralCommandNode literalcommandnode = p_138061_.register(Commands.literal("msg") + .requires(commandSourceStack -> commandSourceStack.hasPermission(0,"minecraft.command.msg")) -+ .then(Commands.m_82129_("targets", EntityArgument.m_91470_()).then(Commands.m_82129_("message", MessageArgument.m_96832_()).executes((p_138063_) -> { - return m_138064_(p_138063_.getSource(), EntityArgument.m_91477_(p_138063_, "targets"), MessageArgument.m_96835_(p_138063_, "message")); ++ .then(Commands.argument("targets", EntityArgument.players()).then(Commands.argument("message", MessageArgument.message()).executes((p_138063_) -> { + return sendMessage(p_138063_.getSource(), EntityArgument.getPlayers(p_138063_, "targets"), MessageArgument.getMessage(p_138063_, "message")); })))); -- p_138061_.register(Commands.m_82127_("tell").redirect(literalcommandnode)); -- p_138061_.register(Commands.m_82127_("w").redirect(literalcommandnode)); -+ p_138061_.register(Commands.m_82127_("tell") +- p_138061_.register(Commands.literal("tell").redirect(literalcommandnode)); +- p_138061_.register(Commands.literal("w").redirect(literalcommandnode)); ++ p_138061_.register(Commands.literal("tell") + .requires(commandSourceStack -> commandSourceStack.hasPermission(0,"minecraft.command.msg")) + .redirect(literalcommandnode)); -+ p_138061_.register(Commands.m_82127_("w") ++ p_138061_.register(Commands.literal("w") + .requires(commandSourceStack -> commandSourceStack.hasPermission(0,"minecraft.command.msg")) + .redirect(literalcommandnode)); } - private static int m_138064_(CommandSourceStack p_138065_, Collection p_138066_, Component p_138067_) { + private static int sendMessage(CommandSourceStack p_138065_, Collection p_138066_, Component p_138067_) { diff --git a/patches/minecraft/net/minecraft/server/commands/OpCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/OpCommand.java.patch index 575a3c55..ea57ad1e 100644 --- a/patches/minecraft/net/minecraft/server/commands/OpCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/OpCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/OpCommand.java @@ -17,7 +_,7 @@ - public static void m_138079_(CommandDispatcher p_138080_) { - p_138080_.register(Commands.m_82127_("op").requires((p_138087_) -> { -- return p_138087_.m_6761_(3); + public static void register(CommandDispatcher p_138080_) { + p_138080_.register(Commands.literal("op").requires((p_138087_) -> { +- return p_138087_.hasPermission(3); + return p_138087_.hasPermission(3,"minecraft.command.op"); - }).then(Commands.m_82129_("targets", GameProfileArgument.m_94584_()).suggests((p_138084_, p_138085_) -> { - PlayerList playerlist = p_138084_.getSource().m_81377_().m_6846_(); - return SharedSuggestionProvider.m_82981_(playerlist.m_11314_().stream().filter((p_180428_) -> { + }).then(Commands.argument("targets", GameProfileArgument.gameProfile()).suggests((p_138084_, p_138085_) -> { + PlayerList playerlist = p_138084_.getSource().getServer().getPlayerList(); + return SharedSuggestionProvider.suggest(playerlist.getPlayers().stream().filter((p_180428_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/PardonCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/PardonCommand.java.patch index 5be47c4a..f891348f 100644 --- a/patches/minecraft/net/minecraft/server/commands/PardonCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/PardonCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/PardonCommand.java @@ -18,7 +_,7 @@ - public static void m_138093_(CommandDispatcher p_138094_) { - p_138094_.register(Commands.m_82127_("pardon").requires((p_138101_) -> { -- return p_138101_.m_6761_(3); + public static void register(CommandDispatcher p_138094_) { + p_138094_.register(Commands.literal("pardon").requires((p_138101_) -> { +- return p_138101_.hasPermission(3); + return p_138101_.hasPermission(3,"minecraft.command.pardon"); - }).then(Commands.m_82129_("targets", GameProfileArgument.m_94584_()).suggests((p_138098_, p_138099_) -> { - return SharedSuggestionProvider.m_82967_(p_138098_.getSource().m_81377_().m_6846_().m_11295_().m_5875_(), p_138099_); + }).then(Commands.argument("targets", GameProfileArgument.gameProfile()).suggests((p_138098_, p_138099_) -> { + return SharedSuggestionProvider.suggest(p_138098_.getSource().getServer().getPlayerList().getBans().getUserList(), p_138099_); }).executes((p_138096_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/PardonIpCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/PardonIpCommand.java.patch index 7698fcdf..82c78bda 100644 --- a/patches/minecraft/net/minecraft/server/commands/PardonIpCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/PardonIpCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/PardonIpCommand.java @@ -17,7 +_,7 @@ - public static void m_138108_(CommandDispatcher p_138109_) { - p_138109_.register(Commands.m_82127_("pardon-ip").requires((p_138116_) -> { -- return p_138116_.m_6761_(3); + public static void register(CommandDispatcher p_138109_) { + p_138109_.register(Commands.literal("pardon-ip").requires((p_138116_) -> { +- return p_138116_.hasPermission(3); + return p_138116_.hasPermission(3,"minecraft.command.pardon-ip"); - }).then(Commands.m_82129_("target", StringArgumentType.word()).suggests((p_138113_, p_138114_) -> { - return SharedSuggestionProvider.m_82967_(p_138113_.getSource().m_81377_().m_6846_().m_11299_().m_5875_(), p_138114_); + }).then(Commands.argument("target", StringArgumentType.word()).suggests((p_138113_, p_138114_) -> { + return SharedSuggestionProvider.suggest(p_138113_.getSource().getServer().getPlayerList().getIpBans().getUserList(), p_138114_); }).executes((p_138111_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/PlaySoundCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/PlaySoundCommand.java.patch index 8b90436e..bdce67e2 100644 --- a/patches/minecraft/net/minecraft/server/commands/PlaySoundCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/PlaySoundCommand.java.patch @@ -3,8 +3,8 @@ @@ -32,7 +_,7 @@ } - p_138157_.register(Commands.m_82127_("playsound").requires((p_138159_) -> { -- return p_138159_.m_6761_(2); + p_138157_.register(Commands.literal("playsound").requires((p_138159_) -> { +- return p_138159_.hasPermission(2); + return p_138159_.hasPermission(2,"minecraft.command.playsound"); }).then(requiredargumentbuilder)); } diff --git a/patches/minecraft/net/minecraft/server/commands/ReloadCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/ReloadCommand.java.patch index ad9bc542..879412a8 100644 --- a/patches/minecraft/net/minecraft/server/commands/ReloadCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/ReloadCommand.java.patch @@ -7,11 +7,11 @@ + + // CraftBukkit start + public static void reload(MinecraftServer minecraftserver) { -+ PackRepository resourcepackrepository = minecraftserver.m_129891_(); -+ WorldData savedata = minecraftserver.m_129910_(); -+ Collection collection = resourcepackrepository.m_10523_(); -+ Collection collection1 = m_138222_(resourcepackrepository, savedata, collection); -+ minecraftserver.m_129861_(collection1); ++ PackRepository resourcepackrepository = minecraftserver.getPackRepository(); ++ WorldData savedata = minecraftserver.getWorldData(); ++ Collection collection = resourcepackrepository.getSelectedIds(); ++ Collection collection1 = discoverNewPacks(resourcepackrepository, savedata, collection); ++ minecraftserver.reloadResources(collection1); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/server/commands/SaveAllCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SaveAllCommand.java.patch index ebc93fa3..224a1c10 100644 --- a/patches/minecraft/net/minecraft/server/commands/SaveAllCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SaveAllCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SaveAllCommand.java @@ -13,7 +_,7 @@ - public static void m_138271_(CommandDispatcher p_138272_) { - p_138272_.register(Commands.m_82127_("save-all").requires((p_138276_) -> { -- return p_138276_.m_6761_(4); + public static void register(CommandDispatcher p_138272_) { + p_138272_.register(Commands.literal("save-all").requires((p_138276_) -> { +- return p_138276_.hasPermission(4); + return p_138276_.hasPermission(4,"minecraft.command.save-all"); }).executes((p_138281_) -> { - return m_138277_(p_138281_.getSource(), false); - }).then(Commands.m_82127_("flush").executes((p_138274_) -> { + return saveAll(p_138281_.getSource(), false); + }).then(Commands.literal("flush").executes((p_138274_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/SaveOffCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SaveOffCommand.java.patch index 97991c8b..2c8b4e68 100644 --- a/patches/minecraft/net/minecraft/server/commands/SaveOffCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SaveOffCommand.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/server/commands/SaveOffCommand.java @@ -12,7 +_,7 @@ - public static void m_138284_(CommandDispatcher p_138285_) { - p_138285_.register(Commands.m_82127_("save-off").requires((p_138289_) -> { -- return p_138289_.m_6761_(4); + public static void register(CommandDispatcher p_138285_) { + p_138285_.register(Commands.literal("save-off").requires((p_138289_) -> { +- return p_138289_.hasPermission(4); + return p_138289_.hasPermission(4,"minecraft.command.save-off"); }).executes((p_138287_) -> { CommandSourceStack commandsourcestack = p_138287_.getSource(); diff --git a/patches/minecraft/net/minecraft/server/commands/SaveOnCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SaveOnCommand.java.patch index 1e9da72e..5ab0a2a7 100644 --- a/patches/minecraft/net/minecraft/server/commands/SaveOnCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SaveOnCommand.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/server/commands/SaveOnCommand.java @@ -12,7 +_,7 @@ - public static void m_138292_(CommandDispatcher p_138293_) { - p_138293_.register(Commands.m_82127_("save-on").requires((p_138297_) -> { -- return p_138297_.m_6761_(4); + public static void register(CommandDispatcher p_138293_) { + p_138293_.register(Commands.literal("save-on").requires((p_138297_) -> { +- return p_138297_.hasPermission(4); + return p_138297_.hasPermission(4,"minecraft.command.save-on"); }).executes((p_138295_) -> { CommandSourceStack commandsourcestack = p_138295_.getSource(); diff --git a/patches/minecraft/net/minecraft/server/commands/SayCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SayCommand.java.patch index ca945bc3..958a6e87 100644 --- a/patches/minecraft/net/minecraft/server/commands/SayCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SayCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SayCommand.java @@ -13,7 +_,7 @@ public class SayCommand { - public static void m_138409_(CommandDispatcher p_138410_) { - p_138410_.register(Commands.m_82127_("say").requires((p_138414_) -> { -- return p_138414_.m_6761_(2); + public static void register(CommandDispatcher p_138410_) { + p_138410_.register(Commands.literal("say").requires((p_138414_) -> { +- return p_138414_.hasPermission(2); + return p_138414_.hasPermission(2,"minecraft.command.say"); - }).then(Commands.m_82129_("message", MessageArgument.m_96832_()).executes((p_138412_) -> { - Component component = MessageArgument.m_96835_(p_138412_, "message"); - Component component1 = new TranslatableComponent("chat.type.announcement", p_138412_.getSource().m_81357_(), component); + }).then(Commands.argument("message", MessageArgument.message()).executes((p_138412_) -> { + Component component = MessageArgument.getMessage(p_138412_, "message"); + Component component1 = new TranslatableComponent("chat.type.announcement", p_138412_.getSource().getDisplayName(), component); diff --git a/patches/minecraft/net/minecraft/server/commands/ScheduleCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/ScheduleCommand.java.patch index ababe862..b915e2c7 100644 --- a/patches/minecraft/net/minecraft/server/commands/ScheduleCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/ScheduleCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/ScheduleCommand.java @@ -52,7 +_,7 @@ } else { - long i = p_138429_.m_81372_().m_46467_() + (long)p_138431_; + long i = p_138429_.getLevel().getGameTime() + (long)p_138431_; ResourceLocation resourcelocation = p_138430_.getFirst(); -- TimerQueue timerqueue = p_138429_.m_81377_().m_129910_().m_5996_().m_7540_(); -+ TimerQueue timerqueue = p_138429_.m_81372_().worldDataServer.m_5996_().m_7540_(); +- TimerQueue timerqueue = p_138429_.getServer().getWorldData().overworldData().getScheduledEvents(); ++ TimerQueue timerqueue = p_138429_.getLevel().worldDataServer.overworldData().getScheduledEvents(); p_138430_.getSecond().ifLeft((p_138453_) -> { String s = resourcelocation.toString(); if (p_138432_) { diff --git a/patches/minecraft/net/minecraft/server/commands/ScoreboardCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/ScoreboardCommand.java.patch index 08e5625b..2958c002 100644 --- a/patches/minecraft/net/minecraft/server/commands/ScoreboardCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/ScoreboardCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/ScoreboardCommand.java @@ -45,7 +_,7 @@ - public static void m_138468_(CommandDispatcher p_138469_) { - p_138469_.register(Commands.m_82127_("scoreboard").requires((p_138552_) -> { -- return p_138552_.m_6761_(2); + public static void register(CommandDispatcher p_138469_) { + p_138469_.register(Commands.literal("scoreboard").requires((p_138552_) -> { +- return p_138552_.hasPermission(2); + return p_138552_.hasPermission(2,"minecraft.command.scoreboard"); - }).then(Commands.m_82127_("objectives").then(Commands.m_82127_("list").executes((p_138585_) -> { - return m_138538_(p_138585_.getSource()); - })).then(Commands.m_82127_("add").then(Commands.m_82129_("objective", StringArgumentType.word()).then(Commands.m_82129_("criteria", ObjectiveCriteriaArgument.m_102555_()).executes((p_138583_) -> { + }).then(Commands.literal("objectives").then(Commands.literal("list").executes((p_138585_) -> { + return listObjectives(p_138585_.getSource()); + })).then(Commands.literal("add").then(Commands.argument("objective", StringArgumentType.word()).then(Commands.argument("criteria", ObjectiveCriteriaArgument.criteria()).executes((p_138583_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/SeedCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SeedCommand.java.patch index ddc587c7..1c10ea8e 100644 --- a/patches/minecraft/net/minecraft/server/commands/SeedCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SeedCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SeedCommand.java @@ -14,7 +_,7 @@ public class SeedCommand { - public static void m_138589_(CommandDispatcher p_138590_, boolean p_138591_) { - p_138590_.register(Commands.m_82127_("seed").requires((p_138596_) -> { -- return !p_138591_ || p_138596_.m_6761_(2); + public static void register(CommandDispatcher p_138590_, boolean p_138591_) { + p_138590_.register(Commands.literal("seed").requires((p_138596_) -> { +- return !p_138591_ || p_138596_.hasPermission(2); + return !p_138591_ || p_138596_.hasPermission(2,"minecraft.command.seed"); }).executes((p_138593_) -> { - long i = p_138593_.getSource().m_81372_().m_7328_(); - Component component = ComponentUtils.m_130748_((new TextComponent(String.valueOf(i))).m_130938_((p_180514_) -> { + long i = p_138593_.getSource().getLevel().getSeed(); + Component component = ComponentUtils.wrapInSquareBrackets((new TextComponent(String.valueOf(i))).withStyle((p_180514_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/SetBlockCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SetBlockCommand.java.patch index d88a8da6..006ccd3c 100644 --- a/patches/minecraft/net/minecraft/server/commands/SetBlockCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SetBlockCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SetBlockCommand.java @@ -23,7 +_,7 @@ - public static void m_138601_(CommandDispatcher p_138602_) { - p_138602_.register(Commands.m_82127_("setblock").requires((p_138606_) -> { -- return p_138606_.m_6761_(2); + public static void register(CommandDispatcher p_138602_) { + p_138602_.register(Commands.literal("setblock").requires((p_138606_) -> { +- return p_138606_.hasPermission(2); + return p_138606_.hasPermission(2,"minecraft.command.setblock"); - }).then(Commands.m_82129_("pos", BlockPosArgument.m_118239_()).then(Commands.m_82129_("block", BlockStateArgument.m_116120_()).executes((p_138618_) -> { - return m_138607_(p_138618_.getSource(), BlockPosArgument.m_118242_(p_138618_, "pos"), BlockStateArgument.m_116123_(p_138618_, "block"), SetBlockCommand.Mode.REPLACE, (Predicate)null); - }).then(Commands.m_82127_("destroy").executes((p_138616_) -> { + }).then(Commands.argument("pos", BlockPosArgument.blockPos()).then(Commands.argument("block", BlockStateArgument.block()).executes((p_138618_) -> { + return setBlock(p_138618_.getSource(), BlockPosArgument.getLoadedBlockPos(p_138618_, "pos"), BlockStateArgument.getBlock(p_138618_, "block"), SetBlockCommand.Mode.REPLACE, (Predicate)null); + }).then(Commands.literal("destroy").executes((p_138616_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/SetPlayerIdleTimeoutCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SetPlayerIdleTimeoutCommand.java.patch index 82987327..80ff1fee 100644 --- a/patches/minecraft/net/minecraft/server/commands/SetPlayerIdleTimeoutCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SetPlayerIdleTimeoutCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SetPlayerIdleTimeoutCommand.java @@ -9,7 +_,7 @@ public class SetPlayerIdleTimeoutCommand { - public static void m_138634_(CommandDispatcher p_138635_) { - p_138635_.register(Commands.m_82127_("setidletimeout").requires((p_138639_) -> { -- return p_138639_.m_6761_(3); + public static void register(CommandDispatcher p_138635_) { + p_138635_.register(Commands.literal("setidletimeout").requires((p_138639_) -> { +- return p_138639_.hasPermission(3); + return p_138639_.hasPermission(3,"minecraft.command.setidletimeout"); - }).then(Commands.m_82129_("minutes", IntegerArgumentType.integer(0)).executes((p_138637_) -> { - return m_138640_(p_138637_.getSource(), IntegerArgumentType.getInteger(p_138637_, "minutes")); + }).then(Commands.argument("minutes", IntegerArgumentType.integer(0)).executes((p_138637_) -> { + return setIdleTimeout(p_138637_.getSource(), IntegerArgumentType.getInteger(p_138637_, "minutes")); }))); diff --git a/patches/minecraft/net/minecraft/server/commands/SetSpawnCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SetSpawnCommand.java.patch index e62912c7..666e12da 100644 --- a/patches/minecraft/net/minecraft/server/commands/SetSpawnCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SetSpawnCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SetSpawnCommand.java @@ -17,7 +_,7 @@ public class SetSpawnCommand { - public static void m_138643_(CommandDispatcher p_138644_) { - p_138644_.register(Commands.m_82127_("spawnpoint").requires((p_138648_) -> { -- return p_138648_.m_6761_(2); + public static void register(CommandDispatcher p_138644_) { + p_138644_.register(Commands.literal("spawnpoint").requires((p_138648_) -> { +- return p_138648_.hasPermission(2); + return p_138648_.hasPermission(2,"minecraft.command.spawnpoint"); }).executes((p_138659_) -> { - return m_138649_(p_138659_.getSource(), Collections.singleton(p_138659_.getSource().m_81375_()), new BlockPos(p_138659_.getSource().m_81371_()), 0.0F); - }).then(Commands.m_82129_("targets", EntityArgument.m_91470_()).executes((p_138657_) -> { + return setSpawn(p_138659_.getSource(), Collections.singleton(p_138659_.getSource().getPlayerOrException()), new BlockPos(p_138659_.getSource().getPosition()), 0.0F); + }).then(Commands.argument("targets", EntityArgument.players()).executes((p_138657_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/SetWorldSpawnCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SetWorldSpawnCommand.java.patch index faf41418..a1900cad 100644 --- a/patches/minecraft/net/minecraft/server/commands/SetWorldSpawnCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SetWorldSpawnCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/SetWorldSpawnCommand.java @@ -11,7 +_,7 @@ public class SetWorldSpawnCommand { - public static void m_138660_(CommandDispatcher p_138661_) { - p_138661_.register(Commands.m_82127_("setworldspawn").requires((p_138665_) -> { -- return p_138665_.m_6761_(2); + public static void register(CommandDispatcher p_138661_) { + p_138661_.register(Commands.literal("setworldspawn").requires((p_138665_) -> { +- return p_138665_.hasPermission(2); + return p_138665_.hasPermission(2,"minecraft.command.setworldspawn"); }).executes((p_138673_) -> { - return m_138666_(p_138673_.getSource(), new BlockPos(p_138673_.getSource().m_81371_()), 0.0F); - }).then(Commands.m_82129_("pos", BlockPosArgument.m_118239_()).executes((p_138671_) -> { + return setSpawn(p_138673_.getSource(), new BlockPos(p_138673_.getSource().getPosition()), 0.0F); + }).then(Commands.argument("pos", BlockPosArgument.blockPos()).executes((p_138671_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch index 1030c902..89473a06 100644 --- a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch @@ -2,50 +2,50 @@ +++ b/net/minecraft/server/commands/SpreadPlayersCommand.java @@ -45,7 +_,7 @@ - public static void m_138696_(CommandDispatcher p_138697_) { - p_138697_.register(Commands.m_82127_("spreadplayers").requires((p_201852_) -> { -- return p_201852_.m_6761_(2); + public static void register(CommandDispatcher p_138697_) { + p_138697_.register(Commands.literal("spreadplayers").requires((p_201852_) -> { +- return p_201852_.hasPermission(2); + return p_201852_.hasPermission(2,"minecraft.command.spreadplayers"); - }).then(Commands.m_82129_("center", Vec2Argument.m_120822_()).then(Commands.m_82129_("spreadDistance", FloatArgumentType.floatArg(0.0F)).then(Commands.m_82129_("maxRange", FloatArgumentType.floatArg(1.0F)).then(Commands.m_82129_("respectTeams", BoolArgumentType.bool()).then(Commands.m_82129_("targets", EntityArgument.m_91460_()).executes((p_138699_) -> { - return m_138702_(p_138699_.getSource(), Vec2Argument.m_120825_(p_138699_, "center"), FloatArgumentType.getFloat(p_138699_, "spreadDistance"), FloatArgumentType.getFloat(p_138699_, "maxRange"), p_138699_.getSource().m_81372_().m_151558_(), BoolArgumentType.getBool(p_138699_, "respectTeams"), EntityArgument.m_91461_(p_138699_, "targets")); - }))).then(Commands.m_82127_("under").then(Commands.m_82129_("maxHeight", IntegerArgumentType.integer()).then(Commands.m_82129_("respectTeams", BoolArgumentType.bool()).then(Commands.m_82129_("targets", EntityArgument.m_91460_()).executes((p_201850_) -> { + }).then(Commands.argument("center", Vec2Argument.vec2()).then(Commands.argument("spreadDistance", FloatArgumentType.floatArg(0.0F)).then(Commands.argument("maxRange", FloatArgumentType.floatArg(1.0F)).then(Commands.argument("respectTeams", BoolArgumentType.bool()).then(Commands.argument("targets", EntityArgument.entities()).executes((p_138699_) -> { + return spreadPlayers(p_138699_.getSource(), Vec2Argument.getVec2(p_138699_, "center"), FloatArgumentType.getFloat(p_138699_, "spreadDistance"), FloatArgumentType.getFloat(p_138699_, "maxRange"), p_138699_.getSource().getLevel().getMaxBuildHeight(), BoolArgumentType.getBool(p_138699_, "respectTeams"), EntityArgument.getEntities(p_138699_, "targets")); + }))).then(Commands.literal("under").then(Commands.argument("maxHeight", IntegerArgumentType.integer()).then(Commands.argument("respectTeams", BoolArgumentType.bool()).then(Commands.argument("targets", EntityArgument.entities()).executes((p_201850_) -> { @@ -173,7 +_,8 @@ spreadplayerscommand$position = p_138732_[i++]; } -- entity.m_20324_((double)Mth.m_14107_(spreadplayerscommand$position.f_138749_) + 0.5D, (double)spreadplayerscommand$position.m_138758_(p_138731_, p_138733_), (double)Mth.m_14107_(spreadplayerscommand$position.f_138750_) + 0.5D); -+ net.minecraftforge.event.entity.EntityTeleportEvent.SpreadPlayersCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportSpreadPlayersCommand(entity, (double)Mth.m_14107_(spreadplayerscommand$position.f_138749_) + 0.5D, (double)spreadplayerscommand$position.m_138758_(p_138731_, p_138733_), (double)Mth.m_14107_(spreadplayerscommand$position.f_138750_) + 0.5D); -+ if (!event.isCanceled()) entity.m_20324_(event.getTargetX(), event.getTargetY(), event.getTargetZ()); +- entity.teleportToWithTicket((double)Mth.floor(spreadplayerscommand$position.x) + 0.5D, (double)spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), (double)Mth.floor(spreadplayerscommand$position.z) + 0.5D); ++ net.minecraftforge.event.entity.EntityTeleportEvent.SpreadPlayersCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportSpreadPlayersCommand(entity, (double)Mth.floor(spreadplayerscommand$position.x) + 0.5D, (double)spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), (double)Mth.floor(spreadplayerscommand$position.z) + 0.5D); ++ if (!event.isCanceled()) entity.teleportToWithTicket(event.getTargetX(), event.getTargetY(), event.getTargetZ()); double d2 = Double.MAX_VALUE; for(SpreadPlayersCommand.Position spreadplayerscommand$position1 : p_138732_) { @@ -255,7 +_,7 @@ boolean flag2; - for(boolean flag1 = p_138759_.m_8055_(blockpos$mutableblockpos).m_60795_(); blockpos$mutableblockpos.m_123342_() > p_138759_.m_141937_(); flag1 = flag2) { - blockpos$mutableblockpos.m_122173_(Direction.DOWN); -- flag2 = p_138759_.m_8055_(blockpos$mutableblockpos).m_60795_(); -+ flag2 = getBlockState(p_138759_, blockpos$mutableblockpos).m_60795_(); + for(boolean flag1 = p_138759_.getBlockState(blockpos$mutableblockpos).isAir(); blockpos$mutableblockpos.getY() > p_138759_.getMinBuildHeight(); flag1 = flag2) { + blockpos$mutableblockpos.move(Direction.DOWN); +- flag2 = p_138759_.getBlockState(blockpos$mutableblockpos).isAir(); ++ flag2 = getBlockState(p_138759_, blockpos$mutableblockpos).isAir(); if (!flag2 && flag1 && flag) { - return blockpos$mutableblockpos.m_123342_() + 1; + return blockpos$mutableblockpos.getY() + 1; } @@ -268,7 +_,7 @@ - public boolean m_138773_(BlockGetter p_138774_, int p_138775_) { - BlockPos blockpos = new BlockPos(this.f_138749_, (double)(this.m_138758_(p_138774_, p_138775_) - 1), this.f_138750_); -- BlockState blockstate = p_138774_.m_8055_(blockpos); + public boolean isSafe(BlockGetter p_138774_, int p_138775_) { + BlockPos blockpos = new BlockPos(this.x, (double)(this.getSpawnY(p_138774_, p_138775_) - 1), this.z); +- BlockState blockstate = p_138774_.getBlockState(blockpos); + BlockState blockstate = getBlockState(p_138774_, blockpos); - Material material = blockstate.m_60767_(); - return blockpos.m_123342_() < p_138775_ && !material.m_76332_() && material != Material.f_76309_; + Material material = blockstate.getMaterial(); + return blockpos.getY() < p_138775_ && !material.isLiquid() && material != Material.FIRE; } @@ -277,5 +_,12 @@ - this.f_138749_ = Mth.m_14064_(p_138762_, p_138763_, p_138765_); - this.f_138750_ = Mth.m_14064_(p_138762_, p_138764_, p_138766_); + this.x = Mth.nextDouble(p_138762_, p_138763_, p_138765_); + this.z = Mth.nextDouble(p_138762_, p_138764_, p_138766_); } + + // CraftBukkit start - add a version of getBlockState which force loads chunks + private static BlockState getBlockState(BlockGetter iblockaccess, BlockPos position) { -+ ((ServerLevel) iblockaccess).m_7726_().m_62227_(position.m_123341_() >> 4, position.m_123343_() >> 4, true); -+ return iblockaccess.m_8055_(position); ++ ((ServerLevel) iblockaccess).getChunkSource().getChunk(position.getX() >> 4, position.getZ() >> 4, true); ++ return iblockaccess.getBlockState(position); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/server/commands/StopCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/StopCommand.java.patch index bcb1c19e..a021921e 100644 --- a/patches/minecraft/net/minecraft/server/commands/StopCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/StopCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/StopCommand.java @@ -8,7 +_,7 @@ public class StopCommand { - public static void m_138785_(CommandDispatcher p_138786_) { - p_138786_.register(Commands.m_82127_("stop").requires((p_138790_) -> { -- return p_138790_.m_6761_(4); + public static void register(CommandDispatcher p_138786_) { + p_138786_.register(Commands.literal("stop").requires((p_138790_) -> { +- return p_138790_.hasPermission(4); + return p_138790_.hasPermission(4,"minecraft.command.stop"); }).executes((p_138788_) -> { - p_138788_.getSource().m_81354_(new TranslatableComponent("commands.stop.stopping"), true); - p_138788_.getSource().m_81377_().m_7570_(false); + p_138788_.getSource().sendSuccess(new TranslatableComponent("commands.stop.stopping"), true); + p_138788_.getSource().getServer().halt(false); diff --git a/patches/minecraft/net/minecraft/server/commands/SummonCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SummonCommand.java.patch index 8870d334..e2e5fa32 100644 --- a/patches/minecraft/net/minecraft/server/commands/SummonCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SummonCommand.java.patch @@ -2,18 +2,18 @@ +++ b/net/minecraft/server/commands/SummonCommand.java @@ -29,7 +_,7 @@ - public static void m_138814_(CommandDispatcher p_138815_) { - p_138815_.register(Commands.m_82127_("summon").requires((p_138819_) -> { -- return p_138819_.m_6761_(2); + public static void register(CommandDispatcher p_138815_) { + p_138815_.register(Commands.literal("summon").requires((p_138819_) -> { +- return p_138819_.hasPermission(2); + return p_138819_.hasPermission(2,"minecraft.command.summon"); - }).then(Commands.m_82129_("entity", EntitySummonArgument.m_93335_()).suggests(SuggestionProviders.f_121645_).executes((p_138832_) -> { - return m_138820_(p_138832_.getSource(), EntitySummonArgument.m_93338_(p_138832_, "entity"), p_138832_.getSource().m_81371_(), new CompoundTag(), true); - }).then(Commands.m_82129_("pos", Vec3Argument.m_120841_()).executes((p_138830_) -> { + }).then(Commands.argument("entity", EntitySummonArgument.id()).suggests(SuggestionProviders.SUMMONABLE_ENTITIES).executes((p_138832_) -> { + return spawnEntity(p_138832_.getSource(), EntitySummonArgument.getSummonableEntity(p_138832_, "entity"), p_138832_.getSource().getPosition(), new CompoundTag(), true); + }).then(Commands.argument("pos", Vec3Argument.vec3()).executes((p_138830_) -> { @@ -58,6 +_,7 @@ - ((Mob)entity).m_6518_(p_138821_.m_81372_(), p_138821_.m_81372_().m_6436_(entity.m_142538_()), MobSpawnType.COMMAND, (SpawnGroupData)null, (CompoundTag)null); + ((Mob)entity).finalizeSpawn(p_138821_.getLevel(), p_138821_.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData)null, (CompoundTag)null); } + serverlevel.prepareEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND); // Magma - add spawn reason - if (!serverlevel.m_8860_(entity)) { - throw f_138811_.create(); + if (!serverlevel.tryAddFreshEntityWithPassengers(entity)) { + throw ERROR_DUPLICATE_UUID.create(); } else { diff --git a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch index a29f269a..0970f152 100644 --- a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch @@ -2,37 +2,37 @@ +++ b/net/minecraft/server/commands/TeleportCommand.java @@ -38,7 +_,7 @@ - public static void m_139008_(CommandDispatcher p_139009_) { - LiteralCommandNode literalcommandnode = p_139009_.register(Commands.m_82127_("teleport").requires((p_139039_) -> { -- return p_139039_.m_6761_(2); + public static void register(CommandDispatcher p_139009_) { + LiteralCommandNode literalcommandnode = p_139009_.register(Commands.literal("teleport").requires((p_139039_) -> { +- return p_139039_.hasPermission(2); + return p_139039_.hasPermission(2,"minecraft.command.teleport"); - }).then(Commands.m_82129_("location", Vec3Argument.m_120841_()).executes((p_139051_) -> { - return m_139025_(p_139051_.getSource(), Collections.singleton(p_139051_.getSource().m_81374_()), p_139051_.getSource().m_81372_(), Vec3Argument.m_120849_(p_139051_, "location"), WorldCoordinates.m_120898_(), (TeleportCommand.LookAt)null); - })).then(Commands.m_82129_("destination", EntityArgument.m_91449_()).executes((p_139049_) -> { + }).then(Commands.argument("location", Vec3Argument.vec3()).executes((p_139051_) -> { + return teleportToPos(p_139051_.getSource(), Collections.singleton(p_139051_.getSource().getEntityOrException()), p_139051_.getSource().getLevel(), Vec3Argument.getCoordinates(p_139051_, "location"), WorldCoordinates.current(), (TeleportCommand.LookAt)null); + })).then(Commands.argument("destination", EntityArgument.entity()).executes((p_139049_) -> { @@ -126,6 +_,9 @@ } - private static void m_139014_(CommandSourceStack p_139015_, Entity p_139016_, ServerLevel p_139017_, double p_139018_, double p_139019_, double p_139020_, Set p_139021_, float p_139022_, float p_139023_, @Nullable TeleportCommand.LookAt p_139024_) throws CommandSyntaxException { + private static void performTeleport(CommandSourceStack p_139015_, Entity p_139016_, ServerLevel p_139017_, double p_139018_, double p_139019_, double p_139020_, Set p_139021_, float p_139022_, float p_139023_, @Nullable TeleportCommand.LookAt p_139024_) throws CommandSyntaxException { + net.minecraftforge.event.entity.EntityTeleportEvent.TeleportCommand 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 = new BlockPos(p_139018_, p_139019_, p_139020_); - if (!Level.m_46741_(blockpos)) { - throw f_139006_.create(); + if (!Level.isInSpawnableBounds(blockpos)) { + throw INVALID_POSITION.create(); @@ -141,14 +_,29 @@ } - if (p_139017_ == p_139016_.f_19853_) { -- ((ServerPlayer)p_139016_).f_8906_.m_9780_(p_139018_, p_139019_, p_139020_, f, f1, p_139021_); -+ ((ServerPlayer)p_139016_).f_8906_.teleport(p_139018_, p_139019_, p_139020_, f, f1, p_139021_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); //CraftBukkit + if (p_139017_ == p_139016_.level) { +- ((ServerPlayer)p_139016_).connection.teleport(p_139018_, p_139019_, p_139020_, f, f1, p_139021_); ++ ((ServerPlayer)p_139016_).connection.teleport(p_139018_, p_139019_, p_139020_, f, f1, p_139021_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); //CraftBukkit } else { -- ((ServerPlayer)p_139016_).m_8999_(p_139017_, p_139018_, p_139019_, p_139020_, f, f1); +- ((ServerPlayer)p_139016_).teleportTo(p_139017_, p_139018_, p_139019_, p_139020_, f, f1); + ((ServerPlayer)p_139016_).teleportTo(p_139017_, p_139018_, p_139019_, p_139020_, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); //CraftBukkit } - p_139016_.m_5616_(f); + p_139016_.setYHeadRot(f); } else { - float f2 = Mth.m_14036_(f1, -90.0F, 90.0F); + float f2 = Mth.clamp(f1, -90.0F, 90.0F); + // CraftBukkit start - Teleport event + org.bukkit.Location to = new org.bukkit.Location(p_139017_.getWorld(), p_139018_, p_139019_, p_139020_, f1, f2); + org.bukkit.event.entity.EntityTeleportEvent bevent = new org.bukkit.event.entity.EntityTeleportEvent(p_139016_.getBukkitEntity(), p_139016_.getBukkitEntity().getLocation(), to); @@ -48,6 +48,6 @@ + f2 = to.getPitch(); + p_139017_ = ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) to.getWorld()).getHandle(); + // CraftBukkit end - if (p_139017_ == p_139016_.f_19853_) { - p_139016_.m_7678_(p_139018_, p_139019_, p_139020_, f, f2); - p_139016_.m_5616_(f); + if (p_139017_ == p_139016_.level) { + p_139016_.moveTo(p_139018_, p_139019_, p_139020_, f, f2); + p_139016_.setYHeadRot(f); diff --git a/patches/minecraft/net/minecraft/server/commands/TellRawCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TellRawCommand.java.patch index e918f49f..aa1d8792 100644 --- a/patches/minecraft/net/minecraft/server/commands/TellRawCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TellRawCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/TellRawCommand.java @@ -12,7 +_,7 @@ public class TellRawCommand { - public static void m_139063_(CommandDispatcher p_139064_) { - p_139064_.register(Commands.m_82127_("tellraw").requires((p_139068_) -> { -- return p_139068_.m_6761_(2); + public static void register(CommandDispatcher p_139064_) { + p_139064_.register(Commands.literal("tellraw").requires((p_139068_) -> { +- return p_139068_.hasPermission(2); + return p_139068_.hasPermission(2,"minecraft.command.tellraw"); - }).then(Commands.m_82129_("targets", EntityArgument.m_91470_()).then(Commands.m_82129_("message", ComponentArgument.m_87114_()).executes((p_139066_) -> { + }).then(Commands.argument("targets", EntityArgument.players()).then(Commands.argument("message", ComponentArgument.textComponent()).executes((p_139066_) -> { int i = 0; diff --git a/patches/minecraft/net/minecraft/server/commands/TimeCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TimeCommand.java.patch index fbe2ccf0..0dab7813 100644 --- a/patches/minecraft/net/minecraft/server/commands/TimeCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TimeCommand.java.patch @@ -2,48 +2,48 @@ +++ b/net/minecraft/server/commands/TimeCommand.java @@ -11,7 +_,7 @@ public class TimeCommand { - public static void m_139071_(CommandDispatcher p_139072_) { - p_139072_.register(Commands.m_82127_("time").requires((p_139076_) -> { -- return p_139076_.m_6761_(2); + public static void register(CommandDispatcher p_139072_) { + p_139072_.register(Commands.literal("time").requires((p_139076_) -> { +- return p_139076_.hasPermission(2); + return p_139076_.hasPermission(2,"minecraft.command.time"); - }).then(Commands.m_82127_("set").then(Commands.m_82127_("day").executes((p_139101_) -> { - return m_139077_(p_139101_.getSource(), 1000); - })).then(Commands.m_82127_("noon").executes((p_139099_) -> { + }).then(Commands.literal("set").then(Commands.literal("day").executes((p_139101_) -> { + return setTime(p_139101_.getSource(), 1000); + })).then(Commands.literal("noon").executes((p_139099_) -> { @@ -43,8 +_,16 @@ } - public static int m_139077_(CommandSourceStack p_139078_, int p_139079_) { -- for(ServerLevel serverlevel : p_139078_.m_81377_().m_129785_()) { -- serverlevel.m_8615_((long)p_139079_); -+ java.util.Iterator iterator = com.google.common.collect.Iterators.singletonIterator(p_139078_.m_81372_()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in + public static int setTime(CommandSourceStack p_139078_, int p_139079_) { +- for(ServerLevel serverlevel : p_139078_.getServer().getAllLevels()) { +- serverlevel.setDayTime((long)p_139079_); ++ java.util.Iterator iterator = com.google.common.collect.Iterators.singletonIterator(p_139078_.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in + while(iterator.hasNext()) { + ServerLevel serverLevel = iterator.next(); + // CraftBukkit start -+ org.bukkit.event.world.TimeSkipEvent event = new org.bukkit.event.world.TimeSkipEvent(serverLevel.getWorld(), org.bukkit.event.world.TimeSkipEvent.SkipReason.COMMAND, p_139079_ - serverLevel.m_46468_()); ++ org.bukkit.event.world.TimeSkipEvent event = new org.bukkit.event.world.TimeSkipEvent(serverLevel.getWorld(), org.bukkit.event.world.TimeSkipEvent.SkipReason.COMMAND, p_139079_ - serverLevel.getDayTime()); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ serverLevel.m_8615_((long) serverLevel.m_46468_() + event.getSkipAmount()); ++ serverLevel.setDayTime((long) serverLevel.getDayTime() + event.getSkipAmount()); + } + // CraftBukkit end } - p_139078_.m_81354_(new TranslatableComponent("commands.time.set", p_139079_), true); + p_139078_.sendSuccess(new TranslatableComponent("commands.time.set", p_139079_), true); @@ -52,8 +_,16 @@ } - public static int m_139082_(CommandSourceStack p_139083_, int p_139084_) { -- for(ServerLevel serverlevel : p_139083_.m_81377_().m_129785_()) { -- serverlevel.m_8615_(serverlevel.m_46468_() + (long)p_139084_); -+ java.util.Iterator iterator = com.google.common.collect.Iterators.singletonIterator(p_139083_.m_81372_()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in + public static int addTime(CommandSourceStack p_139083_, int p_139084_) { +- for(ServerLevel serverlevel : p_139083_.getServer().getAllLevels()) { +- serverlevel.setDayTime(serverlevel.getDayTime() + (long)p_139084_); ++ java.util.Iterator iterator = com.google.common.collect.Iterators.singletonIterator(p_139083_.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in + while (iterator.hasNext()) { + ServerLevel serverLevel = (ServerLevel) iterator.next(); + // CraftBukkit start + org.bukkit.event.world.TimeSkipEvent event = new org.bukkit.event.world.TimeSkipEvent(serverLevel.getWorld(), org.bukkit.event.world.TimeSkipEvent.SkipReason.COMMAND, p_139084_); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ serverLevel.m_8615_(serverLevel.m_46468_() + event.getSkipAmount()); ++ serverLevel.setDayTime(serverLevel.getDayTime() + event.getSkipAmount()); + } + // CraftBukkit end } - int i = m_139069_(p_139083_.m_81372_()); + int i = getDayTime(p_139083_.getLevel()); diff --git a/patches/minecraft/net/minecraft/server/commands/TriggerCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TriggerCommand.java.patch index 79103606..2ba7eece 100644 --- a/patches/minecraft/net/minecraft/server/commands/TriggerCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TriggerCommand.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/TriggerCommand.java +++ b/net/minecraft/server/commands/TriggerCommand.java @@ -79,7 +_,7 @@ - if (p_139140_.m_83321_() != ObjectiveCriteria.f_83589_) { - throw f_139136_.create(); + if (p_139140_.getCriteria() != ObjectiveCriteria.TRIGGER) { + throw ERROR_INVALID_OBJECTIVE.create(); } else { -- Scoreboard scoreboard = p_139139_.m_36329_(); -+ Scoreboard scoreboard = p_139139_.m_20194_().m_129896_(); // CraftBukkit - SPIGOT-6917: use main scoreboard - String s = p_139139_.m_6302_(); - if (!scoreboard.m_83461_(s, p_139140_)) { - throw f_139135_.create(); +- Scoreboard scoreboard = p_139139_.getScoreboard(); ++ Scoreboard scoreboard = p_139139_.getServer().getScoreboard(); // CraftBukkit - SPIGOT-6917: use main scoreboard + String s = p_139139_.getScoreboardName(); + if (!scoreboard.hasPlayerScore(s, p_139140_)) { + throw ERROR_NOT_PRIMED.create(); diff --git a/patches/minecraft/net/minecraft/server/commands/WeatherCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/WeatherCommand.java.patch index bfe80987..7ed49fb5 100644 --- a/patches/minecraft/net/minecraft/server/commands/WeatherCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/WeatherCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/WeatherCommand.java @@ -11,7 +_,7 @@ - public static void m_139166_(CommandDispatcher p_139167_) { - p_139167_.register(Commands.m_82127_("weather").requires((p_139171_) -> { -- return p_139171_.m_6761_(2); + public static void register(CommandDispatcher p_139167_) { + p_139167_.register(Commands.literal("weather").requires((p_139171_) -> { +- return p_139171_.hasPermission(2); + return p_139171_.hasPermission(2,"minecraft.command.weather"); - }).then(Commands.m_82127_("clear").executes((p_139190_) -> { - return m_139172_(p_139190_.getSource(), 6000); - }).then(Commands.m_82129_("duration", IntegerArgumentType.integer(0, 1000000)).executes((p_139188_) -> { + }).then(Commands.literal("clear").executes((p_139190_) -> { + return setClear(p_139190_.getSource(), 6000); + }).then(Commands.argument("duration", IntegerArgumentType.integer(0, 1000000)).executes((p_139188_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/WhitelistCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/WhitelistCommand.java.patch index d4afcc02..55957671 100644 --- a/patches/minecraft/net/minecraft/server/commands/WhitelistCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/WhitelistCommand.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/WhitelistCommand.java @@ -23,7 +_,7 @@ - public static void m_139201_(CommandDispatcher p_139202_) { - p_139202_.register(Commands.m_82127_("whitelist").requires((p_139234_) -> { -- return p_139234_.m_6761_(3); + public static void register(CommandDispatcher p_139202_) { + p_139202_.register(Commands.literal("whitelist").requires((p_139234_) -> { +- return p_139234_.hasPermission(3); + return p_139234_.hasPermission(3,"minecraft.command.whitelist"); - }).then(Commands.m_82127_("on").executes((p_139236_) -> { - return m_139218_(p_139236_.getSource()); - })).then(Commands.m_82127_("off").executes((p_139232_) -> { + }).then(Commands.literal("on").executes((p_139236_) -> { + return enableWhitelist(p_139236_.getSource()); + })).then(Commands.literal("off").executes((p_139232_) -> { diff --git a/patches/minecraft/net/minecraft/server/commands/WorldBorderCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/WorldBorderCommand.java.patch index f2a3a9b4..b1e5768d 100644 --- a/patches/minecraft/net/minecraft/server/commands/WorldBorderCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/WorldBorderCommand.java.patch @@ -3,61 +3,61 @@ @@ -53,7 +_,7 @@ } - private static int m_139256_(CommandSourceStack p_139257_, float p_139258_) throws CommandSyntaxException { -- WorldBorder worldborder = p_139257_.m_81377_().m_129783_().m_6857_(); -+ WorldBorder worldborder = p_139257_.m_81372_().m_6857_(); // CraftBukkit - if (worldborder.m_61964_() == (double)p_139258_) { - throw f_139243_.create(); + private static int setDamageBuffer(CommandSourceStack p_139257_, float p_139258_) throws CommandSyntaxException { +- WorldBorder worldborder = p_139257_.getServer().overworld().getWorldBorder(); ++ WorldBorder worldborder = p_139257_.getLevel().getWorldBorder(); // CraftBukkit + if (worldborder.getDamageSafeZone() == (double)p_139258_) { + throw ERROR_SAME_DAMAGE_BUFFER.create(); } else { @@ -64,7 +_,7 @@ } - private static int m_139269_(CommandSourceStack p_139270_, float p_139271_) throws CommandSyntaxException { -- WorldBorder worldborder = p_139270_.m_81377_().m_129783_().m_6857_(); -+ WorldBorder worldborder = p_139270_.m_81372_().m_6857_(); // CraftBukkit - if (worldborder.m_61965_() == (double)p_139271_) { - throw f_139244_.create(); + private static int setDamageAmount(CommandSourceStack p_139270_, float p_139271_) throws CommandSyntaxException { +- WorldBorder worldborder = p_139270_.getServer().overworld().getWorldBorder(); ++ WorldBorder worldborder = p_139270_.getLevel().getWorldBorder(); // CraftBukkit + if (worldborder.getDamagePerBlock() == (double)p_139271_) { + throw ERROR_SAME_DAMAGE_AMOUNT.create(); } else { @@ -75,7 +_,7 @@ } - private static int m_139259_(CommandSourceStack p_139260_, int p_139261_) throws CommandSyntaxException { -- WorldBorder worldborder = p_139260_.m_81377_().m_129783_().m_6857_(); -+ WorldBorder worldborder = p_139260_.m_81372_().m_6857_(); // CraftBukkit - if (worldborder.m_61967_() == p_139261_) { - throw f_139241_.create(); + private static int setWarningTime(CommandSourceStack p_139260_, int p_139261_) throws CommandSyntaxException { +- WorldBorder worldborder = p_139260_.getServer().overworld().getWorldBorder(); ++ WorldBorder worldborder = p_139260_.getLevel().getWorldBorder(); // CraftBukkit + if (worldborder.getWarningTime() == p_139261_) { + throw ERROR_SAME_WARNING_TIME.create(); } else { @@ -86,7 +_,7 @@ } - private static int m_139272_(CommandSourceStack p_139273_, int p_139274_) throws CommandSyntaxException { -- WorldBorder worldborder = p_139273_.m_81377_().m_129783_().m_6857_(); -+ WorldBorder worldborder = p_139273_.m_81372_().m_6857_(); // CraftBukkit - if (worldborder.m_61968_() == p_139274_) { - throw f_139242_.create(); + private static int setWarningDistance(CommandSourceStack p_139273_, int p_139274_) throws CommandSyntaxException { +- WorldBorder worldborder = p_139273_.getServer().overworld().getWorldBorder(); ++ WorldBorder worldborder = p_139273_.getLevel().getWorldBorder(); // CraftBukkit + if (worldborder.getWarningBlocks() == p_139274_) { + throw ERROR_SAME_WARNING_DISTANCE.create(); } else { @@ -97,13 +_,13 @@ } - private static int m_139250_(CommandSourceStack p_139251_) { -- double d0 = p_139251_.m_81377_().m_129783_().m_6857_().m_61959_(); -+ double d0 = p_139251_.m_81372_().m_6857_().m_61959_(); // CraftBukkit - p_139251_.m_81354_(new TranslatableComponent("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0)), false); - return Mth.m_14107_(d0 + 0.5D); + private static int getSize(CommandSourceStack p_139251_) { +- double d0 = p_139251_.getServer().overworld().getWorldBorder().getSize(); ++ double d0 = p_139251_.getLevel().getWorldBorder().getSize(); // CraftBukkit + p_139251_.sendSuccess(new TranslatableComponent("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0)), false); + return Mth.floor(d0 + 0.5D); } - private static int m_139262_(CommandSourceStack p_139263_, Vec2 p_139264_) throws CommandSyntaxException { -- WorldBorder worldborder = p_139263_.m_81377_().m_129783_().m_6857_(); -+ WorldBorder worldborder = p_139263_.m_81372_().m_6857_(); // CraftBukkit - if (worldborder.m_6347_() == (double)p_139264_.f_82470_ && worldborder.m_6345_() == (double)p_139264_.f_82471_) { - throw f_139237_.create(); - } else if (!((double)Math.abs(p_139264_.f_82470_) > 2.9999984E7D) && !((double)Math.abs(p_139264_.f_82471_) > 2.9999984E7D)) { + private static int setCenter(CommandSourceStack p_139263_, Vec2 p_139264_) throws CommandSyntaxException { +- WorldBorder worldborder = p_139263_.getServer().overworld().getWorldBorder(); ++ WorldBorder worldborder = p_139263_.getLevel().getWorldBorder(); // CraftBukkit + if (worldborder.getCenterX() == (double)p_139264_.x && worldborder.getCenterZ() == (double)p_139264_.y) { + throw ERROR_SAME_CENTER.create(); + } else if (!((double)Math.abs(p_139264_.x) > 2.9999984E7D) && !((double)Math.abs(p_139264_.y) > 2.9999984E7D)) { @@ -116,7 +_,7 @@ } - private static int m_139252_(CommandSourceStack p_139253_, double p_139254_, long p_139255_) throws CommandSyntaxException { -- WorldBorder worldborder = p_139253_.m_81377_().m_129783_().m_6857_(); -+ WorldBorder worldborder = p_139253_.m_81372_().m_6857_(); // CraftBukkit - double d0 = worldborder.m_61959_(); + private static int setSize(CommandSourceStack p_139253_, double p_139254_, long p_139255_) throws CommandSyntaxException { +- WorldBorder worldborder = p_139253_.getServer().overworld().getWorldBorder(); ++ WorldBorder worldborder = p_139253_.getLevel().getWorldBorder(); // CraftBukkit + double d0 = worldborder.getSize(); if (d0 == p_139254_) { - throw f_139238_.create(); + throw ERROR_SAME_SIZE.create(); diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 0619f1cc..38ad9bcf 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java @@ -89,12 +_,39 @@ - public boolean m_7038_() throws IOException { + public boolean initServer() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { - BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); - - String s1; - try { -- while(!DedicatedServer.this.m_129918_() && DedicatedServer.this.m_130010_() && (s1 = bufferedreader.readLine()) != null) { -- DedicatedServer.this.m_139645_(s1, DedicatedServer.this.m_129893_()); +- while(!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s1 = bufferedreader.readLine()) != null) { +- DedicatedServer.this.handleConsoleInput(s1, DedicatedServer.this.createCommandSourceStack()); + if (net.minecraftforge.server.console.TerminalHandler.handleCommands(DedicatedServer.this)) return; + jline.console.ConsoleReader bufferedreader = reader; + // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return @@ -23,7 +23,7 @@ + String s; + try { + // CraftBukkit start - JLine disabling compatibility -+ while (!DedicatedServer.this.m_129918_() && DedicatedServer.this.m_130010_()) { ++ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) { + if (org.bukkit.craftbukkit.Main.useJline) { + s = bufferedreader.readLine(">", null); + } else { @@ -40,12 +40,12 @@ + continue; + } + if (s.trim().length() > 0) { // Trim to filter lines which are just spaces -+ DedicatedServer.this.m_139645_(s, DedicatedServer.this.m_129893_()); ++ DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack()); + } + // CraftBukkit end } } catch (IOException ioexception1) { - DedicatedServer.f_139598_.error("Exception handling console input", (Throwable)ioexception1); + DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)ioexception1); @@ -102,6 +_,27 @@ } @@ -72,14 +72,14 @@ + System.setErr(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel( org.apache.logging.log4j.Level.WARN).buildPrintStream()); + // CraftBukkit end thread.setDaemon(true); - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(f_139598_)); + thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); thread.start(); @@ -120,13 +_,32 @@ - this.m_129913_(dedicatedserverproperties.f_139730_); + this.setLocalIp(dedicatedserverproperties.serverIp); } + // Spigot start -+ this.m_129823_(new DedicatedPlayerList(this, this.f_129746_, this.f_129745_)); ++ this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); + org.spigotmc.SpigotConfig.init((java.io.File) options.valueOf("spigot-settings")); + org.spigotmc.SpigotConfig.registerCommands(); + // Spigot end @@ -87,7 +87,7 @@ + try { + com.destroystokyo.paper.youcandfindpaper.PaperConfig.init((java.io.File) options.valueOf("paper-settings")); + } catch (Exception e) { -+ DedicatedServer.f_139598_.error("Unable to load server configuration", e); ++ DedicatedServer.LOGGER.error("Unable to load server configuration", e); + return false; + } + com.destroystokyo.paper.youcandfindpaper.PaperConfig.registerCommands(); @@ -97,17 +97,17 @@ + org.magmafoundation.magma.configuration.MagmaConfig.instance.registerCommands(); + // Magma end + - this.m_129997_(dedicatedserverproperties.f_139733_); - this.m_129999_(dedicatedserverproperties.f_139734_); - this.m_129853_(dedicatedserverproperties.f_139735_, this.m_139664_()); - this.m_129989_(dedicatedserverproperties.f_139736_); - super.m_7196_(dedicatedserverproperties.f_139725_.get()); - this.m_130004_(dedicatedserverproperties.f_139738_); -- this.f_129749_.m_5458_(dedicatedserverproperties.f_139740_); + this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); + this.setResourcePack(dedicatedserverproperties.resourcePack, this.getPackHash()); + this.setMotd(dedicatedserverproperties.motd); + super.setPlayerIdleTimeout(dedicatedserverproperties.playerIdleTimeout.get()); + this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); +- this.worldData.setGameType(dedicatedserverproperties.gamemode); + // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading - f_139598_.info("Default game type: {}", (Object)dedicatedserverproperties.f_139740_); + LOGGER.info("Default game type: {}", (Object)dedicatedserverproperties.gamemode); InetAddress inetaddress = null; - if (!this.m_130009_().isEmpty()) { + if (!this.getLocalIp().isEmpty()) { @@ -149,10 +_,29 @@ return false; } @@ -122,62 +122,62 @@ + String proxyFlavor = (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport) ? "Velocity" : "BungeeCord"; + String proxyLink = (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; + // Paper end - if (!this.m_129797_()) { - f_139598_.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - f_139598_.warn("The server will make no attempt to authenticate usernames. Beware."); -- f_139598_.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + if (!this.usesAuthentication()) { + LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); +- LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + // Spigot start + // Paper start + if (usingProxy) { -+ DedicatedServer.f_139598_.warn("Whilst this makes it possible to use "+proxyFlavor+", unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); -+ DedicatedServer.f_139598_.warn("Please see "+proxyLink+" for further information."); ++ DedicatedServer.LOGGER.warn("Whilst this makes it possible to use "+proxyFlavor+", unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); ++ DedicatedServer.LOGGER.warn("Please see "+proxyLink+" for further information."); + // Paper end + } else { -+ DedicatedServer.f_139598_.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); ++ DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + } + // Spigot end - f_139598_.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); + LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } @@ -163,15 +_,16 @@ - if (!OldUsersConverter.m_11106_(this)) { + if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; } else { -- this.m_129823_(new DedicatedPlayerList(this, this.m_206579_(), this.f_129745_)); - long i = Util.m_137569_(); - SkullBlockEntity.m_196700_(this.m_129927_(), this.m_129925_(), this); - GameProfileCache.m_11004_(this.m_129797_()); +- this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); + long i = Util.getNanos(); + SkullBlockEntity.setup(this.getProfileCache(), this.getSessionService(), this); + GameProfileCache.setUsesAuthentication(this.usesAuthentication()); + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; - f_139598_.info("Preparing level \"{}\"", (Object)this.m_7123_()); -- this.m_130006_(); -+ this.m_130006_(); // CraftBukkit - pass in levelId //Magma - no need to pass in levelId - long j = Util.m_137569_() - i; + LOGGER.info("Preparing level \"{}\"", (Object)this.getLevelIdName()); +- this.loadLevel(); ++ this.loadLevel(); // CraftBukkit - pass in levelId //Magma - no need to pass in levelId + long j = Util.getNanos() - i; String s = String.format(Locale.ROOT, "%.3fs", (double)j / 1.0E9D); - f_139598_.info("Done ({})! For help, type \"help\"", (Object)s); -+ this.f_129726_ = Util.m_137550_(); //Forge: Update server time to prevent watchdog/spaming during long load. - if (dedicatedserverproperties.f_139744_ != null) { - this.m_129900_().m_46170_(GameRules.f_46153_).m_46246_(dedicatedserverproperties.f_139744_, this); + LOGGER.info("Done ({})! For help, type \"help\"", (Object)s); ++ this.nextTickTime = Util.getMillis(); //Forge: Update server time to prevent watchdog/spaming during long load. + if (dedicatedserverproperties.announcePlayerAchievements != null) { + this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(dedicatedserverproperties.announcePlayerAchievements, this); } @@ -184,9 +_,10 @@ - if (dedicatedserverproperties.f_139747_) { - f_139598_.info("Starting remote control listener"); - this.f_139603_ = RconThread.m_11615_(this); -+ this.remoteConsole = new org.bukkit.craftbukkit.v1_18_R2.command.CraftRemoteConsoleCommandSender(this.f_139602_); // CraftBukkit + if (dedicatedserverproperties.enableRcon) { + LOGGER.info("Starting remote control listener"); + this.rconThread = RconThread.create(this); ++ this.remoteConsole = new org.bukkit.craftbukkit.v1_18_R2.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit } -- if (this.m_139669_() > 0L) { -+ if (false && this.m_139669_() > 0L) { // Spigot - disable +- if (this.getMaxTickLength() > 0L) { ++ if (false && this.getMaxTickLength() > 0L) { // Spigot - disable Thread thread1 = new Thread(new ServerWatchdog(this)); - thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(f_139598_)); + thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); thread1.setName("Server Watchdog"); @@ -195,12 +_,13 @@ } - Items.f_41852_.m_6787_(CreativeModeTab.f_40754_, NonNullList.m_122779_()); + Items.AIR.fillItemCategory(CreativeModeTab.TAB_SEARCH, NonNullList.create()); + // <3 you Grum for this, saves us ~30 patch files! --^ - if (dedicatedserverproperties.f_139721_) { - MinecraftServerStatistics.m_18328_(this); - f_139598_.info("JMX monitoring enabled"); + if (dedicatedserverproperties.enableJmxMonitoring) { + MinecraftServerStatistics.registerJmxMonitoring(this); + LOGGER.info("JMX monitoring enabled"); } - return true; @@ -186,7 +186,7 @@ } @@ -316,6 +_,36 @@ - this.f_139601_.m_7530_(); + this.queryThreadGs4.stop(); } + // Magma start - Add ArcLight stop @@ -211,8 +211,8 @@ + } + } + if (!threads.isEmpty()) { -+ f_139598_.debug("Threads {} not shutting down", String.join(", ", threads)); -+ f_139598_.info("{} threads not shutting down correctly, force exiting", threads.size()); ++ LOGGER.debug("Threads {} not shutting down", String.join(", ", threads)); ++ LOGGER.info("{} threads not shutting down correctly, force exiting", threads.size()); + } + System.exit(0); + }, "Exit Thread"); @@ -221,21 +221,21 @@ + // Magma end } - public void m_5703_(BooleanSupplier p_139661_) { + public void tickChildren(BooleanSupplier p_139661_) { @@ -332,11 +_,21 @@ } - public void m_139665_() { + public void handleConsoleInputs() { + co.aikar.timings.MinecraftTimings.serverCommandTimer.startTiming(); // Spigot - while(!this.f_139600_.isEmpty()) { - ConsoleInput consoleinput = this.f_139600_.remove(0); -- this.m_129892_().m_82117_(consoleinput.f_135929_, consoleinput.f_135928_); + while(!this.consoleInput.isEmpty()) { + ConsoleInput consoleinput = this.consoleInput.remove(0); +- this.getCommands().performCommand(consoleinput.source, consoleinput.msg); + + // CraftBukkit start - ServerCommand for preprocessing -+ org.bukkit.event.server.ServerCommandEvent event = new org.bukkit.event.server.ServerCommandEvent(console, consoleinput.f_135928_); ++ org.bukkit.event.server.ServerCommandEvent event = new org.bukkit.event.server.ServerCommandEvent(console, consoleinput.msg); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) continue; -+ consoleinput = new ConsoleInput(event.getCommand(), consoleinput.f_135929_); ++ consoleinput = new ConsoleInput(event.getCommand(), consoleinput.source); + + //this.getCommands().performCommand(consoleinput.source, consoleinput.msg); // Called in dispatchServerCommand + server.dispatchServerCommand(console, consoleinput); @@ -245,11 +245,11 @@ + co.aikar.timings.MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot } - public boolean m_6982_() { + public boolean isDedicatedServer() { @@ -518,14 +_,74 @@ } - public String m_7138_() { + public String getPluginNames() { - return ""; + // CraftBukkit start - Whole method + StringBuilder result = new StringBuilder(); @@ -277,11 +277,11 @@ + // CraftBukkit end } - public String m_7261_(String p_139644_) { + public String runCommand(String p_139644_) { + org.bukkit.craftbukkit.v1_18_R2.util.Waitable[] waitableArray = new org.bukkit.craftbukkit.v1_18_R2.util.Waitable[1]; - this.f_139602_.m_11512_(); - this.m_18709_(() -> { -- this.m_129892_().m_82117_(this.f_139602_.m_11514_(), p_139644_); + this.rconConsoleSource.prepareForCommand(); + this.executeBlocking(() -> { +- this.getCommands().performCommand(this.rconConsoleSource.createCommandSourceStack(), p_139644_); + // CraftBukkit start - fire RemoteServerCommandEvent + org.bukkit.event.server.RemoteServerCommandEvent event = new org.bukkit.event.server.RemoteServerCommandEvent(remoteConsole, p_139644_); + server.getPluginManager().callEvent(event); @@ -301,7 +301,7 @@ + co.aikar.timings.Timings.generateReport(new co.aikar.timings.TimingsReportListener(sender, waitable)); + } else { + // Paper end -+ ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), f_139602_.m_11514_()); ++ ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), rconConsoleSource.createCommandSourceStack()); + server.dispatchServerCommand(remoteConsole, serverCommand); + } // Paper + // CraftBukkit end @@ -320,7 +320,7 @@ + } + } + // Paper end - return this.f_139602_.m_11513_(); + return this.rconConsoleSource.getCommandResponse(); } @@ -545,6 +_,11 @@ @@ -328,21 +328,21 @@ } + @Override //Forge: Enable formated text for colors in console. -+ public void m_6352_(net.minecraft.network.chat.Component message, java.util.UUID p_108776_) { -+ f_139598_.info(message.getString()); ++ public void sendMessage(net.minecraft.network.chat.Component message, java.util.UUID p_108776_) { ++ LOGGER.info(message.getString()); + } + - public int m_7186_(int p_139659_) { - return this.m_7913_().f_139723_ * p_139659_ / 100; + public int getScaledTrackingDistance(int p_139659_) { + return this.getProperties().entityBroadcastRangePercentage * p_139659_ / 100; } @@ -588,4 +_,15 @@ - public Component m_141958_() { - return this.f_142863_; + public Component getResourcePackPrompt() { + return this.resourcePackPrompt; } + + // CraftBukkit start + public boolean isDebugging() { -+ return this.m_7913_().debug; ++ return this.getProperties().debug; + } + + @Override diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index 85e4ce71..ee8b699b 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -4,7 +4,7 @@ import net.minecraft.world.level.levelgen.WorldGenSettings; public class DedicatedServerProperties extends Settings { -+ public final boolean debug = this.m_139836_("debug", false); // CraftBukkit - public final boolean f_139728_ = this.m_139836_("online-mode", true); - public final boolean f_139729_ = this.m_139836_("prevent-proxy-connections", false); - public final String f_139730_ = this.m_139811_("server-ip", ""); ++ public final boolean debug = this.get("debug", false); // CraftBukkit + public final boolean onlineMode = this.get("online-mode", true); + public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); + public final String serverIp = this.get("server-ip", ""); diff --git a/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch b/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch index 3a281a2d..7c64d15d 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch @@ -8,4 +8,4 @@ + 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 for(ThreadInfo threadinfo : athreadinfo) { - if (threadinfo.getThreadId() == this.f_139782_.m_6304_().getId()) { + if (threadinfo.getThreadId() == this.server.getRunningThread().getId()) { diff --git a/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch b/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch index 49a1241a..48c10413 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch @@ -4,8 +4,8 @@ OutputStream outputstream = Files.newOutputStream(p_139877_); try { -- this.f_139798_.store(outputstream, "Minecraft server properties"); -+ net.minecraftforge.common.util.SortedProperties.store(f_139798_, outputstream, "Minecraft server properties"); +- this.properties.store(outputstream, "Minecraft server properties"); ++ net.minecraftforge.common.util.SortedProperties.store(properties, outputstream, "Minecraft server properties"); } catch (Throwable throwable1) { if (outputstream != null) { try { diff --git a/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch b/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch index 287e16c4..79ebc147 100644 --- a/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch +++ b/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch @@ -5,24 +5,24 @@ } + private java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1); - public void m_139908_() { - this.f_139902_.start(); + public void start() { + this.logAppenderThread.start(); + latch.countDown(); } - public void m_139925_() { + public void close() { @@ -154,7 +_,11 @@ - this.f_139903_.forEach(Runnable::run); + this.finalizers.forEach(Runnable::run); } + private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit - strips color - public void m_139914_(JTextArea p_139915_, JScrollPane p_139916_, String p_139917_) { + public void print(JTextArea p_139915_, JScrollPane p_139916_, String p_139917_) { + try { + latch.await(); + } catch (InterruptedException e){} //Prevent logging until after constructor has ended. if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(() -> { - this.m_139914_(p_139915_, p_139916_, p_139917_); + this.print(p_139915_, p_139916_, p_139917_); @@ -168,7 +_,7 @@ } diff --git a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch index 09005b4f..43a79a48 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch @@ -1,64 +1,64 @@ --- a/net/minecraft/server/level/ChunkHolder.java +++ b/net/minecraft/server/level/ChunkHolder.java @@ -67,6 +_,7 @@ - public final ChunkHolder.PlayerProvider f_140016_; - private boolean f_140017_; - private boolean f_140018_; + public final ChunkHolder.PlayerProvider playerProvider; + private boolean wasAccessibleSinceLastSave; + private boolean resendLight; + LevelChunk currentlyLoading; // Forge: Used to bypass future chain when loading chunks. - private CompletableFuture f_142981_ = CompletableFuture.completedFuture((Void)null); + private CompletableFuture pendingFullStateConfirmation = CompletableFuture.completedFuture((Void)null); public ChunkHolder(ChunkPos p_142986_, int p_142987_, LevelHeightAccessor p_142988_, LevelLightEngine p_142989_, ChunkHolder.LevelChangeListener p_142990_, ChunkHolder.PlayerProvider p_142991_) { @@ -82,6 +_,20 @@ - this.f_140011_ = new ShortSet[p_142988_.m_151559_()]; + this.changedBlocksPerSection = new ShortSet[p_142988_.getSectionsCount()]; } + // CraftBukkit start + public LevelChunk getFullChunkNow() { + // Note: We use the oldTicketLevel for isLoaded checks. -+ if (!m_140083_(this.f_140006_).m_140114_(ChunkHolder.FullChunkStatus.BORDER)) return null; ++ if (!getFullChunkStatus(this.oldTicketLevel).isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) return null; + return this.getFullChunkNowUnchecked(); + } + + public LevelChunk getFullChunkNowUnchecked() { -+ CompletableFuture> statusFuture = this.m_140047_(ChunkStatus.f_62326_); ++ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); + Either either = (Either) statusFuture.getNow(null); + return (either == null) ? null : (LevelChunk) either.left().orElse(null); + } + // CraftBukkit end + - public CompletableFuture> m_140047_(ChunkStatus p_140048_) { - CompletableFuture> completablefuture = this.f_140001_.get(p_140048_.m_62445_()); - return completablefuture == null ? f_139996_ : completablefuture; + public CompletableFuture> getFutureIfPresentUnchecked(ChunkStatus p_140048_) { + CompletableFuture> completablefuture = this.futures.get(p_140048_.getIndex()); + return completablefuture == null ? UNLOADED_CHUNK_FUTURE : completablefuture; @@ -154,6 +_,8 @@ - LevelChunk levelchunk = this.m_140085_(); + LevelChunk levelchunk = this.getTickingChunk(); if (levelchunk != null) { - int i = this.f_142983_.m_151564_(p_140057_.m_123342_()); + int i = this.levelHeightAccessor.getSectionIndex(p_140057_.getY()); + -+ if (i < 0 || i >= this.f_140011_.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 - if (this.f_140011_[i] == null) { - this.f_140010_ = true; - this.f_140011_[i] = new ShortOpenHashSet(); ++ if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 + if (this.changedBlocksPerSection[i] == null) { + this.hasChangedSections = true; + this.changedBlocksPerSection[i] = new ShortOpenHashSet(); @@ -350,6 +_,30 @@ - boolean flag1 = this.f_140007_ <= ChunkMap.f_140127_; - ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus = m_140083_(this.f_140006_); - ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus1 = m_140083_(this.f_140007_); + boolean flag1 = this.ticketLevel <= ChunkMap.MAX_CHUNK_DISTANCE; + ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus = getFullChunkStatus(this.oldTicketLevel); + ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus1 = getFullChunkStatus(this.ticketLevel); + // CraftBukkit start + // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. -+ if (chunkholder$fullchunkstatus.m_140114_(ChunkHolder.FullChunkStatus.BORDER) && !chunkholder$fullchunkstatus1.m_140114_(ChunkHolder.FullChunkStatus.BORDER)) { -+ this.m_140047_(ChunkStatus.f_62326_).thenAccept((either) -> { ++ if (chunkholder$fullchunkstatus.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !chunkholder$fullchunkstatus1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { ++ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { + LevelChunk chunk = (LevelChunk)either.left().orElse(null); + if (chunk != null) { + p_143004_.callbackExecutor.execute(() -> { + // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick + // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag. + // These actions may however happen deferred, so we manually set the needsSaving flag already here. -+ chunk.m_8092_(true); ++ chunk.setUnsaved(true); + chunk.unloadCallback(); + }); + } + }).exceptionally((throwable) -> { + // ensure exceptions are printed, by default this is not the case -+ net.minecraft.server.MinecraftServer.f_129750_.error("Failed to schedule unload callback for chunk " + ChunkHolder.this.f_140009_, throwable); ++ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to schedule unload callback for chunk " + ChunkHolder.this.pos, throwable); + return null; + }); + // Run callback right away if the future was already done @@ -71,12 +71,12 @@ public String toString() { @@ -415,6 +_,24 @@ - this.f_140015_.m_6250_(this.f_140009_, this::m_140094_, this.f_140007_, this::m_140086_); - this.f_140006_ = this.f_140007_; + this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); + this.oldTicketLevel = this.ticketLevel; + // CraftBukkit start + // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins. -+ if (!chunkholder$fullchunkstatus.m_140114_(ChunkHolder.FullChunkStatus.BORDER) && chunkholder$fullchunkstatus1.m_140114_(ChunkHolder.FullChunkStatus.BORDER)) { -+ this.m_140047_(ChunkStatus.f_62326_).thenAccept((either) -> { ++ if (!chunkholder$fullchunkstatus.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && chunkholder$fullchunkstatus1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { ++ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { + LevelChunk chunk = (LevelChunk)either.left().orElse(null); + if (chunk != null) { + p_143004_.callbackExecutor.execute(() -> { @@ -93,7 +93,7 @@ + // CraftBukkit end } - public static ChunkStatus m_140074_(int p_140075_) { + public static ChunkStatus getStatus(int p_140075_) { @@ -464,6 +_,14 @@ } }; @@ -101,11 +101,11 @@ + + // CraftBukkit start + public LevelChunk getFullChunkUnchecked() { -+ CompletableFuture> statusFuture = this.m_140047_(ChunkStatus.f_62326_); ++ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); + Either either = (Either) statusFuture.getNow(null); + return (either == null) ? null : (LevelChunk) either.left().orElse(null); + } + // CraftBukkit end static final class ChunkSaveDebug { - private final Thread f_143023_; + private final Thread thread; diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 2c32a2a9..b206a96c 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch @@ -4,91 +4,91 @@ import org.slf4j.Logger; public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { -- private static final byte f_143034_ = -1; -- private static final byte f_143035_ = 0; -- private static final byte f_143036_ = 1; -- private static final Logger f_140128_ = LogUtils.getLogger(); -- private static final int f_143037_ = 200; -- private static final int f_198789_ = 20; -- private static final int f_202982_ = 10000; -- private static final int f_143038_ = 3; -- public static final int f_143032_ = 33; -- public static final int f_140127_ = 33 + ChunkStatus.m_62421_(); -- public static final int f_143033_ = 31; -- private final Long2ObjectLinkedOpenHashMap f_140129_ = new Long2ObjectLinkedOpenHashMap<>(); -- public volatile Long2ObjectLinkedOpenHashMap f_140130_ = this.f_140129_.clone(); -- private final Long2ObjectLinkedOpenHashMap f_140131_ = new Long2ObjectLinkedOpenHashMap<>(); -- private final LongSet f_140132_ = new LongOpenHashSet(); -- final ServerLevel f_140133_; -- private final ThreadedLevelLightEngine f_140134_; -- private final BlockableEventLoop f_140135_; -- private ChunkGenerator f_140136_; -- private final Supplier f_140137_; -- private final PoiManager f_140138_; -- final LongSet f_140139_ = new LongOpenHashSet(); -- private boolean f_140140_; -- private final ChunkTaskPriorityQueueSorter f_140141_; -- private final ProcessorHandle> f_140142_; -- private final ProcessorHandle> f_140143_; -- public final ChunkProgressListener f_140144_; -- private final ChunkStatusUpdateListener f_143031_; -- public final ChunkMap.DistanceManager f_140145_; -- private final AtomicInteger f_140146_ = new AtomicInteger(); -- private final StructureManager f_140147_; -- private final String f_182284_; -- private final PlayerMap f_140149_ = new PlayerMap(); -- public final Int2ObjectMap f_140150_ = new Int2ObjectOpenHashMap<>(); -- private final Long2ByteMap f_140151_ = new Long2ByteOpenHashMap(); -- private final Long2LongMap f_202981_ = new Long2LongOpenHashMap(); -- private final Queue f_140125_ = Queues.newConcurrentLinkedQueue(); -- int f_140126_; +- private static final byte CHUNK_TYPE_REPLACEABLE = -1; +- private static final byte CHUNK_TYPE_UNKNOWN = 0; +- private static final byte CHUNK_TYPE_FULL = 1; +- private static final Logger LOGGER = LogUtils.getLogger(); +- private static final int CHUNK_SAVED_PER_TICK = 200; +- private static final int CHUNK_SAVED_EAGERLY_PER_TICK = 20; +- private static final int EAGER_CHUNK_SAVE_COOLDOWN_IN_MILLIS = 10000; +- private static final int MIN_VIEW_DISTANCE = 3; +- public static final int MAX_VIEW_DISTANCE = 33; +- public static final int MAX_CHUNK_DISTANCE = 33 + ChunkStatus.maxDistance(); +- public static final int FORCED_TICKET_LEVEL = 31; +- private final Long2ObjectLinkedOpenHashMap updatingChunkMap = new Long2ObjectLinkedOpenHashMap<>(); +- public volatile Long2ObjectLinkedOpenHashMap visibleChunkMap = this.updatingChunkMap.clone(); +- private final Long2ObjectLinkedOpenHashMap pendingUnloads = new Long2ObjectLinkedOpenHashMap<>(); +- private final LongSet entitiesInLevel = new LongOpenHashSet(); +- final ServerLevel level; +- private final ThreadedLevelLightEngine lightEngine; +- private final BlockableEventLoop mainThreadExecutor; +- private ChunkGenerator generator; +- private final Supplier overworldDataStorage; +- private final PoiManager poiManager; +- final LongSet toDrop = new LongOpenHashSet(); +- private boolean modified; +- private final ChunkTaskPriorityQueueSorter queueSorter; +- private final ProcessorHandle> worldgenMailbox; +- private final ProcessorHandle> mainThreadMailbox; +- public final ChunkProgressListener progressListener; +- private final ChunkStatusUpdateListener chunkStatusListener; +- public final ChunkMap.DistanceManager distanceManager; +- private final AtomicInteger tickingGenerated = new AtomicInteger(); +- private final StructureManager structureManager; +- private final String storageName; +- private final PlayerMap playerMap = new PlayerMap(); +- public final Int2ObjectMap entityMap = new Int2ObjectOpenHashMap<>(); +- private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap(); +- private final Long2LongMap chunkSaveCooldowns = new Long2LongOpenHashMap(); +- private final Queue unloadQueue = Queues.newConcurrentLinkedQueue(); +- int viewDistance; - - public ChunkMap(ServerLevel p_143040_, LevelStorageSource.LevelStorageAccess p_143041_, DataFixer p_143042_, StructureManager p_143043_, Executor p_143044_, BlockableEventLoop p_143045_, LightChunkGetter p_143046_, ChunkGenerator p_143047_, ChunkProgressListener p_143048_, ChunkStatusUpdateListener p_143049_, Supplier p_143050_, int p_143051_, boolean p_143052_) { -- super(p_143041_.m_197394_(p_143040_.m_46472_()).resolve("region"), p_143042_, p_143052_); -- this.f_140147_ = p_143043_; -- Path path = p_143041_.m_197394_(p_143040_.m_46472_()); -- this.f_182284_ = path.getFileName().toString(); -- this.f_140133_ = p_143040_; -- this.f_140136_ = p_143047_; -- this.f_140135_ = p_143045_; -- ProcessorMailbox processormailbox = ProcessorMailbox.m_18751_(p_143044_, "worldgen"); -- ProcessorHandle processorhandle = ProcessorHandle.m_18714_("main", p_143045_::m_6937_); -- this.f_140144_ = p_143048_; -- this.f_143031_ = p_143049_; -- ProcessorMailbox processormailbox1 = ProcessorMailbox.m_18751_(p_143044_, "light"); -- this.f_140141_ = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processormailbox, processorhandle, processormailbox1), p_143044_, Integer.MAX_VALUE); -- this.f_140142_ = this.f_140141_.m_140604_(processormailbox, false); -- this.f_140143_ = this.f_140141_.m_140604_(processorhandle, false); -- this.f_140134_ = new ThreadedLevelLightEngine(p_143046_, this, this.f_140133_.m_6042_().m_63935_(), processormailbox1, this.f_140141_.m_140604_(processormailbox1, false)); -- this.f_140145_ = new ChunkMap.DistanceManager(p_143044_, p_143045_); -- this.f_140137_ = p_143050_; -- this.f_140138_ = new PoiManager(path.resolve("poi"), p_143042_, p_143052_, p_143040_); -- this.m_140167_(p_143051_); -- } -- -- protected ChunkGenerator m_183719_() { -- return this.f_140136_; -- } -- -- public void m_183825_() { -- DataResult dataresult = ChunkGenerator.f_62136_.encodeStart(JsonOps.INSTANCE, this.f_140136_); +- super(p_143041_.getDimensionPath(p_143040_.dimension()).resolve("region"), p_143042_, p_143052_); +- this.structureManager = p_143043_; +- Path path = p_143041_.getDimensionPath(p_143040_.dimension()); +- this.storageName = path.getFileName().toString(); +- this.level = p_143040_; +- this.generator = p_143047_; +- this.mainThreadExecutor = p_143045_; +- ProcessorMailbox processormailbox = ProcessorMailbox.create(p_143044_, "worldgen"); +- ProcessorHandle processorhandle = ProcessorHandle.of("main", p_143045_::tell); +- this.progressListener = p_143048_; +- this.chunkStatusListener = p_143049_; +- ProcessorMailbox processormailbox1 = ProcessorMailbox.create(p_143044_, "light"); +- this.queueSorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processormailbox, processorhandle, processormailbox1), p_143044_, Integer.MAX_VALUE); +- this.worldgenMailbox = this.queueSorter.getProcessor(processormailbox, false); +- this.mainThreadMailbox = this.queueSorter.getProcessor(processorhandle, false); +- this.lightEngine = new ThreadedLevelLightEngine(p_143046_, this, this.level.dimensionType().hasSkyLight(), processormailbox1, this.queueSorter.getProcessor(processormailbox1, false)); +- this.distanceManager = new ChunkMap.DistanceManager(p_143044_, p_143045_); +- this.overworldDataStorage = p_143050_; +- this.poiManager = new PoiManager(path.resolve("poi"), p_143042_, p_143052_, p_143040_); +- this.setViewDistance(p_143051_); +- } +- +- protected ChunkGenerator generator() { +- return this.generator; +- } +- +- public void debugReloadGenerator() { +- DataResult dataresult = ChunkGenerator.CODEC.encodeStart(JsonOps.INSTANCE, this.generator); - DataResult dataresult1 = dataresult.flatMap((p_183804_) -> { -- return ChunkGenerator.f_62136_.parse(JsonOps.INSTANCE, p_183804_); +- return ChunkGenerator.CODEC.parse(JsonOps.INSTANCE, p_183804_); - }); - dataresult1.result().ifPresent((p_183808_) -> { -- this.f_140136_ = p_183808_; +- this.generator = p_183808_; - }); - } - -- private static double m_140226_(ChunkPos p_140227_, Entity p_140228_) { -- double d0 = (double)SectionPos.m_175554_(p_140227_.f_45578_, 8); -- double d1 = (double)SectionPos.m_175554_(p_140227_.f_45579_, 8); -- double d2 = d0 - p_140228_.m_20185_(); -- double d3 = d1 - p_140228_.m_20189_(); +- private static double euclideanDistanceSquared(ChunkPos p_140227_, Entity p_140228_) { +- double d0 = (double)SectionPos.sectionToBlockCoord(p_140227_.x, 8); +- double d1 = (double)SectionPos.sectionToBlockCoord(p_140227_.z, 8); +- double d2 = d0 - p_140228_.getX(); +- double d3 = d1 - p_140228_.getZ(); - return d2 * d2 + d3 * d3; - } - -- public static boolean m_200878_(int p_200879_, int p_200880_, int p_200881_, int p_200882_, int p_200883_) { +- public static boolean isChunkInRange(int p_200879_, int p_200880_, int p_200881_, int p_200882_, int p_200883_) { - int i = Math.max(0, Math.abs(p_200879_ - p_200881_) - 1); - int j = Math.max(0, Math.abs(p_200880_ - p_200882_) - 1); - long k = (long)Math.max(0, Math.max(i, j) - 1); @@ -99,75 +99,75 @@ - return i1 <= (long)k1; - } - -- private static boolean m_183828_(int p_183829_, int p_183830_, int p_183831_, int p_183832_, int p_183833_) { -- if (!m_200878_(p_183829_, p_183830_, p_183831_, p_183832_, p_183833_)) { +- private static boolean isChunkOnRangeBorder(int p_183829_, int p_183830_, int p_183831_, int p_183832_, int p_183833_) { +- if (!isChunkInRange(p_183829_, p_183830_, p_183831_, p_183832_, p_183833_)) { - return false; -- } else if (!m_200878_(p_183829_ + 1, p_183830_, p_183831_, p_183832_, p_183833_)) { +- } else if (!isChunkInRange(p_183829_ + 1, p_183830_, p_183831_, p_183832_, p_183833_)) { - return true; -- } else if (!m_200878_(p_183829_, p_183830_ + 1, p_183831_, p_183832_, p_183833_)) { +- } else if (!isChunkInRange(p_183829_, p_183830_ + 1, p_183831_, p_183832_, p_183833_)) { - return true; -- } else if (!m_200878_(p_183829_ - 1, p_183830_, p_183831_, p_183832_, p_183833_)) { +- } else if (!isChunkInRange(p_183829_ - 1, p_183830_, p_183831_, p_183832_, p_183833_)) { - return true; - } else { -- return !m_200878_(p_183829_, p_183830_ - 1, p_183831_, p_183832_, p_183833_); +- return !isChunkInRange(p_183829_, p_183830_ - 1, p_183831_, p_183832_, p_183833_); - } - } - -- protected ThreadedLevelLightEngine m_140166_() { -- return this.f_140134_; +- protected ThreadedLevelLightEngine getLightEngine() { +- return this.lightEngine; - } - - @Nullable -- protected ChunkHolder m_140174_(long p_140175_) { -- return this.f_140129_.get(p_140175_); +- protected ChunkHolder getUpdatingChunkIfPresent(long p_140175_) { +- return this.updatingChunkMap.get(p_140175_); - } - - @Nullable -- protected ChunkHolder m_140327_(long p_140328_) { -- return this.f_140130_.get(p_140328_); +- protected ChunkHolder getVisibleChunkIfPresent(long p_140328_) { +- return this.visibleChunkMap.get(p_140328_); - } - -- protected IntSupplier m_140371_(long p_140372_) { +- protected IntSupplier getChunkQueueLevel(long p_140372_) { - return () -> { -- ChunkHolder chunkholder = this.m_140327_(p_140372_); -- return chunkholder == null ? ChunkTaskPriorityQueue.f_140508_ - 1 : Math.min(chunkholder.m_140094_(), ChunkTaskPriorityQueue.f_140508_ - 1); +- ChunkHolder chunkholder = this.getVisibleChunkIfPresent(p_140372_); +- return chunkholder == null ? ChunkTaskPriorityQueue.PRIORITY_LEVEL_COUNT - 1 : Math.min(chunkholder.getQueueLevel(), ChunkTaskPriorityQueue.PRIORITY_LEVEL_COUNT - 1); - }; - } - -- public String m_140204_(ChunkPos p_140205_) { -- ChunkHolder chunkholder = this.m_140327_(p_140205_.m_45588_()); +- public String getChunkDebugData(ChunkPos p_140205_) { +- ChunkHolder chunkholder = this.getVisibleChunkIfPresent(p_140205_.toLong()); - if (chunkholder == null) { - return "null"; - } else { -- String s = chunkholder.m_140093_() + "\n"; -- ChunkStatus chunkstatus = chunkholder.m_140088_(); -- ChunkAccess chunkaccess = chunkholder.m_140089_(); +- String s = chunkholder.getTicketLevel() + "\n"; +- ChunkStatus chunkstatus = chunkholder.getLastAvailableStatus(); +- ChunkAccess chunkaccess = chunkholder.getLastAvailable(); - if (chunkstatus != null) { -- s = s + "St: \u00a7" + chunkstatus.m_62445_() + chunkstatus + "\u00a7r\n"; +- s = s + "St: \u00a7" + chunkstatus.getIndex() + chunkstatus + "\u00a7r\n"; - } - - if (chunkaccess != null) { -- s = s + "Ch: \u00a7" + chunkaccess.m_6415_().m_62445_() + chunkaccess.m_6415_() + "\u00a7r\n"; +- s = s + "Ch: \u00a7" + chunkaccess.getStatus().getIndex() + chunkaccess.getStatus() + "\u00a7r\n"; - } - -- ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus = chunkholder.m_140091_(); +- ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus = chunkholder.getFullStatus(); - s = s + "\u00a7" + chunkholder$fullchunkstatus.ordinal() + chunkholder$fullchunkstatus; - return s + "\u00a7r"; - } - } - -- private CompletableFuture, ChunkHolder.ChunkLoadingFailure>> m_140210_(ChunkPos p_140211_, int p_140212_, IntFunction p_140213_) { +- private CompletableFuture, ChunkHolder.ChunkLoadingFailure>> getChunkRangeFuture(ChunkPos p_140211_, int p_140212_, IntFunction p_140213_) { - List>> list = new ArrayList<>(); - List list1 = new ArrayList<>(); -- int i = p_140211_.f_45578_; -- int j = p_140211_.f_45579_; +- int i = p_140211_.x; +- int j = p_140211_.z; - - for(int k = -p_140212_; k <= p_140212_; ++k) { - for(int l = -p_140212_; l <= p_140212_; ++l) { - int i1 = Math.max(Math.abs(l), Math.abs(k)); - final ChunkPos chunkpos = new ChunkPos(i + l, j + k); -- long j1 = chunkpos.m_45588_(); -- ChunkHolder chunkholder = this.m_140174_(j1); +- long j1 = chunkpos.toLong(); +- ChunkHolder chunkholder = this.getUpdatingChunkIfPresent(j1); - if (chunkholder == null) { - return CompletableFuture.completedFuture(Either.right(new ChunkHolder.ChunkLoadingFailure() { - public String toString() { @@ -177,20 +177,20 @@ - } - - ChunkStatus chunkstatus = p_140213_.apply(i1); -- CompletableFuture> completablefuture = chunkholder.m_140049_(chunkstatus, this); +- CompletableFuture> completablefuture = chunkholder.getOrScheduleFuture(chunkstatus, this); - list1.add(chunkholder); - list.add(completablefuture); - } - } - -- CompletableFuture>> completablefuture1 = Util.m_137567_(list); +- CompletableFuture>> completablefuture1 = Util.sequence(list); - CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture2 = completablefuture1.thenApply((p_183730_) -> { - List list2 = Lists.newArrayList(); - int k1 = 0; - - for(final Either either : p_183730_) { - if (either == null) { -- throw this.m_203751_(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); +- throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); - } - - Optional optional = either.left(); @@ -211,72 +211,72 @@ - }); - - for(ChunkHolder chunkholder1 : list1) { -- chunkholder1.m_200416_("getChunkRangeFuture " + p_140211_ + " " + p_140212_, completablefuture2); +- chunkholder1.addSaveDependency("getChunkRangeFuture " + p_140211_ + " " + p_140212_, completablefuture2); - } - - return completablefuture2; - } - -- public ReportedException m_203751_(IllegalStateException p_203752_, String p_203753_) { +- public ReportedException debugFuturesAndCreateReportedException(IllegalStateException p_203752_, String p_203753_) { - StringBuilder stringbuilder = new StringBuilder(); - Consumer consumer = (p_203756_) -> { -- p_203756_.m_202980_().forEach((p_203760_) -> { +- p_203756_.getAllFutures().forEach((p_203760_) -> { - ChunkStatus chunkstatus = p_203760_.getFirst(); - CompletableFuture> completablefuture = p_203760_.getSecond(); - if (completablefuture != null && completablefuture.isDone() && completablefuture.join() == null) { -- stringbuilder.append((Object)p_203756_.m_140092_()).append(" - status: ").append((Object)chunkstatus).append(" future: ").append((Object)completablefuture).append(System.lineSeparator()); +- stringbuilder.append((Object)p_203756_.getPos()).append(" - status: ").append((Object)chunkstatus).append(" future: ").append((Object)completablefuture).append(System.lineSeparator()); - } - - }); - }; - stringbuilder.append("Updating:").append(System.lineSeparator()); -- this.f_140129_.values().forEach(consumer); +- this.updatingChunkMap.values().forEach(consumer); - stringbuilder.append("Visible:").append(System.lineSeparator()); -- this.f_140130_.values().forEach(consumer); -- CrashReport crashreport = CrashReport.m_127521_(p_203752_, "Chunk loading"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Chunk loading"); -- crashreportcategory.m_128159_("Details", p_203753_); -- crashreportcategory.m_128159_("Futures", stringbuilder); +- this.visibleChunkMap.values().forEach(consumer); +- CrashReport crashreport = CrashReport.forThrowable(p_203752_, "Chunk loading"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Chunk loading"); +- crashreportcategory.setDetail("Details", p_203753_); +- crashreportcategory.setDetail("Futures", stringbuilder); - return new ReportedException(crashreport); - } - -- public CompletableFuture> m_143117_(ChunkPos p_143118_) { -- return this.m_140210_(p_143118_, 2, (p_203078_) -> { -- return ChunkStatus.f_62326_; +- public CompletableFuture> prepareEntityTickingChunk(ChunkPos p_143118_) { +- return this.getChunkRangeFuture(p_143118_, 2, (p_203078_) -> { +- return ChunkStatus.FULL; - }).thenApplyAsync((p_203086_) -> { - return p_203086_.mapLeft((p_203092_) -> { - return (LevelChunk)p_203092_.get(p_203092_.size() / 2); - }); -- }, this.f_140135_); +- }, this.mainThreadExecutor); - } - - @Nullable -- ChunkHolder m_140176_(long p_140177_, int p_140178_, @Nullable ChunkHolder p_140179_, int p_140180_) { -- if (p_140180_ > f_140127_ && p_140178_ > f_140127_) { +- ChunkHolder updateChunkScheduling(long p_140177_, int p_140178_, @Nullable ChunkHolder p_140179_, int p_140180_) { +- if (p_140180_ > MAX_CHUNK_DISTANCE && p_140178_ > MAX_CHUNK_DISTANCE) { - return p_140179_; - } else { - if (p_140179_ != null) { -- p_140179_.m_140027_(p_140178_); +- p_140179_.setTicketLevel(p_140178_); - } - - if (p_140179_ != null) { -- if (p_140178_ > f_140127_) { -- this.f_140139_.add(p_140177_); +- if (p_140178_ > MAX_CHUNK_DISTANCE) { +- this.toDrop.add(p_140177_); - } else { -- this.f_140139_.remove(p_140177_); +- this.toDrop.remove(p_140177_); - } - } - -- if (p_140178_ <= f_140127_ && p_140179_ == null) { -- p_140179_ = this.f_140131_.remove(p_140177_); +- if (p_140178_ <= MAX_CHUNK_DISTANCE && p_140179_ == null) { +- p_140179_ = this.pendingUnloads.remove(p_140177_); - if (p_140179_ != null) { -- p_140179_.m_140027_(p_140178_); +- p_140179_.setTicketLevel(p_140178_); - } else { -- p_140179_ = new ChunkHolder(new ChunkPos(p_140177_), p_140178_, this.f_140133_, this.f_140134_, this.f_140141_, this); +- p_140179_ = new ChunkHolder(new ChunkPos(p_140177_), p_140178_, this.level, this.lightEngine, this.queueSorter, this); - } - -- this.f_140129_.put(p_140177_, p_140179_); -- this.f_140140_ = true; +- this.updatingChunkMap.put(p_140177_, p_140179_); +- this.modified = true; - } - - return p_140179_; @@ -285,17 +285,17 @@ - - public void close() throws IOException { - try { -- this.f_140141_.close(); -- this.f_140138_.close(); +- this.queueSorter.close(); +- this.poiManager.close(); - } finally { - super.close(); - } - - } - -- protected void m_140318_(boolean p_140319_) { +- protected void saveAllChunks(boolean p_140319_) { - if (p_140319_) { -- List list = this.f_140130_.values().stream().filter(ChunkHolder::m_140095_).peek(ChunkHolder::m_140096_).collect(Collectors.toList()); +- List list = this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); - MutableBoolean mutableboolean = new MutableBoolean(); - - do { @@ -303,343 +303,343 @@ - list.stream().map((p_203102_) -> { - CompletableFuture completablefuture; - do { -- completablefuture = p_203102_.m_140090_(); -- this.f_140135_.m_18701_(completablefuture::isDone); -- } while(completablefuture != p_203102_.m_140090_()); +- completablefuture = p_203102_.getChunkToSave(); +- this.mainThreadExecutor.managedBlock(completablefuture::isDone); +- } while(completablefuture != p_203102_.getChunkToSave()); - - return completablefuture.join(); - }).filter((p_203088_) -> { - return p_203088_ instanceof ImposterProtoChunk || p_203088_ instanceof LevelChunk; -- }).filter(this::m_140258_).forEach((p_203051_) -> { +- }).filter(this::save).forEach((p_203051_) -> { - mutableboolean.setTrue(); - }); - } while(mutableboolean.isTrue()); - -- this.m_140353_(() -> { +- this.processUnloads(() -> { - return true; - }); -- this.m_63514_(); +- this.flushWorker(); - } else { -- this.f_140130_.values().forEach(this::m_198874_); +- this.visibleChunkMap.values().forEach(this::saveChunkIfNeeded); - } - - } - -- protected void m_140280_(BooleanSupplier p_140281_) { -- ProfilerFiller profilerfiller = this.f_140133_.m_46473_(); -- profilerfiller.m_6180_("poi"); -- this.f_140138_.m_6202_(p_140281_); -- profilerfiller.m_6182_("chunk_unload"); -- if (!this.f_140133_.m_7441_()) { -- this.m_140353_(p_140281_); +- protected void tick(BooleanSupplier p_140281_) { +- ProfilerFiller profilerfiller = this.level.getProfiler(); +- profilerfiller.push("poi"); +- this.poiManager.tick(p_140281_); +- profilerfiller.popPush("chunk_unload"); +- if (!this.level.noSave()) { +- this.processUnloads(p_140281_); - } - -- profilerfiller.m_7238_(); +- profilerfiller.pop(); - } - -- public boolean m_201907_() { -- return this.f_140134_.m_142182_() || !this.f_140131_.isEmpty() || !this.f_140129_.isEmpty() || this.f_140138_.m_202164_() || !this.f_140139_.isEmpty() || !this.f_140125_.isEmpty() || this.f_140141_.m_201909_() || this.f_140145_.m_201911_(); +- public boolean hasWork() { +- return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() || !this.unloadQueue.isEmpty() || this.queueSorter.hasWork() || this.distanceManager.hasTickets(); - } - -- private void m_140353_(BooleanSupplier p_140354_) { -- LongIterator longiterator = this.f_140139_.iterator(); +- private void processUnloads(BooleanSupplier p_140354_) { +- LongIterator longiterator = this.toDrop.iterator(); - -- for(int i = 0; longiterator.hasNext() && (p_140354_.getAsBoolean() || i < 200 || this.f_140139_.size() > 2000); longiterator.remove()) { +- for(int i = 0; longiterator.hasNext() && (p_140354_.getAsBoolean() || i < 200 || this.toDrop.size() > 2000); longiterator.remove()) { - long j = longiterator.nextLong(); -- ChunkHolder chunkholder = this.f_140129_.remove(j); +- ChunkHolder chunkholder = this.updatingChunkMap.remove(j); - if (chunkholder != null) { -- this.f_140131_.put(j, chunkholder); -- this.f_140140_ = true; +- this.pendingUnloads.put(j, chunkholder); +- this.modified = true; - ++i; -- this.m_140181_(j, chunkholder); +- this.scheduleUnload(j, chunkholder); - } - } - -- int k = Math.max(0, this.f_140125_.size() - 2000); +- int k = Math.max(0, this.unloadQueue.size() - 2000); - - Runnable runnable; -- while((p_140354_.getAsBoolean() || k > 0) && (runnable = this.f_140125_.poll()) != null) { +- while((p_140354_.getAsBoolean() || k > 0) && (runnable = this.unloadQueue.poll()) != null) { - --k; - runnable.run(); - } - - int l = 0; -- ObjectIterator objectiterator = this.f_140130_.values().iterator(); +- ObjectIterator objectiterator = this.visibleChunkMap.values().iterator(); - - while(l < 20 && p_140354_.getAsBoolean() && objectiterator.hasNext()) { -- if (this.m_198874_(objectiterator.next())) { +- if (this.saveChunkIfNeeded(objectiterator.next())) { - ++l; - } - } - - } - -- private void m_140181_(long p_140182_, ChunkHolder p_140183_) { -- CompletableFuture completablefuture = p_140183_.m_140090_(); +- private void scheduleUnload(long p_140182_, ChunkHolder p_140183_) { +- CompletableFuture completablefuture = p_140183_.getChunkToSave(); - completablefuture.thenAcceptAsync((p_203002_) -> { -- CompletableFuture completablefuture1 = p_140183_.m_140090_(); +- CompletableFuture completablefuture1 = p_140183_.getChunkToSave(); - if (completablefuture1 != completablefuture) { -- this.m_140181_(p_140182_, p_140183_); +- this.scheduleUnload(p_140182_, p_140183_); - } else { -- if (this.f_140131_.remove(p_140182_, p_140183_) && p_203002_ != null) { +- if (this.pendingUnloads.remove(p_140182_, p_140183_) && p_203002_ != null) { - if (p_203002_ instanceof LevelChunk) { -- ((LevelChunk)p_203002_).m_62913_(false); +- ((LevelChunk)p_203002_).setLoaded(false); - } - -- this.m_140258_(p_203002_); -- if (this.f_140132_.remove(p_140182_) && p_203002_ instanceof LevelChunk) { +- this.save(p_203002_); +- if (this.entitiesInLevel.remove(p_140182_) && p_203002_ instanceof LevelChunk) { - LevelChunk levelchunk = (LevelChunk)p_203002_; -- this.f_140133_.m_8712_(levelchunk); +- this.level.unload(levelchunk); - } - -- this.f_140134_.m_9330_(p_203002_.m_7697_()); -- this.f_140134_.m_9409_(); -- this.f_140144_.m_5511_(p_203002_.m_7697_(), (ChunkStatus)null); -- this.f_202981_.remove(p_203002_.m_7697_().m_45588_()); +- this.lightEngine.updateChunkStatus(p_203002_.getPos()); +- this.lightEngine.tryScheduleUpdate(); +- this.progressListener.onStatusChange(p_203002_.getPos(), (ChunkStatus)null); +- this.chunkSaveCooldowns.remove(p_203002_.getPos().toLong()); - } - - } -- }, this.f_140125_::add).whenComplete((p_202996_, p_202997_) -> { +- }, this.unloadQueue::add).whenComplete((p_202996_, p_202997_) -> { - if (p_202997_ != null) { -- f_140128_.error("Failed to save chunk {}", p_140183_.m_140092_(), p_202997_); +- LOGGER.error("Failed to save chunk {}", p_140183_.getPos(), p_202997_); - } - - }); - } - -- protected boolean m_140324_() { -- if (!this.f_140140_) { +- protected boolean promoteChunkMap() { +- if (!this.modified) { - return false; - } else { -- this.f_140130_ = this.f_140129_.clone(); -- this.f_140140_ = false; +- this.visibleChunkMap = this.updatingChunkMap.clone(); +- this.modified = false; - return true; - } - } - -- public CompletableFuture> m_140292_(ChunkHolder p_140293_, ChunkStatus p_140294_) { -- ChunkPos chunkpos = p_140293_.m_140092_(); -- if (p_140294_ == ChunkStatus.f_62314_) { -- return this.m_140417_(chunkpos); +- public CompletableFuture> schedule(ChunkHolder p_140293_, ChunkStatus p_140294_) { +- ChunkPos chunkpos = p_140293_.getPos(); +- if (p_140294_ == ChunkStatus.EMPTY) { +- return this.scheduleChunkLoad(chunkpos); - } else { -- if (p_140294_ == ChunkStatus.f_62323_) { -- this.f_140145_.m_140792_(TicketType.f_9446_, chunkpos, 33 + ChunkStatus.m_62370_(ChunkStatus.f_62323_), chunkpos); +- if (p_140294_ == ChunkStatus.LIGHT) { +- this.distanceManager.addTicket(TicketType.LIGHT, chunkpos, 33 + ChunkStatus.getDistance(ChunkStatus.LIGHT), chunkpos); - } - -- Optional optional = p_140293_.m_140049_(p_140294_.m_62482_(), this).getNow(ChunkHolder.f_139995_).left(); -- if (optional.isPresent() && optional.get().m_6415_().m_62427_(p_140294_)) { -- CompletableFuture> completablefuture = p_140294_.m_62364_(this.f_140133_, this.f_140147_, this.f_140134_, (p_203081_) -> { -- return this.m_140383_(p_140293_); +- Optional optional = p_140293_.getOrScheduleFuture(p_140294_.getParent(), this).getNow(ChunkHolder.UNLOADED_CHUNK).left(); +- if (optional.isPresent() && optional.get().getStatus().isOrAfter(p_140294_)) { +- CompletableFuture> completablefuture = p_140294_.load(this.level, this.structureManager, this.lightEngine, (p_203081_) -> { +- return this.protoChunkToFullChunk(p_140293_); - }, optional.get()); -- this.f_140144_.m_5511_(chunkpos, p_140294_); +- this.progressListener.onStatusChange(chunkpos, p_140294_); - return completablefuture; - } else { -- return this.m_140360_(p_140293_, p_140294_); +- return this.scheduleChunkGeneration(p_140293_, p_140294_); - } - } - } - -- private CompletableFuture> m_140417_(ChunkPos p_140418_) { +- private CompletableFuture> scheduleChunkLoad(ChunkPos p_140418_) { - return CompletableFuture.supplyAsync(() -> { - try { -- this.f_140133_.m_46473_().m_6174_("chunkLoad"); -- CompoundTag compoundtag = this.m_140427_(p_140418_); +- this.level.getProfiler().incrementCounter("chunkLoad"); +- CompoundTag compoundtag = this.readChunk(p_140418_); - if (compoundtag != null) { -- boolean flag = compoundtag.m_128425_("Status", 8); +- boolean flag = compoundtag.contains("Status", 8); - if (flag) { -- ChunkAccess chunkaccess = ChunkSerializer.m_188230_(this.f_140133_, this.f_140138_, p_140418_, compoundtag); -- this.m_140229_(p_140418_, chunkaccess.m_6415_().m_62494_()); +- ChunkAccess chunkaccess = ChunkSerializer.read(this.level, this.poiManager, p_140418_, compoundtag); +- this.markPosition(p_140418_, chunkaccess.getStatus().getChunkType()); - return Either.left(chunkaccess); - } - -- f_140128_.error("Chunk file at {} is missing level data, skipping", (Object)p_140418_); +- LOGGER.error("Chunk file at {} is missing level data, skipping", (Object)p_140418_); - } - } catch (ReportedException reportedexception) { - Throwable throwable = reportedexception.getCause(); - if (!(throwable instanceof IOException)) { -- this.m_140422_(p_140418_); +- this.markPositionReplaceable(p_140418_); - throw reportedexception; - } - -- f_140128_.error("Couldn't load chunk {}", p_140418_, throwable); +- LOGGER.error("Couldn't load chunk {}", p_140418_, throwable); - } catch (Exception exception) { -- f_140128_.error("Couldn't load chunk {}", p_140418_, exception); +- LOGGER.error("Couldn't load chunk {}", p_140418_, exception); - } - -- this.m_140422_(p_140418_); -- return Either.left(new ProtoChunk(p_140418_, UpgradeData.f_63320_, this.f_140133_, this.f_140133_.m_5962_().m_175515_(Registry.f_122885_), (BlendingData)null)); -- }, this.f_140135_); +- this.markPositionReplaceable(p_140418_); +- return Either.left(new ProtoChunk(p_140418_, UpgradeData.EMPTY, this.level, this.level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), (BlendingData)null)); +- }, this.mainThreadExecutor); - } - -- private void m_140422_(ChunkPos p_140423_) { -- this.f_140151_.put(p_140423_.m_45588_(), (byte)-1); +- private void markPositionReplaceable(ChunkPos p_140423_) { +- this.chunkTypeCache.put(p_140423_.toLong(), (byte)-1); - } - -- private byte m_140229_(ChunkPos p_140230_, ChunkStatus.ChunkType p_140231_) { -- return this.f_140151_.put(p_140230_.m_45588_(), (byte)(p_140231_ == ChunkStatus.ChunkType.PROTOCHUNK ? -1 : 1)); +- private byte markPosition(ChunkPos p_140230_, ChunkStatus.ChunkType p_140231_) { +- return this.chunkTypeCache.put(p_140230_.toLong(), (byte)(p_140231_ == ChunkStatus.ChunkType.PROTOCHUNK ? -1 : 1)); - } - -- private CompletableFuture> m_140360_(ChunkHolder p_140361_, ChunkStatus p_140362_) { -- ChunkPos chunkpos = p_140361_.m_140092_(); -- CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.m_140210_(chunkpos, p_140362_.m_62488_(), (p_203072_) -> { -- return this.m_140262_(p_140362_, p_203072_); +- private CompletableFuture> scheduleChunkGeneration(ChunkHolder p_140361_, ChunkStatus p_140362_) { +- ChunkPos chunkpos = p_140361_.getPos(); +- CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture(chunkpos, p_140362_.getRange(), (p_203072_) -> { +- return this.getDependencyStatus(p_140362_, p_203072_); - }); -- this.f_140133_.m_46473_().m_6525_(() -> { -- return "chunkGenerate " + p_140362_.m_62467_(); +- this.level.getProfiler().incrementCounter(() -> { +- return "chunkGenerate " + p_140362_.getName(); - }); - Executor executor = (p_203100_) -> { -- this.f_140142_.m_6937_(ChunkTaskPriorityQueueSorter.m_140642_(p_140361_, p_203100_)); +- this.worldgenMailbox.tell(ChunkTaskPriorityQueueSorter.message(p_140361_, p_203100_)); - }; - return completablefuture.thenComposeAsync((p_203016_) -> { - return p_203016_.map((p_203022_) -> { - try { -- CompletableFuture> completablefuture1 = p_140362_.m_187788_(executor, this.f_140133_, this.f_140136_, this.f_140147_, this.f_140134_, (p_203062_) -> { -- return this.m_140383_(p_140361_); +- CompletableFuture> completablefuture1 = p_140362_.generate(executor, this.level, this.generator, this.structureManager, this.lightEngine, (p_203062_) -> { +- return this.protoChunkToFullChunk(p_140361_); - }, p_203022_, false); -- this.f_140144_.m_5511_(chunkpos, p_140362_); +- this.progressListener.onStatusChange(chunkpos, p_140362_); - return completablefuture1; - } catch (Exception exception) { - exception.getStackTrace(); -- CrashReport crashreport = CrashReport.m_127521_(exception, "Exception generating new chunk"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Chunk to be generated"); -- crashreportcategory.m_128159_("Location", String.format("%d,%d", chunkpos.f_45578_, chunkpos.f_45579_)); -- crashreportcategory.m_128159_("Position hash", ChunkPos.m_45589_(chunkpos.f_45578_, chunkpos.f_45579_)); -- crashreportcategory.m_128159_("Generator", this.f_140136_); -- this.f_140135_.execute(() -> { +- CrashReport crashreport = CrashReport.forThrowable(exception, "Exception generating new chunk"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Chunk to be generated"); +- crashreportcategory.setDetail("Location", String.format("%d,%d", chunkpos.x, chunkpos.z)); +- crashreportcategory.setDetail("Position hash", ChunkPos.asLong(chunkpos.x, chunkpos.z)); +- crashreportcategory.setDetail("Generator", this.generator); +- this.mainThreadExecutor.execute(() -> { - throw new ReportedException(crashreport); - }); - throw new ReportedException(crashreport); - } - }, (p_203010_) -> { -- this.m_140375_(chunkpos); +- this.releaseLightTicket(chunkpos); - return CompletableFuture.completedFuture(Either.right(p_203010_)); - }); - }, executor); - } - -- protected void m_140375_(ChunkPos p_140376_) { -- this.f_140135_.m_6937_(Util.m_137474_(() -> { -- this.f_140145_.m_140823_(TicketType.f_9446_, p_140376_, 33 + ChunkStatus.m_62370_(ChunkStatus.f_62323_), p_140376_); +- protected void releaseLightTicket(ChunkPos p_140376_) { +- this.mainThreadExecutor.tell(Util.name(() -> { +- this.distanceManager.removeTicket(TicketType.LIGHT, p_140376_, 33 + ChunkStatus.getDistance(ChunkStatus.LIGHT), p_140376_); - }, () -> { - return "release light ticket " + p_140376_; - })); - } - -- private ChunkStatus m_140262_(ChunkStatus p_140263_, int p_140264_) { +- private ChunkStatus getDependencyStatus(ChunkStatus p_140263_, int p_140264_) { - ChunkStatus chunkstatus; - if (p_140264_ == 0) { -- chunkstatus = p_140263_.m_62482_(); +- chunkstatus = p_140263_.getParent(); - } else { -- chunkstatus = ChunkStatus.m_156185_(ChunkStatus.m_62370_(p_140263_) + p_140264_); +- chunkstatus = ChunkStatus.getStatusAroundFullChunk(ChunkStatus.getDistance(p_140263_) + p_140264_); - } - - return chunkstatus; - } - -- private static void m_143064_(ServerLevel p_143065_, List p_143066_) { +- private static void postLoadProtoChunk(ServerLevel p_143065_, List p_143066_) { - if (!p_143066_.isEmpty()) { -- p_143065_.m_143327_(EntityType.m_147045_(p_143066_, p_143065_)); +- p_143065_.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(p_143066_, p_143065_)); - } - - } - -- private CompletableFuture> m_140383_(ChunkHolder p_140384_) { -- CompletableFuture> completablefuture = p_140384_.m_140047_(ChunkStatus.f_62326_.m_62482_()); +- private CompletableFuture> protoChunkToFullChunk(ChunkHolder p_140384_) { +- CompletableFuture> completablefuture = p_140384_.getFutureIfPresentUnchecked(ChunkStatus.FULL.getParent()); - return completablefuture.thenApplyAsync((p_202987_) -> { -- ChunkStatus chunkstatus = ChunkHolder.m_140074_(p_140384_.m_140093_()); -- return !chunkstatus.m_62427_(ChunkStatus.f_62326_) ? ChunkHolder.f_139995_ : p_202987_.mapLeft((p_202990_) -> { -- ChunkPos chunkpos = p_140384_.m_140092_(); +- ChunkStatus chunkstatus = ChunkHolder.getStatus(p_140384_.getTicketLevel()); +- return !chunkstatus.isOrAfter(ChunkStatus.FULL) ? ChunkHolder.UNLOADED_CHUNK : p_202987_.mapLeft((p_202990_) -> { +- ChunkPos chunkpos = p_140384_.getPos(); - ProtoChunk protochunk = (ProtoChunk)p_202990_; - LevelChunk levelchunk; - if (protochunk instanceof ImposterProtoChunk) { -- levelchunk = ((ImposterProtoChunk)protochunk).m_62768_(); +- levelchunk = ((ImposterProtoChunk)protochunk).getWrapped(); - } else { -- levelchunk = new LevelChunk(this.f_140133_, protochunk, (p_203037_) -> { -- m_143064_(this.f_140133_, protochunk.m_63293_()); +- levelchunk = new LevelChunk(this.level, protochunk, (p_203037_) -> { +- postLoadProtoChunk(this.level, protochunk.getEntities()); - }); -- p_140384_.m_140052_(new ImposterProtoChunk(levelchunk, false)); +- p_140384_.replaceProtoChunk(new ImposterProtoChunk(levelchunk, false)); - } - -- levelchunk.m_62879_(() -> { -- return ChunkHolder.m_140083_(p_140384_.m_140093_()); +- levelchunk.setFullStatus(() -> { +- return ChunkHolder.getFullChunkStatus(p_140384_.getTicketLevel()); - }); -- levelchunk.m_62952_(); -- if (this.f_140132_.add(chunkpos.m_45588_())) { -- levelchunk.m_62913_(true); -- levelchunk.m_156369_(); -- levelchunk.m_187958_(this.f_140133_); +- levelchunk.runPostLoad(); +- if (this.entitiesInLevel.add(chunkpos.toLong())) { +- levelchunk.setLoaded(true); +- levelchunk.registerAllBlockEntitiesAfterLevelLoad(); +- levelchunk.registerTickContainerInLevel(this.level); - } - - return levelchunk; - }); - }, (p_203095_) -> { -- this.f_140143_.m_6937_(ChunkTaskPriorityQueueSorter.m_140624_(p_203095_, p_140384_.m_140092_().m_45588_(), p_140384_::m_140093_)); +- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(p_203095_, p_140384_.getPos().toLong(), p_140384_::getTicketLevel)); - }); - } - -- public CompletableFuture> m_143053_(ChunkHolder p_143054_) { -- ChunkPos chunkpos = p_143054_.m_140092_(); -- CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.m_140210_(chunkpos, 1, (p_203059_) -> { -- return ChunkStatus.f_62326_; +- public CompletableFuture> prepareTickingChunk(ChunkHolder p_143054_) { +- ChunkPos chunkpos = p_143054_.getPos(); +- CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture(chunkpos, 1, (p_203059_) -> { +- return ChunkStatus.FULL; - }); - CompletableFuture> completablefuture1 = completablefuture.thenApplyAsync((p_203067_) -> { - return p_203067_.mapLeft((p_212884_) -> { - return (LevelChunk)p_212884_.get(p_212884_.size() / 2); - }); - }, (p_203084_) -> { -- this.f_140143_.m_6937_(ChunkTaskPriorityQueueSorter.m_140642_(p_143054_, p_203084_)); +- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(p_143054_, p_203084_)); - }).thenApplyAsync((p_212878_) -> { - return p_212878_.ifLeft((p_212888_) -> { -- p_212888_.m_62812_(); -- this.f_140133_.m_184102_(p_212888_); +- p_212888_.postProcessGeneration(); +- this.level.startTickingChunk(p_212888_); - }); -- }, this.f_140135_); +- }, this.mainThreadExecutor); - completablefuture1.thenAcceptAsync((p_212860_) -> { - p_212860_.ifLeft((p_212863_) -> { -- this.f_140146_.getAndIncrement(); +- this.tickingGenerated.getAndIncrement(); - MutableObject mutableobject = new MutableObject<>(); -- this.m_183262_(chunkpos, false).forEach((p_212873_) -> { -- this.m_183760_(p_212873_, mutableobject, p_212863_); +- this.getPlayers(chunkpos, false).forEach((p_212873_) -> { +- this.playerLoadedChunk(p_212873_, mutableobject, p_212863_); - }); - }); - }, (p_212876_) -> { -- this.f_140143_.m_6937_(ChunkTaskPriorityQueueSorter.m_140642_(p_143054_, p_212876_)); +- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(p_143054_, p_212876_)); - }); - return completablefuture1; - } - -- public CompletableFuture> m_143109_(ChunkHolder p_143110_) { -- return this.m_140210_(p_143110_.m_140092_(), 1, ChunkStatus::m_156185_).thenApplyAsync((p_212865_) -> { +- public CompletableFuture> prepareAccessibleChunk(ChunkHolder p_143110_) { +- return this.getChunkRangeFuture(p_143110_.getPos(), 1, ChunkStatus::getStatusAroundFullChunk).thenApplyAsync((p_212865_) -> { - return p_212865_.mapLeft((p_212869_) -> { - return (LevelChunk)p_212869_.get(p_212869_.size() / 2); - }); - }, (p_212852_) -> { -- this.f_140143_.m_6937_(ChunkTaskPriorityQueueSorter.m_140642_(p_143110_, p_212852_)); +- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(p_143110_, p_212852_)); - }); - } - -- public int m_140368_() { -- return this.f_140146_.get(); +- public int getTickingGenerated() { +- return this.tickingGenerated.get(); - } - -- private boolean m_198874_(ChunkHolder p_198875_) { -- if (!p_198875_.m_140095_()) { +- private boolean saveChunkIfNeeded(ChunkHolder p_198875_) { +- if (!p_198875_.wasAccessibleSinceLastSave()) { - return false; - } else { -- ChunkAccess chunkaccess = p_198875_.m_140090_().getNow((ChunkAccess)null); +- ChunkAccess chunkaccess = p_198875_.getChunkToSave().getNow((ChunkAccess)null); - if (!(chunkaccess instanceof ImposterProtoChunk) && !(chunkaccess instanceof LevelChunk)) { - return false; - } else { -- long i = chunkaccess.m_7697_().m_45588_(); -- long j = this.f_202981_.getOrDefault(i, -1L); +- long i = chunkaccess.getPos().toLong(); +- long j = this.chunkSaveCooldowns.getOrDefault(i, -1L); - long k = System.currentTimeMillis(); - if (k < j) { - return false; - } else { -- boolean flag = this.m_140258_(chunkaccess); -- p_198875_.m_140096_(); +- boolean flag = this.save(chunkaccess); +- p_198875_.refreshAccessibility(); - if (flag) { -- this.f_202981_.put(i, k + 10000L); +- this.chunkSaveCooldowns.put(i, k + 10000L); - } - - return flag; @@ -648,124 +648,124 @@ - } - } - -- private boolean m_140258_(ChunkAccess p_140259_) { -- this.f_140138_.m_63796_(p_140259_.m_7697_()); -- if (!p_140259_.m_6344_()) { +- private boolean save(ChunkAccess p_140259_) { +- this.poiManager.flush(p_140259_.getPos()); +- if (!p_140259_.isUnsaved()) { - return false; - } else { -- p_140259_.m_8092_(false); -- ChunkPos chunkpos = p_140259_.m_7697_(); +- p_140259_.setUnsaved(false); +- ChunkPos chunkpos = p_140259_.getPos(); - - try { -- ChunkStatus chunkstatus = p_140259_.m_6415_(); -- if (chunkstatus.m_62494_() != ChunkStatus.ChunkType.LEVELCHUNK) { -- if (this.m_140425_(chunkpos)) { +- ChunkStatus chunkstatus = p_140259_.getStatus(); +- if (chunkstatus.getChunkType() != ChunkStatus.ChunkType.LEVELCHUNK) { +- if (this.isExistingChunkFull(chunkpos)) { - return false; - } - -- if (chunkstatus == ChunkStatus.f_62314_ && p_140259_.m_6633_().values().stream().noneMatch(StructureStart::m_73603_)) { +- if (chunkstatus == ChunkStatus.EMPTY && p_140259_.getAllStarts().values().stream().noneMatch(StructureStart::isValid)) { - return false; - } - } - -- this.f_140133_.m_46473_().m_6174_("chunkSave"); -- CompoundTag compoundtag = ChunkSerializer.m_63454_(this.f_140133_, p_140259_); -- this.m_63502_(chunkpos, compoundtag); -- this.m_140229_(chunkpos, chunkstatus.m_62494_()); +- this.level.getProfiler().incrementCounter("chunkSave"); +- CompoundTag compoundtag = ChunkSerializer.write(this.level, p_140259_); +- this.write(chunkpos, compoundtag); +- this.markPosition(chunkpos, chunkstatus.getChunkType()); - return true; - } catch (Exception exception) { -- f_140128_.error("Failed to save chunk {},{}", chunkpos.f_45578_, chunkpos.f_45579_, exception); +- LOGGER.error("Failed to save chunk {},{}", chunkpos.x, chunkpos.z, exception); - return false; - } - } - } - -- private boolean m_140425_(ChunkPos p_140426_) { -- byte b0 = this.f_140151_.get(p_140426_.m_45588_()); +- private boolean isExistingChunkFull(ChunkPos p_140426_) { +- byte b0 = this.chunkTypeCache.get(p_140426_.toLong()); - if (b0 != 0) { - return b0 == 1; - } else { - CompoundTag compoundtag; - try { -- compoundtag = this.m_140427_(p_140426_); +- compoundtag = this.readChunk(p_140426_); - if (compoundtag == null) { -- this.m_140422_(p_140426_); +- this.markPositionReplaceable(p_140426_); - return false; - } - } catch (Exception exception) { -- f_140128_.error("Failed to read chunk {}", p_140426_, exception); -- this.m_140422_(p_140426_); +- LOGGER.error("Failed to read chunk {}", p_140426_, exception); +- this.markPositionReplaceable(p_140426_); - return false; - } - -- ChunkStatus.ChunkType chunkstatus$chunktype = ChunkSerializer.m_63485_(compoundtag); -- return this.m_140229_(p_140426_, chunkstatus$chunktype) == 1; +- ChunkStatus.ChunkType chunkstatus$chunktype = ChunkSerializer.getChunkTypeFromTag(compoundtag); +- return this.markPosition(p_140426_, chunkstatus$chunktype) == 1; - } - } - -- protected void m_140167_(int p_140168_) { -- int i = Mth.m_14045_(p_140168_ + 1, 3, 33); -- if (i != this.f_140126_) { -- int j = this.f_140126_; -- this.f_140126_ = i; -- this.f_140145_.m_140777_(this.f_140126_ + 1); +- protected void setViewDistance(int p_140168_) { +- int i = Mth.clamp(p_140168_ + 1, 3, 33); +- if (i != this.viewDistance) { +- int j = this.viewDistance; +- this.viewDistance = i; +- this.distanceManager.updatePlayerTickets(this.viewDistance + 1); - -- for(ChunkHolder chunkholder : this.f_140129_.values()) { -- ChunkPos chunkpos = chunkholder.m_140092_(); +- for(ChunkHolder chunkholder : this.updatingChunkMap.values()) { +- ChunkPos chunkpos = chunkholder.getPos(); - MutableObject mutableobject = new MutableObject<>(); -- this.m_183262_(chunkpos, false).forEach((p_212857_) -> { -- SectionPos sectionpos = p_212857_.m_8965_(); -- boolean flag = m_200878_(chunkpos.f_45578_, chunkpos.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), j); -- boolean flag1 = m_200878_(chunkpos.f_45578_, chunkpos.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), this.f_140126_); -- this.m_183754_(p_212857_, chunkpos, mutableobject, flag, flag1); +- this.getPlayers(chunkpos, false).forEach((p_212857_) -> { +- SectionPos sectionpos = p_212857_.getLastSectionPos(); +- boolean flag = isChunkInRange(chunkpos.x, chunkpos.z, sectionpos.x(), sectionpos.z(), j); +- boolean flag1 = isChunkInRange(chunkpos.x, chunkpos.z, sectionpos.x(), sectionpos.z(), this.viewDistance); +- this.updateChunkTracking(p_212857_, chunkpos, mutableobject, flag, flag1); - }); - } - } - - } - -- protected void m_183754_(ServerPlayer p_183755_, ChunkPos p_183756_, MutableObject p_183757_, boolean p_183758_, boolean p_183759_) { -- if (p_183755_.f_19853_ == this.f_140133_) { +- protected void updateChunkTracking(ServerPlayer p_183755_, ChunkPos p_183756_, MutableObject p_183757_, boolean p_183758_, boolean p_183759_) { +- if (p_183755_.level == this.level) { - if (p_183759_ && !p_183758_) { -- ChunkHolder chunkholder = this.m_140327_(p_183756_.m_45588_()); -+ private static final byte f_143034_ = -1; -+ private static final byte f_143035_ = 0; -+ private static final byte f_143036_ = 1; -+ private static final Logger f_140128_ = LogUtils.getLogger(); -+ private static final int f_143037_ = 200; -+ private static final int f_198789_ = 20; -+ private static final int f_202982_ = 10000; -+ private static final int f_143038_ = 3; -+ public static final int f_143032_ = 33; -+ public static final int f_140127_ = 33 + ChunkStatus.m_62421_(); -+ public static final int f_143033_ = 31; -+ private final Long2ObjectLinkedOpenHashMap f_140129_ = new Long2ObjectLinkedOpenHashMap<>(); -+ public volatile Long2ObjectLinkedOpenHashMap f_140130_ = this.f_140129_.clone(); -+ private final Long2ObjectLinkedOpenHashMap f_140131_ = new Long2ObjectLinkedOpenHashMap<>(); -+ private final LongSet f_140132_ = new LongOpenHashSet(); -+ public final ServerLevel f_140133_; -+ private final ThreadedLevelLightEngine f_140134_; -+ private final BlockableEventLoop f_140135_; -+ private ChunkGenerator f_140136_; -+ private final Supplier f_140137_; -+ private final PoiManager f_140138_; -+ final LongSet f_140139_ = new LongOpenHashSet(); -+ private boolean f_140140_; -+ private final ChunkTaskPriorityQueueSorter f_140141_; -+ private final ProcessorHandle> f_140142_; -+ private final ProcessorHandle> f_140143_; -+ public final ChunkProgressListener f_140144_; -+ private final ChunkStatusUpdateListener f_143031_; -+ public final ChunkMap.DistanceManager f_140145_; -+ private final AtomicInteger f_140146_ = new AtomicInteger(); -+ private final StructureManager f_140147_; -+ private final String f_182284_; -+ private final PlayerMap f_140149_ = new PlayerMap(); -+ public final Int2ObjectMap f_140150_ = new Int2ObjectOpenHashMap<>(); -+ private final Long2ByteMap f_140151_ = new Long2ByteOpenHashMap(); -+ private final Long2LongMap f_202981_ = new Long2LongOpenHashMap(); -+ private final Queue f_140125_ = Queues.newConcurrentLinkedQueue(); -+ int f_140126_; +- ChunkHolder chunkholder = this.getVisibleChunkIfPresent(p_183756_.toLong()); ++ private static final byte CHUNK_TYPE_REPLACEABLE = -1; ++ private static final byte CHUNK_TYPE_UNKNOWN = 0; ++ private static final byte CHUNK_TYPE_FULL = 1; ++ private static final Logger LOGGER = LogUtils.getLogger(); ++ private static final int CHUNK_SAVED_PER_TICK = 200; ++ private static final int CHUNK_SAVED_EAGERLY_PER_TICK = 20; ++ private static final int EAGER_CHUNK_SAVE_COOLDOWN_IN_MILLIS = 10000; ++ private static final int MIN_VIEW_DISTANCE = 3; ++ public static final int MAX_VIEW_DISTANCE = 33; ++ public static final int MAX_CHUNK_DISTANCE = 33 + ChunkStatus.maxDistance(); ++ public static final int FORCED_TICKET_LEVEL = 31; ++ private final Long2ObjectLinkedOpenHashMap updatingChunkMap = new Long2ObjectLinkedOpenHashMap<>(); ++ public volatile Long2ObjectLinkedOpenHashMap visibleChunkMap = this.updatingChunkMap.clone(); ++ private final Long2ObjectLinkedOpenHashMap pendingUnloads = new Long2ObjectLinkedOpenHashMap<>(); ++ private final LongSet entitiesInLevel = new LongOpenHashSet(); ++ public final ServerLevel level; ++ private final ThreadedLevelLightEngine lightEngine; ++ private final BlockableEventLoop mainThreadExecutor; ++ private ChunkGenerator generator; ++ private final Supplier overworldDataStorage; ++ private final PoiManager poiManager; ++ final LongSet toDrop = new LongOpenHashSet(); ++ private boolean modified; ++ private final ChunkTaskPriorityQueueSorter queueSorter; ++ private final ProcessorHandle> worldgenMailbox; ++ private final ProcessorHandle> mainThreadMailbox; ++ public final ChunkProgressListener progressListener; ++ private final ChunkStatusUpdateListener chunkStatusListener; ++ public final ChunkMap.DistanceManager distanceManager; ++ private final AtomicInteger tickingGenerated = new AtomicInteger(); ++ private final StructureManager structureManager; ++ private final String storageName; ++ private final PlayerMap playerMap = new PlayerMap(); ++ public final Int2ObjectMap entityMap = new Int2ObjectOpenHashMap<>(); ++ private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap(); ++ private final Long2LongMap chunkSaveCooldowns = new Long2LongOpenHashMap(); ++ private final Queue unloadQueue = Queues.newConcurrentLinkedQueue(); ++ int viewDistance; + + // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() + public final CallbackExecutor callbackExecutor = new CallbackExecutor(); @@ -791,51 +791,51 @@ + // CraftBukkit end + + public ChunkMap(ServerLevel p_143040_, LevelStorageSource.LevelStorageAccess p_143041_, DataFixer p_143042_, StructureManager p_143043_, Executor p_143044_, BlockableEventLoop p_143045_, LightChunkGetter p_143046_, ChunkGenerator p_143047_, ChunkProgressListener p_143048_, ChunkStatusUpdateListener p_143049_, Supplier p_143050_, int p_143051_, boolean p_143052_) { -+ super( p_143041_.m_197394_( p_143040_.m_46472_() ).resolve( "region" ), p_143042_, p_143052_ ); -+ this.f_140147_ = p_143043_; -+ Path path = p_143041_.m_197394_( p_143040_.m_46472_() ); -+ this.f_182284_ = path.getFileName().toString(); -+ this.f_140133_ = p_143040_; -+ this.f_140136_ = p_143047_; -+ this.f_140135_ = p_143045_; -+ ProcessorMailbox processormailbox = ProcessorMailbox.m_18751_( p_143044_, "worldgen" ); -+ ProcessorHandle processorhandle = ProcessorHandle.m_18714_( "main", p_143045_::m_6937_ ); -+ this.f_140144_ = p_143048_; -+ this.f_143031_ = p_143049_; -+ ProcessorMailbox processormailbox1 = ProcessorMailbox.m_18751_( p_143044_, "light" ); -+ this.f_140141_ = new ChunkTaskPriorityQueueSorter( ImmutableList.of( processormailbox, processorhandle, processormailbox1 ), p_143044_, Integer.MAX_VALUE ); -+ this.f_140142_ = this.f_140141_.m_140604_( processormailbox, false ); -+ this.f_140143_ = this.f_140141_.m_140604_( processorhandle, false ); -+ this.f_140134_ = new ThreadedLevelLightEngine( p_143046_, this, this.f_140133_.m_6042_().m_63935_(), processormailbox1, this.f_140141_.m_140604_( processormailbox1, false ) ); -+ this.f_140145_ = new ChunkMap.DistanceManager( p_143044_, p_143045_ ); -+ this.f_140137_ = p_143050_; -+ this.f_140138_ = new PoiManager( path.resolve( "poi" ), p_143042_, p_143052_, p_143040_ ); -+ this.m_140167_( p_143051_ ); -+ } -+ -+ protected ChunkGenerator m_183719_() { -+ return this.f_140136_; -+ } -+ -+ public void m_183825_() { -+ DataResult dataresult = ChunkGenerator.f_62136_.encodeStart( JsonOps.INSTANCE, this.f_140136_ ); ++ super( p_143041_.getDimensionPath( p_143040_.dimension() ).resolve( "region" ), p_143042_, p_143052_ ); ++ this.structureManager = p_143043_; ++ Path path = p_143041_.getDimensionPath( p_143040_.dimension() ); ++ this.storageName = path.getFileName().toString(); ++ this.level = p_143040_; ++ this.generator = p_143047_; ++ this.mainThreadExecutor = p_143045_; ++ ProcessorMailbox processormailbox = ProcessorMailbox.create( p_143044_, "worldgen" ); ++ ProcessorHandle processorhandle = ProcessorHandle.of( "main", p_143045_::tell ); ++ this.progressListener = p_143048_; ++ this.chunkStatusListener = p_143049_; ++ ProcessorMailbox processormailbox1 = ProcessorMailbox.create( p_143044_, "light" ); ++ this.queueSorter = new ChunkTaskPriorityQueueSorter( ImmutableList.of( processormailbox, processorhandle, processormailbox1 ), p_143044_, Integer.MAX_VALUE ); ++ this.worldgenMailbox = this.queueSorter.getProcessor( processormailbox, false ); ++ this.mainThreadMailbox = this.queueSorter.getProcessor( processorhandle, false ); ++ this.lightEngine = new ThreadedLevelLightEngine( p_143046_, this, this.level.dimensionType().hasSkyLight(), processormailbox1, this.queueSorter.getProcessor( processormailbox1, false ) ); ++ this.distanceManager = new ChunkMap.DistanceManager( p_143044_, p_143045_ ); ++ this.overworldDataStorage = p_143050_; ++ this.poiManager = new PoiManager( path.resolve( "poi" ), p_143042_, p_143052_, p_143040_ ); ++ this.setViewDistance( p_143051_ ); ++ } ++ ++ protected ChunkGenerator generator() { ++ return this.generator; ++ } ++ ++ public void debugReloadGenerator() { ++ DataResult dataresult = ChunkGenerator.CODEC.encodeStart( JsonOps.INSTANCE, this.generator ); + DataResult dataresult1 = dataresult.flatMap( (p_183804_) -> { -+ return ChunkGenerator.f_62136_.parse( JsonOps.INSTANCE, p_183804_ ); ++ return ChunkGenerator.CODEC.parse( JsonOps.INSTANCE, p_183804_ ); + } ); + dataresult1.result().ifPresent( (p_183808_) -> { -+ this.f_140136_ = p_183808_; ++ this.generator = p_183808_; + } ); + } + -+ private static double m_140226_(ChunkPos p_140227_, Entity p_140228_) { -+ double d0 = (double) SectionPos.m_175554_( p_140227_.f_45578_, 8 ); -+ double d1 = (double) SectionPos.m_175554_( p_140227_.f_45579_, 8 ); -+ double d2 = d0 - p_140228_.m_20185_(); -+ double d3 = d1 - p_140228_.m_20189_(); ++ private static double euclideanDistanceSquared(ChunkPos p_140227_, Entity p_140228_) { ++ double d0 = (double) SectionPos.sectionToBlockCoord( p_140227_.x, 8 ); ++ double d1 = (double) SectionPos.sectionToBlockCoord( p_140227_.z, 8 ); ++ double d2 = d0 - p_140228_.getX(); ++ double d3 = d1 - p_140228_.getZ(); + return d2 * d2 + d3 * d3; + } + -+ public static boolean m_200878_(int p_200879_, int p_200880_, int p_200881_, int p_200882_, int p_200883_) { ++ public static boolean isChunkInRange(int p_200879_, int p_200880_, int p_200881_, int p_200882_, int p_200883_) { + int i = Math.max( 0, Math.abs( p_200879_ - p_200881_ ) - 1 ); + int j = Math.max( 0, Math.abs( p_200880_ - p_200882_ ) - 1 ); + long k = (long) Math.max( 0, Math.max( i, j ) - 1 ); @@ -846,58 +846,58 @@ + return i1 <= (long) k1; + } + -+ private static boolean m_183828_(int p_183829_, int p_183830_, int p_183831_, int p_183832_, int p_183833_) { -+ if (!m_200878_( p_183829_, p_183830_, p_183831_, p_183832_, p_183833_ )) { ++ private static boolean isChunkOnRangeBorder(int p_183829_, int p_183830_, int p_183831_, int p_183832_, int p_183833_) { ++ if (!isChunkInRange( p_183829_, p_183830_, p_183831_, p_183832_, p_183833_ )) { + return false; -+ } else if (!m_200878_( p_183829_ + 1, p_183830_, p_183831_, p_183832_, p_183833_ )) { ++ } else if (!isChunkInRange( p_183829_ + 1, p_183830_, p_183831_, p_183832_, p_183833_ )) { + return true; -+ } else if (!m_200878_( p_183829_, p_183830_ + 1, p_183831_, p_183832_, p_183833_ )) { ++ } else if (!isChunkInRange( p_183829_, p_183830_ + 1, p_183831_, p_183832_, p_183833_ )) { + return true; -+ } else if (!m_200878_( p_183829_ - 1, p_183830_, p_183831_, p_183832_, p_183833_ )) { ++ } else if (!isChunkInRange( p_183829_ - 1, p_183830_, p_183831_, p_183832_, p_183833_ )) { + return true; + } else { -+ return !m_200878_( p_183829_, p_183830_ - 1, p_183831_, p_183832_, p_183833_ ); ++ return !isChunkInRange( p_183829_, p_183830_ - 1, p_183831_, p_183832_, p_183833_ ); + } + } + -+ protected ThreadedLevelLightEngine m_140166_() { -+ return this.f_140134_; ++ protected ThreadedLevelLightEngine getLightEngine() { ++ return this.lightEngine; + } + + @Nullable -+ protected ChunkHolder m_140174_(long p_140175_) { -+ return this.f_140129_.get( p_140175_ ); ++ protected ChunkHolder getUpdatingChunkIfPresent(long p_140175_) { ++ return this.updatingChunkMap.get( p_140175_ ); + } + + @Nullable -+ protected ChunkHolder m_140327_(long p_140328_) { -+ return this.f_140130_.get( p_140328_ ); ++ protected ChunkHolder getVisibleChunkIfPresent(long p_140328_) { ++ return this.visibleChunkMap.get( p_140328_ ); + } + -+ protected IntSupplier m_140371_(long p_140372_) { ++ protected IntSupplier getChunkQueueLevel(long p_140372_) { + return () -> { -+ ChunkHolder chunkholder = this.m_140327_( p_140372_ ); -+ return chunkholder == null ? ChunkTaskPriorityQueue.f_140508_ - 1 : Math.min( chunkholder.m_140094_(), ChunkTaskPriorityQueue.f_140508_ - 1 ); ++ ChunkHolder chunkholder = this.getVisibleChunkIfPresent( p_140372_ ); ++ return chunkholder == null ? ChunkTaskPriorityQueue.PRIORITY_LEVEL_COUNT - 1 : Math.min( chunkholder.getQueueLevel(), ChunkTaskPriorityQueue.PRIORITY_LEVEL_COUNT - 1 ); + }; + } + -+ public String m_140204_(ChunkPos p_140205_) { -+ ChunkHolder chunkholder = this.m_140327_( p_140205_.m_45588_() ); ++ public String getChunkDebugData(ChunkPos p_140205_) { ++ ChunkHolder chunkholder = this.getVisibleChunkIfPresent( p_140205_.toLong() ); + if (chunkholder == null) { + return "null"; + } else { -+ String s = chunkholder.m_140093_() + "\n"; -+ ChunkStatus chunkstatus = chunkholder.m_140088_(); -+ ChunkAccess chunkaccess = chunkholder.m_140089_(); ++ String s = chunkholder.getTicketLevel() + "\n"; ++ ChunkStatus chunkstatus = chunkholder.getLastAvailableStatus(); ++ ChunkAccess chunkaccess = chunkholder.getLastAvailable(); + if (chunkstatus != null) { -+ s = s + "St: \u00a7" + chunkstatus.m_62445_() + chunkstatus + "\u00a7r\n"; ++ s = s + "St: \u00a7" + chunkstatus.getIndex() + chunkstatus + "\u00a7r\n"; + } + + if (chunkaccess != null) { -+ s = s + "Ch: \u00a7" + chunkaccess.m_6415_().m_62445_() + chunkaccess.m_6415_() + "\u00a7r\n"; ++ s = s + "Ch: \u00a7" + chunkaccess.getStatus().getIndex() + chunkaccess.getStatus() + "\u00a7r\n"; + } + -+ ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus = chunkholder.m_140091_(); ++ ChunkHolder.FullChunkStatus chunkholder$fullchunkstatus = chunkholder.getFullStatus(); + s = s + "\u00a7" + chunkholder$fullchunkstatus.ordinal() + chunkholder$fullchunkstatus; + return s + "\u00a7r"; + } @@ -907,22 +907,22 @@ + public final int getEffectiveViewDistance() { + // TODO this needs to be checked on update + // Mojang currently sets it to +1 of the configured view distance. So subtract one to get the one we really want. -+ return this.f_140126_ - 1; ++ return this.viewDistance - 1; + } + // Paper end + -+ private CompletableFuture, ChunkHolder.ChunkLoadingFailure>> m_140210_(ChunkPos p_140211_, int p_140212_, IntFunction p_140213_) { ++ private CompletableFuture, ChunkHolder.ChunkLoadingFailure>> getChunkRangeFuture(ChunkPos p_140211_, int p_140212_, IntFunction p_140213_) { + List>> list = new ArrayList<>(); + List list1 = new ArrayList<>(); -+ int i = p_140211_.f_45578_; -+ int j = p_140211_.f_45579_; ++ int i = p_140211_.x; ++ int j = p_140211_.z; + + for (int k = -p_140212_; k <= p_140212_; ++k) { + for (int l = -p_140212_; l <= p_140212_; ++l) { + int i1 = Math.max( Math.abs( l ), Math.abs( k ) ); + final ChunkPos chunkpos = new ChunkPos( i + l, j + k ); -+ long j1 = chunkpos.m_45588_(); -+ ChunkHolder chunkholder = this.m_140174_( j1 ); ++ long j1 = chunkpos.toLong(); ++ ChunkHolder chunkholder = this.getUpdatingChunkIfPresent( j1 ); + if (chunkholder == null) { + return CompletableFuture.completedFuture( Either.right( new ChunkHolder.ChunkLoadingFailure() { + public String toString() { @@ -932,20 +932,20 @@ + } + + ChunkStatus chunkstatus = p_140213_.apply( i1 ); -+ CompletableFuture> completablefuture = chunkholder.m_140049_( chunkstatus, this ); ++ CompletableFuture> completablefuture = chunkholder.getOrScheduleFuture( chunkstatus, this ); + list1.add( chunkholder ); + list.add( completablefuture ); + } + } + -+ CompletableFuture>> completablefuture1 = Util.m_137567_( list ); ++ CompletableFuture>> completablefuture1 = Util.sequence( list ); + CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture2 = completablefuture1.thenApply( (p_183730_) -> { + List list2 = Lists.newArrayList(); + int k1 = 0; + + for (final Either either : p_183730_) { + if (either == null) { -+ throw this.m_203751_( new IllegalStateException( "At least one of the chunk futures were null" ), "n/a" ); ++ throw this.debugFuturesAndCreateReportedException( new IllegalStateException( "At least one of the chunk futures were null" ), "n/a" ); + } + + Optional optional = either.left(); @@ -966,72 +966,72 @@ + } ); + + for (ChunkHolder chunkholder1 : list1) { -+ chunkholder1.m_200416_( "getChunkRangeFuture " + p_140211_ + " " + p_140212_, completablefuture2 ); ++ chunkholder1.addSaveDependency( "getChunkRangeFuture " + p_140211_ + " " + p_140212_, completablefuture2 ); + } + + return completablefuture2; + } + -+ public ReportedException m_203751_(IllegalStateException p_203752_, String p_203753_) { ++ public ReportedException debugFuturesAndCreateReportedException(IllegalStateException p_203752_, String p_203753_) { + StringBuilder stringbuilder = new StringBuilder(); + Consumer consumer = (p_203756_) -> { -+ p_203756_.m_202980_().forEach( (p_203760_) -> { ++ p_203756_.getAllFutures().forEach( (p_203760_) -> { + ChunkStatus chunkstatus = p_203760_.getFirst(); + CompletableFuture> completablefuture = p_203760_.getSecond(); + if (completablefuture != null && completablefuture.isDone() && completablefuture.join() == null) { -+ stringbuilder.append( (Object) p_203756_.m_140092_() ).append( " - status: " ).append( (Object) chunkstatus ).append( " future: " ).append( (Object) completablefuture ).append( System.lineSeparator() ); ++ stringbuilder.append( (Object) p_203756_.getPos() ).append( " - status: " ).append( (Object) chunkstatus ).append( " future: " ).append( (Object) completablefuture ).append( System.lineSeparator() ); + } + + } ); + }; + stringbuilder.append( "Updating:" ).append( System.lineSeparator() ); -+ this.f_140129_.values().forEach( consumer ); ++ this.updatingChunkMap.values().forEach( consumer ); + stringbuilder.append( "Visible:" ).append( System.lineSeparator() ); -+ this.f_140130_.values().forEach( consumer ); -+ CrashReport crashreport = CrashReport.m_127521_( p_203752_, "Chunk loading" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Chunk loading" ); -+ crashreportcategory.m_128159_( "Details", p_203753_ ); -+ crashreportcategory.m_128159_( "Futures", stringbuilder ); ++ this.visibleChunkMap.values().forEach( consumer ); ++ CrashReport crashreport = CrashReport.forThrowable( p_203752_, "Chunk loading" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Chunk loading" ); ++ crashreportcategory.setDetail( "Details", p_203753_ ); ++ crashreportcategory.setDetail( "Futures", stringbuilder ); + return new ReportedException( crashreport ); + } + -+ public CompletableFuture> m_143117_(ChunkPos p_143118_) { -+ return this.m_140210_( p_143118_, 2, (p_203078_) -> { -+ return ChunkStatus.f_62326_; ++ public CompletableFuture> prepareEntityTickingChunk(ChunkPos p_143118_) { ++ return this.getChunkRangeFuture( p_143118_, 2, (p_203078_) -> { ++ return ChunkStatus.FULL; + } ).thenApplyAsync( (p_203086_) -> { + return p_203086_.mapLeft( (p_203092_) -> { + return (LevelChunk) p_203092_.get( p_203092_.size() / 2 ); + } ); -+ }, this.f_140135_ ); ++ }, this.mainThreadExecutor ); + } + + @Nullable -+ ChunkHolder m_140176_(long p_140177_, int p_140178_, @Nullable ChunkHolder p_140179_, int p_140180_) { -+ if (p_140180_ > f_140127_ && p_140178_ > f_140127_) { ++ ChunkHolder updateChunkScheduling(long p_140177_, int p_140178_, @Nullable ChunkHolder p_140179_, int p_140180_) { ++ if (p_140180_ > MAX_CHUNK_DISTANCE && p_140178_ > MAX_CHUNK_DISTANCE) { + return p_140179_; + } else { + if (p_140179_ != null) { -+ p_140179_.m_140027_( p_140178_ ); ++ p_140179_.setTicketLevel( p_140178_ ); + } + + if (p_140179_ != null) { -+ if (p_140178_ > f_140127_) { -+ this.f_140139_.add( p_140177_ ); ++ if (p_140178_ > MAX_CHUNK_DISTANCE) { ++ this.toDrop.add( p_140177_ ); + } else { -+ this.f_140139_.remove( p_140177_ ); ++ this.toDrop.remove( p_140177_ ); + } + } + -+ if (p_140178_ <= f_140127_ && p_140179_ == null) { -+ p_140179_ = this.f_140131_.remove( p_140177_ ); ++ if (p_140178_ <= MAX_CHUNK_DISTANCE && p_140179_ == null) { ++ p_140179_ = this.pendingUnloads.remove( p_140177_ ); + if (p_140179_ != null) { -+ p_140179_.m_140027_( p_140178_ ); ++ p_140179_.setTicketLevel( p_140178_ ); + } else { -+ p_140179_ = new ChunkHolder( new ChunkPos( p_140177_ ), p_140178_, this.f_140133_, this.f_140134_, this.f_140141_, this ); ++ p_140179_ = new ChunkHolder( new ChunkPos( p_140177_ ), p_140178_, this.level, this.lightEngine, this.queueSorter, this ); + } + -+ this.f_140129_.put( p_140177_, p_140179_ ); -+ this.f_140140_ = true; ++ this.updatingChunkMap.put( p_140177_, p_140179_ ); ++ this.modified = true; + } + + return p_140179_; @@ -1040,17 +1040,17 @@ + + public void close() throws IOException { + try { -+ this.f_140141_.close(); -+ this.f_140138_.close(); ++ this.queueSorter.close(); ++ this.poiManager.close(); + } finally { + super.close(); + } + + } + -+ protected void m_140318_(boolean p_140319_) { ++ protected void saveAllChunks(boolean p_140319_) { + if (p_140319_) { -+ List list = this.f_140130_.values().stream().filter( ChunkHolder::m_140095_ ).peek( ChunkHolder::m_140096_ ).collect( Collectors.toList() ); ++ List list = this.visibleChunkMap.values().stream().filter( ChunkHolder::wasAccessibleSinceLastSave ).peek( ChunkHolder::refreshAccessibility ).collect( Collectors.toList() ); + MutableBoolean mutableboolean = new MutableBoolean(); + + do { @@ -1058,103 +1058,103 @@ + list.stream().map( (p_203102_) -> { + CompletableFuture completablefuture; + do { -+ completablefuture = p_203102_.m_140090_(); -+ this.f_140135_.m_18701_( completablefuture::isDone ); -+ } while (completablefuture != p_203102_.m_140090_()); ++ completablefuture = p_203102_.getChunkToSave(); ++ this.mainThreadExecutor.managedBlock( completablefuture::isDone ); ++ } while (completablefuture != p_203102_.getChunkToSave()); + + return completablefuture.join(); + } ).filter( (p_203088_) -> { + return p_203088_ instanceof ImposterProtoChunk || p_203088_ instanceof LevelChunk; -+ } ).filter( this::m_140258_ ).forEach( (p_203051_) -> { ++ } ).filter( this::save ).forEach( (p_203051_) -> { + mutableboolean.setTrue(); + } ); + } while (mutableboolean.isTrue()); + -+ this.m_140353_( () -> { ++ this.processUnloads( () -> { + return true; + } ); -+ this.m_63514_(); ++ this.flushWorker(); + } else { -+ this.f_140130_.values().forEach( this::m_198874_ ); ++ this.visibleChunkMap.values().forEach( this::saveChunkIfNeeded ); + } + + } + -+ protected void m_140280_(BooleanSupplier p_140281_) { -+ ProfilerFiller profilerfiller = this.f_140133_.m_46473_(); -+ profilerfiller.m_6180_( "poi" ); -+ this.f_140138_.m_6202_( p_140281_ ); -+ profilerfiller.m_6182_( "chunk_unload" ); -+ if (!this.f_140133_.m_7441_()) { -+ this.m_140353_( p_140281_ ); ++ protected void tick(BooleanSupplier p_140281_) { ++ ProfilerFiller profilerfiller = this.level.getProfiler(); ++ profilerfiller.push( "poi" ); ++ this.poiManager.tick( p_140281_ ); ++ profilerfiller.popPush( "chunk_unload" ); ++ if (!this.level.noSave()) { ++ this.processUnloads( p_140281_ ); + } + -+ profilerfiller.m_7238_(); ++ profilerfiller.pop(); + } + -+ public boolean m_201907_() { -+ return this.f_140134_.m_142182_() || !this.f_140131_.isEmpty() || !this.f_140129_.isEmpty() || this.f_140138_.m_202164_() || !this.f_140139_.isEmpty() || !this.f_140125_.isEmpty() || this.f_140141_.m_201909_() || this.f_140145_.m_201911_(); ++ public boolean hasWork() { ++ return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() || !this.unloadQueue.isEmpty() || this.queueSorter.hasWork() || this.distanceManager.hasTickets(); + } + -+ private void m_140353_(BooleanSupplier p_140354_) { -+ LongIterator longiterator = this.f_140139_.iterator(); ++ private void processUnloads(BooleanSupplier p_140354_) { ++ LongIterator longiterator = this.toDrop.iterator(); + -+ for (int i = 0; longiterator.hasNext() && (p_140354_.getAsBoolean() || i < 200 || this.f_140139_.size() > 2000); longiterator.remove()) { ++ for (int i = 0; longiterator.hasNext() && (p_140354_.getAsBoolean() || i < 200 || this.toDrop.size() > 2000); longiterator.remove()) { + long j = longiterator.nextLong(); -+ ChunkHolder chunkholder = this.f_140129_.remove( j ); ++ ChunkHolder chunkholder = this.updatingChunkMap.remove( j ); if (chunkholder != null) { -- LevelChunk levelchunk = chunkholder.m_140085_(); +- LevelChunk levelchunk = chunkholder.getTickingChunk(); - if (levelchunk != null) { -- this.m_183760_(p_183755_, p_183757_, levelchunk); +- this.playerLoadedChunk(p_183755_, p_183757_, levelchunk); - } - -- DebugPackets.m_133676_(this.f_140133_, p_183756_); +- DebugPackets.sendPoiPacketsForChunk(this.level, p_183756_); - } - } - - if (!p_183759_ && p_183758_) { -- p_183755_.m_9088_(p_183756_); +- p_183755_.untrackChunk(p_183756_); - } - - } - } - -- public int m_140394_() { -- return this.f_140130_.size(); +- public int size() { +- return this.visibleChunkMap.size(); - } - -- public net.minecraft.server.level.DistanceManager m_143145_() { -- return this.f_140145_; +- public net.minecraft.server.level.DistanceManager getDistanceManager() { +- return this.distanceManager; - } - -- protected Iterable m_140416_() { -- return Iterables.unmodifiableIterable(this.f_140130_.values()); +- protected Iterable getChunks() { +- return Iterables.unmodifiableIterable(this.visibleChunkMap.values()); - } - -- void m_140274_(Writer p_140275_) throws IOException { -- CsvOutput csvoutput = CsvOutput.m_13619_().m_13630_("x").m_13630_("z").m_13630_("level").m_13630_("in_memory").m_13630_("status").m_13630_("full_status").m_13630_("accessible_ready").m_13630_("ticking_ready").m_13630_("entity_ticking_ready").m_13630_("ticket").m_13630_("spawning").m_13630_("block_entity_count").m_13630_("ticking_ticket").m_13630_("ticking_level").m_13630_("block_ticks").m_13630_("fluid_ticks").m_13628_(p_140275_); -- TickingTracker tickingtracker = this.f_140145_.m_183915_(); +- void dumpChunks(Writer p_140275_) throws IOException { +- CsvOutput csvoutput = CsvOutput.builder().addColumn("x").addColumn("z").addColumn("level").addColumn("in_memory").addColumn("status").addColumn("full_status").addColumn("accessible_ready").addColumn("ticking_ready").addColumn("entity_ticking_ready").addColumn("ticket").addColumn("spawning").addColumn("block_entity_count").addColumn("ticking_ticket").addColumn("ticking_level").addColumn("block_ticks").addColumn("fluid_ticks").build(p_140275_); +- TickingTracker tickingtracker = this.distanceManager.tickingTracker(); - -- for(Entry entry : this.f_140130_.long2ObjectEntrySet()) { +- for(Entry entry : this.visibleChunkMap.long2ObjectEntrySet()) { - long i = entry.getLongKey(); - ChunkPos chunkpos = new ChunkPos(i); - ChunkHolder chunkholder = entry.getValue(); -- Optional optional = Optional.ofNullable(chunkholder.m_140089_()); +- Optional optional = Optional.ofNullable(chunkholder.getLastAvailable()); - Optional optional1 = optional.flatMap((p_212880_) -> { - return p_212880_ instanceof LevelChunk ? Optional.of((LevelChunk)p_212880_) : Optional.empty(); - }); -- csvoutput.m_13624_(chunkpos.f_45578_, chunkpos.f_45579_, chunkholder.m_140093_(), optional.isPresent(), optional.map(ChunkAccess::m_6415_).orElse((ChunkStatus)null), optional1.map(LevelChunk::m_6708_).orElse((ChunkHolder.FullChunkStatus)null), m_140278_(chunkholder.m_140082_()), m_140278_(chunkholder.m_140026_()), m_140278_(chunkholder.m_140073_()), this.f_140145_.m_140838_(i), this.m_183879_(chunkpos), optional1.map((p_203074_) -> { -- return p_203074_.m_62954_().size(); -- }).orElse(0), tickingtracker.m_184175_(i), tickingtracker.m_6172_(i), optional1.map((p_212886_) -> { -- return p_212886_.m_183531_().m_183574_(); +- csvoutput.writeRow(chunkpos.x, chunkpos.z, chunkholder.getTicketLevel(), optional.isPresent(), optional.map(ChunkAccess::getStatus).orElse((ChunkStatus)null), optional1.map(LevelChunk::getFullStatus).orElse((ChunkHolder.FullChunkStatus)null), printFuture(chunkholder.getFullChunkFuture()), printFuture(chunkholder.getTickingChunkFuture()), printFuture(chunkholder.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkpos), optional1.map((p_203074_) -> { +- return p_203074_.getBlockEntities().size(); +- }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((p_212886_) -> { +- return p_212886_.getBlockTicks().count(); - }).orElse(0), optional1.map((p_212882_) -> { -- return p_212882_.m_183526_().m_183574_(); +- return p_212882_.getFluidTicks().count(); - }).orElse(0)); - } - - } - -- private static String m_140278_(CompletableFuture> p_140279_) { +- private static String printFuture(CompletableFuture> p_140279_) { - try { - Either either = p_140279_.getNow((Either)null); - return either != null ? either.map((p_212867_) -> { @@ -1170,18 +1170,18 @@ - } - - @Nullable -- private CompoundTag m_140427_(ChunkPos p_140428_) throws IOException { -- CompoundTag compoundtag = this.m_63512_(p_140428_); -- return compoundtag == null ? null : this.m_188288_(this.f_140133_.m_46472_(), this.f_140137_, compoundtag, this.f_140136_.m_187743_()); +- private CompoundTag readChunk(ChunkPos p_140428_) throws IOException { +- CompoundTag compoundtag = this.read(p_140428_); +- return compoundtag == null ? null : this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, compoundtag, this.generator.getTypeNameForDataFixer()); - } - -- boolean m_183879_(ChunkPos p_183880_) { -- long i = p_183880_.m_45588_(); -- if (!this.f_140145_.m_140847_(i)) { +- boolean anyPlayerCloseEnoughForSpawning(ChunkPos p_183880_) { +- long i = p_183880_.toLong(); +- if (!this.distanceManager.hasPlayersNearby(i)) { - return false; - } else { -- for(ServerPlayer serverplayer : this.f_140149_.m_183926_(i)) { -- if (this.m_183751_(serverplayer, p_183880_)) { +- for(ServerPlayer serverplayer : this.playerMap.getPlayers(i)) { +- if (this.playerIsCloseEnoughForSpawning(serverplayer, p_183880_)) { - return true; - } - } @@ -1190,15 +1190,15 @@ - } - } - -- public List m_183888_(ChunkPos p_183889_) { -- long i = p_183889_.m_45588_(); -- if (!this.f_140145_.m_140847_(i)) { +- public List getPlayersCloseForSpawning(ChunkPos p_183889_) { +- long i = p_183889_.toLong(); +- if (!this.distanceManager.hasPlayersNearby(i)) { - return List.of(); - } else { - Builder builder = ImmutableList.builder(); - -- for(ServerPlayer serverplayer : this.f_140149_.m_183926_(i)) { -- if (this.m_183751_(serverplayer, p_183889_)) { +- for(ServerPlayer serverplayer : this.playerMap.getPlayers(i)) { +- if (this.playerIsCloseEnoughForSpawning(serverplayer, p_183889_)) { - builder.add(serverplayer); - } - } @@ -1207,129 +1207,129 @@ - } - } - -- private boolean m_183751_(ServerPlayer p_183752_, ChunkPos p_183753_) { -- if (p_183752_.m_5833_()) { +- private boolean playerIsCloseEnoughForSpawning(ServerPlayer p_183752_, ChunkPos p_183753_) { +- if (p_183752_.isSpectator()) { - return false; - } else { -- double d0 = m_140226_(p_183753_, p_183752_); +- double d0 = euclideanDistanceSquared(p_183753_, p_183752_); - return d0 < 16384.0D; - } - } - -- private boolean m_140329_(ServerPlayer p_140330_) { -- return p_140330_.m_5833_() && !this.f_140133_.m_46469_().m_46207_(GameRules.f_46146_); +- private boolean skipPlayer(ServerPlayer p_140330_) { +- return p_140330_.isSpectator() && !this.level.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS); - } - -- void m_140192_(ServerPlayer p_140193_, boolean p_140194_) { -- boolean flag = this.m_140329_(p_140193_); -- boolean flag1 = this.f_140149_.m_8260_(p_140193_); -- int i = SectionPos.m_123171_(p_140193_.m_146903_()); -- int j = SectionPos.m_123171_(p_140193_.m_146907_()); +- void updatePlayerStatus(ServerPlayer p_140193_, boolean p_140194_) { +- boolean flag = this.skipPlayer(p_140193_); +- boolean flag1 = this.playerMap.ignoredOrUnknown(p_140193_); +- int i = SectionPos.blockToSectionCoord(p_140193_.getBlockX()); +- int j = SectionPos.blockToSectionCoord(p_140193_.getBlockZ()); - if (p_140194_) { -- this.f_140149_.m_8252_(ChunkPos.m_45589_(i, j), p_140193_, flag); -- this.m_140373_(p_140193_); +- this.playerMap.addPlayer(ChunkPos.asLong(i, j), p_140193_, flag); +- this.updatePlayerPos(p_140193_); - if (!flag) { -- this.f_140145_.m_140802_(SectionPos.m_123194_(p_140193_), p_140193_); +- this.distanceManager.addPlayer(SectionPos.of(p_140193_), p_140193_); - } - } else { -- SectionPos sectionpos = p_140193_.m_8965_(); -- this.f_140149_.m_8249_(sectionpos.m_123251_().m_45588_(), p_140193_); +- SectionPos sectionpos = p_140193_.getLastSectionPos(); +- this.playerMap.removePlayer(sectionpos.chunk().toLong(), p_140193_); - if (!flag1) { -- this.f_140145_.m_140828_(sectionpos, p_140193_); +- this.distanceManager.removePlayer(sectionpos, p_140193_); - } - } - -- for(int l = i - this.f_140126_ - 1; l <= i + this.f_140126_ + 1; ++l) { -- for(int k = j - this.f_140126_ - 1; k <= j + this.f_140126_ + 1; ++k) { -- if (m_200878_(l, k, i, j, this.f_140126_)) { +- for(int l = i - this.viewDistance - 1; l <= i + this.viewDistance + 1; ++l) { +- for(int k = j - this.viewDistance - 1; k <= j + this.viewDistance + 1; ++k) { +- if (isChunkInRange(l, k, i, j, this.viewDistance)) { - ChunkPos chunkpos = new ChunkPos(l, k); -- this.m_183754_(p_140193_, chunkpos, new MutableObject<>(), !p_140194_, p_140194_); +- this.updateChunkTracking(p_140193_, chunkpos, new MutableObject<>(), !p_140194_, p_140194_); - } - } - } - - } - -- private SectionPos m_140373_(ServerPlayer p_140374_) { -- SectionPos sectionpos = SectionPos.m_123194_(p_140374_); -- p_140374_.m_9119_(sectionpos); -- p_140374_.f_8906_.m_141995_(new ClientboundSetChunkCacheCenterPacket(sectionpos.m_123170_(), sectionpos.m_123222_())); +- private SectionPos updatePlayerPos(ServerPlayer p_140374_) { +- SectionPos sectionpos = SectionPos.of(p_140374_); +- p_140374_.setLastSectionPos(sectionpos); +- p_140374_.connection.send(new ClientboundSetChunkCacheCenterPacket(sectionpos.x(), sectionpos.z())); - return sectionpos; - } - -- public void m_140184_(ServerPlayer p_140185_) { -- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -- if (chunkmap$trackedentity.f_140472_ == p_140185_) { -- chunkmap$trackedentity.m_140487_(this.f_140133_.m_6907_()); +- public void move(ServerPlayer p_140185_) { +- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { +- if (chunkmap$trackedentity.entity == p_140185_) { +- chunkmap$trackedentity.updatePlayers(this.level.players()); - } else { -- chunkmap$trackedentity.m_140497_(p_140185_); +- chunkmap$trackedentity.updatePlayer(p_140185_); - } - } - -- int i2 = SectionPos.m_123171_(p_140185_.m_146903_()); -- int j2 = SectionPos.m_123171_(p_140185_.m_146907_()); -- SectionPos sectionpos = p_140185_.m_8965_(); -- SectionPos sectionpos1 = SectionPos.m_123194_(p_140185_); -- long i = sectionpos.m_123251_().m_45588_(); -- long j = sectionpos1.m_123251_().m_45588_(); -- boolean flag = this.f_140149_.m_8262_(p_140185_); -- boolean flag1 = this.m_140329_(p_140185_); -- boolean flag2 = sectionpos.m_123252_() != sectionpos1.m_123252_(); +- int i2 = SectionPos.blockToSectionCoord(p_140185_.getBlockX()); +- int j2 = SectionPos.blockToSectionCoord(p_140185_.getBlockZ()); +- SectionPos sectionpos = p_140185_.getLastSectionPos(); +- SectionPos sectionpos1 = SectionPos.of(p_140185_); +- long i = sectionpos.chunk().toLong(); +- long j = sectionpos1.chunk().toLong(); +- boolean flag = this.playerMap.ignored(p_140185_); +- boolean flag1 = this.skipPlayer(p_140185_); +- boolean flag2 = sectionpos.asLong() != sectionpos1.asLong(); - if (flag2 || flag != flag1) { -- this.m_140373_(p_140185_); +- this.updatePlayerPos(p_140185_); - if (!flag) { -- this.f_140145_.m_140828_(sectionpos, p_140185_); +- this.distanceManager.removePlayer(sectionpos, p_140185_); - } - - if (!flag1) { -- this.f_140145_.m_140802_(sectionpos1, p_140185_); +- this.distanceManager.addPlayer(sectionpos1, p_140185_); - } - - if (!flag && flag1) { -- this.f_140149_.m_8256_(p_140185_); +- this.playerMap.ignorePlayer(p_140185_); - } - - if (flag && !flag1) { -- this.f_140149_.m_8258_(p_140185_); +- this.playerMap.unIgnorePlayer(p_140185_); - } - - if (i != j) { -- this.f_140149_.m_8245_(i, j, p_140185_); +- this.playerMap.updatePlayer(i, j, p_140185_); - } - } - -- int k = sectionpos.m_123170_(); -- int l = sectionpos.m_123222_(); -- if (Math.abs(k - i2) <= this.f_140126_ * 2 && Math.abs(l - j2) <= this.f_140126_ * 2) { -- int l2 = Math.min(i2, k) - this.f_140126_ - 1; -- int j3 = Math.min(j2, l) - this.f_140126_ - 1; -- int k3 = Math.max(i2, k) + this.f_140126_ + 1; -- int l3 = Math.max(j2, l) + this.f_140126_ + 1; +- int k = sectionpos.x(); +- int l = sectionpos.z(); +- if (Math.abs(k - i2) <= this.viewDistance * 2 && Math.abs(l - j2) <= this.viewDistance * 2) { +- int l2 = Math.min(i2, k) - this.viewDistance - 1; +- int j3 = Math.min(j2, l) - this.viewDistance - 1; +- int k3 = Math.max(i2, k) + this.viewDistance + 1; +- int l3 = Math.max(j2, l) + this.viewDistance + 1; - - for(int k1 = l2; k1 <= k3; ++k1) { - for(int l1 = j3; l1 <= l3; ++l1) { -- boolean flag5 = m_200878_(k1, l1, k, l, this.f_140126_); -- boolean flag6 = m_200878_(k1, l1, i2, j2, this.f_140126_); -- this.m_183754_(p_140185_, new ChunkPos(k1, l1), new MutableObject<>(), flag5, flag6); +- boolean flag5 = isChunkInRange(k1, l1, k, l, this.viewDistance); +- boolean flag6 = isChunkInRange(k1, l1, i2, j2, this.viewDistance); +- this.updateChunkTracking(p_140185_, new ChunkPos(k1, l1), new MutableObject<>(), flag5, flag6); - } - } - } else { -- for(int i1 = k - this.f_140126_ - 1; i1 <= k + this.f_140126_ + 1; ++i1) { -- for(int j1 = l - this.f_140126_ - 1; j1 <= l + this.f_140126_ + 1; ++j1) { -- if (m_200878_(i1, j1, k, l, this.f_140126_)) { +- for(int i1 = k - this.viewDistance - 1; i1 <= k + this.viewDistance + 1; ++i1) { +- for(int j1 = l - this.viewDistance - 1; j1 <= l + this.viewDistance + 1; ++j1) { +- if (isChunkInRange(i1, j1, k, l, this.viewDistance)) { - boolean flag3 = true; - boolean flag4 = false; -- this.m_183754_(p_140185_, new ChunkPos(i1, j1), new MutableObject<>(), true, false); +- this.updateChunkTracking(p_140185_, new ChunkPos(i1, j1), new MutableObject<>(), true, false); - } - } - } - -- for(int k2 = i2 - this.f_140126_ - 1; k2 <= i2 + this.f_140126_ + 1; ++k2) { -- for(int i3 = j2 - this.f_140126_ - 1; i3 <= j2 + this.f_140126_ + 1; ++i3) { -- if (m_200878_(k2, i3, i2, j2, this.f_140126_)) { +- for(int k2 = i2 - this.viewDistance - 1; k2 <= i2 + this.viewDistance + 1; ++k2) { +- for(int i3 = j2 - this.viewDistance - 1; i3 <= j2 + this.viewDistance + 1; ++i3) { +- if (isChunkInRange(k2, i3, i2, j2, this.viewDistance)) { - boolean flag7 = false; - boolean flag8 = true; -- this.m_183754_(p_140185_, new ChunkPos(k2, i3), new MutableObject<>(), false, true); +- this.updateChunkTracking(p_140185_, new ChunkPos(k2, i3), new MutableObject<>(), false, true); - } - } - } @@ -1337,13 +1337,13 @@ - - } - -- public List m_183262_(ChunkPos p_183801_, boolean p_183802_) { -- Set set = this.f_140149_.m_183926_(p_183801_.m_45588_()); +- public List getPlayers(ChunkPos p_183801_, boolean p_183802_) { +- Set set = this.playerMap.getPlayers(p_183801_.toLong()); - Builder builder = ImmutableList.builder(); - - for(ServerPlayer serverplayer : set) { -- SectionPos sectionpos = serverplayer.m_8965_(); -- if (p_183802_ && m_183828_(p_183801_.f_45578_, p_183801_.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), this.f_140126_) || !p_183802_ && m_200878_(p_183801_.f_45578_, p_183801_.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), this.f_140126_)) { +- SectionPos sectionpos = serverplayer.getLastSectionPos(); +- if (p_183802_ && isChunkOnRangeBorder(p_183801_.x, p_183801_.z, sectionpos.x(), sectionpos.z(), this.viewDistance) || !p_183802_ && isChunkInRange(p_183801_.x, p_183801_.z, sectionpos.x(), sectionpos.z(), this.viewDistance)) { - builder.add(serverplayer); - } - } @@ -1351,25 +1351,25 @@ - return builder.build(); - } - -- protected void m_140199_(Entity p_140200_) { +- protected void addEntity(Entity p_140200_) { - if (!(p_140200_ instanceof EnderDragonPart)) { -- EntityType entitytype = p_140200_.m_6095_(); -- int i = entitytype.m_20681_() * 16; +- EntityType entitytype = p_140200_.getType(); +- int i = entitytype.clientTrackingRange() * 16; - if (i != 0) { -- int j = entitytype.m_20682_(); -- if (this.f_140150_.containsKey(p_140200_.m_142049_())) { -- throw (IllegalStateException)Util.m_137570_(new IllegalStateException("Entity is already tracked!")); +- int j = entitytype.updateInterval(); +- if (this.entityMap.containsKey(p_140200_.getId())) { +- throw (IllegalStateException)Util.pauseInIde(new IllegalStateException("Entity is already tracked!")); - } else { -- ChunkMap.TrackedEntity chunkmap$trackedentity = new ChunkMap.TrackedEntity(p_140200_, i, j, entitytype.m_20683_()); -- this.f_140150_.put(p_140200_.m_142049_(), chunkmap$trackedentity); -- chunkmap$trackedentity.m_140487_(this.f_140133_.m_6907_()); +- ChunkMap.TrackedEntity chunkmap$trackedentity = new ChunkMap.TrackedEntity(p_140200_, i, j, entitytype.trackDeltas()); +- this.entityMap.put(p_140200_.getId(), chunkmap$trackedentity); +- chunkmap$trackedentity.updatePlayers(this.level.players()); - if (p_140200_ instanceof ServerPlayer) { - ServerPlayer serverplayer = (ServerPlayer)p_140200_; -- this.m_140192_(serverplayer, true); +- this.updatePlayerStatus(serverplayer, true); - -- for(ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.f_140150_.values()) { -- if (chunkmap$trackedentity1.f_140472_ != serverplayer) { -- chunkmap$trackedentity1.m_140497_(serverplayer); +- for(ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.entityMap.values()) { +- if (chunkmap$trackedentity1.entity != serverplayer) { +- chunkmap$trackedentity1.updatePlayer(serverplayer); - } - } - } @@ -1379,89 +1379,89 @@ - } - } - -- protected void m_140331_(Entity p_140332_) { +- protected void removeEntity(Entity p_140332_) { - if (p_140332_ instanceof ServerPlayer) { - ServerPlayer serverplayer = (ServerPlayer)p_140332_; -- this.m_140192_(serverplayer, false); +- this.updatePlayerStatus(serverplayer, false); - -- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -- chunkmap$trackedentity.m_140485_(serverplayer); +- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { +- chunkmap$trackedentity.removePlayer(serverplayer); - } - } - -- ChunkMap.TrackedEntity chunkmap$trackedentity1 = this.f_140150_.remove(p_140332_.m_142049_()); +- ChunkMap.TrackedEntity chunkmap$trackedentity1 = this.entityMap.remove(p_140332_.getId()); - if (chunkmap$trackedentity1 != null) { -- chunkmap$trackedentity1.m_140482_(); +- chunkmap$trackedentity1.broadcastRemoved(); - } - - } - -- protected void m_140421_() { +- protected void tick() { - List list = Lists.newArrayList(); -- List list1 = this.f_140133_.m_6907_(); +- List list1 = this.level.players(); - -- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -- SectionPos sectionpos = chunkmap$trackedentity.f_140474_; -- SectionPos sectionpos1 = SectionPos.m_123194_(chunkmap$trackedentity.f_140472_); +- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { +- SectionPos sectionpos = chunkmap$trackedentity.lastSectionPos; +- SectionPos sectionpos1 = SectionPos.of(chunkmap$trackedentity.entity); - boolean flag = !Objects.equals(sectionpos, sectionpos1); - if (flag) { -- chunkmap$trackedentity.m_140487_(list1); -- Entity entity = chunkmap$trackedentity.f_140472_; +- chunkmap$trackedentity.updatePlayers(list1); +- Entity entity = chunkmap$trackedentity.entity; - if (entity instanceof ServerPlayer) { - list.add((ServerPlayer)entity); - } - -- chunkmap$trackedentity.f_140474_ = sectionpos1; +- chunkmap$trackedentity.lastSectionPos = sectionpos1; - } - -- if (flag || this.f_140145_.m_183913_(sectionpos1.m_123251_().m_45588_())) { -- chunkmap$trackedentity.f_140471_.m_8533_(); +- if (flag || this.distanceManager.inEntityTickingRange(sectionpos1.chunk().toLong())) { +- chunkmap$trackedentity.serverEntity.sendChanges(); - } - } - - if (!list.isEmpty()) { -- for(ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.f_140150_.values()) { -- chunkmap$trackedentity1.m_140487_(list); +- for(ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.entityMap.values()) { +- chunkmap$trackedentity1.updatePlayers(list); - } - } - - } - -- public void m_140201_(Entity p_140202_, Packet p_140203_) { -- ChunkMap.TrackedEntity chunkmap$trackedentity = this.f_140150_.get(p_140202_.m_142049_()); +- public void broadcast(Entity p_140202_, Packet p_140203_) { +- ChunkMap.TrackedEntity chunkmap$trackedentity = this.entityMap.get(p_140202_.getId()); - if (chunkmap$trackedentity != null) { -- chunkmap$trackedentity.m_140489_(p_140203_); +- chunkmap$trackedentity.broadcast(p_140203_); - } - - } - -- protected void m_140333_(Entity p_140334_, Packet p_140335_) { -- ChunkMap.TrackedEntity chunkmap$trackedentity = this.f_140150_.get(p_140334_.m_142049_()); +- protected void broadcastAndSend(Entity p_140334_, Packet p_140335_) { +- ChunkMap.TrackedEntity chunkmap$trackedentity = this.entityMap.get(p_140334_.getId()); - if (chunkmap$trackedentity != null) { -- chunkmap$trackedentity.m_140499_(p_140335_); +- chunkmap$trackedentity.broadcastAndSend(p_140335_); - } - - } - -- private void m_183760_(ServerPlayer p_183761_, MutableObject p_183762_, LevelChunk p_183763_) { +- private void playerLoadedChunk(ServerPlayer p_183761_, MutableObject p_183762_, LevelChunk p_183763_) { - if (p_183762_.getValue() == null) { -- p_183762_.setValue(new ClientboundLevelChunkWithLightPacket(p_183763_, this.f_140134_, (BitSet)null, (BitSet)null, true)); +- p_183762_.setValue(new ClientboundLevelChunkWithLightPacket(p_183763_, this.lightEngine, (BitSet)null, (BitSet)null, true)); - } - -- p_183761_.m_184135_(p_183763_.m_7697_(), p_183762_.getValue()); -- DebugPackets.m_133676_(this.f_140133_, p_183763_.m_7697_()); +- p_183761_.trackChunk(p_183763_.getPos(), p_183762_.getValue()); +- DebugPackets.sendPoiPacketsForChunk(this.level, p_183763_.getPos()); - List list = Lists.newArrayList(); - List list1 = Lists.newArrayList(); - -- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -- Entity entity = chunkmap$trackedentity.f_140472_; -- if (entity != p_183761_ && entity.m_146902_().equals(p_183763_.m_7697_())) { -- chunkmap$trackedentity.m_140497_(p_183761_); -- if (entity instanceof Mob && ((Mob)entity).m_21524_() != null) { +- for(ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { +- Entity entity = chunkmap$trackedentity.entity; +- if (entity != p_183761_ && entity.chunkPosition().equals(p_183763_.getPos())) { +- chunkmap$trackedentity.updatePlayer(p_183761_); +- if (entity instanceof Mob && ((Mob)entity).getLeashHolder() != null) { - list.add(entity); - } - -- if (!entity.m_20197_().isEmpty()) { +- if (!entity.getPassengers().isEmpty()) { - list1.add(entity); - } - } @@ -1469,28 +1469,28 @@ - - if (!list.isEmpty()) { - for(Entity entity1 : list) { -- p_183761_.f_8906_.m_141995_(new ClientboundSetEntityLinkPacket(entity1, ((Mob)entity1).m_21524_())); +- p_183761_.connection.send(new ClientboundSetEntityLinkPacket(entity1, ((Mob)entity1).getLeashHolder())); - } - } - - if (!list1.isEmpty()) { - for(Entity entity2 : list1) { -- p_183761_.f_8906_.m_141995_(new ClientboundSetPassengersPacket(entity2)); +- p_183761_.connection.send(new ClientboundSetPassengersPacket(entity2)); - } - } - - } - -- protected PoiManager m_140424_() { -- return this.f_140138_; +- protected PoiManager getPoiManager() { +- return this.poiManager; - } - -- public String m_182285_() { -- return this.f_182284_; +- public String getStorageName() { +- return this.storageName; - } - -- void m_143075_(ChunkPos p_143076_, ChunkHolder.FullChunkStatus p_143077_) { -- this.f_143031_.m_156794_(p_143076_, p_143077_); +- void onFullChunkStatusChange(ChunkPos p_143076_, ChunkHolder.FullChunkStatus p_143077_) { +- this.chunkStatusListener.onChunkStatusChange(p_143076_, p_143077_); - } - - class DistanceManager extends net.minecraft.server.level.DistanceManager { @@ -1498,288 +1498,288 @@ - super(p_140459_, p_140460_); - } - -- protected boolean m_7009_(long p_140462_) { -- return ChunkMap.this.f_140139_.contains(p_140462_); +- protected boolean isChunkToRemove(long p_140462_) { +- return ChunkMap.this.toDrop.contains(p_140462_); - } - - @Nullable -- protected ChunkHolder m_7316_(long p_140469_) { -- return ChunkMap.this.m_140174_(p_140469_); +- protected ChunkHolder getChunk(long p_140469_) { +- return ChunkMap.this.getUpdatingChunkIfPresent(p_140469_); - } - - @Nullable -- protected ChunkHolder m_7288_(long p_140464_, int p_140465_, @Nullable ChunkHolder p_140466_, int p_140467_) { -- return ChunkMap.this.m_140176_(p_140464_, p_140465_, p_140466_, p_140467_); +- protected ChunkHolder updateChunkScheduling(long p_140464_, int p_140465_, @Nullable ChunkHolder p_140466_, int p_140467_) { +- return ChunkMap.this.updateChunkScheduling(p_140464_, p_140465_, p_140466_, p_140467_); - } - } - - public class TrackedEntity { -- final ServerEntity f_140471_; -- final Entity f_140472_; -- private final int f_140473_; -- SectionPos f_140474_; -- public final Set f_140475_ = Sets.newIdentityHashSet(); +- final ServerEntity serverEntity; +- final Entity entity; +- private final int range; +- SectionPos lastSectionPos; +- public final Set seenBy = Sets.newIdentityHashSet(); - - public TrackedEntity(Entity p_140478_, int p_140479_, int p_140480_, boolean p_140481_) { -- this.f_140471_ = new ServerEntity(ChunkMap.this.f_140133_, p_140478_, p_140480_, p_140481_, this::m_140489_); -- this.f_140472_ = p_140478_; -- this.f_140473_ = p_140479_; -- this.f_140474_ = SectionPos.m_123194_(p_140478_); +- this.serverEntity = new ServerEntity(ChunkMap.this.level, p_140478_, p_140480_, p_140481_, this::broadcast); +- this.entity = p_140478_; +- this.range = p_140479_; +- this.lastSectionPos = SectionPos.of(p_140478_); - } - - public boolean equals(Object p_140506_) { - if (p_140506_ instanceof ChunkMap.TrackedEntity) { -- return ((ChunkMap.TrackedEntity)p_140506_).f_140472_.m_142049_() == this.f_140472_.m_142049_(); +- return ((ChunkMap.TrackedEntity)p_140506_).entity.getId() == this.entity.getId(); - } else { - return false; - } - } - - public int hashCode() { -- return this.f_140472_.m_142049_(); +- return this.entity.getId(); - } - -- public void m_140489_(Packet p_140490_) { -- for(ServerPlayerConnection serverplayerconnection : this.f_140475_) { -- serverplayerconnection.m_141995_(p_140490_); +- public void broadcast(Packet p_140490_) { +- for(ServerPlayerConnection serverplayerconnection : this.seenBy) { +- serverplayerconnection.send(p_140490_); - } - - } - -- public void m_140499_(Packet p_140500_) { -- this.m_140489_(p_140500_); -- if (this.f_140472_ instanceof ServerPlayer) { -- ((ServerPlayer)this.f_140472_).f_8906_.m_141995_(p_140500_); +- public void broadcastAndSend(Packet p_140500_) { +- this.broadcast(p_140500_); +- if (this.entity instanceof ServerPlayer) { +- ((ServerPlayer)this.entity).connection.send(p_140500_); - } - - } - -- public void m_140482_() { -- for(ServerPlayerConnection serverplayerconnection : this.f_140475_) { -- this.f_140471_.m_8534_(serverplayerconnection.m_142253_()); +- public void broadcastRemoved() { +- for(ServerPlayerConnection serverplayerconnection : this.seenBy) { +- this.serverEntity.removePairing(serverplayerconnection.getPlayer()); - } - - } - -- public void m_140485_(ServerPlayer p_140486_) { -- if (this.f_140475_.remove(p_140486_.f_8906_)) { -- this.f_140471_.m_8534_(p_140486_); +- public void removePlayer(ServerPlayer p_140486_) { +- if (this.seenBy.remove(p_140486_.connection)) { +- this.serverEntity.removePairing(p_140486_); - } - - } - -- public void m_140497_(ServerPlayer p_140498_) { -- if (p_140498_ != this.f_140472_) { -- Vec3 vec3 = p_140498_.m_20182_().m_82546_(this.f_140471_.m_8540_()); -- double d0 = (double)Math.min(this.m_140496_(), (ChunkMap.this.f_140126_ - 1) * 16); -- double d1 = vec3.f_82479_ * vec3.f_82479_ + vec3.f_82481_ * vec3.f_82481_; +- public void updatePlayer(ServerPlayer p_140498_) { +- if (p_140498_ != this.entity) { +- Vec3 vec3 = p_140498_.position().subtract(this.serverEntity.sentPos()); +- double d0 = (double)Math.min(this.getEffectiveRange(), (ChunkMap.this.viewDistance - 1) * 16); +- double d1 = vec3.x * vec3.x + vec3.z * vec3.z; - double d2 = d0 * d0; -- boolean flag = d1 <= d2 && this.f_140472_.m_6459_(p_140498_); -+ this.f_140131_.put( j, chunkholder ); -+ this.f_140140_ = true; +- boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(p_140498_); ++ this.pendingUnloads.put( j, chunkholder ); ++ this.modified = true; + ++i; -+ this.m_140181_( j, chunkholder ); ++ this.scheduleUnload( j, chunkholder ); + } + } + -+ int k = Math.max( 0, this.f_140125_.size() - 2000 ); ++ int k = Math.max( 0, this.unloadQueue.size() - 2000 ); + + Runnable runnable; -+ while ((p_140354_.getAsBoolean() || k > 0) && (runnable = this.f_140125_.poll()) != null) { ++ while ((p_140354_.getAsBoolean() || k > 0) && (runnable = this.unloadQueue.poll()) != null) { + --k; + runnable.run(); + } + + int l = 0; -+ ObjectIterator objectiterator = this.f_140130_.values().iterator(); ++ ObjectIterator objectiterator = this.visibleChunkMap.values().iterator(); + + while (l < 20 && p_140354_.getAsBoolean() && objectiterator.hasNext()) { -+ if (this.m_198874_( objectiterator.next() )) { ++ if (this.saveChunkIfNeeded( objectiterator.next() )) { + ++l; + } + } + + } + -+ private void m_140181_(long p_140182_, ChunkHolder p_140183_) { -+ CompletableFuture completablefuture = p_140183_.m_140090_(); ++ private void scheduleUnload(long p_140182_, ChunkHolder p_140183_) { ++ CompletableFuture completablefuture = p_140183_.getChunkToSave(); + completablefuture.thenAcceptAsync( (p_203002_) -> { -+ CompletableFuture completablefuture1 = p_140183_.m_140090_(); ++ CompletableFuture completablefuture1 = p_140183_.getChunkToSave(); + if (completablefuture1 != completablefuture) { -+ this.m_140181_( p_140182_, p_140183_ ); ++ this.scheduleUnload( p_140182_, p_140183_ ); + } else { -+ if (this.f_140131_.remove( p_140182_, p_140183_ ) && p_203002_ != null) { ++ if (this.pendingUnloads.remove( p_140182_, p_140183_ ) && p_203002_ != null) { + if (p_203002_ instanceof LevelChunk) { -+ ((LevelChunk) p_203002_).m_62913_( false ); ++ ((LevelChunk) p_203002_).setLoaded( false ); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.world.ChunkEvent.Unload( p_203002_ ) ); + } + -+ this.m_140258_( p_203002_ ); -+ if (this.f_140132_.remove( p_140182_ ) && p_203002_ instanceof LevelChunk) { ++ this.save( p_203002_ ); ++ if (this.entitiesInLevel.remove( p_140182_ ) && p_203002_ instanceof LevelChunk) { + LevelChunk levelchunk = (LevelChunk) p_203002_; -+ this.f_140133_.m_8712_( levelchunk ); ++ this.level.unload( levelchunk ); + } + -+ this.f_140134_.m_9330_( p_203002_.m_7697_() ); -+ this.f_140134_.m_9409_(); -+ this.f_140144_.m_5511_( p_203002_.m_7697_(), (ChunkStatus) null ); -+ this.f_202981_.remove( p_203002_.m_7697_().m_45588_() ); ++ this.lightEngine.updateChunkStatus( p_203002_.getPos() ); ++ this.lightEngine.tryScheduleUpdate(); ++ this.progressListener.onStatusChange( p_203002_.getPos(), (ChunkStatus) null ); ++ this.chunkSaveCooldowns.remove( p_203002_.getPos().toLong() ); + } + + } -+ }, this.f_140125_::add ).whenComplete( (p_202996_, p_202997_) -> { ++ }, this.unloadQueue::add ).whenComplete( (p_202996_, p_202997_) -> { + if (p_202997_ != null) { -+ f_140128_.error( "Failed to save chunk {}", p_140183_.m_140092_(), p_202997_ ); ++ LOGGER.error( "Failed to save chunk {}", p_140183_.getPos(), p_202997_ ); + } + + } ); + } + -+ protected boolean m_140324_() { -+ if (!this.f_140140_) { ++ protected boolean promoteChunkMap() { ++ if (!this.modified) { + return false; + } else { -+ this.f_140130_ = this.f_140129_.clone(); -+ this.f_140140_ = false; ++ this.visibleChunkMap = this.updatingChunkMap.clone(); ++ this.modified = false; + return true; + } + } + -+ public CompletableFuture> m_140292_(ChunkHolder p_140293_, ChunkStatus p_140294_) { -+ ChunkPos chunkpos = p_140293_.m_140092_(); -+ if (p_140294_ == ChunkStatus.f_62314_) { -+ return this.m_140417_( chunkpos ); ++ public CompletableFuture> schedule(ChunkHolder p_140293_, ChunkStatus p_140294_) { ++ ChunkPos chunkpos = p_140293_.getPos(); ++ if (p_140294_ == ChunkStatus.EMPTY) { ++ return this.scheduleChunkLoad( chunkpos ); + } else { -+ if (p_140294_ == ChunkStatus.f_62323_) { -+ this.f_140145_.m_140792_( TicketType.f_9446_, chunkpos, 33 + ChunkStatus.m_62370_( ChunkStatus.f_62323_ ), chunkpos ); ++ if (p_140294_ == ChunkStatus.LIGHT) { ++ this.distanceManager.addTicket( TicketType.LIGHT, chunkpos, 33 + ChunkStatus.getDistance( ChunkStatus.LIGHT ), chunkpos ); + } + -+ Optional optional = p_140293_.m_140049_( p_140294_.m_62482_(), this ).getNow( ChunkHolder.f_139995_ ).left(); -+ if (optional.isPresent() && optional.get().m_6415_().m_62427_( p_140294_ )) { -+ CompletableFuture> completablefuture = p_140294_.m_62364_( this.f_140133_, this.f_140147_, this.f_140134_, (p_203081_) -> { -+ return this.m_140383_( p_140293_ ); ++ Optional optional = p_140293_.getOrScheduleFuture( p_140294_.getParent(), this ).getNow( ChunkHolder.UNLOADED_CHUNK ).left(); ++ if (optional.isPresent() && optional.get().getStatus().isOrAfter( p_140294_ )) { ++ CompletableFuture> completablefuture = p_140294_.load( this.level, this.structureManager, this.lightEngine, (p_203081_) -> { ++ return this.protoChunkToFullChunk( p_140293_ ); + }, optional.get() ); -+ this.f_140144_.m_5511_( chunkpos, p_140294_ ); ++ this.progressListener.onStatusChange( chunkpos, p_140294_ ); + return completablefuture; + } else { -+ return this.m_140360_( p_140293_, p_140294_ ); ++ return this.scheduleChunkGeneration( p_140293_, p_140294_ ); + } + } + } + -+ private CompletableFuture> m_140417_(ChunkPos p_140418_) { ++ private CompletableFuture> scheduleChunkLoad(ChunkPos p_140418_) { + return CompletableFuture.supplyAsync( () -> { -+ try (co.aikar.timings.Timing ignored = this.f_140133_.timings.chunkLoad.startTimingIfSync()) { // Paper -+ this.f_140133_.m_46473_().m_6174_( "chunkLoad" ); ++ try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoad.startTimingIfSync()) { // Paper ++ this.level.getProfiler().incrementCounter( "chunkLoad" ); + CompoundTag compoundtag; // Paper -+ try (co.aikar.timings.Timing ignored2 = this.f_140133_.timings.chunkIO.startTimingIfSync()) { // Paper start - timings -+ compoundtag = this.m_140427_(p_140418_); ++ try (co.aikar.timings.Timing ignored2 = this.level.timings.chunkIO.startTimingIfSync()) { // Paper start - timings ++ compoundtag = this.readChunk(p_140418_); + } // Paper end + -+ if (compoundtag != null) {try (co.aikar.timings.Timing ignored2 = this.f_140133_.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings -+ boolean flag = compoundtag.m_128425_( "Status", 8 ); ++ if (compoundtag != null) {try (co.aikar.timings.Timing ignored2 = this.level.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings ++ boolean flag = compoundtag.contains( "Status", 8 ); + if (flag) { -+ ChunkAccess chunkaccess = ChunkSerializer.m_188230_( this.f_140133_, this.f_140138_, p_140418_, compoundtag ); -+ this.m_140229_( p_140418_, chunkaccess.m_6415_().m_62494_() ); ++ ChunkAccess chunkaccess = ChunkSerializer.read( this.level, this.poiManager, p_140418_, compoundtag ); ++ this.markPosition( p_140418_, chunkaccess.getStatus().getChunkType() ); + return Either.left( chunkaccess ); + } + -+ f_140128_.error( "Chunk file at {} is missing level data, skipping", (Object) p_140418_ ); ++ LOGGER.error( "Chunk file at {} is missing level data, skipping", (Object) p_140418_ ); + }} // Paper + } catch (ReportedException reportedexception) { + Throwable throwable = reportedexception.getCause(); + if (!(throwable instanceof IOException)) { -+ this.m_140422_( p_140418_ ); ++ this.markPositionReplaceable( p_140418_ ); + throw reportedexception; + } + -+ f_140128_.error( "Couldn't load chunk {}", p_140418_, throwable ); ++ LOGGER.error( "Couldn't load chunk {}", p_140418_, throwable ); + } catch (Exception exception) { -+ f_140128_.error( "Couldn't load chunk {}", p_140418_, exception ); ++ LOGGER.error( "Couldn't load chunk {}", p_140418_, exception ); + } + -+ this.m_140422_( p_140418_ ); -+ return Either.left( new ProtoChunk( p_140418_, UpgradeData.f_63320_, this.f_140133_, this.f_140133_.m_5962_().m_175515_( Registry.f_122885_ ), (BlendingData) null ) ); -+ }, this.f_140135_ ); ++ this.markPositionReplaceable( p_140418_ ); ++ return Either.left( new ProtoChunk( p_140418_, UpgradeData.EMPTY, this.level, this.level.registryAccess().registryOrThrow( Registry.BIOME_REGISTRY ), (BlendingData) null ) ); ++ }, this.mainThreadExecutor ); + } + -+ private void m_140422_(ChunkPos p_140423_) { -+ this.f_140151_.put( p_140423_.m_45588_(), (byte) -1 ); ++ private void markPositionReplaceable(ChunkPos p_140423_) { ++ this.chunkTypeCache.put( p_140423_.toLong(), (byte) -1 ); + } + -+ private byte m_140229_(ChunkPos p_140230_, ChunkStatus.ChunkType p_140231_) { -+ return this.f_140151_.put( p_140230_.m_45588_(), (byte) (p_140231_ == ChunkStatus.ChunkType.PROTOCHUNK ? -1 : 1) ); ++ private byte markPosition(ChunkPos p_140230_, ChunkStatus.ChunkType p_140231_) { ++ return this.chunkTypeCache.put( p_140230_.toLong(), (byte) (p_140231_ == ChunkStatus.ChunkType.PROTOCHUNK ? -1 : 1) ); + } + -+ private CompletableFuture> m_140360_(ChunkHolder p_140361_, ChunkStatus p_140362_) { -+ ChunkPos chunkpos = p_140361_.m_140092_(); -+ CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.m_140210_( chunkpos, p_140362_.m_62488_(), (p_203072_) -> { -+ return this.m_140262_( p_140362_, p_203072_ ); ++ private CompletableFuture> scheduleChunkGeneration(ChunkHolder p_140361_, ChunkStatus p_140362_) { ++ ChunkPos chunkpos = p_140361_.getPos(); ++ CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture( chunkpos, p_140362_.getRange(), (p_203072_) -> { ++ return this.getDependencyStatus( p_140362_, p_203072_ ); + } ); -+ this.f_140133_.m_46473_().m_6525_( () -> { -+ return "chunkGenerate " + p_140362_.m_62467_(); ++ this.level.getProfiler().incrementCounter( () -> { ++ return "chunkGenerate " + p_140362_.getName(); + } ); + Executor executor = (p_203100_) -> { -+ this.f_140142_.m_6937_( ChunkTaskPriorityQueueSorter.m_140642_( p_140361_, p_203100_ ) ); ++ this.worldgenMailbox.tell( ChunkTaskPriorityQueueSorter.message( p_140361_, p_203100_ ) ); + }; + return completablefuture.thenComposeAsync( (p_203016_) -> { + return p_203016_.map( (p_203022_) -> { + try { -+ CompletableFuture> completablefuture1 = p_140362_.m_187788_( executor, this.f_140133_, this.f_140136_, this.f_140147_, this.f_140134_, (p_203062_) -> { -+ return this.m_140383_( p_140361_ ); ++ CompletableFuture> completablefuture1 = p_140362_.generate( executor, this.level, this.generator, this.structureManager, this.lightEngine, (p_203062_) -> { ++ return this.protoChunkToFullChunk( p_140361_ ); + }, p_203022_, false ); -+ this.f_140144_.m_5511_( chunkpos, p_140362_ ); ++ this.progressListener.onStatusChange( chunkpos, p_140362_ ); + return completablefuture1; + } catch (Exception exception) { + exception.getStackTrace(); -+ CrashReport crashreport = CrashReport.m_127521_( exception, "Exception generating new chunk" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Chunk to be generated" ); -+ crashreportcategory.m_128159_( "Location", String.format( "%d,%d", chunkpos.f_45578_, chunkpos.f_45579_ ) ); -+ crashreportcategory.m_128159_( "Position hash", ChunkPos.m_45589_( chunkpos.f_45578_, chunkpos.f_45579_ ) ); -+ crashreportcategory.m_128159_( "Generator", this.f_140136_ ); -+ this.f_140135_.execute( () -> { ++ CrashReport crashreport = CrashReport.forThrowable( exception, "Exception generating new chunk" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Chunk to be generated" ); ++ crashreportcategory.setDetail( "Location", String.format( "%d,%d", chunkpos.x, chunkpos.z ) ); ++ crashreportcategory.setDetail( "Position hash", ChunkPos.asLong( chunkpos.x, chunkpos.z ) ); ++ crashreportcategory.setDetail( "Generator", this.generator ); ++ this.mainThreadExecutor.execute( () -> { + throw new ReportedException( crashreport ); + } ); + throw new ReportedException( crashreport ); + } + }, (p_203010_) -> { -+ this.m_140375_( chunkpos ); ++ this.releaseLightTicket( chunkpos ); + return CompletableFuture.completedFuture( Either.right( p_203010_ ) ); + } ); + }, executor ); + } + -+ protected void m_140375_(ChunkPos p_140376_) { -+ this.f_140135_.m_6937_( Util.m_137474_( () -> { -+ this.f_140145_.m_140823_( TicketType.f_9446_, p_140376_, 33 + ChunkStatus.m_62370_( ChunkStatus.f_62323_ ), p_140376_ ); ++ protected void releaseLightTicket(ChunkPos p_140376_) { ++ this.mainThreadExecutor.tell( Util.name( () -> { ++ this.distanceManager.removeTicket( TicketType.LIGHT, p_140376_, 33 + ChunkStatus.getDistance( ChunkStatus.LIGHT ), p_140376_ ); + }, () -> { + return "release light ticket " + p_140376_; + } ) ); + } + -+ private ChunkStatus m_140262_(ChunkStatus p_140263_, int p_140264_) { ++ private ChunkStatus getDependencyStatus(ChunkStatus p_140263_, int p_140264_) { + ChunkStatus chunkstatus; + if (p_140264_ == 0) { -+ chunkstatus = p_140263_.m_62482_(); ++ chunkstatus = p_140263_.getParent(); + } else { -+ chunkstatus = ChunkStatus.m_156185_( ChunkStatus.m_62370_( p_140263_ ) + p_140264_ ); ++ chunkstatus = ChunkStatus.getStatusAroundFullChunk( ChunkStatus.getDistance( p_140263_ ) + p_140264_ ); + } + + return chunkstatus; + } + -+ private static void m_143064_(ServerLevel p_143065_, List p_143066_) { ++ private static void postLoadProtoChunk(ServerLevel p_143065_, List p_143066_) { + if (!p_143066_.isEmpty()) { + // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities -+ p_143065_.m_143327_( EntityType.m_147045_( p_143066_, p_143065_ ).filter( (entity) -> { ++ p_143065_.addWorldGenChunkEntities( EntityType.loadEntitiesRecursive( p_143066_, p_143065_ ).filter( (entity) -> { + boolean needsRemoval = false; + net.minecraft.server.dedicated.DedicatedServer server = p_143065_.getCraftServer().getServer(); -+ if (!server.m_6997_() && entity instanceof net.minecraft.world.entity.npc.Npc) { -+ entity.m_146870_(); ++ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.Npc) { ++ entity.discard(); + needsRemoval = true; + } -+ if (!server.m_6998_() && (entity instanceof net.minecraft.world.entity.animal.Animal || entity instanceof net.minecraft.world.entity.animal.WaterAnimal)) { -+ entity.m_146870_(); ++ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.Animal || entity instanceof net.minecraft.world.entity.animal.WaterAnimal)) { ++ entity.discard(); + needsRemoval = true; + } + return !needsRemoval; @@ -1789,34 +1789,34 @@ + + } + -+ private CompletableFuture> m_140383_(ChunkHolder p_140384_) { -+ CompletableFuture> completablefuture = p_140384_.m_140047_( ChunkStatus.f_62326_.m_62482_() ); ++ private CompletableFuture> protoChunkToFullChunk(ChunkHolder p_140384_) { ++ CompletableFuture> completablefuture = p_140384_.getFutureIfPresentUnchecked( ChunkStatus.FULL.getParent() ); + return completablefuture.thenApplyAsync( (p_202987_) -> { -+ ChunkStatus chunkstatus = ChunkHolder.m_140074_( p_140384_.m_140093_() ); -+ return !chunkstatus.m_62427_( ChunkStatus.f_62326_ ) ? ChunkHolder.f_139995_ : p_202987_.mapLeft( (p_202990_) -> { -+ try (co.aikar.timings.Timing ignored = f_140133_.timings.chunkPostLoad.startTimingIfSync()) { // Paper -+ ChunkPos chunkpos = p_140384_.m_140092_(); ++ ChunkStatus chunkstatus = ChunkHolder.getStatus( p_140384_.getTicketLevel() ); ++ return !chunkstatus.isOrAfter( ChunkStatus.FULL ) ? ChunkHolder.UNLOADED_CHUNK : p_202987_.mapLeft( (p_202990_) -> { ++ try (co.aikar.timings.Timing ignored = level.timings.chunkPostLoad.startTimingIfSync()) { // Paper ++ ChunkPos chunkpos = p_140384_.getPos(); + ProtoChunk protochunk = (ProtoChunk) p_202990_; + LevelChunk levelchunk; + if (protochunk instanceof ImposterProtoChunk) { -+ levelchunk = ((ImposterProtoChunk) protochunk).m_62768_(); ++ levelchunk = ((ImposterProtoChunk) protochunk).getWrapped(); + } else { -+ levelchunk = new LevelChunk( this.f_140133_, protochunk, (p_203037_) -> { -+ m_143064_( this.f_140133_, protochunk.m_63293_() ); ++ levelchunk = new LevelChunk( this.level, protochunk, (p_203037_) -> { ++ postLoadProtoChunk( this.level, protochunk.getEntities() ); + } ); -+ p_140384_.m_140052_( new ImposterProtoChunk( levelchunk, false ) ); ++ p_140384_.replaceProtoChunk( new ImposterProtoChunk( levelchunk, false ) ); + } + -+ levelchunk.m_62879_( () -> { -+ return ChunkHolder.m_140083_( p_140384_.m_140093_() ); ++ levelchunk.setFullStatus( () -> { ++ return ChunkHolder.getFullChunkStatus( p_140384_.getTicketLevel() ); + } ); -+ levelchunk.m_62952_(); -+ if (this.f_140132_.add( chunkpos.m_45588_() )) { -+ levelchunk.m_62913_( true ); ++ levelchunk.runPostLoad(); ++ if (this.entitiesInLevel.add( chunkpos.toLong() )) { ++ levelchunk.setLoaded( true ); + try { + p_140384_.currentlyLoading = levelchunk; // Forge - bypass the future chain when getChunk is called, this prevents deadlocks. -+ levelchunk.m_156369_(); -+ levelchunk.m_187958_( this.f_140133_ ); ++ levelchunk.registerAllBlockEntitiesAfterLevelLoad(); ++ levelchunk.registerTickContainerInLevel( this.level ); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.world.ChunkEvent.Load( levelchunk ) ); + } finally { + p_140384_.currentlyLoading = null; // Forge - Stop bypassing the future chain. @@ -1827,73 +1827,73 @@ + } // Paper + } ); + }, (p_203095_) -> { -+ this.f_140143_.m_6937_( ChunkTaskPriorityQueueSorter.m_140624_( p_203095_, p_140384_.m_140092_().m_45588_(), p_140384_::m_140093_ ) ); ++ this.mainThreadMailbox.tell( ChunkTaskPriorityQueueSorter.message( p_203095_, p_140384_.getPos().toLong(), p_140384_::getTicketLevel ) ); + } ); + } + -+ public CompletableFuture> m_143053_(ChunkHolder p_143054_) { -+ ChunkPos chunkpos = p_143054_.m_140092_(); -+ CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.m_140210_( chunkpos, 1, (p_203059_) -> { -+ return ChunkStatus.f_62326_; ++ public CompletableFuture> prepareTickingChunk(ChunkHolder p_143054_) { ++ ChunkPos chunkpos = p_143054_.getPos(); ++ CompletableFuture, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture( chunkpos, 1, (p_203059_) -> { ++ return ChunkStatus.FULL; + } ); + CompletableFuture> completablefuture1 = completablefuture.thenApplyAsync( (p_203067_) -> { + return p_203067_.mapLeft( (p_212884_) -> { + return (LevelChunk) p_212884_.get( p_212884_.size() / 2 ); + } ); + }, (p_203084_) -> { -+ this.f_140143_.m_6937_( ChunkTaskPriorityQueueSorter.m_140642_( p_143054_, p_203084_ ) ); ++ this.mainThreadMailbox.tell( ChunkTaskPriorityQueueSorter.message( p_143054_, p_203084_ ) ); + } ).thenApplyAsync( (p_212878_) -> { + return p_212878_.ifLeft( (p_212888_) -> { -+ p_212888_.m_62812_(); -+ this.f_140133_.m_184102_( p_212888_ ); ++ p_212888_.postProcessGeneration(); ++ this.level.startTickingChunk( p_212888_ ); + } ); -+ }, this.f_140135_ ); ++ }, this.mainThreadExecutor ); + completablefuture1.thenAcceptAsync( (p_212860_) -> { + p_212860_.ifLeft( (p_212863_) -> { -+ this.f_140146_.getAndIncrement(); ++ this.tickingGenerated.getAndIncrement(); + MutableObject mutableobject = new MutableObject<>(); -+ this.m_183262_( chunkpos, false ).forEach( (p_212873_) -> { -+ this.m_183760_( p_212873_, mutableobject, p_212863_ ); ++ this.getPlayers( chunkpos, false ).forEach( (p_212873_) -> { ++ this.playerLoadedChunk( p_212873_, mutableobject, p_212863_ ); + } ); + } ); + }, (p_212876_) -> { -+ this.f_140143_.m_6937_( ChunkTaskPriorityQueueSorter.m_140642_( p_143054_, p_212876_ ) ); ++ this.mainThreadMailbox.tell( ChunkTaskPriorityQueueSorter.message( p_143054_, p_212876_ ) ); + } ); + return completablefuture1; + } + -+ public CompletableFuture> m_143109_(ChunkHolder p_143110_) { -+ return this.m_140210_( p_143110_.m_140092_(), 1, ChunkStatus::m_156185_ ).thenApplyAsync( (p_212865_) -> { ++ public CompletableFuture> prepareAccessibleChunk(ChunkHolder p_143110_) { ++ return this.getChunkRangeFuture( p_143110_.getPos(), 1, ChunkStatus::getStatusAroundFullChunk ).thenApplyAsync( (p_212865_) -> { + return p_212865_.mapLeft( (p_212869_) -> { + return (LevelChunk) p_212869_.get( p_212869_.size() / 2 ); + } ); + }, (p_212852_) -> { -+ this.f_140143_.m_6937_( ChunkTaskPriorityQueueSorter.m_140642_( p_143110_, p_212852_ ) ); ++ this.mainThreadMailbox.tell( ChunkTaskPriorityQueueSorter.message( p_143110_, p_212852_ ) ); + } ); + } + -+ public int m_140368_() { -+ return this.f_140146_.get(); ++ public int getTickingGenerated() { ++ return this.tickingGenerated.get(); + } + -+ private boolean m_198874_(ChunkHolder p_198875_) { -+ if (!p_198875_.m_140095_()) { ++ private boolean saveChunkIfNeeded(ChunkHolder p_198875_) { ++ if (!p_198875_.wasAccessibleSinceLastSave()) { + return false; + } else { -+ ChunkAccess chunkaccess = p_198875_.m_140090_().getNow( (ChunkAccess) null ); ++ ChunkAccess chunkaccess = p_198875_.getChunkToSave().getNow( (ChunkAccess) null ); + if (!(chunkaccess instanceof ImposterProtoChunk) && !(chunkaccess instanceof LevelChunk)) { + return false; + } else { -+ long i = chunkaccess.m_7697_().m_45588_(); -+ long j = this.f_202981_.getOrDefault( i, -1L ); ++ long i = chunkaccess.getPos().toLong(); ++ long j = this.chunkSaveCooldowns.getOrDefault( i, -1L ); + long k = System.currentTimeMillis(); + if (k < j) { + return false; + } else { -+ boolean flag = this.m_140258_( chunkaccess ); -+ p_198875_.m_140096_(); ++ boolean flag = this.save( chunkaccess ); ++ p_198875_.refreshAccessibility(); + if (flag) { -+ this.f_202981_.put( i, k + 10000L ); ++ this.chunkSaveCooldowns.put( i, k + 10000L ); + } + + return flag; @@ -1902,141 +1902,141 @@ + } + } + -+ public boolean m_140258_(ChunkAccess p_140259_) { //Magma - private -> public -+ this.f_140138_.m_63796_( p_140259_.m_7697_() ); -+ if (!p_140259_.m_6344_()) { ++ public boolean save(ChunkAccess p_140259_) { //Magma - private -> public ++ this.poiManager.flush( p_140259_.getPos() ); ++ if (!p_140259_.isUnsaved()) { + return false; + } else { -+ p_140259_.m_8092_( false ); -+ ChunkPos chunkpos = p_140259_.m_7697_(); ++ p_140259_.setUnsaved( false ); ++ ChunkPos chunkpos = p_140259_.getPos(); + + try { -+ ChunkStatus chunkstatus = p_140259_.m_6415_(); -+ if (chunkstatus.m_62494_() != ChunkStatus.ChunkType.LEVELCHUNK) { -+ if (this.m_140425_( chunkpos )) { ++ ChunkStatus chunkstatus = p_140259_.getStatus(); ++ if (chunkstatus.getChunkType() != ChunkStatus.ChunkType.LEVELCHUNK) { ++ if (this.isExistingChunkFull( chunkpos )) { + return false; + } + -+ if (chunkstatus == ChunkStatus.f_62314_ && p_140259_.m_6633_().values().stream().noneMatch( StructureStart::m_73603_ )) { ++ if (chunkstatus == ChunkStatus.EMPTY && p_140259_.getAllStarts().values().stream().noneMatch( StructureStart::isValid )) { + return false; + } + } + -+ this.f_140133_.m_46473_().m_6174_( "chunkSave" ); -+ CompoundTag compoundtag = ChunkSerializer.m_63454_( this.f_140133_, p_140259_ ); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.world.ChunkDataEvent.Save( p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.f_140133_, compoundtag ) ); -+ this.m_63502_( chunkpos, compoundtag ); -+ this.m_140229_( chunkpos, chunkstatus.m_62494_() ); ++ this.level.getProfiler().incrementCounter( "chunkSave" ); ++ CompoundTag compoundtag = ChunkSerializer.write( this.level, p_140259_ ); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.world.ChunkDataEvent.Save( p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.level, compoundtag ) ); ++ this.write( chunkpos, compoundtag ); ++ this.markPosition( chunkpos, chunkstatus.getChunkType() ); + return true; + } catch (Exception exception) { -+ f_140128_.error( "Failed to save chunk {},{}", chunkpos.f_45578_, chunkpos.f_45579_, exception ); ++ LOGGER.error( "Failed to save chunk {},{}", chunkpos.x, chunkpos.z, exception ); + return false; + } + } + } + -+ private boolean m_140425_(ChunkPos p_140426_) { -+ byte b0 = this.f_140151_.get( p_140426_.m_45588_() ); ++ private boolean isExistingChunkFull(ChunkPos p_140426_) { ++ byte b0 = this.chunkTypeCache.get( p_140426_.toLong() ); + if (b0 != 0) { + return b0 == 1; + } else { + CompoundTag compoundtag; + try { -+ compoundtag = this.m_140427_( p_140426_ ); ++ compoundtag = this.readChunk( p_140426_ ); + if (compoundtag == null) { -+ this.m_140422_( p_140426_ ); ++ this.markPositionReplaceable( p_140426_ ); + return false; + } + } catch (Exception exception) { -+ f_140128_.error( "Failed to read chunk {}", p_140426_, exception ); -+ this.m_140422_( p_140426_ ); ++ LOGGER.error( "Failed to read chunk {}", p_140426_, exception ); ++ this.markPositionReplaceable( p_140426_ ); + return false; + } + -+ ChunkStatus.ChunkType chunkstatus$chunktype = ChunkSerializer.m_63485_( compoundtag ); -+ return this.m_140229_( p_140426_, chunkstatus$chunktype ) == 1; ++ ChunkStatus.ChunkType chunkstatus$chunktype = ChunkSerializer.getChunkTypeFromTag( compoundtag ); ++ return this.markPosition( p_140426_, chunkstatus$chunktype ) == 1; + } + } + -+ protected void m_140167_(int p_140168_) { -+ int i = Mth.m_14045_( p_140168_ + 1, 3, 33 ); -+ if (i != this.f_140126_) { -+ int j = this.f_140126_; -+ this.f_140126_ = i; -+ this.f_140145_.m_140777_( this.f_140126_ + 1 ); ++ protected void setViewDistance(int p_140168_) { ++ int i = Mth.clamp( p_140168_ + 1, 3, 33 ); ++ if (i != this.viewDistance) { ++ int j = this.viewDistance; ++ this.viewDistance = i; ++ this.distanceManager.updatePlayerTickets( this.viewDistance + 1 ); + -+ for (ChunkHolder chunkholder : this.f_140129_.values()) { -+ ChunkPos chunkpos = chunkholder.m_140092_(); ++ for (ChunkHolder chunkholder : this.updatingChunkMap.values()) { ++ ChunkPos chunkpos = chunkholder.getPos(); + MutableObject mutableobject = new MutableObject<>(); -+ this.m_183262_( chunkpos, false ).forEach( (p_212857_) -> { -+ SectionPos sectionpos = p_212857_.m_8965_(); -+ boolean flag = m_200878_( chunkpos.f_45578_, chunkpos.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), j ); -+ boolean flag1 = m_200878_( chunkpos.f_45578_, chunkpos.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), this.f_140126_ ); -+ this.m_183754_( p_212857_, chunkpos, mutableobject, flag, flag1 ); ++ this.getPlayers( chunkpos, false ).forEach( (p_212857_) -> { ++ SectionPos sectionpos = p_212857_.getLastSectionPos(); ++ boolean flag = isChunkInRange( chunkpos.x, chunkpos.z, sectionpos.x(), sectionpos.z(), j ); ++ boolean flag1 = isChunkInRange( chunkpos.x, chunkpos.z, sectionpos.x(), sectionpos.z(), this.viewDistance ); ++ this.updateChunkTracking( p_212857_, chunkpos, mutableobject, flag, flag1 ); + } ); + } + } + + } + -+ protected void m_183754_(ServerPlayer p_183755_, ChunkPos p_183756_, MutableObject p_183757_, boolean p_183758_, boolean p_183759_) { -+ if (p_183755_.f_19853_ == this.f_140133_) { -+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch( p_183758_, p_183759_, p_183755_, p_183756_, this.f_140133_ ); ++ protected void updateChunkTracking(ServerPlayer p_183755_, ChunkPos p_183756_, MutableObject p_183757_, boolean p_183758_, boolean p_183759_) { ++ if (p_183755_.level == this.level) { ++ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch( p_183758_, p_183759_, p_183755_, p_183756_, this.level ); + if (p_183759_ && !p_183758_) { -+ ChunkHolder chunkholder = this.m_140327_( p_183756_.m_45588_() ); ++ ChunkHolder chunkholder = this.getVisibleChunkIfPresent( p_183756_.toLong() ); + if (chunkholder != null) { -+ LevelChunk levelchunk = chunkholder.m_140085_(); ++ LevelChunk levelchunk = chunkholder.getTickingChunk(); + if (levelchunk != null) { -+ this.m_183760_( p_183755_, p_183757_, levelchunk ); ++ this.playerLoadedChunk( p_183755_, p_183757_, levelchunk ); + } + -+ DebugPackets.m_133676_( this.f_140133_, p_183756_ ); ++ DebugPackets.sendPoiPacketsForChunk( this.level, p_183756_ ); + } + } + + if (!p_183759_ && p_183758_) { -+ p_183755_.m_9088_( p_183756_ ); ++ p_183755_.untrackChunk( p_183756_ ); + } + + } + } + -+ public int m_140394_() { -+ return this.f_140130_.size(); ++ public int size() { ++ return this.visibleChunkMap.size(); + } + -+ public net.minecraft.server.level.DistanceManager m_143145_() { -+ return this.f_140145_; ++ public net.minecraft.server.level.DistanceManager getDistanceManager() { ++ return this.distanceManager; + } + -+ protected Iterable m_140416_() { -+ return Iterables.unmodifiableIterable( this.f_140130_.values() ); ++ protected Iterable getChunks() { ++ return Iterables.unmodifiableIterable( this.visibleChunkMap.values() ); + } + -+ void m_140274_(Writer p_140275_) throws IOException { -+ CsvOutput csvoutput = CsvOutput.m_13619_().m_13630_( "x" ).m_13630_( "z" ).m_13630_( "level" ).m_13630_( "in_memory" ).m_13630_( "status" ).m_13630_( "full_status" ).m_13630_( "accessible_ready" ).m_13630_( "ticking_ready" ).m_13630_( "entity_ticking_ready" ).m_13630_( "ticket" ).m_13630_( "spawning" ).m_13630_( "block_entity_count" ).m_13630_( "ticking_ticket" ).m_13630_( "ticking_level" ).m_13630_( "block_ticks" ).m_13630_( "fluid_ticks" ).m_13628_( p_140275_ ); -+ TickingTracker tickingtracker = this.f_140145_.m_183915_(); ++ void dumpChunks(Writer p_140275_) throws IOException { ++ CsvOutput csvoutput = CsvOutput.builder().addColumn( "x" ).addColumn( "z" ).addColumn( "level" ).addColumn( "in_memory" ).addColumn( "status" ).addColumn( "full_status" ).addColumn( "accessible_ready" ).addColumn( "ticking_ready" ).addColumn( "entity_ticking_ready" ).addColumn( "ticket" ).addColumn( "spawning" ).addColumn( "block_entity_count" ).addColumn( "ticking_ticket" ).addColumn( "ticking_level" ).addColumn( "block_ticks" ).addColumn( "fluid_ticks" ).build( p_140275_ ); ++ TickingTracker tickingtracker = this.distanceManager.tickingTracker(); + -+ for (Entry entry : this.f_140130_.long2ObjectEntrySet()) { ++ for (Entry entry : this.visibleChunkMap.long2ObjectEntrySet()) { + long i = entry.getLongKey(); + ChunkPos chunkpos = new ChunkPos( i ); + ChunkHolder chunkholder = entry.getValue(); -+ Optional optional = Optional.ofNullable( chunkholder.m_140089_() ); ++ Optional optional = Optional.ofNullable( chunkholder.getLastAvailable() ); + Optional optional1 = optional.flatMap( (p_212880_) -> { + return p_212880_ instanceof LevelChunk ? Optional.of( (LevelChunk) p_212880_ ) : Optional.empty(); + } ); -+ csvoutput.m_13624_( chunkpos.f_45578_, chunkpos.f_45579_, chunkholder.m_140093_(), optional.isPresent(), optional.map( ChunkAccess::m_6415_ ).orElse( (ChunkStatus) null ), optional1.map( LevelChunk::m_6708_ ).orElse( (ChunkHolder.FullChunkStatus) null ), m_140278_( chunkholder.m_140082_() ), m_140278_( chunkholder.m_140026_() ), m_140278_( chunkholder.m_140073_() ), this.f_140145_.m_140838_( i ), this.m_183879_( chunkpos ), optional1.map( (p_203074_) -> { -+ return p_203074_.m_62954_().size(); -+ } ).orElse( 0 ), tickingtracker.m_184175_( i ), tickingtracker.m_6172_( i ), optional1.map( (p_212886_) -> { -+ return p_212886_.m_183531_().m_183574_(); ++ csvoutput.writeRow( chunkpos.x, chunkpos.z, chunkholder.getTicketLevel(), optional.isPresent(), optional.map( ChunkAccess::getStatus ).orElse( (ChunkStatus) null ), optional1.map( LevelChunk::getFullStatus ).orElse( (ChunkHolder.FullChunkStatus) null ), printFuture( chunkholder.getFullChunkFuture() ), printFuture( chunkholder.getTickingChunkFuture() ), printFuture( chunkholder.getEntityTickingChunkFuture() ), this.distanceManager.getTicketDebugString( i ), this.anyPlayerCloseEnoughForSpawning( chunkpos ), optional1.map( (p_203074_) -> { ++ return p_203074_.getBlockEntities().size(); ++ } ).orElse( 0 ), tickingtracker.getTicketDebugString( i ), tickingtracker.getLevel( i ), optional1.map( (p_212886_) -> { ++ return p_212886_.getBlockTicks().count(); + } ).orElse( 0 ), optional1.map( (p_212882_) -> { -+ return p_212882_.m_183526_().m_183574_(); ++ return p_212882_.getFluidTicks().count(); + } ).orElse( 0 ) ); + } + + } + -+ private static String m_140278_(CompletableFuture> p_140279_) { ++ private static String printFuture(CompletableFuture> p_140279_) { + try { + Either either = p_140279_.getNow( (Either) null ); + return either != null ? either.map( (p_212867_) -> { @@ -2052,28 +2052,28 @@ + } + + @Nullable -+ private CompoundTag m_140427_(ChunkPos p_140428_) throws IOException { -+ CompoundTag compoundtag = this.m_63512_( p_140428_ ); -+ return compoundtag == null ? null : this.upgradeChunkTag( this.f_140133_.m_46472_(), this.f_140137_, compoundtag, this.f_140136_.m_187743_(), p_140428_, f_140133_ ); // CraftBukkit ++ private CompoundTag readChunk(ChunkPos p_140428_) throws IOException { ++ CompoundTag compoundtag = this.read( p_140428_ ); ++ return compoundtag == null ? null : this.upgradeChunkTag( this.level.dimension(), this.overworldDataStorage, compoundtag, this.generator.getTypeNameForDataFixer(), p_140428_, level ); // CraftBukkit + } + -+ boolean m_183879_(ChunkPos p_183880_) { ++ boolean anyPlayerCloseEnoughForSpawning(ChunkPos p_183880_) { + // Spigot start + return anyPlayerCloseEnoughForSpawning( p_183880_, false ); + } + + boolean anyPlayerCloseEnoughForSpawning(ChunkPos p_183880_, boolean reducedRange) { -+ int chunkRange = f_140133_.spigotConfig.mobSpawnRange; -+ chunkRange = (chunkRange > f_140133_.spigotConfig.viewDistance) ? (byte) f_140133_.spigotConfig.viewDistance : chunkRange; ++ int chunkRange = level.spigotConfig.mobSpawnRange; ++ chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; + chunkRange = (chunkRange > 8) ? 8 : chunkRange; + + double blockRange = (reducedRange) ? Math.pow( chunkRange << 4, 2 ) : 16384.0D; + // Spigot end -+ long i = p_183880_.m_45588_(); -+ if (!this.f_140145_.m_140847_( i )) { ++ long i = p_183880_.toLong(); ++ if (!this.distanceManager.hasPlayersNearby( i )) { + return false; + } else { -+ for (ServerPlayer serverplayer : this.f_140149_.m_183926_( i )) { ++ for (ServerPlayer serverplayer : this.playerMap.getPlayers( i )) { + if (this.playerIsCloseEnoughForSpawning( serverplayer, p_183880_, blockRange )) { // Spigot + return true; + } @@ -2083,14 +2083,14 @@ + } + } + -+ public List m_183888_(ChunkPos p_183889_) { -+ long i = p_183889_.m_45588_(); -+ if (!this.f_140145_.m_140847_( i )) { ++ public List getPlayersCloseForSpawning(ChunkPos p_183889_) { ++ long i = p_183889_.toLong(); ++ if (!this.distanceManager.hasPlayersNearby( i )) { + return List.of(); + } else { + Builder builder = ImmutableList.builder(); + -+ for (ServerPlayer serverplayer : this.f_140149_.m_183926_( i )) { ++ for (ServerPlayer serverplayer : this.playerMap.getPlayers( i )) { + if (this.playerIsCloseEnoughForSpawning( serverplayer, p_183889_, 16384.0D )) { // Spigot + builder.add( serverplayer ); + } @@ -2100,133 +2100,133 @@ + } + } + -+ private boolean m_183751_(ServerPlayer p_183752_, ChunkPos p_183753_) { ++ private boolean playerIsCloseEnoughForSpawning(ServerPlayer p_183752_, ChunkPos p_183753_) { + return this.playerIsCloseEnoughForSpawning( p_183752_, p_183753_, 0D ); + } + + private boolean playerIsCloseEnoughForSpawning(ServerPlayer p_183752_, ChunkPos p_183753_, double range) { // Spigot -+ if (p_183752_.m_5833_()) { ++ if (p_183752_.isSpectator()) { + return false; + } else { -+ double d0 = m_140226_( p_183753_, p_183752_ ); ++ double d0 = euclideanDistanceSquared( p_183753_, p_183752_ ); + return d0 < range; // Spigot + } + } + -+ private boolean m_140329_(ServerPlayer p_140330_) { -+ return p_140330_.m_5833_() && !this.f_140133_.m_46469_().m_46207_( GameRules.f_46146_ ); ++ private boolean skipPlayer(ServerPlayer p_140330_) { ++ return p_140330_.isSpectator() && !this.level.getGameRules().getBoolean( GameRules.RULE_SPECTATORSGENERATECHUNKS ); + } + -+ void m_140192_(ServerPlayer p_140193_, boolean p_140194_) { -+ boolean flag = this.m_140329_( p_140193_ ); -+ boolean flag1 = this.f_140149_.m_8260_( p_140193_ ); -+ int i = SectionPos.m_123171_( p_140193_.m_146903_() ); -+ int j = SectionPos.m_123171_( p_140193_.m_146907_() ); ++ void updatePlayerStatus(ServerPlayer p_140193_, boolean p_140194_) { ++ boolean flag = this.skipPlayer( p_140193_ ); ++ boolean flag1 = this.playerMap.ignoredOrUnknown( p_140193_ ); ++ int i = SectionPos.blockToSectionCoord( p_140193_.getBlockX() ); ++ int j = SectionPos.blockToSectionCoord( p_140193_.getBlockZ() ); + if (p_140194_) { -+ this.f_140149_.m_8252_( ChunkPos.m_45589_( i, j ), p_140193_, flag ); -+ this.m_140373_( p_140193_ ); ++ this.playerMap.addPlayer( ChunkPos.asLong( i, j ), p_140193_, flag ); ++ this.updatePlayerPos( p_140193_ ); + if (!flag) { -+ this.f_140145_.m_140802_( SectionPos.m_123194_( p_140193_ ), p_140193_ ); ++ this.distanceManager.addPlayer( SectionPos.of( p_140193_ ), p_140193_ ); + } + } else { -+ SectionPos sectionpos = p_140193_.m_8965_(); -+ this.f_140149_.m_8249_( sectionpos.m_123251_().m_45588_(), p_140193_ ); ++ SectionPos sectionpos = p_140193_.getLastSectionPos(); ++ this.playerMap.removePlayer( sectionpos.chunk().toLong(), p_140193_ ); + if (!flag1) { -+ this.f_140145_.m_140828_( sectionpos, p_140193_ ); ++ this.distanceManager.removePlayer( sectionpos, p_140193_ ); + } + } + -+ for (int l = i - this.f_140126_ - 1; l <= i + this.f_140126_ + 1; ++l) { -+ for (int k = j - this.f_140126_ - 1; k <= j + this.f_140126_ + 1; ++k) { -+ if (m_200878_( l, k, i, j, this.f_140126_ )) { ++ for (int l = i - this.viewDistance - 1; l <= i + this.viewDistance + 1; ++l) { ++ for (int k = j - this.viewDistance - 1; k <= j + this.viewDistance + 1; ++k) { ++ if (isChunkInRange( l, k, i, j, this.viewDistance )) { + ChunkPos chunkpos = new ChunkPos( l, k ); -+ this.m_183754_( p_140193_, chunkpos, new MutableObject<>(), !p_140194_, p_140194_ ); ++ this.updateChunkTracking( p_140193_, chunkpos, new MutableObject<>(), !p_140194_, p_140194_ ); + } + } + } + + } + -+ private SectionPos m_140373_(ServerPlayer p_140374_) { -+ SectionPos sectionpos = SectionPos.m_123194_( p_140374_ ); -+ p_140374_.m_9119_( sectionpos ); -+ p_140374_.f_8906_.m_141995_( new ClientboundSetChunkCacheCenterPacket( sectionpos.m_123170_(), sectionpos.m_123222_() ) ); ++ private SectionPos updatePlayerPos(ServerPlayer p_140374_) { ++ SectionPos sectionpos = SectionPos.of( p_140374_ ); ++ p_140374_.setLastSectionPos( sectionpos ); ++ p_140374_.connection.send( new ClientboundSetChunkCacheCenterPacket( sectionpos.x(), sectionpos.z() ) ); + return sectionpos; + } + -+ public void m_140184_(ServerPlayer p_140185_) { -+ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -+ if (chunkmap$trackedentity.f_140472_ == p_140185_) { -+ chunkmap$trackedentity.m_140487_( this.f_140133_.m_6907_() ); ++ public void move(ServerPlayer p_140185_) { ++ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { ++ if (chunkmap$trackedentity.entity == p_140185_) { ++ chunkmap$trackedentity.updatePlayers( this.level.players() ); + } else { -+ chunkmap$trackedentity.m_140497_( p_140185_ ); ++ chunkmap$trackedentity.updatePlayer( p_140185_ ); + } + } + -+ int i2 = SectionPos.m_123171_( p_140185_.m_146903_() ); -+ int j2 = SectionPos.m_123171_( p_140185_.m_146907_() ); -+ SectionPos sectionpos = p_140185_.m_8965_(); -+ SectionPos sectionpos1 = SectionPos.m_123194_( p_140185_ ); -+ long i = sectionpos.m_123251_().m_45588_(); -+ long j = sectionpos1.m_123251_().m_45588_(); -+ boolean flag = this.f_140149_.m_8262_( p_140185_ ); -+ boolean flag1 = this.m_140329_( p_140185_ ); -+ boolean flag2 = sectionpos.m_123252_() != sectionpos1.m_123252_(); ++ int i2 = SectionPos.blockToSectionCoord( p_140185_.getBlockX() ); ++ int j2 = SectionPos.blockToSectionCoord( p_140185_.getBlockZ() ); ++ SectionPos sectionpos = p_140185_.getLastSectionPos(); ++ SectionPos sectionpos1 = SectionPos.of( p_140185_ ); ++ long i = sectionpos.chunk().toLong(); ++ long j = sectionpos1.chunk().toLong(); ++ boolean flag = this.playerMap.ignored( p_140185_ ); ++ boolean flag1 = this.skipPlayer( p_140185_ ); ++ boolean flag2 = sectionpos.asLong() != sectionpos1.asLong(); + if (flag2 || flag != flag1) { -+ this.m_140373_( p_140185_ ); ++ this.updatePlayerPos( p_140185_ ); + if (!flag) { -+ this.f_140145_.m_140828_( sectionpos, p_140185_ ); ++ this.distanceManager.removePlayer( sectionpos, p_140185_ ); + } + + if (!flag1) { -+ this.f_140145_.m_140802_( sectionpos1, p_140185_ ); ++ this.distanceManager.addPlayer( sectionpos1, p_140185_ ); + } + + if (!flag && flag1) { -+ this.f_140149_.m_8256_( p_140185_ ); ++ this.playerMap.ignorePlayer( p_140185_ ); + } + + if (flag && !flag1) { -+ this.f_140149_.m_8258_( p_140185_ ); ++ this.playerMap.unIgnorePlayer( p_140185_ ); + } + + if (i != j) { -+ this.f_140149_.m_8245_( i, j, p_140185_ ); ++ this.playerMap.updatePlayer( i, j, p_140185_ ); + } + } + -+ int k = sectionpos.m_123170_(); -+ int l = sectionpos.m_123222_(); -+ if (Math.abs( k - i2 ) <= this.f_140126_ * 2 && Math.abs( l - j2 ) <= this.f_140126_ * 2) { -+ int l2 = Math.min( i2, k ) - this.f_140126_ - 1; -+ int j3 = Math.min( j2, l ) - this.f_140126_ - 1; -+ int k3 = Math.max( i2, k ) + this.f_140126_ + 1; -+ int l3 = Math.max( j2, l ) + this.f_140126_ + 1; ++ int k = sectionpos.x(); ++ int l = sectionpos.z(); ++ if (Math.abs( k - i2 ) <= this.viewDistance * 2 && Math.abs( l - j2 ) <= this.viewDistance * 2) { ++ int l2 = Math.min( i2, k ) - this.viewDistance - 1; ++ int j3 = Math.min( j2, l ) - this.viewDistance - 1; ++ int k3 = Math.max( i2, k ) + this.viewDistance + 1; ++ int l3 = Math.max( j2, l ) + this.viewDistance + 1; + + for (int k1 = l2; k1 <= k3; ++k1) { + for (int l1 = j3; l1 <= l3; ++l1) { -+ boolean flag5 = m_200878_( k1, l1, k, l, this.f_140126_ ); -+ boolean flag6 = m_200878_( k1, l1, i2, j2, this.f_140126_ ); -+ this.m_183754_( p_140185_, new ChunkPos( k1, l1 ), new MutableObject<>(), flag5, flag6 ); ++ boolean flag5 = isChunkInRange( k1, l1, k, l, this.viewDistance ); ++ boolean flag6 = isChunkInRange( k1, l1, i2, j2, this.viewDistance ); ++ this.updateChunkTracking( p_140185_, new ChunkPos( k1, l1 ), new MutableObject<>(), flag5, flag6 ); + } + } + } else { -+ for (int i1 = k - this.f_140126_ - 1; i1 <= k + this.f_140126_ + 1; ++i1) { -+ for (int j1 = l - this.f_140126_ - 1; j1 <= l + this.f_140126_ + 1; ++j1) { -+ if (m_200878_( i1, j1, k, l, this.f_140126_ )) { ++ for (int i1 = k - this.viewDistance - 1; i1 <= k + this.viewDistance + 1; ++i1) { ++ for (int j1 = l - this.viewDistance - 1; j1 <= l + this.viewDistance + 1; ++j1) { ++ if (isChunkInRange( i1, j1, k, l, this.viewDistance )) { + boolean flag3 = true; + boolean flag4 = false; -+ this.m_183754_( p_140185_, new ChunkPos( i1, j1 ), new MutableObject<>(), true, false ); ++ this.updateChunkTracking( p_140185_, new ChunkPos( i1, j1 ), new MutableObject<>(), true, false ); + } + } + } + -+ for (int k2 = i2 - this.f_140126_ - 1; k2 <= i2 + this.f_140126_ + 1; ++k2) { -+ for (int i3 = j2 - this.f_140126_ - 1; i3 <= j2 + this.f_140126_ + 1; ++i3) { -+ if (m_200878_( k2, i3, i2, j2, this.f_140126_ )) { ++ for (int k2 = i2 - this.viewDistance - 1; k2 <= i2 + this.viewDistance + 1; ++k2) { ++ for (int i3 = j2 - this.viewDistance - 1; i3 <= j2 + this.viewDistance + 1; ++i3) { ++ if (isChunkInRange( k2, i3, i2, j2, this.viewDistance )) { + boolean flag7 = false; + boolean flag8 = true; -+ this.m_183754_( p_140185_, new ChunkPos( k2, i3 ), new MutableObject<>(), false, true ); ++ this.updateChunkTracking( p_140185_, new ChunkPos( k2, i3 ), new MutableObject<>(), false, true ); + } + } + } @@ -2234,13 +2234,13 @@ + + } + -+ public List m_183262_(ChunkPos p_183801_, boolean p_183802_) { -+ Set set = this.f_140149_.m_183926_( p_183801_.m_45588_() ); ++ public List getPlayers(ChunkPos p_183801_, boolean p_183802_) { ++ Set set = this.playerMap.getPlayers( p_183801_.toLong() ); + Builder builder = ImmutableList.builder(); + + for (ServerPlayer serverplayer : set) { -+ SectionPos sectionpos = serverplayer.m_8965_(); -+ if (p_183802_ && m_183828_( p_183801_.f_45578_, p_183801_.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), this.f_140126_ ) || !p_183802_ && m_200878_( p_183801_.f_45578_, p_183801_.f_45579_, sectionpos.m_123170_(), sectionpos.m_123222_(), this.f_140126_ )) { ++ SectionPos sectionpos = serverplayer.getLastSectionPos(); ++ if (p_183802_ && isChunkOnRangeBorder( p_183801_.x, p_183801_.z, sectionpos.x(), sectionpos.z(), this.viewDistance ) || !p_183802_ && isChunkInRange( p_183801_.x, p_183801_.z, sectionpos.x(), sectionpos.z(), this.viewDistance )) { + builder.add( serverplayer ); + } + } @@ -2248,27 +2248,27 @@ + return builder.build(); + } + -+ protected void m_140199_(Entity p_140200_) { ++ protected void addEntity(Entity p_140200_) { + org.spigotmc.AsyncCatcher.catchOp( "entity track" ); // Spigot + if (!(p_140200_ instanceof net.minecraftforge.entity.PartEntity)) { -+ EntityType entitytype = p_140200_.m_6095_(); -+ int i = entitytype.m_20681_() * 16; ++ EntityType entitytype = p_140200_.getType(); ++ int i = entitytype.clientTrackingRange() * 16; + i = org.spigotmc.TrackingRange.getEntityTrackingRange(p_140200_, i); // Spigot + if (i != 0) { -+ int j = entitytype.m_20682_(); -+ if (this.f_140150_.containsKey( p_140200_.m_142049_() )) { -+ throw (IllegalStateException) Util.m_137570_( new IllegalStateException( "Entity is already tracked!" ) ); ++ int j = entitytype.updateInterval(); ++ if (this.entityMap.containsKey( p_140200_.getId() )) { ++ throw (IllegalStateException) Util.pauseInIde( new IllegalStateException( "Entity is already tracked!" ) ); + } else { -+ ChunkMap.TrackedEntity chunkmap$trackedentity = new ChunkMap.TrackedEntity( p_140200_, i, j, entitytype.m_20683_() ); -+ this.f_140150_.put( p_140200_.m_142049_(), chunkmap$trackedentity ); -+ chunkmap$trackedentity.m_140487_( this.f_140133_.m_6907_() ); ++ ChunkMap.TrackedEntity chunkmap$trackedentity = new ChunkMap.TrackedEntity( p_140200_, i, j, entitytype.trackDeltas() ); ++ this.entityMap.put( p_140200_.getId(), chunkmap$trackedentity ); ++ chunkmap$trackedentity.updatePlayers( this.level.players() ); + if (p_140200_ instanceof ServerPlayer) { + ServerPlayer serverplayer = (ServerPlayer) p_140200_; -+ this.m_140192_( serverplayer, true ); ++ this.updatePlayerStatus( serverplayer, true ); + -+ for (ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.f_140150_.values()) { -+ if (chunkmap$trackedentity1.f_140472_ != serverplayer) { -+ chunkmap$trackedentity1.m_140497_( serverplayer ); ++ for (ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.entityMap.values()) { ++ if (chunkmap$trackedentity1.entity != serverplayer) { ++ chunkmap$trackedentity1.updatePlayer( serverplayer ); + } + } + } @@ -2278,128 +2278,128 @@ + } + } + -+ protected void m_140331_(Entity p_140332_) { ++ protected void removeEntity(Entity p_140332_) { + org.spigotmc.AsyncCatcher.catchOp( "entity untrack" ); // Spigot + if (p_140332_ instanceof ServerPlayer) { + ServerPlayer serverplayer = (ServerPlayer) p_140332_; -+ this.m_140192_( serverplayer, false ); ++ this.updatePlayerStatus( serverplayer, false ); + -+ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -+ chunkmap$trackedentity.m_140485_( serverplayer ); ++ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { ++ chunkmap$trackedentity.removePlayer( serverplayer ); + } + } + -+ ChunkMap.TrackedEntity chunkmap$trackedentity1 = this.f_140150_.remove( p_140332_.m_142049_() ); ++ ChunkMap.TrackedEntity chunkmap$trackedentity1 = this.entityMap.remove( p_140332_.getId() ); + if (chunkmap$trackedentity1 != null) { -+ chunkmap$trackedentity1.m_140482_(); ++ chunkmap$trackedentity1.broadcastRemoved(); + } + + } + -+ protected void m_140421_() { ++ protected void tick() { + List list = Lists.newArrayList(); -+ List list1 = this.f_140133_.m_6907_(); -+ f_140133_.timings.tracker1.startTiming(); // Paper ++ List list1 = this.level.players(); ++ level.timings.tracker1.startTiming(); // Paper + -+ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -+ SectionPos sectionpos = chunkmap$trackedentity.f_140474_; -+ SectionPos sectionpos1 = SectionPos.m_123194_( chunkmap$trackedentity.f_140472_ ); ++ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { ++ SectionPos sectionpos = chunkmap$trackedentity.lastSectionPos; ++ SectionPos sectionpos1 = SectionPos.of( chunkmap$trackedentity.entity ); + boolean flag = !Objects.equals( sectionpos, sectionpos1 ); if (flag) { -- if (this.f_140475_.add(p_140498_.f_8906_)) { -- this.f_140471_.m_8541_(p_140498_); +- if (this.seenBy.add(p_140498_.connection)) { +- this.serverEntity.addPairing(p_140498_); - } -- } else if (this.f_140475_.remove(p_140498_.f_8906_)) { -- this.f_140471_.m_8534_(p_140498_); +- } else if (this.seenBy.remove(p_140498_.connection)) { +- this.serverEntity.removePairing(p_140498_); - } - - } - } - -- private int m_140483_(int p_140484_) { -- return ChunkMap.this.f_140133_.m_142572_().m_7186_(p_140484_); +- private int scaledRange(int p_140484_) { +- return ChunkMap.this.level.getServer().getScaledTrackingDistance(p_140484_); - } - -- private int m_140496_() { -- int i = this.f_140473_; +- private int getEffectiveRange() { +- int i = this.range; - -- for(Entity entity : this.f_140472_.m_146897_()) { -- int j = entity.m_6095_().m_20681_() * 16; +- for(Entity entity : this.entity.getIndirectPassengers()) { +- int j = entity.getType().clientTrackingRange() * 16; - if (j > i) { - i = j; - } - } - -- return this.m_140483_(i); +- return this.scaledRange(i); - } - -- public void m_140487_(List p_140488_) { +- public void updatePlayers(List p_140488_) { - for(ServerPlayer serverplayer : p_140488_) { -- this.m_140497_(serverplayer); +- this.updatePlayer(serverplayer); - } - - } - } -+ chunkmap$trackedentity.m_140487_( list1 ); -+ Entity entity = chunkmap$trackedentity.f_140472_; ++ chunkmap$trackedentity.updatePlayers( list1 ); ++ Entity entity = chunkmap$trackedentity.entity; + if (entity instanceof ServerPlayer) { + list.add( (ServerPlayer) entity ); + } + -+ chunkmap$trackedentity.f_140474_ = sectionpos1; ++ chunkmap$trackedentity.lastSectionPos = sectionpos1; + } + -+ if (flag || this.f_140145_.m_183913_( sectionpos1.m_123251_().m_45588_() )) { -+ chunkmap$trackedentity.f_140471_.m_8533_(); ++ if (flag || this.distanceManager.inEntityTickingRange( sectionpos1.chunk().toLong() )) { ++ chunkmap$trackedentity.serverEntity.sendChanges(); + } + } -+ f_140133_.timings.tracker1.stopTiming(); // Paper ++ level.timings.tracker1.stopTiming(); // Paper + + if (!list.isEmpty()) { -+ f_140133_.timings.tracker2.startTiming(); // Paper -+ for (ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.f_140150_.values()) { -+ chunkmap$trackedentity1.m_140487_( list ); ++ level.timings.tracker2.startTiming(); // Paper ++ for (ChunkMap.TrackedEntity chunkmap$trackedentity1 : this.entityMap.values()) { ++ chunkmap$trackedentity1.updatePlayers( list ); + } -+ f_140133_.timings.tracker2.stopTiming(); // Paper ++ level.timings.tracker2.stopTiming(); // Paper + } + + } + -+ public void m_140201_(Entity p_140202_, Packet p_140203_) { -+ ChunkMap.TrackedEntity chunkmap$trackedentity = this.f_140150_.get( p_140202_.m_142049_() ); ++ public void broadcast(Entity p_140202_, Packet p_140203_) { ++ ChunkMap.TrackedEntity chunkmap$trackedentity = this.entityMap.get( p_140202_.getId() ); + if (chunkmap$trackedentity != null) { -+ chunkmap$trackedentity.m_140489_( p_140203_ ); ++ chunkmap$trackedentity.broadcast( p_140203_ ); + } + + } + -+ protected void m_140333_(Entity p_140334_, Packet p_140335_) { -+ ChunkMap.TrackedEntity chunkmap$trackedentity = this.f_140150_.get( p_140334_.m_142049_() ); ++ protected void broadcastAndSend(Entity p_140334_, Packet p_140335_) { ++ ChunkMap.TrackedEntity chunkmap$trackedentity = this.entityMap.get( p_140334_.getId() ); + if (chunkmap$trackedentity != null) { -+ chunkmap$trackedentity.m_140499_( p_140335_ ); ++ chunkmap$trackedentity.broadcastAndSend( p_140335_ ); + } + + } + -+ private void m_183760_(ServerPlayer p_183761_, MutableObject p_183762_, LevelChunk p_183763_) { ++ private void playerLoadedChunk(ServerPlayer p_183761_, MutableObject p_183762_, LevelChunk p_183763_) { + if (p_183762_.getValue() == null) { -+ p_183762_.setValue( new ClientboundLevelChunkWithLightPacket( p_183763_, this.f_140134_, (BitSet) null, (BitSet) null, true ) ); ++ p_183762_.setValue( new ClientboundLevelChunkWithLightPacket( p_183763_, this.lightEngine, (BitSet) null, (BitSet) null, true ) ); + } + -+ p_183761_.m_184135_( p_183763_.m_7697_(), p_183762_.getValue() ); -+ DebugPackets.m_133676_( this.f_140133_, p_183763_.m_7697_() ); ++ p_183761_.trackChunk( p_183763_.getPos(), p_183762_.getValue() ); ++ DebugPackets.sendPoiPacketsForChunk( this.level, p_183763_.getPos() ); + List list = Lists.newArrayList(); + List list1 = Lists.newArrayList(); + -+ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.f_140150_.values()) { -+ Entity entity = chunkmap$trackedentity.f_140472_; -+ if (entity != p_183761_ && entity.m_146902_().equals( p_183763_.m_7697_() )) { -+ chunkmap$trackedentity.m_140497_( p_183761_ ); -+ if (entity instanceof Mob && ((Mob) entity).m_21524_() != null) { ++ for (ChunkMap.TrackedEntity chunkmap$trackedentity : this.entityMap.values()) { ++ Entity entity = chunkmap$trackedentity.entity; ++ if (entity != p_183761_ && entity.chunkPosition().equals( p_183763_.getPos() )) { ++ chunkmap$trackedentity.updatePlayer( p_183761_ ); ++ if (entity instanceof Mob && ((Mob) entity).getLeashHolder() != null) { + list.add( entity ); + } + -+ if (!entity.m_20197_().isEmpty()) { ++ if (!entity.getPassengers().isEmpty()) { + list1.add( entity ); + } + } @@ -2407,28 +2407,28 @@ + + if (!list.isEmpty()) { + for (Entity entity1 : list) { -+ p_183761_.f_8906_.m_141995_( new ClientboundSetEntityLinkPacket( entity1, ((Mob) entity1).m_21524_() ) ); ++ p_183761_.connection.send( new ClientboundSetEntityLinkPacket( entity1, ((Mob) entity1).getLeashHolder() ) ); + } + } + + if (!list1.isEmpty()) { + for (Entity entity2 : list1) { -+ p_183761_.f_8906_.m_141995_( new ClientboundSetPassengersPacket( entity2 ) ); ++ p_183761_.connection.send( new ClientboundSetPassengersPacket( entity2 ) ); + } + } + + } + -+ protected PoiManager m_140424_() { -+ return this.f_140138_; ++ protected PoiManager getPoiManager() { ++ return this.poiManager; + } + -+ public String m_182285_() { -+ return this.f_182284_; ++ public String getStorageName() { ++ return this.storageName; + } + -+ void m_143075_(ChunkPos p_143076_, ChunkHolder.FullChunkStatus p_143077_) { -+ this.f_143031_.m_156794_( p_143076_, p_143077_ ); ++ void onFullChunkStatusChange(ChunkPos p_143076_, ChunkHolder.FullChunkStatus p_143077_) { ++ this.chunkStatusListener.onChunkStatusChange( p_143076_, p_143077_ ); + } + + class DistanceManager extends net.minecraft.server.level.DistanceManager { @@ -2436,123 +2436,123 @@ + super( p_140459_, p_140460_ ); + } + -+ protected boolean m_7009_(long p_140462_) { -+ return ChunkMap.this.f_140139_.contains( p_140462_ ); ++ protected boolean isChunkToRemove(long p_140462_) { ++ return ChunkMap.this.toDrop.contains( p_140462_ ); + } + + @Nullable -+ protected ChunkHolder m_7316_(long p_140469_) { -+ return ChunkMap.this.m_140174_( p_140469_ ); ++ protected ChunkHolder getChunk(long p_140469_) { ++ return ChunkMap.this.getUpdatingChunkIfPresent( p_140469_ ); + } + + @Nullable -+ protected ChunkHolder m_7288_(long p_140464_, int p_140465_, @Nullable ChunkHolder p_140466_, int p_140467_) { -+ return ChunkMap.this.m_140176_( p_140464_, p_140465_, p_140466_, p_140467_ ); ++ protected ChunkHolder updateChunkScheduling(long p_140464_, int p_140465_, @Nullable ChunkHolder p_140466_, int p_140467_) { ++ return ChunkMap.this.updateChunkScheduling( p_140464_, p_140465_, p_140466_, p_140467_ ); + } + } + + public class TrackedEntity { -+ final ServerEntity f_140471_; -+ final Entity f_140472_; -+ private final int f_140473_; -+ SectionPos f_140474_; -+ public final Set f_140475_ = Sets.newIdentityHashSet(); ++ final ServerEntity serverEntity; ++ final Entity entity; ++ private final int range; ++ SectionPos lastSectionPos; ++ public final Set seenBy = Sets.newIdentityHashSet(); + + public TrackedEntity(Entity p_140478_, int p_140479_, int p_140480_, boolean p_140481_) { -+ this.f_140471_ = new ServerEntity( ChunkMap.this.f_140133_, p_140478_, p_140480_, p_140481_, this::m_140489_, f_140475_ ); // CraftBukkit -+ this.f_140472_ = p_140478_; -+ this.f_140473_ = p_140479_; -+ this.f_140474_ = SectionPos.m_123194_( p_140478_ ); ++ this.serverEntity = new ServerEntity( ChunkMap.this.level, p_140478_, p_140480_, p_140481_, this::broadcast, seenBy ); // CraftBukkit ++ this.entity = p_140478_; ++ this.range = p_140479_; ++ this.lastSectionPos = SectionPos.of( p_140478_ ); + } + + public boolean equals(Object p_140506_) { + if (p_140506_ instanceof ChunkMap.TrackedEntity) { -+ return ((ChunkMap.TrackedEntity) p_140506_).f_140472_.m_142049_() == this.f_140472_.m_142049_(); ++ return ((ChunkMap.TrackedEntity) p_140506_).entity.getId() == this.entity.getId(); + } else { + return false; + } + } + + public int hashCode() { -+ return this.f_140472_.m_142049_(); ++ return this.entity.getId(); + } + -+ public void m_140489_(Packet p_140490_) { -+ for (ServerPlayerConnection serverplayerconnection : this.f_140475_) { -+ serverplayerconnection.m_141995_( p_140490_ ); ++ public void broadcast(Packet p_140490_) { ++ for (ServerPlayerConnection serverplayerconnection : this.seenBy) { ++ serverplayerconnection.send( p_140490_ ); + } + + } + -+ public void m_140499_(Packet p_140500_) { -+ this.m_140489_( p_140500_ ); -+ if (this.f_140472_ instanceof ServerPlayer) { -+ ((ServerPlayer) this.f_140472_).f_8906_.m_141995_( p_140500_ ); ++ public void broadcastAndSend(Packet p_140500_) { ++ this.broadcast( p_140500_ ); ++ if (this.entity instanceof ServerPlayer) { ++ ((ServerPlayer) this.entity).connection.send( p_140500_ ); + } + + } + -+ public void m_140482_() { -+ for (ServerPlayerConnection serverplayerconnection : this.f_140475_) { -+ this.f_140471_.m_8534_( serverplayerconnection.m_142253_() ); ++ public void broadcastRemoved() { ++ for (ServerPlayerConnection serverplayerconnection : this.seenBy) { ++ this.serverEntity.removePairing( serverplayerconnection.getPlayer() ); + } + + } + -+ public void m_140485_(ServerPlayer p_140486_) { ++ public void removePlayer(ServerPlayer p_140486_) { + org.spigotmc.AsyncCatcher.catchOp( "player tracker clear" ); // Spigot -+ if (this.f_140475_.remove( p_140486_.f_8906_ )) { -+ this.f_140471_.m_8534_( p_140486_ ); ++ if (this.seenBy.remove( p_140486_.connection )) { ++ this.serverEntity.removePairing( p_140486_ ); + } + + } + -+ public void m_140497_(ServerPlayer p_140498_) { ++ public void updatePlayer(ServerPlayer p_140498_) { + org.spigotmc.AsyncCatcher.catchOp( "player tracker update" ); // Spigot -+ if (p_140498_ != this.f_140472_) { -+ Vec3 vec3 = p_140498_.m_20182_().m_82546_(this.f_140471_.m_8540_()); //Magma - this makes no sense! If I use this.entity.position() (like Forge does), valkyrien skies crashes, but when I use this it works fine... -+ double d0 = (double) Math.min( this.m_140496_(), (ChunkMap.this.f_140126_ - 1) * 16 ); -+ double d1 = vec3.f_82479_ * vec3.f_82479_ + vec3.f_82481_ * vec3.f_82481_; ++ if (p_140498_ != this.entity) { ++ Vec3 vec3 = p_140498_.position().subtract(this.serverEntity.sentPos()); //Magma - this makes no sense! If I use this.entity.position() (like Forge does), valkyrien skies crashes, but when I use this it works fine... ++ double d0 = (double) Math.min( this.getEffectiveRange(), (ChunkMap.this.viewDistance - 1) * 16 ); ++ double d1 = vec3.x * vec3.x + vec3.z * vec3.z; + double d2 = d0 * d0; -+ boolean flag = d1 <= d2 && this.f_140472_.m_6459_( p_140498_ ); ++ boolean flag = d1 <= d2 && this.entity.broadcastToPlayer( p_140498_ ); + + // CraftBukkit start - respect vanish API -+ if (!p_140498_.getBukkitEntity().canSee( this.f_140472_.getBukkitEntity() )) { ++ if (!p_140498_.getBukkitEntity().canSee( this.entity.getBukkitEntity() )) { + flag = false; + } + // CraftBukkit end + + if (flag) { -+ if (this.f_140475_.add( p_140498_.f_8906_ )) { -+ this.f_140471_.m_8541_( p_140498_ ); ++ if (this.seenBy.add( p_140498_.connection )) { ++ this.serverEntity.addPairing( p_140498_ ); + } -+ } else if (this.f_140475_.remove( p_140498_.f_8906_ )) { -+ this.f_140471_.m_8534_( p_140498_ ); ++ } else if (this.seenBy.remove( p_140498_.connection )) { ++ this.serverEntity.removePairing( p_140498_ ); + } + + } + } + -+ private int m_140483_(int p_140484_) { -+ return ChunkMap.this.f_140133_.m_142572_().m_7186_( p_140484_ ); ++ private int scaledRange(int p_140484_) { ++ return ChunkMap.this.level.getServer().getScaledTrackingDistance( p_140484_ ); + } + -+ private int m_140496_() { -+ int i = this.f_140473_; ++ private int getEffectiveRange() { ++ int i = this.range; + -+ for (Entity entity : this.f_140472_.m_146897_()) { -+ int j = entity.m_6095_().m_20681_() * 16; ++ for (Entity entity : this.entity.getIndirectPassengers()) { ++ int j = entity.getType().clientTrackingRange() * 16; + if (j > i) { + i = j; + } + } + -+ return this.m_140483_( i ); ++ return this.scaledRange( i ); + } + -+ public void m_140487_(List p_140488_) { ++ public void updatePlayers(List p_140488_) { + for (ServerPlayer serverplayer : p_140488_) { -+ this.m_140497_( serverplayer ); ++ this.updatePlayer( serverplayer ); + } + + } diff --git a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch index 68b0bb16..b6eb7f95 100644 --- a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch @@ -1,70 +1,70 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java @@ -59,6 +_,8 @@ - private long f_140771_; - private int f_183902_ = 10; + private long ticketTickCounter; + private int simulationDistance = 10; + private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); + protected DistanceManager(Executor p_140774_, Executor p_140775_) { - ProcessorHandle processorhandle = ProcessorHandle.m_18714_("player ticket throttler", p_140775_::execute); + ProcessorHandle processorhandle = ProcessorHandle.of("player ticket throttler", p_140775_::execute); ChunkTaskPriorityQueueSorter chunktaskpriorityqueuesorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processorhandle), p_140774_, 4); @@ -119,10 +_,22 @@ } - if (!this.f_140765_.isEmpty()) { -- this.f_140765_.forEach((p_183908_) -> { + if (!this.chunksToUpdateFutures.isEmpty()) { +- this.chunksToUpdateFutures.forEach((p_183908_) -> { + // CraftBukkit start + // Iterate pending chunk updates with protection against concurrent modification exceptions -+ java.util.Iterator iter = this.f_140765_.iterator(); -+ int expectedSize = this.f_140765_.size(); ++ java.util.Iterator iter = this.chunksToUpdateFutures.iterator(); ++ int expectedSize = this.chunksToUpdateFutures.size(); + do { + ChunkHolder p_183908_ = iter.next(); + iter.remove(); + expectedSize--; - p_183908_.m_143003_(p_140806_, this.f_140770_); + p_183908_.updateFutures(p_140806_, this.mainThreadExecutor); - }); -- this.f_140765_.clear(); +- this.chunksToUpdateFutures.clear(); + // Reset iterator if set was modified using add() -+ if (this.f_140765_.size() != expectedSize) { -+ expectedSize = this.f_140765_.size(); -+ iter = this.f_140765_.iterator(); ++ if (this.chunksToUpdateFutures.size() != expectedSize) { ++ expectedSize = this.chunksToUpdateFutures.size(); ++ iter = this.chunksToUpdateFutures.iterator(); + } + } while (iter.hasNext()); + // CraftBukkit end return true; } else { - if (!this.f_140769_.isEmpty()) { + if (!this.ticketsToRelease.isEmpty()) { @@ -164,6 +_,25 @@ - this.f_140762_.m_140715_(p_140785_, p_140786_.m_9433_(), true); + this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); } + if (p_140786_.isForceTicks()) { -+ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.m_14246_(4)); -+ tickets.m_14253_(ticket); ++ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.create(4)); ++ tickets.addOrGet(ticket); + } + } + + boolean addTicketCB(long p_140785_, Ticket p_140786_) { -+ SortedArraySet> sortedarrayset = this.m_140857_(p_140785_); -+ int i = m_140797_(sortedarrayset); -+ Ticket ticket = sortedarrayset.m_14253_(p_140786_); -+ ticket.m_9429_(this.f_140771_); -+ if (p_140786_.m_9433_() < i) { -+ this.f_140762_.m_140715_(p_140785_, p_140786_.m_9433_(), true); ++ SortedArraySet> sortedarrayset = this.getTickets(p_140785_); ++ int i = getTicketLevelAt(sortedarrayset); ++ Ticket ticket = sortedarrayset.addOrGet(p_140786_); ++ ticket.setCreatedTick(this.ticketTickCounter); ++ if (p_140786_.getTicketLevel() < i) { ++ this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); + } + if (p_140786_.isForceTicks()) { -+ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.m_14246_(4)); -+ tickets.m_14253_(ticket); ++ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.create(4)); ++ tickets.addOrGet(ticket); + } + return p_140786_ == ticket; // CraftBukkit } - void m_140818_(long p_140819_, Ticket p_140820_) { + void removeTicket(long p_140819_, Ticket p_140820_) { @@ -176,31 +_,108 @@ } - this.f_140762_.m_140715_(p_140819_, m_140797_(sortedarrayset), false); + this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); + + if (p_140820_.isForceTicks()) { + SortedArraySet> tickets = forcedTickets.get(p_140819_); @@ -75,16 +75,16 @@ + } + + boolean removeTicketCB(long p_140819_, Ticket p_140820_) { -+ SortedArraySet> sortedarrayset = this.m_140857_(p_140819_); ++ SortedArraySet> sortedarrayset = this.getTickets(p_140819_); + if (sortedarrayset.remove(p_140820_)) { + } + boolean removed = false; // CraftBukkit + if (sortedarrayset.isEmpty()) { -+ this.f_140761_.remove(p_140819_); ++ this.tickets.remove(p_140819_); + removed = true; // CraftBukkit + } + -+ this.f_140762_.m_140715_(p_140819_, m_140797_(sortedarrayset), false); ++ this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); + + if (p_140820_.isForceTicks()) { + SortedArraySet> tickets = forcedTickets.get(p_140819_); @@ -95,24 +95,24 @@ + return removed; // CraftBukkit } - public void m_140792_(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { - this.m_140784_(p_140794_.m_45588_(), new Ticket<>(p_140793_, p_140795_, p_140796_)); + public void addTicket(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { + this.addTicket(p_140794_.toLong(), new Ticket<>(p_140793_, p_140795_, p_140796_)); } + public boolean addRegionTicketAtDistance(TicketType ticketType, ChunkPos chunkcoordintpair, int level, T identifier) { -+ return this.addTicketCB(chunkcoordintpair.m_45588_(), new Ticket<>(ticketType, level, identifier)); ++ return this.addTicketCB(chunkcoordintpair.toLong(), new Ticket<>(ticketType, level, identifier)); + // CraftBukkit end + } + - public void m_140823_(TicketType p_140824_, ChunkPos p_140825_, int p_140826_, T p_140827_) { + public void removeTicket(TicketType p_140824_, ChunkPos p_140825_, int p_140826_, T p_140827_) { Ticket ticket = new Ticket<>(p_140824_, p_140826_, p_140827_); - this.m_140818_(p_140825_.m_45588_(), ticket); + this.removeTicket(p_140825_.toLong(), ticket); } + public boolean removeTicketAtLevel(TicketType ticketType, ChunkPos chunkcoordintpair, int level, T identifier) { + Ticket ticket = new Ticket<>(ticketType, level, identifier); + -+ return this.removeTicketCB(chunkcoordintpair.m_45588_(), ticket); ++ return this.removeTicketCB(chunkcoordintpair.toLong(), ticket); + // CraftBukkit end + } + @@ -120,12 +120,12 @@ + public void removeAllTicketsFor(TicketType ticketType, int ticketLevel, T ticketIdentifier) { + Ticket target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier); + -+ for (java.util.Iterator>>> iterator = this.f_140761_.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) { ++ for (java.util.Iterator>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) { + Entry>> entry = iterator.next(); + SortedArraySet> tickets = entry.getValue(); + if (tickets.remove(target)) { + // copied from removeTicket -+ this.f_140762_.m_140715_(entry.getLongKey(), m_140797_(tickets), false); ++ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false); + + // can't use entry after it's removed + if (tickets.isEmpty()) { @@ -136,27 +136,27 @@ + } + // CraftBukkit end + - public void m_140840_(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) { + public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) { - Ticket ticket = new Ticket<>(p_140841_, 33 - p_140843_, p_140844_); + addRegionTicket(p_140841_, p_140842_, p_140843_, p_140844_, false); + } + public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_, boolean forceTicks) { + Ticket ticket = new Ticket<>(p_140841_, 33 - p_140843_, p_140844_, forceTicks); - long i = p_140842_.m_45588_(); - this.m_140784_(i, ticket); - this.f_183901_.m_184151_(i, ticket); + long i = p_140842_.toLong(); + this.addTicket(i, ticket); + this.tickingTicketsTracker.addTicket(i, ticket); } - public void m_140849_(TicketType p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_) { + public void removeRegionTicket(TicketType p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_) { - Ticket ticket = new Ticket<>(p_140850_, 33 - p_140852_, p_140853_); + removeRegionTicket(p_140850_, p_140851_, p_140852_, p_140853_, false); + } + + public void removeRegionTicket(TicketType p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_, boolean forceTicks) { + Ticket ticket = new Ticket<>(p_140850_, 33 - p_140852_, p_140853_, forceTicks); - long i = p_140851_.m_45588_(); - this.m_140818_(i, ticket); - this.f_183901_.m_184165_(i, ticket); + long i = p_140851_.toLong(); + this.removeTicket(i, ticket); + this.tickingTicketsTracker.removeTicket(i, ticket); } + @Deprecated(forRemoval = true, since = "1.18.2") // Use addRegionTicket overload @@ -169,13 +169,13 @@ + removeRegionTicket(type, pos, distance, value, true); + } + - private SortedArraySet> m_140857_(long p_140858_) { - return this.f_140761_.computeIfAbsent(p_140858_, (p_183923_) -> { - return SortedArraySet.m_14246_(4); + private SortedArraySet> getTickets(long p_140858_) { + return this.tickets.computeIfAbsent(p_140858_, (p_183923_) -> { + return SortedArraySet.create(4); @@ -286,6 +_,11 @@ - public String m_140837_() { - return this.f_140766_.m_140558_(); + public String getDebugStatus() { + return this.ticketThrottler.getDebugStatus(); + } + + public boolean shouldForceTicks(long chunkPos) { @@ -183,4 +183,4 @@ + return tickets != null && !tickets.isEmpty(); } - private void m_143207_(String p_143208_) { + private void dumpTickets(String p_143208_) { diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index 8c6db922..3ab997e5 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -79,6 +_,16 @@ - this.m_8488_(); + this.clearCache(); } + // CraftBukkit start - properly implement isChunkLoaded + public boolean isChunkLoaded(int chunkX, int chunkZ) { -+ ChunkHolder chunk = this.f_8325_.m_140174_(ChunkPos.m_45589_(chunkX, chunkZ)); ++ ChunkHolder chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkPos.asLong(chunkX, chunkZ)); + if (chunk == null) { + return false; + } @@ -14,23 +14,23 @@ + } + // CraftBukkit end + - public ThreadedLevelLightEngine m_7827_() { - return this.f_8331_; + public ThreadedLevelLightEngine getLightEngine() { + return this.lightEngine; } @@ -126,7 +_,9 @@ - profilerfiller.m_6174_("getChunkCacheMiss"); - CompletableFuture> completablefuture = this.m_8456_(p_8360_, p_8361_, p_8362_, p_8363_); -+ this.f_8329_.timings.syncChunkLoad.startTiming(); // Paper - this.f_8332_.m_18701_(completablefuture::isDone); -+ this.f_8329_.timings.syncChunkLoad.stopTiming(); // Paper + profilerfiller.incrementCounter("getChunkCacheMiss"); + CompletableFuture> completablefuture = this.getChunkFutureMainThread(p_8360_, p_8361_, p_8362_, p_8363_); ++ this.level.timings.syncChunkLoad.startTiming(); // Paper + this.mainThreadProcessor.managedBlock(completablefuture::isDone); ++ this.level.timings.syncChunkLoad.stopTiming(); // Paper ChunkAccess chunkaccess1 = completablefuture.join().map((p_8406_) -> { return p_8406_; }, (p_8423_) -> { @@ -152,7 +_,9 @@ for(int j = 0; j < 4; ++j) { - if (i == this.f_8337_[j] && this.f_8338_[j] == ChunkStatus.f_62326_) { - ChunkAccess chunkaccess = this.f_8339_[j]; + if (i == this.lastChunkPos[j] && this.lastChunkStatus[j] == ChunkStatus.FULL) { + ChunkAccess chunkaccess = this.lastChunk[j]; - return chunkaccess instanceof LevelChunk ? (LevelChunk)chunkaccess : null; + if (chunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime + return chunkaccess instanceof LevelChunk ? (LevelChunk)chunkaccess : null; @@ -43,55 +43,55 @@ return null; } else { + if (chunkholder.currentlyLoading != null) return chunkholder.currentlyLoading; // Forge: If the requested chunk is loading, bypass the future chain to prevent a deadlock. - Either either = chunkholder.m_140080_(ChunkStatus.f_62326_).getNow((Either)null); + Either either = chunkholder.getFutureIfPresent(ChunkStatus.FULL).getNow((Either)null); if (either == null) { return null; @@ -206,7 +_,15 @@ - long i = chunkpos.m_45588_(); - int j = 33 + ChunkStatus.m_62370_(p_8459_); - ChunkHolder chunkholder = this.m_8364_(i); + long i = chunkpos.toLong(); + int j = 33 + ChunkStatus.getDistance(p_8459_); + ChunkHolder chunkholder = this.getVisibleChunkIfPresent(i); - if (p_8460_) { + // CraftBukkit start - don't add new ticket for currently unloading chunk + boolean currentlyUnloading = false; + if (chunkholder != null) { -+ ChunkHolder.FullChunkStatus oldChunkState = ChunkHolder.m_140083_(chunkholder.f_140006_); -+ ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.m_140083_(chunkholder.m_140093_()); -+ currentlyUnloading = (oldChunkState.m_140114_(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.m_140114_(ChunkHolder.FullChunkStatus.BORDER)); ++ ChunkHolder.FullChunkStatus oldChunkState = ChunkHolder.getFullChunkStatus(chunkholder.oldTicketLevel); ++ ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(chunkholder.getTicketLevel()); ++ currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)); + } + if (p_8460_ && !currentlyUnloading) { + // CraftBukkit end - this.f_8327_.m_140792_(TicketType.f_9449_, chunkpos, j, chunkpos); - if (this.m_8416_(chunkholder, j)) { - ProfilerFiller profilerfiller = this.f_8329_.m_46473_(); + this.distanceManager.addTicket(TicketType.UNKNOWN, chunkpos, j, chunkpos); + if (this.chunkAbsent(chunkholder, j)) { + ProfilerFiller profilerfiller = this.level.getProfiler(); @@ -224,7 +_,7 @@ } - private boolean m_8416_(@Nullable ChunkHolder p_8417_, int p_8418_) { -- return p_8417_ == null || p_8417_.m_140093_() > p_8418_; -+ return p_8417_ == null || p_8417_.f_140006_ > p_8418_; // CraftBukkit using oldTicketLevel for isLoaded checks + private boolean chunkAbsent(@Nullable ChunkHolder p_8417_, int p_8418_) { +- return p_8417_ == null || p_8417_.getTicketLevel() > p_8418_; ++ return p_8417_ == null || p_8417_.oldTicketLevel > p_8418_; // CraftBukkit using oldTicketLevel for isLoaded checks } - public boolean m_5563_(int p_8429_, int p_8430_) { + public boolean hasChunk(int p_8429_, int p_8430_) { @@ -276,6 +_,12 @@ } } + // Paper start - helper + public boolean isPositionTicking(Entity entity) { -+ return this.m_143239_(ChunkPos.m_45589_(net.minecraft.util.Mth.m_14107_(entity.m_20185_()) >> 4, net.minecraft.util.Mth.m_14107_(entity.m_20189_()) >> 4)); ++ return this.isPositionTicking(ChunkPos.asLong(net.minecraft.util.Mth.floor(entity.getX()) >> 4, net.minecraft.util.Mth.floor(entity.getZ()) >> 4)); + } + // Paper end + - public boolean m_143239_(long p_143240_) { - ChunkHolder chunkholder = this.m_8364_(p_143240_); + public boolean isPositionTicking(long p_143240_) { + ChunkHolder chunkholder = this.getVisibleChunkIfPresent(p_143240_); if (chunkholder == null) { @@ -290,26 +_,55 @@ - public void m_8419_(boolean p_8420_) { - this.m_8489_(); -- this.f_8325_.m_140318_(p_8420_); -+ try (co.aikar.timings.Timing timed = f_8329_.timings.chunkSaveData.startTiming()) { // Paper - Timings -+ this.f_8325_.m_140318_(p_8420_); + public void save(boolean p_8420_) { + this.runDistanceManagerUpdates(); +- this.chunkMap.saveAllChunks(p_8420_); ++ try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings ++ this.chunkMap.saveAllChunks(p_8420_); + } // Paper - Timings } @@ -102,156 +102,156 @@ + + public void close(boolean save) throws IOException { + if (save) { -+ this.m_8419_(true); ++ this.save(true); + } + // CraftBukkit end - this.m_8419_(true); - this.f_8331_.close(); - this.f_8325_.close(); + this.save(true); + this.lightEngine.close(); + this.chunkMap.close(); } + // CraftBukkit start - modelled on below + public void purgeUnload() { -+ this.f_8329_.m_46473_().m_6180_("purge"); -+ this.f_8327_.m_140776_(); -+ this.m_8489_(); -+ this.f_8329_.m_46473_().m_6182_("unload"); -+ this.f_8325_.m_140280_(() -> true); -+ this.f_8329_.m_46473_().m_7238_(); -+ this.m_8488_(); ++ this.level.getProfiler().push("purge"); ++ this.distanceManager.purgeStaleTickets(); ++ this.runDistanceManagerUpdates(); ++ this.level.getProfiler().popPush("unload"); ++ this.chunkMap.tick(() -> true); ++ this.level.getProfiler().pop(); ++ this.clearCache(); + } + // CraftBukkit end + - public void m_201698_(BooleanSupplier p_201913_, boolean p_201914_) { - this.f_8329_.m_46473_().m_6180_("purge"); -+ this.f_8329_.timings.doChunkMap.startTiming(); // Spigot - this.f_8327_.m_140776_(); - this.m_8489_(); -+ this.f_8329_.timings.doChunkMap.stopTiming(); // Spigot - this.f_8329_.m_46473_().m_6182_("chunks"); + public void tick(BooleanSupplier p_201913_, boolean p_201914_) { + this.level.getProfiler().push("purge"); ++ this.level.timings.doChunkMap.startTiming(); // Spigot + this.distanceManager.purgeStaleTickets(); + this.runDistanceManagerUpdates(); ++ this.level.timings.doChunkMap.stopTiming(); // Spigot + this.level.getProfiler().popPush("chunks"); if (p_201914_) { -+ this.f_8329_.timings.chunks.startTiming(); // Paper - timings - this.m_8490_(); -+ this.f_8329_.timings.chunks.stopTiming(); // Paper - timings ++ this.level.timings.chunks.startTiming(); // Paper - timings + this.tickChunks(); ++ this.level.timings.chunks.stopTiming(); // Paper - timings } -+ this.f_8329_.timings.doChunkUnload.startTiming(); // Spigot - this.f_8329_.m_46473_().m_6182_("unload"); - this.f_8325_.m_140280_(p_201913_); -+ this.f_8329_.timings.doChunkUnload.stopTiming(); // Spigot - this.f_8329_.m_46473_().m_7238_(); - this.m_8488_(); ++ this.level.timings.doChunkUnload.startTiming(); // Spigot + this.level.getProfiler().popPush("unload"); + this.chunkMap.tick(p_201913_); ++ this.level.timings.doChunkUnload.stopTiming(); // Spigot + this.level.getProfiler().pop(); + this.clearCache(); } @@ -326,14 +_,17 @@ - ProfilerFiller profilerfiller = this.f_8329_.m_46473_(); - profilerfiller.m_6180_("pollingChunks"); - int k = this.f_8329_.m_46469_().m_46215_(GameRules.f_46143_); -- boolean flag1 = leveldata.m_6793_() % 400L == 0L; -+ boolean flag1 = f_8329_.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && leveldata.m_6793_() % f_8329_.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - profilerfiller.m_6180_("naturalSpawnCount"); -+ this.f_8329_.timings.countNaturalMobs.startTiming(); // Paper - timings - int l = this.f_8327_.m_140816_(); - NaturalSpawner.SpawnState naturalspawner$spawnstate = NaturalSpawner.m_186524_(l, this.f_8329_.m_8583_(), this::m_8370_, new LocalMobCapCalculator(this.f_8325_)); -+ this.f_8329_.timings.countNaturalMobs.stopTiming(); // Paper - timings - this.f_8340_ = naturalspawner$spawnstate; - profilerfiller.m_6182_("filteringLoadedChunks"); + ProfilerFiller profilerfiller = this.level.getProfiler(); + profilerfiller.push("pollingChunks"); + int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); +- boolean flag1 = leveldata.getGameTime() % 400L == 0L; ++ boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && leveldata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit + profilerfiller.push("naturalSpawnCount"); ++ this.level.timings.countNaturalMobs.startTiming(); // Paper - timings + int l = this.distanceManager.getNaturalSpawnChunkCount(); + NaturalSpawner.SpawnState naturalspawner$spawnstate = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap)); ++ this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings + this.lastSpawnState = naturalspawner$spawnstate; + profilerfiller.popPush("filteringLoadedChunks"); List list = Lists.newArrayListWithCapacity(l); -+ this.f_8329_.timings.chunkTicks.startTiming(); // Paper - for(ChunkHolder chunkholder : this.f_8325_.m_140416_()) { - LevelChunk levelchunk = chunkholder.m_140085_(); ++ this.level.timings.chunkTicks.startTiming(); // Paper + for(ChunkHolder chunkholder : this.chunkMap.getChunks()) { + LevelChunk levelchunk = chunkholder.getTickingChunk(); if (levelchunk != null) { @@ -342,15 +_,15 @@ } - profilerfiller.m_6182_("spawnAndTick"); -- boolean flag2 = this.f_8329_.m_46469_().m_46207_(GameRules.f_46134_); -+ boolean flag2 = this.f_8329_.m_46469_().m_46207_(GameRules.f_46134_) && !f_8329_.m_6907_().isEmpty(); // CraftBukkit + profilerfiller.popPush("spawnAndTick"); +- boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); ++ boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.players().isEmpty(); // CraftBukkit Collections.shuffle(list); for(ServerChunkCache.ChunkAndHolder serverchunkcache$chunkandholder : list) { - LevelChunk levelchunk1 = serverchunkcache$chunkandholder.f_184028_; - ChunkPos chunkpos = levelchunk1.m_7697_(); -- if (this.f_8329_.m_201916_(chunkpos) && this.f_8325_.m_183879_(chunkpos)) { -+ if ((this.f_8329_.m_201916_(chunkpos) && this.f_8325_.m_183879_(chunkpos)) || this.f_8327_.shouldForceTicks(chunkpos.m_45588_())) { - levelchunk1.m_187632_(j); -- if (flag2 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) { -+ if (flag2 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos) && this.f_8325_.anyPlayerCloseEnoughForSpawning(chunkpos, true)) { // Spigot - NaturalSpawner.m_47029_(this.f_8329_, levelchunk1, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag1); + 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 (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkpos)) { ++ if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos, true)) { // Spigot + NaturalSpawner.spawnForChunk(this.level, levelchunk1, naturalspawner$spawnstate, this.spawnFriendlies, this.spawnEnemies, flag1); } @@ -359,15 +_,20 @@ } } } -+ this.f_8329_.timings.chunkTicks.stopTiming(); // Paper ++ this.level.timings.chunkTicks.stopTiming(); // Paper - profilerfiller.m_6182_("customSpawners"); + profilerfiller.popPush("customSpawners"); if (flag2) { -- this.f_8329_.m_8799_(this.f_8335_, this.f_8336_); -+ try (co.aikar.timings.Timing ignored = this.f_8329_.timings.miscMobSpawning.startTiming()) { // Paper - timings -+ this.f_8329_.m_8799_(this.f_8335_, this.f_8336_); +- this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); ++ try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings ++ this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); + } // Paper - timings } - profilerfiller.m_6182_("broadcast"); + profilerfiller.popPush("broadcast"); list.forEach((p_184022_) -> { -+ this.f_8329_.timings.broadcastChunkUpdates.startTiming(); // Paper - timing - p_184022_.f_184029_.m_140054_(p_184022_.f_184028_); -+ this.f_8329_.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing ++ this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing + p_184022_.holder.broadcastChanges(p_184022_.chunk); ++ this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing }); - profilerfiller.m_7238_(); - profilerfiller.m_7238_(); + profilerfiller.pop(); + profilerfiller.pop(); @@ -421,11 +_,29 @@ } - public void m_8387_(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) { -- this.f_8327_.m_140840_(p_8388_, p_8389_, p_8390_, p_8391_); + public void addRegionTicket(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) { +- this.distanceManager.addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_); + addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, false); + } + + public void addRegionTicket(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_, boolean forceTicks) { -+ this.f_8327_.addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, forceTicks); ++ this.distanceManager.addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, forceTicks); } - public void m_8438_(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) { -- this.f_8327_.m_140849_(p_8439_, p_8440_, p_8441_, p_8442_); + public void removeRegionTicket(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) { +- this.distanceManager.removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_); + removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, false); + } + + public void removeRegionTicket(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_, boolean forceTicks) { -+ this.f_8327_.removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, forceTicks); ++ this.distanceManager.removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, forceTicks); + } + + @Deprecated(forRemoval = true, since = "1.18.2") // Use addRegionTicket overload + public void registerTickingTicket(TicketType type, ChunkPos pos, int distance, T value) { -+ this.f_8327_.registerTicking(type, pos, distance, value); ++ this.distanceManager.registerTicking(type, pos, distance, value); + } + + @Deprecated(forRemoval = true, since = "1.18.2") // Use removeRegionTicket overload + public void releaseTickingTicket(TicketType type, ChunkPos pos, int distance, T value) { -+ this.f_8327_.releaseTicking(type, pos, distance, value); ++ this.distanceManager.releaseTicking(type, pos, distance, value); } - public void m_6692_(ChunkPos p_8400_, boolean p_8401_) { + public void updateChunkForced(ChunkPos p_8400_, boolean p_8401_) { @@ -524,11 +_,16 @@ } - public boolean m_7245_() { -- if (ServerChunkCache.this.m_8489_()) { + public boolean pollTask() { +- if (ServerChunkCache.this.runDistanceManagerUpdates()) { - return true; - } else { -- ServerChunkCache.this.f_8331_.m_9409_(); -- return super.m_7245_(); +- ServerChunkCache.this.lightEngine.tryScheduleUpdate(); +- return super.pollTask(); + try { -+ if (ServerChunkCache.this.m_8489_()) { ++ if (ServerChunkCache.this.runDistanceManagerUpdates()) { + return true; + } else { -+ ServerChunkCache.this.f_8331_.m_9409_(); -+ return super.m_7245_(); ++ ServerChunkCache.this.lightEngine.tryScheduleUpdate(); ++ return super.pollTask(); + } + } finally { -+ ServerChunkCache.this.f_8325_.callbackExecutor.run(); ++ ServerChunkCache.this.chunkMap.callbackExecutor.run(); + net.minecraft.server.MinecraftServer.getServerInstance().drainQueuedTasks(); } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch index 6ad9925d..66b4fa5c 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -57,8 +_,12 @@ - private List f_8523_ = Collections.emptyList(); - private boolean f_8524_; - private boolean f_8525_; + private List lastPassengers = Collections.emptyList(); + private boolean wasRiding; + private boolean wasOnGround; + // CraftBukkit start + private final Set trackedPlayers; @@ -11,90 +11,86 @@ + public ServerEntity(ServerLevel p_8528_, Entity p_8529_, int p_8530_, boolean p_8531_, Consumer> p_8532_, Set trackedPlayers) { + this.trackedPlayers = trackedPlayers; + // CraftBukkit end - this.f_8509_ = p_8528_; - this.f_8513_ = p_8532_; - this.f_8510_ = p_8529_; + this.level = p_8528_; + this.broadcast = p_8532_; + this.entity = p_8529_; @@ -75,24 +_,23 @@ - List list = this.f_8510_.m_20197_(); - if (!list.equals(this.f_8523_)) { - this.f_8523_ = list; -- this.f_8513_.accept(new ClientboundSetPassengersPacket(this.f_8510_)); -+ this.m_8538_(new ClientboundSetPassengersPacket(this.f_8510_)); // CraftBukkit + List list = this.entity.getPassengers(); + if (!list.equals(this.lastPassengers)) { + this.lastPassengers = list; +- this.broadcast.accept(new ClientboundSetPassengersPacket(this.entity)); ++ this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit } - if (this.f_8510_ instanceof ItemFrame && this.f_8521_ % 10 == 0) { - ItemFrame itemframe = (ItemFrame)this.f_8510_; - ItemStack itemstack = itemframe.m_31822_(); -- if (itemstack.m_41720_() instanceof MapItem) { -- Integer integer = MapItem.m_151131_(itemstack); -- MapItemSavedData mapitemsaveddata = MapItem.m_151128_(integer, this.f_8509_); + if (this.entity instanceof ItemFrame && this.tickCount % 10 == 0) { + ItemFrame itemframe = (ItemFrame)this.entity; + ItemStack itemstack = itemframe.getItem(); +- if (itemstack.getItem() instanceof MapItem) { +- Integer integer = MapItem.getMapId(itemstack); +- MapItemSavedData mapitemsaveddata = MapItem.getSavedData(integer, this.level); - if (mapitemsaveddata != null) { -- for(ServerPlayer serverplayer : this.f_8509_.m_6907_()) { -+ Integer integer = MapItem.m_151131_(itemstack); -+ MapItemSavedData mapitemsaveddata = MapItem.m_42853_(itemstack, this.f_8509_); +- for(ServerPlayer serverplayer : this.level.players()) { ++ Integer integer = MapItem.getMapId(itemstack); ++ MapItemSavedData mapitemsaveddata = MapItem.getSavedData(itemstack, this.level); + if (mapitemsaveddata != null) { + for(net.minecraft.server.network.ServerPlayerConnection tracked : this.trackedPlayers) { // CraftBukkit -+ ServerPlayer serverplayer = tracked.m_142253_(); // Magma - mapitemsaveddata.m_77918_(serverplayer, itemstack); - Packet packet = mapitemsaveddata.m_164796_(integer, serverplayer); ++ ServerPlayer serverplayer = tracked.getPlayer(); // Magma + mapitemsaveddata.tickCarriedBy(serverplayer, itemstack); + Packet packet = mapitemsaveddata.getUpdatePacket(integer, serverplayer); if (packet != null) { - serverplayer.f_8906_.m_141995_(packet); + serverplayer.connection.send(packet); } } - } } - this.m_8543_(); + this.sendDirtyEntityData(); @@ -121,6 +_,17 @@ Packet packet1 = null; - boolean flag3 = flag2 || this.f_8521_ % 60 == 0; - boolean flag4 = Math.abs(l - this.f_8517_) >= 1 || Math.abs(k1 - this.f_8518_) >= 1; + boolean flag3 = flag2 || this.tickCount % 60 == 0; + boolean flag4 = Math.abs(l - this.yRotp) >= 1 || Math.abs(k1 - this.xRotp) >= 1; + + // CraftBukkit start - Code moved from below + if (flag3) { -+ this.m_8544_(); ++ this.updateSentPos(); + } + if (flag4) { -+ this.f_8517_ = l; -+ this.f_8518_ = k1; ++ this.yRotp = l; ++ this.xRotp = k1; + } + // CraftBukkit end + - if (this.f_8521_ > 0 || this.f_8510_ instanceof AbstractArrow) { - long i = ClientboundMoveEntityPacket.m_132511_(vec3.f_82479_); - long j = ClientboundMoveEntityPacket.m_132511_(vec3.f_82480_); -@@ -157,14 +_,16 @@ + if (this.tickCount > 0 || this.entity instanceof AbstractArrow) { + long i = ClientboundMoveEntityPacket.entityToPacket(vec3.x); + long j = ClientboundMoveEntityPacket.entityToPacket(vec3.y); +@@ -157,6 +_,7 @@ } - this.m_8543_(); + this.sendDirtyEntityData(); + /* CraftBukkit start - Code moved up if (flag3) { -- this.m_8544_(); -+ this.updateSentPos(); + this.updateSentPos(); } - - if (flag4) { -- this.f_8517_ = l; -- this.f_8518_ = k1; -+ this.yRotp = l; -+ this.xRotp = k1; +@@ -165,6 +_,7 @@ + this.yRotp = l; + this.xRotp = k1; } + // CraftBukkit end */ - this.f_8524_ = false; + this.wasRiding = false; } @@ -180,7 +_,23 @@ - ++this.f_8521_; - if (this.f_8510_.f_19864_) { -- this.m_8538_(new ClientboundSetEntityMotionPacket(this.f_8510_)); + ++this.tickCount; + if (this.entity.hurtMarked) { +- this.broadcastAndSend(new ClientboundSetEntityMotionPacket(this.entity)); + // CraftBukkit start - Create PlayerVelocity event + boolean cancelled = false; -+ if (this.f_8510_ instanceof ServerPlayer) { -+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.f_8510_.getBukkitEntity(); ++ if (this.entity instanceof ServerPlayer) { ++ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.entity.getBukkitEntity(); + org.bukkit.util.Vector velocity = player.getVelocity(); + org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity.clone()); -+ this.f_8510_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.entity.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + cancelled = true; + } else if (!velocity.equals(event.getVelocity())) { @@ -102,82 +98,82 @@ + } + } + if (!cancelled) { -+ this.m_8538_(new ClientboundSetEntityMotionPacket(this.f_8510_)); ++ this.broadcastAndSend(new ClientboundSetEntityMotionPacket(this.entity)); + } + // CraftBukkit end - this.f_8510_.f_19864_ = false; + this.entity.hurtMarked = false; } @@ -189,16 +_,29 @@ - public void m_8534_(ServerPlayer p_8535_) { - this.f_8510_.m_6452_(p_8535_); - p_8535_.f_8906_.m_141995_(new ClientboundRemoveEntitiesPacket(this.f_8510_.m_142049_())); -+ net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(this.f_8510_, p_8535_); + public void removePairing(ServerPlayer p_8535_) { + this.entity.stopSeenByPlayer(p_8535_); + p_8535_.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId())); ++ net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(this.entity, p_8535_); } - public void m_8541_(ServerPlayer p_8542_) { -- this.m_8536_(p_8542_.f_8906_::m_141995_); + public void addPairing(ServerPlayer p_8542_) { +- this.sendPairingData(p_8542_.connection::send); + this.sendPairingData_ent = p_8542_; -+ this.m_8536_(p_8542_.f_8906_::m_141995_); // CraftBukkit - add player - this.f_8510_.m_6457_(p_8542_); -+ net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(this.f_8510_, p_8542_); ++ this.sendPairingData(p_8542_.connection::send); // CraftBukkit - add player + this.entity.startSeenByPlayer(p_8542_); ++ net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(this.entity, p_8542_); } + //Magma start - add original method to prevent errors with mods relying on it [fix for quark] + @org.jetbrains.annotations.Nullable public ServerPlayer sendPairingData_ent = null; - public void m_8536_(Consumer> p_8537_) { + public void sendPairingData(Consumer> p_8537_) { + this.sendPairingData(p_8537_, sendPairingData_ent); + sendPairingData_ent = null; + } + //Magma end + + public void sendPairingData(Consumer> p_8537_, @org.jetbrains.annotations.Nullable ServerPlayer entityplayer) { // CraftBukkit - add player - if (this.f_8510_.m_146910_()) { -- f_8508_.warn("Fetching packet for removed entity {}", (Object)this.f_8510_); + if (this.entity.isRemoved()) { +- LOGGER.warn("Fetching packet for removed entity {}", (Object)this.entity); + // CraftBukkit start - Remove useless error spam, just return + // LOGGER.warn("Fetching packet for removed entity {}", (Object)this.entity); + // CraftBukkit end } - Packet packet = this.f_8510_.m_5654_(); + Packet packet = this.entity.getAddEntityPacket(); @@ -211,6 +_,14 @@ - boolean flag = this.f_8512_; - if (this.f_8510_ instanceof LivingEntity) { - Collection collection = ((LivingEntity)this.f_8510_).m_21204_().m_22170_(); + boolean flag = this.trackDelta; + if (this.entity instanceof LivingEntity) { + Collection collection = ((LivingEntity)this.entity).getAttributes().getSyncableAttributes(); + + // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health -+ int id = entityplayer == null ? this.f_8510_.m_142049_() : entityplayer.m_142049_(); //Magma - add null check -+ if (this.f_8510_.m_142049_() == id && this.f_8510_ instanceof ServerPlayer player) { //Magma - add class check ++ int id = entityplayer == null ? this.entity.getId() : entityplayer.getId(); //Magma - add null check ++ if (this.entity.getId() == id && this.entity instanceof ServerPlayer player) { //Magma - add class check + player.getBukkitEntity().injectScaledMaxHealth(collection, false); + } + // CraftBukkit end + if (!collection.isEmpty()) { - p_8537_.accept(new ClientboundUpdateAttributesPacket(this.f_8510_.m_142049_(), collection)); + p_8537_.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), collection)); } @@ -238,7 +_,13 @@ if (!list.isEmpty()) { - p_8537_.accept(new ClientboundSetEquipmentPacket(this.f_8510_.m_142049_(), list)); + p_8537_.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list)); } -+ ((LivingEntity) this.f_8510_).m_21315_(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending ++ ((LivingEntity) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending } + + // CraftBukkit start - Fix for nonsensical head yaw -+ this.f_8519_ = Mth.m_14143_(this.f_8510_.m_6080_() * 256.0F / 360.0F); -+ p_8537_.accept(new ClientboundRotateHeadPacket(this.f_8510_, (byte) f_8519_)); ++ this.yHeadRotp = Mth.floor(this.entity.getYHeadRot() * 256.0F / 360.0F); ++ p_8537_.accept(new ClientboundRotateHeadPacket(this.entity, (byte) yHeadRotp)); + // CraftBukkit end - if (this.f_8510_ instanceof LivingEntity) { - LivingEntity livingentity = (LivingEntity)this.f_8510_; + if (this.entity instanceof LivingEntity) { + LivingEntity livingentity = (LivingEntity)this.entity; @@ -274,6 +_,11 @@ - if (this.f_8510_ instanceof LivingEntity) { - Set set = ((LivingEntity)this.f_8510_).m_21204_().m_22145_(); + if (this.entity instanceof LivingEntity) { + Set set = ((LivingEntity)this.entity).getAttributes().getDirtyAttributes(); if (!set.isEmpty()) { + // CraftBukkit start - Send scaled max health -+ if (this.f_8510_ instanceof ServerPlayer) { -+ ((ServerPlayer) this.f_8510_).getBukkitEntity().injectScaledMaxHealth(set, false); ++ if (this.entity instanceof ServerPlayer) { ++ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false); + } + // CraftBukkit end - this.m_8538_(new ClientboundUpdateAttributesPacket(this.f_8510_.m_142049_(), set)); + this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set)); } diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index 3735405f..de5c067a 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -181,23 +_,44 @@ - private final List f_8558_; + private final List customSpawners; @Nullable - private final EndDragonFight f_8559_; -- final Int2ObjectMap f_143247_ = new Int2ObjectOpenHashMap<>(); -+ final Int2ObjectMap> f_143247_ = new Int2ObjectOpenHashMap<>(); - private final StructureFeatureManager f_8560_; - private final StructureCheck f_196556_; - private final boolean f_8561_; + private final EndDragonFight dragonFight; +- final Int2ObjectMap dragonParts = new Int2ObjectOpenHashMap<>(); ++ final Int2ObjectMap> dragonParts = new Int2ObjectOpenHashMap<>(); + private final StructureFeatureManager structureFeatureManager; + private final StructureCheck structureCheck; + private final boolean tickTime; + private net.minecraftforge.common.util.WorldCapabilityData capabilityData; + + // CraftBukkit start @@ -18,44 +18,44 @@ + public final UUID uuid; + + public LevelChunk getChunkIfLoaded(int x, int z) { -+ return this.f_8547_.m_62227_(x, z, false); ++ return this.chunkSource.getChunk(x, z, false); + } public ServerLevel(MinecraftServer p_203762_, Executor p_203763_, LevelStorageSource.LevelStorageAccess p_203764_, ServerLevelData p_203765_, ResourceKey p_203766_, Holder p_203767_, ChunkProgressListener p_203768_, ChunkGenerator p_203769_, boolean p_203770_, long p_203771_, List p_203772_, boolean p_203773_) { - super(p_203765_, p_203766_, p_203767_, p_203762_::m_129905_, false, p_203770_, p_203771_); + super(p_203765_, p_203766_, p_203767_, p_203762_::getProfiler, false, p_203770_, p_203771_); + convertable = p_203764_; + setGeneratorAndEnv(generator, org.magmafoundation.magma.forge.ForgeInject.environments.getOrDefault(getTypeKey(), org.bukkit.World.Environment.CUSTOM)); -+ this.pvpMode = p_203762_.m_129799_(); ++ this.pvpMode = p_203762_.isPvpAllowed(); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.forceRandomizedUUIDForDimensions.getValues() && p_203765_ instanceof net.minecraft.world.level.storage.DerivedLevelData) -+ uuid = org.bukkit.craftbukkit.v1_18_R2.util.WorldUUID.getUUID(p_203764_.m_197394_(p_203766_).toFile()); -+ else uuid = org.bukkit.craftbukkit.v1_18_R2.util.WorldUUID.getUUID(p_203764_.f_78271_.toFile()); ++ uuid = org.bukkit.craftbukkit.v1_18_R2.util.WorldUUID.getUUID(p_203764_.getDimensionPath(p_203766_).toFile()); ++ else uuid = org.bukkit.craftbukkit.v1_18_R2.util.WorldUUID.getUUID(p_203764_.levelPath.toFile()); + // CraftBukkit end - this.f_8561_ = p_203773_; - this.f_8548_ = p_203762_; - this.f_8558_ = p_203772_; - this.f_8549_ = p_203765_; + this.tickTime = p_203773_; + this.server = p_203762_; + this.customSpawners = p_203772_; + this.serverLevelData = p_203765_; + if (generator != null) + p_203769_ = new org.bukkit.craftbukkit.v1_18_R2.generator.CustomChunkGenerator(this, p_203769_, generator); + p_203769_.conf = spigotConfig; // Spigot - p_203769_.m_211700_(); - boolean flag = p_203762_.m_6365_(); - DataFixer datafixer = p_203762_.m_129933_(); - EntityPersistentStorage entitypersistentstorage = new EntityStorage(this, p_203764_.m_197394_(p_203766_).resolve("entities"), datafixer, flag, p_203762_); - this.f_143244_ = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage); -- this.f_8547_ = new ServerChunkCache(this, p_203764_, datafixer, p_203762_.m_129909_(), p_203763_, p_203769_, p_203762_.m_6846_().m_11312_(), p_203762_.m_6846_().m_184213_(), flag, p_203768_, this.f_143244_::m_157524_, () -> { -+ this.f_8547_ = new ServerChunkCache(this, p_203764_, datafixer, p_203762_.m_129909_(), p_203763_, p_203769_, this.spigotConfig.viewDistance, this.spigotConfig.simulationDistance, flag, p_203768_, this.f_143244_::m_157524_, () -> { // Spigot - return p_203762_.m_129783_().m_8895_(); + p_203769_.ensureStructuresGenerated(); + boolean flag = p_203762_.forceSynchronousWrites(); + DataFixer datafixer = p_203762_.getFixerUpper(); + EntityPersistentStorage entitypersistentstorage = new EntityStorage(this, p_203764_.getDimensionPath(p_203766_).resolve("entities"), datafixer, flag, p_203762_); + this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage); +- this.chunkSource = new ServerChunkCache(this, p_203764_, datafixer, p_203762_.getStructureManager(), p_203763_, p_203769_, p_203762_.getPlayerList().getViewDistance(), p_203762_.getPlayerList().getSimulationDistance(), flag, p_203768_, this.entityManager::updateChunkStatus, () -> { ++ this.chunkSource = new ServerChunkCache(this, p_203764_, datafixer, p_203762_.getStructureManager(), p_203763_, p_203769_, this.spigotConfig.viewDistance, this.spigotConfig.simulationDistance, flag, p_203768_, this.entityManager::updateChunkStatus, () -> { // Spigot + return p_203762_.overworld().getDataStorage(); }); - this.f_8552_ = new PortalForcer(this); + this.portalForcer = new PortalForcer(this); @@ -223,6 +_,30 @@ } - this.f_143245_ = new SleepStatus(); + this.sleepStatus = new SleepStatus(); + this.initCapabilities(); + + // CraftBukkit start + this.world = new org.bukkit.craftbukkit.v1_18_R2.CraftWorld((ServerLevel) this, generator, biomeProvider, environment); -+ m_6857_().world = this; ++ getWorldBorder().world = this; + // CraftBukkit end + + this.getCraftServer().addWorld(this.getWorld()); //Magma - add world to bukkit's world list @@ -77,151 +77,151 @@ + return super.getTypeKey(); } - public void m_8606_(int p_8607_, int p_8608_, boolean p_8609_, boolean p_8610_) { + public void setWeatherParameters(int p_8607_, int p_8608_, boolean p_8609_, boolean p_8610_) { @@ -251,8 +_,8 @@ - int i = this.m_46469_().m_46215_(GameRules.f_151486_); - if (this.f_143245_.m_144002_(i) && this.f_143245_.m_144004_(i, this.f_8546_)) { - if (this.m_46469_().m_46207_(GameRules.f_46140_)) { -- long j = this.f_46442_.m_6792_() + 24000L; -- this.m_8615_(j - j % 24000L); -+ long j = this.m_46468_() + 24000L; -+ this.m_8615_(net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, j - j % 24000L, this.m_46468_())); + 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)) { +- long j = this.levelData.getDayTime() + 24000L; +- this.setDayTime(j - j % 24000L); ++ long j = this.getDayTime() + 24000L; ++ this.setDayTime(net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, j - j % 24000L, this.getDayTime())); } - this.m_8804_(); + this.wakeUpAllPlayers(); @@ -264,6 +_,7 @@ - this.m_46465_(); - this.m_8809_(); - profilerfiller.m_6182_("tickPending"); + this.updateSkyBrightness(); + this.tickTime(); + profilerfiller.popPush("tickPending"); + timings.scheduledBlocks.startTiming(); // Paper - if (!this.m_46659_()) { - long k = this.m_46467_(); - profilerfiller.m_6180_("blockTicks"); + if (!this.isDebug()) { + long k = this.getGameTime(); + profilerfiller.push("blockTicks"); @@ -272,28 +_,38 @@ - this.f_184047_.m_193225_(k, 65536, this::m_184076_); - profilerfiller.m_7238_(); + this.fluidTicks.tick(k, 65536, this::tickFluid); + profilerfiller.pop(); } + timings.scheduledBlocks.stopTiming(); // Paper - profilerfiller.m_6182_("raid"); + profilerfiller.popPush("raid"); + this.timings.raids.startTiming(); // Paper - timings - this.f_8565_.m_37957_(); + this.raids.tick(); + this.timings.raids.stopTiming(); // Paper - timings - profilerfiller.m_6182_("chunkSource"); + profilerfiller.popPush("chunkSource"); + this.timings.chunkProviderTick.startTiming(); // Paper - timings - this.m_7726_().m_201698_(p_8794_, true); + this.getChunkSource().tick(p_8794_, true); + this.timings.chunkProviderTick.stopTiming(); // Paper - timings - profilerfiller.m_6182_("blockEvents"); + profilerfiller.popPush("blockEvents"); + timings.doSounds.startTiming(); // Spigot - this.m_8807_(); + this.runBlockEvents(); + timings.doSounds.stopTiming(); // Spigot - this.f_8557_ = false; - profilerfiller.m_7238_(); -- boolean flag = !this.f_8546_.isEmpty() || !this.m_8902_().isEmpty(); -+ boolean flag = !this.f_8546_.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones + this.handlingTick = false; + profilerfiller.pop(); +- boolean flag = !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); ++ boolean flag = !this.players.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones if (flag) { - this.m_8886_(); + this.resetEmptyTime(); } - if (flag || this.f_8551_++ < 300) { - profilerfiller.m_6180_("entities"); + if (flag || this.emptyTime++ < 300) { + profilerfiller.push("entities"); + timings.tickEntities.startTiming(); // Spigot - if (this.f_8559_ != null) { - profilerfiller.m_6180_("dragonFight"); - this.f_8559_.m_64095_(); - profilerfiller.m_7238_(); + if (this.dragonFight != null) { + profilerfiller.push("dragonFight"); + this.dragonFight.tick(); + profilerfiller.pop(); } + org.spigotmc.ActivationRange.activateEntities(this); // Spigot + timings.entityTick.startTiming(); // Spigot - this.f_143243_.m_156910_((p_184065_) -> { - if (!p_184065_.m_146910_()) { - if (this.m_143342_(p_184065_)) { + this.entityTickList.forEach((p_184065_) -> { + if (!p_184065_.isRemoved()) { + if (this.shouldDiscardEntity(p_184065_)) { @@ -313,12 +_,16 @@ } - profilerfiller.m_6180_("tick"); -- this.m_46653_(this::m_8647_, p_184065_); -+ if (!p_184065_.m_146910_() && !(p_184065_ instanceof net.minecraftforge.entity.PartEntity)) { -+ this.m_46653_(this::m_8647_, p_184065_); + profilerfiller.push("tick"); +- this.guardEntityTick(this::tickNonPassenger, p_184065_); ++ if (!p_184065_.isRemoved() && !(p_184065_ instanceof net.minecraftforge.entity.PartEntity)) { ++ this.guardEntityTick(this::tickNonPassenger, p_184065_); + } - profilerfiller.m_7238_(); + profilerfiller.pop(); } } } }); + timings.entityTick.stopTiming(); // Spigot + timings.tickEntities.stopTiming(); // Spigot - profilerfiller.m_7238_(); - this.m_46463_(); + profilerfiller.pop(); + this.tickBlockEntities(); } @@ -377,7 +_,7 @@ - int j = chunkpos.m_45605_(); - ProfilerFiller profilerfiller = this.m_46473_(); - profilerfiller.m_6180_("thunder"); -- if (flag && this.m_46470_() && this.f_46441_.nextInt(100000) == 0) { -+ if (flag && this.m_46470_() && this.spigotConfig.thunderChance > 0 && this.f_46441_.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot - BlockPos blockpos = this.m_143288_(this.m_46496_(i, 0, j, 15)); - if (this.m_46758_(blockpos)) { - DifficultyInstance difficultyinstance = this.m_6436_(blockpos); + int j = chunkpos.getMinBlockZ(); + ProfilerFiller profilerfiller = this.getProfiler(); + profilerfiller.push("thunder"); +- if (flag && this.isThundering() && this.random.nextInt(100000) == 0) { ++ if (flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot + BlockPos blockpos = this.findLightningTargetAround(this.getBlockRandomPos(i, 0, j, 15)); + if (this.isRainingAt(blockpos)) { + DifficultyInstance difficultyinstance = this.getCurrentDifficultyAt(blockpos); @@ -402,6 +_,7 @@ - BlockPos blockpos2 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); - BlockPos blockpos3 = blockpos2.m_7495_(); - Biome biome = this.m_204166_(blockpos2).m_203334_(); + BlockPos blockpos2 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, this.getBlockRandomPos(i, 0, j, 15)); + BlockPos blockpos3 = blockpos2.below(); + Biome biome = this.getBiome(blockpos2).value(); + if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks - if (biome.m_47477_(this, blockpos3)) { - this.m_46597_(blockpos3, Blocks.f_50126_.m_49966_()); + if (biome.shouldFreeze(this, blockpos3)) { + this.setBlockAndUpdate(blockpos3, Blocks.ICE.defaultBlockState()); } @@ -422,6 +_,7 @@ } - profilerfiller.m_6182_("tickBlocks"); + profilerfiller.popPush("tickBlocks"); + timings.chunkTicksBlocks.startTiming(); // Paper if (p_8716_ > 0) { - for(LevelChunkSection levelchunksection : p_8715_.m_7103_()) { - if (levelchunksection.m_63014_()) { + for(LevelChunkSection levelchunksection : p_8715_.getSections()) { + if (levelchunksection.isRandomlyTicking()) { @@ -446,6 +_,7 @@ } } + timings.chunkTicksBlocks.stopTiming(); // Paper - profilerfiller.m_7238_(); + profilerfiller.pop(); } @@ -592,15 +_,19 @@ - this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); + this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel), this.dimension()); } + /* The function in use here has been replaced in order to only send the weather info to players in the correct dimension, + * rather than to all players on the server. This is what causes the client-side rain, as the + * client believes that it has started raining locally, rather than in another dimension. + */ - if (flag != this.m_46471_()) { + if (flag != this.isRaining()) { if (flag) { -- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132155_, 0.0F)); -+ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132155_, 0.0F), this.m_46472_()); +- this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.STOP_RAINING, 0.0F)); ++ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.STOP_RAINING, 0.0F), this.dimension()); } else { -- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132154_, 0.0F)); -+ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132154_, 0.0F), this.m_46472_()); +- this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); ++ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F), this.dimension()); } -- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132160_, this.f_46438_)); -- this.f_8548_.m_6846_().m_11268_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_)); -+ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132160_, this.f_46438_), this.m_46472_()); -+ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); +- this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); +- this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); ++ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); ++ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel), this.dimension()); } } @@ -633,6 +_,22 @@ } - public void m_8647_(Entity p_8648_) { + public void tickNonPassenger(Entity p_8648_) { + ++co.aikar.timings.TimingHistory.entityTicks; // Paper - timings + // Spigot start + co.aikar.timings.Timing timer; // Paper + if (!org.spigotmc.ActivationRange.checkIfActive(p_8648_)) { -+ p_8648_.f_19797_++; -+ timer = p_8648_.m_6095_().inactiveTickTimer.startTiming(); try { // Paper - timings ++ p_8648_.tickCount++; ++ timer = p_8648_.getType().inactiveTickTimer.startTiming(); try { // Paper - timings + p_8648_.inactiveTick(); + } finally { timer.stopTiming(); } // Paper + return; @@ -229,62 +229,62 @@ + // Spigot end + // Paper start- timings + co.aikar.timings.TimingHistory.activatedEntityTicks++; -+ timer = p_8648_.m_20202_() != null ? p_8648_.m_6095_().passengerTickTimer.startTiming() : p_8648_.m_6095_().tickTimer.startTiming(); ++ timer = p_8648_.getVehicle() != null ? p_8648_.getType().passengerTickTimer.startTiming() : p_8648_.getType().tickTimer.startTiming(); + try { + // Paper end - timings - p_8648_.m_146867_(); - ProfilerFiller profilerfiller = this.m_46473_(); - ++p_8648_.f_19797_; + p_8648_.setOldPosAndRot(); + ProfilerFiller profilerfiller = this.getProfiler(); + ++p_8648_.tickCount; @@ -641,12 +_,13 @@ }); - profilerfiller.m_6174_("tickNonPassenger"); - p_8648_.m_8119_(); + profilerfiller.incrementCounter("tickNonPassenger"); + p_8648_.tick(); + p_8648_.postTick(); // CraftBukkit - this.m_46473_().m_7238_(); + this.getProfiler().pop(); - for(Entity entity : p_8648_.m_20197_()) { - this.m_8662_(p_8648_, entity); + for(Entity entity : p_8648_.getPassengers()) { + this.tickPassenger(p_8648_, entity); } - + } finally { timer.stopTiming(); } // Paper - timings } - private void m_8662_(Entity p_8663_, Entity p_8664_) { + private void tickPassenger(Entity p_8663_, Entity p_8664_) { @@ -656,10 +_,12 @@ - ++p_8664_.f_19797_; - ProfilerFiller profilerfiller = this.m_46473_(); - profilerfiller.m_6521_(() -> { -- return Registry.f_122826_.m_7981_(p_8664_.m_6095_()).toString(); -+ return p_8664_.m_6095_().getRegistryName() == null ? p_8664_.m_6095_().toString() : p_8664_.m_6095_().getRegistryName().toString(); + ++p_8664_.tickCount; + ProfilerFiller profilerfiller = this.getProfiler(); + profilerfiller.push(() -> { +- return Registry.ENTITY_TYPE.getKey(p_8664_.getType()).toString(); ++ return p_8664_.getType().getRegistryName() == null ? p_8664_.getType().toString() : p_8664_.getType().getRegistryName().toString(); }); - profilerfiller.m_6174_("tickPassenger"); + profilerfiller.incrementCounter("tickPassenger"); + if (p_8664_.canUpdate()) - p_8664_.m_6083_(); + p_8664_.rideTick(); + p_8664_.postTick(); // CraftBukkit - profilerfiller.m_7238_(); + profilerfiller.pop(); - for(Entity entity : p_8664_.m_20197_()) { + for(Entity entity : p_8664_.getPassengers()) { @@ -679,6 +_,8 @@ - public void m_8643_(@Nullable ProgressListener p_8644_, boolean p_8645_, boolean p_8646_) { - ServerChunkCache serverchunkcache = this.m_7726_(); + public void save(@Nullable ProgressListener p_8644_, boolean p_8645_, boolean p_8646_) { + ServerChunkCache serverchunkcache = this.getChunkSource(); if (!p_8646_) { + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit + try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper if (p_8644_ != null) { - p_8644_.m_6309_(new TranslatableComponent("menu.savingLevel")); + p_8644_.progressStartNoAbort(new TranslatableComponent("menu.savingLevel")); } @@ -688,13 +_,17 @@ - p_8644_.m_6307_(new TranslatableComponent("menu.savingChunks")); + p_8644_.progressStage(new TranslatableComponent("menu.savingChunks")); } + timings.worldSaveChunks.startTiming(); // Paper - serverchunkcache.m_8419_(p_8645_); + serverchunkcache.save(p_8645_); + timings.worldSaveChunks.stopTiming(); // Paper + }// Paper if (p_8645_) { - this.f_143244_.m_157561_(); + this.entityManager.saveAll(); } else { - this.f_143244_.m_157554_(); + this.entityManager.autoSave(); } + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Save(this)); @@ -294,32 +294,32 @@ @@ -740,15 +_,39 @@ } - public boolean m_7967_(Entity p_8837_) { -- return this.m_8872_(p_8837_); + public boolean addFreshEntity(Entity p_8837_) { +- return this.addEntity(p_8837_); + // CraftBukkit start + return this.addFreshEntity(p_8837_, p_8837_.spawnReason); + } + + public boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + prepareAddEntity(reason); -+ return this.m_8872_(entity); ++ return this.addEntity(entity); + // CraftBukkit end } - public boolean m_8847_(Entity p_8848_) { -- return this.m_8872_(p_8848_); + public boolean addWithUUID(Entity p_8848_) { +- return this.addEntity(p_8848_); + // CraftBukkit start + return this.addWithUUID(p_8848_, p_8848_.spawnReason); + } + + public boolean addWithUUID(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + prepareAddEntity(reason); -+ return this.m_8872_(entity); ++ return this.addEntity(entity); + // CraftBukkit end } - public void m_143334_(Entity p_143335_) { -- this.m_8872_(p_143335_); + public void addDuringTeleport(Entity p_143335_) { +- this.addEntity(p_143335_); + // CraftBukkit start + // SPIGOT-6415: Don't call spawn event for entities which travel trough worlds, + // since it is only an implementation detail, that a new entity is created when @@ -329,19 +329,19 @@ + + public void addDuringTeleport(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + prepareAddEntity(reason); -+ this.m_8872_(entity); ++ this.addEntity(entity); + // CraftBukkit end } - public void m_8622_(ServerPlayer p_8623_) { + public void addDuringCommandTeleport(ServerPlayer p_8623_) { @@ -767,7 +_,55 @@ - this.m_8853_(p_8846_); + this.addPlayer(p_8846_); } + /** @deprecated To be removed in 1.19. See {@link #removePlayerImmediately(ServerPlayer, Entity.RemovalReason)} as a possible replacement. */ + @Deprecated(forRemoval = true, since = "1.18.1") + public void removePlayer(ServerPlayer p_8850_, boolean keepData) { -+ p_8850_.m_146870_(); ++ p_8850_.discard(); + this.removeEntity(p_8850_, keepData); + } + @@ -350,22 +350,22 @@ + public void removeEntityComplete(Entity p_8865_, boolean keepData) { + if(p_8865_.isMultipartEntity()) { + for(net.minecraftforge.entity.PartEntity parts : p_8865_.getParts()) { -+ parts.m_146870_(); ++ parts.discard(); + } + } + -+ this.m_7726_().m_8443_(p_8865_); ++ this.getChunkSource().removeEntity(p_8865_); + if (p_8865_ instanceof ServerPlayer) { + ServerPlayer serverplayerentity = (ServerPlayer)p_8865_; -+ this.f_8546_.remove(serverplayerentity); ++ this.players.remove(serverplayerentity); + } + -+ this.m_6188_().m_83420_(p_8865_); ++ this.getScoreboard().entityRemoved(p_8865_); + if (p_8865_ instanceof Mob) { -+ this.f_143246_.remove(((Mob)p_8865_).m_21573_()); ++ this.navigatingMobs.remove(((Mob)p_8865_).getNavigation()); + } + -+ p_8865_.m_146870_(); ++ p_8865_.discard(); + // onRemovedFromWorld and EntityLeaveWorldEvent are called by discard, so no need to do it ourselves here lest we double-call + } + @@ -378,27 +378,27 @@ + /** @deprecated To be removed in 1.19. See {@link Entity#setRemoved(Entity.RemovalReason)} as a possible replacement. */ + @Deprecated(forRemoval = true, since = "1.18.1") + public void removeEntity(Entity p_8868_, boolean keepData) { -+ if (this.f_8557_) { -+ throw (IllegalStateException) net.minecraft.Util.m_137570_(new IllegalStateException("Removing entity while ticking!")); ++ if (this.handlingTick) { ++ throw (IllegalStateException) net.minecraft.Util.pauseInIde(new IllegalStateException("Removing entity while ticking!")); + } else { + removeEntityComplete(p_8868_, keepData); + } + } + - private void m_8853_(ServerPlayer p_8854_) { + private void addPlayer(ServerPlayer p_8854_) { + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_8854_, this))) return; - Entity entity = this.m_142646_().m_142694_(p_8854_.m_142081_()); + Entity entity = this.getEntities().get(p_8854_.getUUID()); if (entity != null) { - f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_142081_().toString()); + LOGGER.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.getUUID().toString()); @@ -775,28 +_,73 @@ - this.m_143261_((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); + this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } -- this.f_143244_.m_157533_(p_8854_); +- this.entityManager.addNewEntity(p_8854_); - } - -- private boolean m_8872_(Entity p_8873_) { -+ this.f_143244_.addNewEntityWithoutEvent(p_8854_); +- private boolean addEntity(Entity p_8873_) { ++ this.entityManager.addNewEntityWithoutEvent(p_8854_); + p_8854_.onAddedToWorld(); + } + @@ -409,14 +409,14 @@ + } + + // CraftBukkit start -+ public boolean m_8872_(Entity p_8873_) { ++ public boolean addEntity(Entity p_8873_) { + org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot - if (p_8873_.m_146910_()) { -- f_8566_.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.m_20613_(p_8873_.m_6095_())); + if (p_8873_.isRemoved()) { +- LOGGER.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.getKey(p_8873_.getType())); + // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit return false; } else { -- return this.f_143244_.m_157533_(p_8873_); +- return this.entityManager.addNewEntity(p_8873_); + org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason = addEntity_spawnReason; + addEntity_spawnReason = null; //reset + //Magma end @@ -427,7 +427,7 @@ + } + // CraftBukkit end + -+ if (this.f_143244_.m_157533_(p_8873_)) { ++ if (this.entityManager.addNewEntity(p_8873_)) { + p_8873_.onAddedToWorld(); + return true; + } else { @@ -442,24 +442,24 @@ + trySpawnReason.set(spawnReason); } - public boolean m_8860_(Entity p_8861_) { - if (p_8861_.m_142428_().map(Entity::m_142081_).anyMatch(this.f_143244_::m_157550_)) { + public boolean tryAddFreshEntityWithPassengers(Entity p_8861_) { + if (p_8861_.getSelfAndPassengers().map(Entity::getUUID).anyMatch(this.entityManager::isLoaded)) { return false; } else { + this.prepareEntity(p_8861_, trySpawnReason.getAndSet(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT)); // Magma - add spawn reason - this.m_47205_(p_8861_); + this.addFreshEntityWithPassengers(p_8861_); return true; } } + public boolean tryAddFreshEntityWithPassengers(Entity p_8861_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + trySpawnReason.set(reason); -+ return m_8860_(p_8861_); ++ return tryAddFreshEntityWithPassengers(p_8861_); + } + - public void m_8712_(LevelChunk p_8713_) { + public void unload(LevelChunk p_8713_) { + // Spigot Start -+ for (net.minecraft.world.level.block.entity.BlockEntity tileentity : p_8713_.m_62954_().values()) { ++ for (net.minecraft.world.level.block.entity.BlockEntity tileentity : p_8713_.getBlockEntities().values()) { + if (tileentity instanceof net.minecraft.world.Container) { + for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { + h.closeInventory(); @@ -467,11 +467,11 @@ + } + } + // Spigot End - p_8713_.m_187957_(); - p_8713_.m_187979_(this); + p_8713_.clearAllBlockEntities(); + p_8713_.unregisterTickContainerFromLevel(this); } @@ -805,12 +_,41 @@ - p_143262_.m_142687_(p_143263_); + p_143262_.remove(p_143263_); } + // CraftBukkit start @@ -486,22 +486,22 @@ + return false; + } + -+ return this.m_7967_(entitylightning); ++ return this.addFreshEntity(entitylightning); + } + // CraftBukkit end + - public void m_6801_(int p_8612_, BlockPos p_8613_, int p_8614_) { + public void destroyBlockProgress(int p_8612_, BlockPos p_8613_, int p_8614_) { + // CraftBukkit start + Player entityhuman = null; -+ Entity entity = this.m_6815_(p_8612_); ++ Entity entity = this.getEntity(p_8612_); + if (entity instanceof Player) entityhuman = (Player) entity; + // CraftBukkit end + - for(ServerPlayer serverplayer : this.f_8548_.m_6846_().m_11314_()) { - if (serverplayer != null && serverplayer.f_19853_ == this && serverplayer.m_142049_() != p_8612_) { - double d0 = (double)p_8613_.m_123341_() - serverplayer.m_20185_(); - double d1 = (double)p_8613_.m_123342_() - serverplayer.m_20186_(); - double d2 = (double)p_8613_.m_123343_() - serverplayer.m_20189_(); + for(ServerPlayer serverplayer : this.server.getPlayerList().getPlayers()) { + if (serverplayer != null && serverplayer.level == this && serverplayer.getId() != p_8612_) { + double d0 = (double)p_8613_.getX() - serverplayer.getX(); + double d1 = (double)p_8613_.getY() - serverplayer.getY(); + double d2 = (double)p_8613_.getZ() - serverplayer.getZ(); + + // CraftBukkit start + if (entityhuman != null && !serverplayer.getBukkitEntity().canSee(entityhuman.getBukkitEntity())) { @@ -510,58 +510,58 @@ + // CraftBukkit end + if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { - serverplayer.f_8906_.m_141995_(new ClientboundBlockDestructionPacket(p_8612_, p_8613_, p_8614_)); + serverplayer.connection.send(new ClientboundBlockDestructionPacket(p_8612_, p_8613_, p_8614_)); } @@ -820,10 +_,20 @@ } - public void m_6263_(@Nullable Player p_8675_, double p_8676_, double p_8677_, double p_8678_, SoundEvent p_8679_, SoundSource p_8680_, float p_8681_, float p_8682_) { + public void playSound(@Nullable Player p_8675_, double p_8676_, double p_8677_, double p_8678_, SoundEvent p_8679_, SoundSource p_8680_, float p_8681_, float p_8682_) { + net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_8675_, p_8679_, p_8680_, p_8681_, p_8682_); + if (event.isCanceled() || event.getSound() == null) return; + p_8679_ = event.getSound(); + p_8680_ = event.getCategory(); + p_8681_ = event.getVolume(); - this.f_8548_.m_6846_().m_11241_(p_8675_, p_8676_, p_8677_, p_8678_, p_8681_ > 1.0F ? (double)(16.0F * p_8681_) : 16.0D, this.m_46472_(), new ClientboundSoundPacket(p_8679_, p_8680_, p_8676_, p_8677_, p_8678_, p_8681_, p_8682_)); + this.server.getPlayerList().broadcast(p_8675_, p_8676_, p_8677_, p_8678_, p_8681_ > 1.0F ? (double)(16.0F * p_8681_) : 16.0D, this.dimension(), new ClientboundSoundPacket(p_8679_, p_8680_, p_8676_, p_8677_, p_8678_, p_8681_, p_8682_)); } - public void m_6269_(@Nullable Player p_8689_, Entity p_8690_, SoundEvent p_8691_, SoundSource p_8692_, float p_8693_, float p_8694_) { + public void playSound(@Nullable Player p_8689_, Entity p_8690_, SoundEvent p_8691_, SoundSource p_8692_, float p_8693_, float p_8694_) { + net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_8689_, p_8691_, p_8692_, p_8693_, p_8694_); + if (event.isCanceled() || event.getSound() == null) return; + p_8691_ = event.getSound(); + p_8692_ = event.getCategory(); + p_8693_ = event.getVolume(); - this.f_8548_.m_6846_().m_11241_(p_8689_, p_8690_.m_20185_(), p_8690_.m_20186_(), p_8690_.m_20189_(), p_8693_ > 1.0F ? (double)(16.0F * p_8693_) : 16.0D, this.m_46472_(), new ClientboundSoundEntityPacket(p_8691_, p_8692_, p_8690_, p_8693_, p_8694_)); + this.server.getPlayerList().broadcast(p_8689_, p_8690_.getX(), p_8690_.getY(), p_8690_.getZ(), p_8693_ > 1.0F ? (double)(16.0F * p_8693_) : 16.0D, this.dimension(), new ClientboundSoundEntityPacket(p_8691_, p_8692_, p_8690_, p_8693_, p_8694_)); } @@ -840,6 +_,7 @@ } - public void m_142346_(@Nullable Entity p_143268_, GameEvent p_143269_, BlockPos p_143270_) { + public void gameEvent(@Nullable Entity p_143268_, GameEvent p_143269_, BlockPos p_143270_) { + if (net.minecraftforge.common.ForgeHooks.onVanillaGameEvent(this, p_143268_, p_143269_, p_143270_)) - this.m_151513_(p_143268_, p_143269_, p_143270_, p_143269_.m_157827_()); + this.postGameEventInRadius(p_143268_, p_143269_, p_143270_, p_143269_.getNotificationRadius()); } @@ -875,6 +_,35 @@ } } -+ public void m_46672_(BlockPos p_215045_, Block p_215046_) { ++ public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { + if (!org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) { -+ super.m_46672_(p_215045_, p_215046_); ++ super.updateNeighborsAt(p_215045_, p_215046_); + return; + } -+ net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215045_, this.m_8055_(p_215045_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); ++ net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215045_, this.getBlockState(p_215045_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); + this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215045_, p_215046_, (Direction)null); + } + -+ public void m_46590_(BlockPos p_215052_, Block p_215053_, Direction p_215054_) { ++ public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_) { + if (!org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) { -+ super.m_46590_(p_215052_, p_215053_, p_215054_); ++ super.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_); + return; + } + java.util.EnumSet directions = java.util.EnumSet.allOf(Direction.class); + directions.remove(p_215054_); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215052_, this.m_8055_(p_215052_), directions, false).isCanceled()) ++ 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_); + } @@ -574,21 +574,21 @@ + this.neighborUpdater.neighborChanged(p_215035_, p_215036_, p_215037_, p_215038_, p_215039_); + } + - public void m_7605_(Entity p_8650_, byte p_8651_) { - this.m_7726_().m_8394_(p_8650_, new ClientboundEntityEventPacket(p_8650_, p_8651_)); + public void broadcastEntityEvent(Entity p_8650_, byte p_8651_) { + this.getChunkSource().broadcastAndSend(p_8650_, new ClientboundEntityEventPacket(p_8650_, p_8651_)); } @@ -885,6 +_,7 @@ - public Explosion m_7703_(@Nullable Entity p_8653_, @Nullable DamageSource p_8654_, @Nullable ExplosionDamageCalculator p_8655_, double p_8656_, double p_8657_, double p_8658_, float p_8659_, boolean p_8660_, Explosion.BlockInteraction p_8661_) { + public Explosion explode(@Nullable Entity p_8653_, @Nullable DamageSource p_8654_, @Nullable ExplosionDamageCalculator p_8655_, double p_8656_, double p_8657_, double p_8658_, float p_8659_, boolean p_8660_, Explosion.BlockInteraction p_8661_) { Explosion explosion = new Explosion(this, p_8653_, p_8654_, p_8655_, p_8656_, p_8657_, p_8658_, p_8659_, p_8660_, p_8661_); + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; - explosion.m_46061_(); - explosion.m_46075_(false); + explosion.explode(); + explosion.finalizeExplosion(false); if (p_8661_ == Explosion.BlockInteraction.NONE) { @@ -956,12 +_,21 @@ } - public int m_8767_(T p_8768_, double p_8769_, double p_8770_, double p_8771_, int p_8772_, double p_8773_, double p_8774_, double p_8775_, double p_8776_) { + public int sendParticles(T p_8768_, double p_8769_, double p_8770_, double p_8771_, int p_8772_, double p_8773_, double p_8774_, double p_8775_, double p_8776_) { - ClientboundLevelParticlesPacket clientboundlevelparticlespacket = new ClientboundLevelParticlesPacket(p_8768_, false, p_8769_, p_8770_, p_8771_, (float)p_8773_, (float)p_8774_, (float)p_8775_, (float)p_8776_, p_8772_); + + // CraftBukkit - visibility api support @@ -600,46 +600,46 @@ + // CraftBukkit end int i = 0; - for(int j = 0; j < this.f_8546_.size(); ++j) { - ServerPlayer serverplayer = this.f_8546_.get(j); -- if (this.m_8636_(serverplayer, false, p_8769_, p_8770_, p_8771_, clientboundlevelparticlespacket)) { + for(int j = 0; j < this.players.size(); ++j) { + ServerPlayer serverplayer = this.players.get(j); +- if (this.sendParticles(serverplayer, false, p_8769_, p_8770_, p_8771_, clientboundlevelparticlespacket)) { + if (sender != null && !serverplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit + -+ if (this.m_8636_(serverplayer, force, p_8769_, p_8770_, p_8771_, clientboundlevelparticlespacket)) { // CraftBukkit ++ if (this.sendParticles(serverplayer, force, p_8769_, p_8770_, p_8771_, clientboundlevelparticlespacket)) { // CraftBukkit ++i; } } @@ -1048,6 +_,7 @@ } - public void m_142325_(String p_143305_, MapItemSavedData p_143306_) { + public void setMapData(String p_143305_, MapItemSavedData p_143306_) { + p_143306_.id = p_143305_; // CraftBukkit - this.m_142572_().m_129783_().m_8895_().m_164855_(p_143305_, p_143306_); + this.getServer().overworld().getDataStorage().set(p_143305_, p_143306_); } @@ -1400,19 +_,42 @@ } - public static void m_8617_(ServerLevel p_8618_) { + public static void makeObsidianPlatform(ServerLevel p_8618_) { + // CraftBukkit start + ServerLevel.makeObsidianPlatform(p_8618_, null); + } + + public static void makeObsidianPlatform(ServerLevel p_8618_, Entity entity) { + // CraftBukkit end - BlockPos blockpos = f_8562_; - int i = blockpos.m_123341_(); - int j = blockpos.m_123342_() - 2; - int k = blockpos.m_123343_(); + BlockPos blockpos = END_SPAWN_POINT; + int i = blockpos.getX(); + int j = blockpos.getY() - 2; + int k = blockpos.getZ(); + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator(p_8618_); - BlockPos.m_121976_(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((p_207578_) -> { -- p_8618_.m_46597_(p_207578_, Blocks.f_50016_.m_49966_()); -+ blockList.m_7731_(p_207578_, Blocks.f_50016_.m_49966_(), 3); + BlockPos.betweenClosed(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((p_207578_) -> { +- p_8618_.setBlockAndUpdate(p_207578_, Blocks.AIR.defaultBlockState()); ++ blockList.setBlock(p_207578_, Blocks.AIR.defaultBlockState(), 3); }); - BlockPos.m_121976_(i - 2, j, k - 2, i + 2, j, k + 2).forEach((p_184101_) -> { -- p_8618_.m_46597_(p_184101_, Blocks.f_50080_.m_49966_()); -+ blockList.m_7731_(p_184101_, Blocks.f_50080_.m_49966_(), 3); + BlockPos.betweenClosed(i - 2, j, k - 2, i + 2, j, k + 2).forEach((p_184101_) -> { +- p_8618_.setBlockAndUpdate(p_184101_, Blocks.OBSIDIAN.defaultBlockState()); ++ blockList.setBlock(p_184101_, Blocks.OBSIDIAN.defaultBlockState(), 3); }); + org.bukkit.World bworld = p_8618_.getWorld(); + org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); @@ -653,90 +653,90 @@ + + protected void initCapabilities() { + this.gatherCapabilities(); -+ capabilityData = this.m_8895_().m_164861_(e -> net.minecraftforge.common.util.WorldCapabilityData.load(e, getCapabilities()), () -> new net.minecraftforge.common.util.WorldCapabilityData(getCapabilities()), net.minecraftforge.common.util.WorldCapabilityData.ID); ++ capabilityData = this.getDataStorage().computeIfAbsent(e -> net.minecraftforge.common.util.WorldCapabilityData.load(e, getCapabilities()), () -> new net.minecraftforge.common.util.WorldCapabilityData(getCapabilities()), net.minecraftforge.common.util.WorldCapabilityData.ID); + capabilityData.setCapabilities(getCapabilities()); } - public LevelEntityGetter m_142646_() { + public LevelEntityGetter getEntities() { + org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot - return this.f_143244_.m_157567_(); + return this.entityManager.getEntityGetter(); } @@ -1480,6 +_,7 @@ } - public void m_141985_(Entity p_143371_) { + public void onTrackingStart(Entity p_143371_) { + org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot - ServerLevel.this.m_7726_().m_8463_(p_143371_); + ServerLevel.this.getChunkSource().addEntity(p_143371_); if (p_143371_ instanceof ServerPlayer) { ServerPlayer serverplayer = (ServerPlayer)p_143371_; @@ -1497,17 +_,41 @@ - ServerLevel.this.f_143246_.add(mob); + ServerLevel.this.navigatingMobs.add(mob); } - if (p_143371_ instanceof EnderDragon) { - EnderDragon enderdragon = (EnderDragon)p_143371_; - -- for(EnderDragonPart enderdragonpart : enderdragon.m_31156_()) { +- for(EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { + if (p_143371_.isMultipartEntity()) { + for(net.minecraftforge.entity.PartEntity enderdragonpart : p_143371_.getParts()) { - ServerLevel.this.f_143247_.put(enderdragonpart.m_142049_(), enderdragonpart); + ServerLevel.this.dragonParts.put(enderdragonpart.getId(), enderdragonpart); } } + p_143371_.valid = true; // CraftBukkit } - public void m_141981_(Entity p_143375_) { + public void onTrackingEnd(Entity p_143375_) { + org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot + // Spigot start + if ( p_143375_ instanceof Player ) + { -+ m_142572_().f_129762_.values().stream().map( ServerLevel::m_8895_ ).forEach( (worldData) -> ++ getServer().levels.values().stream().map( ServerLevel::getDataStorage ).forEach( (worldData) -> + { -+ for (Object o : worldData.f_78144_.values() ) ++ for (Object o : worldData.cache.values() ) + { + if ( o instanceof MapItemSavedData ) + { + MapItemSavedData map = (MapItemSavedData) o; -+ map.f_77896_.remove( (Player) p_143375_ ); -+ map.f_77893_.removeIf( holdingPlayer -> holdingPlayer.f_77959_ == p_143375_ ); ++ map.carriedByPlayers.remove( (Player) p_143375_ ); ++ map.carriedBy.removeIf( holdingPlayer -> holdingPlayer.player == p_143375_ ); + } + } + } ); + } + // Spigot end + // Spigot Start -+ if (p_143375_.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(p_143375_ instanceof ServerPlayer) || p_143375_.m_146911_() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message ++ if (p_143375_.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(p_143375_ instanceof ServerPlayer) || p_143375_.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message + for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) p_143375_.getBukkitEntity()).getInventory().getViewers())) { + h.closeInventory(); + } + } + // Spigot End - ServerLevel.this.m_7726_().m_8443_(p_143375_); + ServerLevel.this.getChunkSource().removeEntity(p_143375_); if (p_143375_ instanceof ServerPlayer) { ServerPlayer serverplayer = (ServerPlayer)p_143375_; @@ -1525,10 +_,8 @@ - ServerLevel.this.f_143246_.remove(mob); + ServerLevel.this.navigatingMobs.remove(mob); } - if (p_143375_ instanceof EnderDragon) { - EnderDragon enderdragon = (EnderDragon)p_143375_; - -- for(EnderDragonPart enderdragonpart : enderdragon.m_31156_()) { +- for(EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { + if (p_143375_.isMultipartEntity()) { + for(net.minecraftforge.entity.PartEntity enderdragonpart : p_143375_.getParts()) { - ServerLevel.this.f_143247_.remove(enderdragonpart.m_142049_()); + ServerLevel.this.dragonParts.remove(enderdragonpart.getId()); } } @@ -1538,6 +_,22 @@ - gameeventlistenerregistrar.m_157854_(p_143375_.f_19853_); + gameeventlistenerregistrar.onListenerRemoved(p_143375_.level); } + // CraftBukkit start + p_143375_.valid = false; + if (!(p_143375_ instanceof ServerPlayer)) { -+ for (ServerPlayer player : f_8546_) { ++ for (ServerPlayer player : players) { + player.getBukkitEntity().onEntityRemove(p_143375_); + } + } @@ -749,6 +749,6 @@ + + @Override + public java.util.Collection> getPartEntities() { -+ return this.f_143247_.values(); ++ return this.dragonParts.values(); } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index df0f24a1..9ee0578e 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,63 +1,63 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -174,7 +_,7 @@ - private Vec3 f_8933_; + private Vec3 enteredNetherPosition; @Nullable - private Vec3 f_184126_; -- private SectionPos f_8934_ = SectionPos.m_123173_(0, 0, 0); -+ private SectionPos f_8934_ = SectionPos.m_123173_( 0, 0, 0 ); - private ResourceKey f_8935_ = Level.f_46428_; + private Vec3 enteredLavaOnVehiclePosition; +- private SectionPos lastSectionPos = SectionPos.of(0, 0, 0); ++ private SectionPos lastSectionPos = SectionPos.of( 0, 0, 0 ); + private ResourceKey respawnDimension = Level.OVERWORLD; @Nullable - private BlockPos f_8936_; + private BlockPos respawnPosition; @@ -185,36 +_,36 @@ - private boolean f_184127_ = true; - private final ContainerSynchronizer f_143379_ = new ContainerSynchronizer() { - public void m_142589_(AbstractContainerMenu p_143448_, NonNullList p_143449_, ItemStack p_143450_, int[] p_143451_) { -- ServerPlayer.this.f_8906_.m_141995_(new ClientboundContainerSetContentPacket(p_143448_.f_38840_, p_143448_.m_182425_(), p_143449_, p_143450_)); -+ ServerPlayer.this.f_8906_.m_141995_( new ClientboundContainerSetContentPacket( p_143448_.f_38840_, p_143448_.m_182425_(), p_143449_, p_143450_ ) ); + private boolean allowsListing = true; + private final ContainerSynchronizer containerSynchronizer = new ContainerSynchronizer() { + public void sendInitialData(AbstractContainerMenu p_143448_, NonNullList p_143449_, ItemStack p_143450_, int[] p_143451_) { +- ServerPlayer.this.connection.send(new ClientboundContainerSetContentPacket(p_143448_.containerId, p_143448_.incrementStateId(), p_143449_, p_143450_)); ++ ServerPlayer.this.connection.send( new ClientboundContainerSetContentPacket( p_143448_.containerId, p_143448_.incrementStateId(), p_143449_, p_143450_ ) ); - for(int i = 0; i < p_143451_.length; ++i) { -- this.m_143454_(p_143448_, i, p_143451_[i]); +- this.broadcastDataValue(p_143448_, i, p_143451_[i]); + for (int i = 0; i < p_143451_.length; ++i) { -+ this.m_143454_( p_143448_, i, p_143451_[i] ); ++ this.broadcastDataValue( p_143448_, i, p_143451_[i] ); } } - public void m_142074_(AbstractContainerMenu p_143441_, int p_143442_, ItemStack p_143443_) { -- ServerPlayer.this.f_8906_.m_141995_(new ClientboundContainerSetSlotPacket(p_143441_.f_38840_, p_143441_.m_182425_(), p_143442_, p_143443_)); -+ ServerPlayer.this.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( p_143441_.f_38840_, p_143441_.m_182425_(), p_143442_, p_143443_ ) ); + public void sendSlotChange(AbstractContainerMenu p_143441_, int p_143442_, ItemStack p_143443_) { +- ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(p_143441_.containerId, p_143441_.incrementStateId(), p_143442_, p_143443_)); ++ ServerPlayer.this.connection.send( new ClientboundContainerSetSlotPacket( p_143441_.containerId, p_143441_.incrementStateId(), p_143442_, p_143443_ ) ); } - public void m_142529_(AbstractContainerMenu p_143445_, ItemStack p_143446_) { -- ServerPlayer.this.f_8906_.m_141995_(new ClientboundContainerSetSlotPacket(-1, p_143445_.m_182425_(), -1, p_143446_)); -+ ServerPlayer.this.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( -1, p_143445_.m_182425_(), -1, p_143446_ ) ); + public void sendCarriedChange(AbstractContainerMenu p_143445_, ItemStack p_143446_) { +- ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(-1, p_143445_.incrementStateId(), -1, p_143446_)); ++ ServerPlayer.this.connection.send( new ClientboundContainerSetSlotPacket( -1, p_143445_.incrementStateId(), -1, p_143446_ ) ); } - public void m_142145_(AbstractContainerMenu p_143437_, int p_143438_, int p_143439_) { -- this.m_143454_(p_143437_, p_143438_, p_143439_); -+ this.m_143454_( p_143437_, p_143438_, p_143439_ ); + public void sendDataChange(AbstractContainerMenu p_143437_, int p_143438_, int p_143439_) { +- this.broadcastDataValue(p_143437_, p_143438_, p_143439_); ++ this.broadcastDataValue( p_143437_, p_143438_, p_143439_ ); } - private void m_143454_(AbstractContainerMenu p_143455_, int p_143456_, int p_143457_) { -- ServerPlayer.this.f_8906_.m_141995_(new ClientboundContainerSetDataPacket(p_143455_.f_38840_, p_143456_, p_143457_)); -+ ServerPlayer.this.f_8906_.m_141995_( new ClientboundContainerSetDataPacket( p_143455_.f_38840_, p_143456_, p_143457_ ) ); + private void broadcastDataValue(AbstractContainerMenu p_143455_, int p_143456_, int p_143457_) { +- ServerPlayer.this.connection.send(new ClientboundContainerSetDataPacket(p_143455_.containerId, p_143456_, p_143457_)); ++ ServerPlayer.this.connection.send( new ClientboundContainerSetDataPacket( p_143455_.containerId, p_143456_, p_143457_ ) ); } }; - private final ContainerListener f_143380_ = new ContainerListener() { - public void m_7934_(AbstractContainerMenu p_143466_, int p_143467_, ItemStack p_143468_) { -- Slot slot = p_143466_.m_38853_(p_143467_); -+ Slot slot = p_143466_.m_38853_( p_143467_ ); + private final ContainerListener containerListener = new ContainerListener() { + public void slotChanged(AbstractContainerMenu p_143466_, int p_143467_, ItemStack p_143468_) { +- Slot slot = p_143466_.getSlot(p_143467_); ++ Slot slot = p_143466_.getSlot( p_143467_ ); if (!(slot instanceof ResultSlot)) { - if (slot.f_40218_ == ServerPlayer.this.m_150109_()) { -- CriteriaTriggers.f_10571_.m_43149_(ServerPlayer.this, ServerPlayer.this.m_150109_(), p_143468_); -+ CriteriaTriggers.f_10571_.m_43149_( ServerPlayer.this, ServerPlayer.this.m_150109_(), p_143468_ ); + if (slot.container == ServerPlayer.this.getInventory()) { +- CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), p_143468_); ++ CriteriaTriggers.INVENTORY_CHANGED.trigger( ServerPlayer.this, ServerPlayer.this.getInventory(), p_143468_ ); } } @@ -227,22 +_,88 @@ - public int f_8943_; - public boolean f_8944_; + public int latency; + public boolean wonGame; + // CraftBukkit start + public String displayName; @@ -82,36 +82,36 @@ + // CraftBukkit end + public ServerPlayer(MinecraftServer p_143384_, ServerLevel p_143385_, GameProfile p_143386_) { -- super(p_143385_, p_143385_.m_8900_(), p_143385_.m_8901_(), p_143386_); -- this.f_8939_ = p_143384_.m_7950_(this); -- this.f_8941_ = p_143384_.m_177933_(this); -+ super( p_143385_, p_143385_.m_8900_(), p_143385_.m_8901_(), p_143386_ ); -+ this.f_8939_ = p_143384_.m_7950_( this ); -+ this.f_8941_ = p_143384_.m_177933_( this ); - this.f_8924_ = p_143384_; -- this.f_8910_ = p_143384_.m_6846_().m_11239_(this); -- this.f_8909_ = p_143384_.m_6846_().m_11296_(this); -+ this.f_8910_ = p_143384_.m_6846_().getPlayerStats( this ); -+ this.f_8909_ = p_143384_.m_6846_().m_11296_( this ); - this.f_19793_ = 1.0F; -- this.m_9201_(p_143385_); +- super(p_143385_, p_143385_.getSharedSpawnPos(), p_143385_.getSharedSpawnAngle(), p_143386_); +- this.textFilter = p_143384_.createTextFilterForPlayer(this); +- this.gameMode = p_143384_.createGameModeForPlayer(this); ++ super( p_143385_, p_143385_.getSharedSpawnPos(), p_143385_.getSharedSpawnAngle(), p_143386_ ); ++ this.textFilter = p_143384_.createTextFilterForPlayer( this ); ++ this.gameMode = p_143384_.createGameModeForPlayer( this ); + this.server = p_143384_; +- this.stats = p_143384_.getPlayerList().getPlayerStats(this); +- this.advancements = p_143384_.getPlayerList().getPlayerAdvancements(this); ++ this.stats = p_143384_.getPlayerList().getPlayerStats( this ); ++ this.advancements = p_143384_.getPlayerList().getPlayerAdvancements( this ); + this.maxUpStep = 1.0F; +- this.fudgeSpawnLocation(p_143385_); - } -+ this.m_9201_( p_143385_ ); ++ this.fudgeSpawnLocation( p_143385_ ); + + // CraftBukkit start -+ this.displayName = this.m_6302_(); ++ this.displayName = this.getScoreboardName(); + this.bukkitPickUpLoot = true; -+ this.maxHealthCache = this.m_21233_(); ++ this.maxHealthCache = this.getMaxHealth(); + } + + // Yes, this doesn't match Vanilla, but it's the best we can do for now. + // If this is an issue, PRs are welcome + public final BlockPos getSpawnPoint(ServerLevel worldserver) { -+ BlockPos blockposition = worldserver.m_8900_(); ++ BlockPos blockposition = worldserver.getSharedSpawnPos(); + -+ if (worldserver.m_6042_().m_63935_() && worldserver.f_8549_.m_5464_() != GameType.ADVENTURE) { -+ int i = Math.max( 0, this.f_8924_.m_129803_( worldserver ) ); -+ int j = Mth.m_14107_( worldserver.m_6857_().m_61941_( (double) blockposition.m_123341_(), (double) blockposition.m_123343_() ) ); ++ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != GameType.ADVENTURE) { ++ int i = Math.max( 0, this.server.getSpawnRadius( worldserver ) ); ++ int j = Mth.floor( worldserver.getWorldBorder().getDistanceToBorder( (double) blockposition.getX(), (double) blockposition.getZ() ) ); + + if (j < i) { + i = j; @@ -124,14 +124,14 @@ + long k = (long) (i * 2 + 1); + long l = k * k; + int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; -+ int j1 = this.m_9237_( i1 ); ++ int j1 = this.getCoprime( i1 ); + int k1 = (new Random()).nextInt( i1 ); + + for (int l1 = 0; l1 < i1; ++l1) { + int i2 = (k1 + j1 * l1) % i1; + int j2 = i2 % (i * 2 + 1); + int k2 = i2 / (i * 2 + 1); -+ BlockPos blockposition1 = PlayerRespawnLogic.m_183928_( worldserver, blockposition.m_123341_() + j2 - i, blockposition.m_123343_() + k2 - i ); ++ BlockPos blockposition1 = PlayerRespawnLogic.getOverworldRespawnPos( worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i ); + + if (blockposition1 != null) { + return blockposition1; @@ -143,14 +143,14 @@ + } + // CraftBukkit end - private void m_9201_(ServerLevel p_9202_) { - BlockPos blockpos = p_9202_.m_8900_(); -- if (p_9202_.m_6042_().m_63935_() && p_9202_.m_142572_().m_129910_().m_5464_() != GameType.ADVENTURE) { -- int i = Math.max(0, this.f_8924_.m_129803_(p_9202_)); -- int j = Mth.m_14107_(p_9202_.m_6857_().m_61941_((double)blockpos.m_123341_(), (double)blockpos.m_123343_())); -+ if (p_9202_.m_6042_().m_63935_() && p_9202_.f_8549_.m_5464_() != GameType.ADVENTURE) { -+ int i = Math.max( 0, this.f_8924_.m_129803_( p_9202_ ) ); -+ int j = Mth.m_14107_( p_9202_.m_6857_().m_61941_( (double) blockpos.m_123341_(), (double) blockpos.m_123343_() ) ); + private void fudgeSpawnLocation(ServerLevel p_9202_) { + BlockPos blockpos = p_9202_.getSharedSpawnPos(); +- if (p_9202_.dimensionType().hasSkyLight() && p_9202_.getServer().getWorldData().getGameType() != GameType.ADVENTURE) { +- int i = Math.max(0, this.server.getSpawnRadius(p_9202_)); +- int j = Mth.floor(p_9202_.getWorldBorder().getDistanceToBorder((double)blockpos.getX(), (double)blockpos.getZ())); ++ if (p_9202_.dimensionType().hasSkyLight() && p_9202_.serverLevelData.getGameType() != GameType.ADVENTURE) { ++ int i = Math.max( 0, this.server.getSpawnRadius( p_9202_ ) ); ++ int j = Mth.floor( p_9202_.getWorldBorder().getDistanceToBorder( (double) blockpos.getX(), (double) blockpos.getZ() ) ); if (j < i) { i = j; } @@ -162,10 +162,10 @@ + long k = (long) (i * 2 + 1); long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int)l; -- int j1 = this.m_9237_(i1); +- int j1 = this.getCoprime(i1); - int k1 = (new Random()).nextInt(i1); + int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; -+ int j1 = this.m_9237_( i1 ); ++ int j1 = this.getCoprime( i1 ); + int k1 = (new Random()).nextInt( i1 ); - for(int l1 = 0; l1 < i1; ++l1) { @@ -173,116 +173,116 @@ int i2 = (k1 + j1 * l1) % i1; int j2 = i2 % (i * 2 + 1); int k2 = i2 / (i * 2 + 1); -- BlockPos blockpos1 = PlayerRespawnLogic.m_183928_(p_9202_, blockpos.m_123341_() + j2 - i, blockpos.m_123343_() + k2 - i); -+ BlockPos blockpos1 = PlayerRespawnLogic.m_183928_( p_9202_, blockpos.m_123341_() + j2 - i, blockpos.m_123343_() + k2 - i ); +- BlockPos blockpos1 = PlayerRespawnLogic.getOverworldRespawnPos(p_9202_, blockpos.getX() + j2 - i, blockpos.getZ() + k2 - i); ++ BlockPos blockpos1 = PlayerRespawnLogic.getOverworldRespawnPos( p_9202_, blockpos.getX() + j2 - i, blockpos.getZ() + k2 - i ); if (blockpos1 != null) { -- this.m_20035_(blockpos1, 0.0F, 0.0F); -- if (p_9202_.m_45786_(this)) { -+ this.m_20035_( blockpos1, 0.0F, 0.0F ); -+ if (p_9202_.m_45786_( this )) { +- this.moveTo(blockpos1, 0.0F, 0.0F); +- if (p_9202_.noCollision(this)) { ++ this.moveTo( blockpos1, 0.0F, 0.0F ); ++ if (p_9202_.noCollision( this )) { break; } } } } else { -- this.m_20035_(blockpos, 0.0F, 0.0F); -+ this.m_20035_( blockpos, 0.0F, 0.0F ); +- this.moveTo(blockpos, 0.0F, 0.0F); ++ this.moveTo( blockpos, 0.0F, 0.0F ); -- while(!p_9202_.m_45786_(this) && this.m_20186_() < (double)(p_9202_.m_151558_() - 1)) { -- this.m_6034_(this.m_20185_(), this.m_20186_() + 1.0D, this.m_20189_()); -+ while (!p_9202_.m_45786_( this ) && this.m_20186_() < (double) (p_9202_.m_151558_() - 1)) { -+ this.m_6034_( this.m_20185_(), this.m_20186_() + 1.0D, this.m_20189_() ); +- while(!p_9202_.noCollision(this) && this.getY() < (double)(p_9202_.getMaxBuildHeight() - 1)) { +- this.setPos(this.getX(), this.getY() + 1.0D, this.getZ()); ++ while (!p_9202_.noCollision( this ) && this.getY() < (double) (p_9202_.getMaxBuildHeight() - 1)) { ++ this.setPos( this.getX(), this.getY() + 1.0D, this.getZ() ); } } @@ -284,74 +_,131 @@ } - public void m_7378_(CompoundTag p_9131_) { -- super.m_7378_(p_9131_); -- if (p_9131_.m_128425_("enteredNetherPosition", 10)) { -- CompoundTag compoundtag = p_9131_.m_128469_("enteredNetherPosition"); -- this.f_8933_ = new Vec3(compoundtag.m_128459_("x"), compoundtag.m_128459_("y"), compoundtag.m_128459_("z")); + public void readAdditionalSaveData(CompoundTag p_9131_) { +- super.readAdditionalSaveData(p_9131_); +- if (p_9131_.contains("enteredNetherPosition", 10)) { +- CompoundTag compoundtag = p_9131_.getCompound("enteredNetherPosition"); +- this.enteredNetherPosition = new Vec3(compoundtag.getDouble("x"), compoundtag.getDouble("y"), compoundtag.getDouble("z")); - } - -- this.f_8928_ = p_9131_.m_128471_("seenCredits"); -- if (p_9131_.m_128425_("recipeBook", 10)) { -- this.f_8929_.m_12794_(p_9131_.m_128469_("recipeBook"), this.f_8924_.m_129894_()); +- this.seenCredits = p_9131_.getBoolean("seenCredits"); +- if (p_9131_.contains("recipeBook", 10)) { +- this.recipeBook.fromNbt(p_9131_.getCompound("recipeBook"), this.server.getRecipeManager()); - } -+ super.m_7378_( p_9131_ ); -+ if (p_9131_.m_128425_( "enteredNetherPosition", 10 )) { -+ CompoundTag compoundtag = p_9131_.m_128469_( "enteredNetherPosition" ); -+ this.f_8933_ = new Vec3( compoundtag.m_128459_( "x" ), compoundtag.m_128459_( "y" ), compoundtag.m_128459_( "z" ) ); ++ super.readAdditionalSaveData( p_9131_ ); ++ if (p_9131_.contains( "enteredNetherPosition", 10 )) { ++ CompoundTag compoundtag = p_9131_.getCompound( "enteredNetherPosition" ); ++ this.enteredNetherPosition = new Vec3( compoundtag.getDouble( "x" ), compoundtag.getDouble( "y" ), compoundtag.getDouble( "z" ) ); + } + -+ this.f_8928_ = p_9131_.m_128471_( "seenCredits" ); -+ if (p_9131_.m_128425_( "recipeBook", 10 )) { -+ this.f_8929_.m_12794_( p_9131_.m_128469_( "recipeBook" ), this.f_8924_.m_129894_() ); ++ this.seenCredits = p_9131_.getBoolean( "seenCredits" ); ++ if (p_9131_.contains( "recipeBook", 10 )) { ++ this.recipeBook.fromNbt( p_9131_.getCompound( "recipeBook" ), this.server.getRecipeManager() ); + } + + this.getBukkitEntity().readExtraData( p_9131_ ); // CraftBukkit - if (this.m_5803_()) { - this.m_5796_(); + if (this.isSleeping()) { + this.stopSleeping(); } -- if (p_9131_.m_128425_("SpawnX", 99) && p_9131_.m_128425_("SpawnY", 99) && p_9131_.m_128425_("SpawnZ", 99)) { -- this.f_8936_ = new BlockPos(p_9131_.m_128451_("SpawnX"), p_9131_.m_128451_("SpawnY"), p_9131_.m_128451_("SpawnZ")); -- this.f_8937_ = p_9131_.m_128471_("SpawnForced"); -- this.f_8938_ = p_9131_.m_128457_("SpawnAngle"); -- if (p_9131_.m_128441_("SpawnDimension")) { -- this.f_8935_ = Level.f_46427_.parse(NbtOps.f_128958_, p_9131_.m_128423_("SpawnDimension")).resultOrPartial(f_8907_::error).orElse(Level.f_46428_); +- if (p_9131_.contains("SpawnX", 99) && p_9131_.contains("SpawnY", 99) && p_9131_.contains("SpawnZ", 99)) { +- this.respawnPosition = new BlockPos(p_9131_.getInt("SpawnX"), p_9131_.getInt("SpawnY"), p_9131_.getInt("SpawnZ")); +- this.respawnForced = p_9131_.getBoolean("SpawnForced"); +- this.respawnAngle = p_9131_.getFloat("SpawnAngle"); +- if (p_9131_.contains("SpawnDimension")) { +- this.respawnDimension = Level.RESOURCE_KEY_CODEC.parse(NbtOps.INSTANCE, p_9131_.get("SpawnDimension")).resultOrPartial(LOGGER::error).orElse(Level.OVERWORLD); + // CraftBukkit start -+ String spawnWorld = p_9131_.m_128461_( "SpawnWorld" ); ++ String spawnWorld = p_9131_.getString( "SpawnWorld" ); + org.bukkit.craftbukkit.v1_18_R2.CraftWorld oldWorld = (org.bukkit.craftbukkit.v1_18_R2.CraftWorld) org.bukkit.Bukkit.getWorld( spawnWorld ); + if (oldWorld != null) { -+ this.f_8935_ = oldWorld.getHandle().m_46472_(); ++ this.respawnDimension = oldWorld.getHandle().dimension(); + } + // CraftBukkit end + -+ if (p_9131_.m_128425_( "SpawnX", 99 ) && p_9131_.m_128425_( "SpawnY", 99 ) && p_9131_.m_128425_( "SpawnZ", 99 )) { -+ this.f_8936_ = new BlockPos( p_9131_.m_128451_( "SpawnX" ), p_9131_.m_128451_( "SpawnY" ), p_9131_.m_128451_( "SpawnZ" ) ); -+ this.f_8937_ = p_9131_.m_128471_( "SpawnForced" ); -+ this.f_8938_ = p_9131_.m_128457_( "SpawnAngle" ); -+ if (p_9131_.m_128441_( "SpawnDimension" )) { -+ this.f_8935_ = Level.f_46427_.parse( NbtOps.f_128958_, p_9131_.m_128423_( "SpawnDimension" ) ).resultOrPartial( f_8907_::error ).orElse( Level.f_46428_ ); ++ if (p_9131_.contains( "SpawnX", 99 ) && p_9131_.contains( "SpawnY", 99 ) && p_9131_.contains( "SpawnZ", 99 )) { ++ this.respawnPosition = new BlockPos( p_9131_.getInt( "SpawnX" ), p_9131_.getInt( "SpawnY" ), p_9131_.getInt( "SpawnZ" ) ); ++ this.respawnForced = p_9131_.getBoolean( "SpawnForced" ); ++ this.respawnAngle = p_9131_.getFloat( "SpawnAngle" ); ++ if (p_9131_.contains( "SpawnDimension" )) { ++ this.respawnDimension = Level.RESOURCE_KEY_CODEC.parse( NbtOps.INSTANCE, p_9131_.get( "SpawnDimension" ) ).resultOrPartial( LOGGER::error ).orElse( Level.OVERWORLD ); } } + + //Magma start - load forge captures -+ net.minecraft.nbt.ListTag forgeCaptures = p_9131_.m_128437_("ForgeCaptures", 10); ++ net.minecraft.nbt.ListTag forgeCaptures = p_9131_.getList("ForgeCaptures", 10); + setForgeCaptures(this, forgeCaptures); + //Magma end } - public void m_7380_(CompoundTag p_9197_) { -- super.m_7380_(p_9197_); -- this.m_143430_(p_9197_); -- p_9197_.m_128379_("seenCredits", this.f_8928_); -+ super.m_7380_( p_9197_ ); -+ this.m_143430_( p_9197_ ); -+ p_9197_.m_128379_( "seenCredits", this.f_8928_ ); - if (this.f_8933_ != null) { + public void addAdditionalSaveData(CompoundTag p_9197_) { +- super.addAdditionalSaveData(p_9197_); +- this.storeGameTypes(p_9197_); +- p_9197_.putBoolean("seenCredits", this.seenCredits); ++ super.addAdditionalSaveData( p_9197_ ); ++ this.storeGameTypes( p_9197_ ); ++ p_9197_.putBoolean( "seenCredits", this.seenCredits ); + if (this.enteredNetherPosition != null) { CompoundTag compoundtag = new CompoundTag(); -- compoundtag.m_128347_("x", this.f_8933_.f_82479_); -- compoundtag.m_128347_("y", this.f_8933_.f_82480_); -- compoundtag.m_128347_("z", this.f_8933_.f_82481_); -- p_9197_.m_128365_("enteredNetherPosition", compoundtag); -+ compoundtag.m_128347_( "x", this.f_8933_.f_82479_ ); -+ compoundtag.m_128347_( "y", this.f_8933_.f_82480_ ); -+ compoundtag.m_128347_( "z", this.f_8933_.f_82481_ ); -+ p_9197_.m_128365_( "enteredNetherPosition", compoundtag ); +- compoundtag.putDouble("x", this.enteredNetherPosition.x); +- compoundtag.putDouble("y", this.enteredNetherPosition.y); +- compoundtag.putDouble("z", this.enteredNetherPosition.z); +- p_9197_.put("enteredNetherPosition", compoundtag); ++ compoundtag.putDouble( "x", this.enteredNetherPosition.x ); ++ compoundtag.putDouble( "y", this.enteredNetherPosition.y ); ++ compoundtag.putDouble( "z", this.enteredNetherPosition.z ); ++ p_9197_.put( "enteredNetherPosition", compoundtag ); } - Entity entity1 = this.m_20201_(); - Entity entity = this.m_20202_(); -- if (entity != null && entity1 != this && entity1.m_146898_()) { + Entity entity1 = this.getRootVehicle(); + Entity entity = this.getVehicle(); +- if (entity != null && entity1 != this && entity1.hasExactlyOnePlayerPassenger()) { + // CraftBukkit start - handle non-persistent vehicles + boolean persistVehicle = true; + if (entity1 != null) { + Entity vehicle; -+ for (vehicle = entity1; vehicle != null; vehicle = vehicle.m_20202_()) { ++ for (vehicle = entity1; vehicle != null; vehicle = vehicle.getVehicle()) { + if (!vehicle.persist) { + persistVehicle = false; + break; @@ -290,43 +290,43 @@ + } + } + -+ if (persistVehicle && entity1 != null && entity != null && entity != this && entity.m_146898_()) { ++ if (persistVehicle && entity1 != null && entity != null && entity != this && entity.hasExactlyOnePlayerPassenger()) { + // CraftBukkit end CompoundTag compoundtag1 = new CompoundTag(); CompoundTag compoundtag2 = new CompoundTag(); -- entity1.m_20223_(compoundtag2); -- compoundtag1.m_128362_("Attach", entity.m_142081_()); -- compoundtag1.m_128365_("Entity", compoundtag2); -- p_9197_.m_128365_("RootVehicle", compoundtag1); -+ entity1.m_20223_( compoundtag2 ); -+ compoundtag1.m_128362_( "Attach", entity.m_142081_() ); -+ compoundtag1.m_128365_( "Entity", compoundtag2 ); -+ p_9197_.m_128365_( "RootVehicle", compoundtag1 ); +- entity1.save(compoundtag2); +- compoundtag1.putUUID("Attach", entity.getUUID()); +- compoundtag1.put("Entity", compoundtag2); +- p_9197_.put("RootVehicle", compoundtag1); ++ entity1.save( compoundtag2 ); ++ compoundtag1.putUUID( "Attach", entity.getUUID() ); ++ compoundtag1.put( "Entity", compoundtag2 ); ++ p_9197_.put( "RootVehicle", compoundtag1 ); } -- p_9197_.m_128365_("recipeBook", this.f_8929_.m_12805_()); -- p_9197_.m_128359_("Dimension", this.f_19853_.m_46472_().m_135782_().toString()); -+ p_9197_.m_128365_( "recipeBook", this.f_8929_.m_12805_() ); -+ p_9197_.m_128359_( "Dimension", this.f_19853_.m_46472_().m_135782_().toString() ); - if (this.f_8936_ != null) { -- p_9197_.m_128405_("SpawnX", this.f_8936_.m_123341_()); -- p_9197_.m_128405_("SpawnY", this.f_8936_.m_123342_()); -- p_9197_.m_128405_("SpawnZ", this.f_8936_.m_123343_()); -- p_9197_.m_128379_("SpawnForced", this.f_8937_); -- p_9197_.m_128350_("SpawnAngle", this.f_8938_); -- ResourceLocation.f_135803_.encodeStart(NbtOps.f_128958_, this.f_8935_.m_135782_()).resultOrPartial(f_8907_::error).ifPresent((p_9134_) -> { -- p_9197_.m_128365_("SpawnDimension", p_9134_); +- p_9197_.put("recipeBook", this.recipeBook.toNbt()); +- p_9197_.putString("Dimension", this.level.dimension().location().toString()); ++ p_9197_.put( "recipeBook", this.recipeBook.toNbt() ); ++ p_9197_.putString( "Dimension", this.level.dimension().location().toString() ); + if (this.respawnPosition != null) { +- p_9197_.putInt("SpawnX", this.respawnPosition.getX()); +- p_9197_.putInt("SpawnY", this.respawnPosition.getY()); +- p_9197_.putInt("SpawnZ", this.respawnPosition.getZ()); +- p_9197_.putBoolean("SpawnForced", this.respawnForced); +- p_9197_.putFloat("SpawnAngle", this.respawnAngle); +- ResourceLocation.CODEC.encodeStart(NbtOps.INSTANCE, this.respawnDimension.location()).resultOrPartial(LOGGER::error).ifPresent((p_9134_) -> { +- p_9197_.put("SpawnDimension", p_9134_); - }); - } - - } -+ p_9197_.m_128405_( "SpawnX", this.f_8936_.m_123341_() ); -+ p_9197_.m_128405_( "SpawnY", this.f_8936_.m_123342_() ); -+ p_9197_.m_128405_( "SpawnZ", this.f_8936_.m_123343_() ); -+ p_9197_.m_128379_( "SpawnForced", this.f_8937_ ); -+ p_9197_.m_128350_( "SpawnAngle", this.f_8938_ ); -+ ResourceLocation.f_135803_.encodeStart( NbtOps.f_128958_, this.f_8935_.m_135782_() ).resultOrPartial( f_8907_::error ).ifPresent( (p_9134_) -> { -+ p_9197_.m_128365_( "SpawnDimension", p_9134_ ); ++ p_9197_.putInt( "SpawnX", this.respawnPosition.getX() ); ++ p_9197_.putInt( "SpawnY", this.respawnPosition.getY() ); ++ p_9197_.putInt( "SpawnZ", this.respawnPosition.getZ() ); ++ p_9197_.putBoolean( "SpawnForced", this.respawnForced ); ++ p_9197_.putFloat( "SpawnAngle", this.respawnAngle ); ++ ResourceLocation.CODEC.encodeStart( NbtOps.INSTANCE, this.respawnDimension.location() ).resultOrPartial( LOGGER::error ).ifPresent( (p_9134_) -> { ++ p_9197_.put( "SpawnDimension", p_9134_ ); + } ); + } + @@ -334,514 +334,514 @@ + + //Magma start - save forge captures + Inventory forgeCaptures = getForgeCaptures(); -+ if (forgeCaptures != null) p_9197_.m_128365_("ForgeCaptures", forgeCaptures.m_36026_(new net.minecraft.nbt.ListTag())); ++ if (forgeCaptures != null) p_9197_.put("ForgeCaptures", forgeCaptures.save(new net.minecraft.nbt.ListTag())); + //Magma end + } + + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(Level world) { -+ this.f_19853_ = world; ++ this.level = world; + if (world == null) { -+ this.m_146912_(); ++ this.unsetRemoved(); + Vec3 position = null; -+ if (this.f_8935_ != null) { -+ world = this.m_183503_().getCraftServer().getHandle().m_7873_().m_129880_( this.f_8935_ ); -+ if (world != null && this.m_8961_() != null) { -+ position = Player.m_36130_( (ServerLevel) world, this.m_8961_(), this.m_8962_(), false, false ).orElse( null ); ++ if (this.respawnDimension != null) { ++ world = this.getLevel().getCraftServer().getHandle().getServer().getLevel( this.respawnDimension ); ++ if (world != null && this.getRespawnPosition() != null) { ++ position = Player.findRespawnPositionAndUseSpawnBlock( (ServerLevel) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false ).orElse( null ); + } + } + if (world == null || position == null) { + world = ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) org.bukkit.Bukkit.getServer().getWorlds().get( 0 )).getHandle(); -+ position = Vec3.m_82512_( ((ServerLevel) world).m_8900_() ); ++ position = Vec3.atCenterOf( ((ServerLevel) world).getSharedSpawnPos() ); + } -+ this.f_19853_ = world; -+ this.m_6034_( position.m_7096_(), position.m_7098_(), position.m_7094_() ); ++ this.level = world; ++ this.setPos( position.x(), position.y(), position.z() ); + } -+ this.f_8941_.m_9260_( (ServerLevel) world ); ++ this.gameMode.setLevel( (ServerLevel) world ); + } + // CraftBukkit end - public void m_8985_(int p_8986_) { -- float f = (float)this.m_36323_(); -+ float f = (float) this.m_36323_(); + public void setExperiencePoints(int p_8986_) { +- float f = (float)this.getXpNeededForNextLevel(); ++ float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -- this.f_36080_ = Mth.m_14036_((float)p_8986_ / f, 0.0F, f1); -+ this.f_36080_ = Mth.m_14036_( (float) p_8986_ / f, 0.0F, f1 ); - this.f_8920_ = -1; +- this.experienceProgress = Mth.clamp((float)p_8986_ / f, 0.0F, f1); ++ this.experienceProgress = Mth.clamp( (float) p_8986_ / f, 0.0F, f1 ); + this.lastSentExp = -1; } @@ -361,43 +_,46 @@ } - public void m_6749_(int p_9200_) { -- super.m_6749_(p_9200_); -+ super.m_6749_( p_9200_ ); - this.f_8920_ = -1; + public void giveExperienceLevels(int p_9200_) { +- super.giveExperienceLevels(p_9200_); ++ super.giveExperienceLevels( p_9200_ ); + this.lastSentExp = -1; } - public void m_7408_(ItemStack p_9079_, int p_9080_) { -- super.m_7408_(p_9079_, p_9080_); -+ super.m_7408_( p_9079_, p_9080_ ); - this.f_8920_ = -1; + public void onEnchantmentPerformed(ItemStack p_9079_, int p_9080_) { +- super.onEnchantmentPerformed(p_9079_, p_9080_); ++ super.onEnchantmentPerformed( p_9079_, p_9080_ ); + this.lastSentExp = -1; } - public void m_143399_(AbstractContainerMenu p_143400_) { -- p_143400_.m_38893_(this.f_143380_); -- p_143400_.m_150416_(this.f_143379_); -+ p_143400_.m_38893_( this.f_143380_ ); -+ p_143400_.m_150416_( this.f_143379_ ); + public void initMenu(AbstractContainerMenu p_143400_) { +- p_143400_.addSlotListener(this.containerListener); +- p_143400_.setSynchronizer(this.containerSynchronizer); ++ p_143400_.addSlotListener( this.containerListener ); ++ p_143400_.setSynchronizer( this.containerSynchronizer ); } - public void m_143429_() { -- this.m_143399_(this.f_36095_); -+ this.m_143399_( this.f_36095_ ); + public void initInventoryMenu() { +- this.initMenu(this.inventoryMenu); ++ this.initMenu( this.inventoryMenu ); } - public void m_8108_() { - super.m_8108_(); -- this.f_8906_.m_141995_(new ClientboundPlayerCombatEnterPacket()); -+ this.f_8906_.m_141995_( new ClientboundPlayerCombatEnterPacket() ); + public void onEnterCombat() { + super.onEnterCombat(); +- this.connection.send(new ClientboundPlayerCombatEnterPacket()); ++ this.connection.send( new ClientboundPlayerCombatEnterPacket() ); } - public void m_8098_() { - super.m_8098_(); -- this.f_8906_.m_141995_(new ClientboundPlayerCombatEndPacket(this.m_21231_())); -+ this.f_8906_.m_141995_( new ClientboundPlayerCombatEndPacket( this.m_21231_() ) ); + public void onLeaveCombat() { + super.onLeaveCombat(); +- this.connection.send(new ClientboundPlayerCombatEndPacket(this.getCombatTracker())); ++ this.connection.send( new ClientboundPlayerCombatEndPacket( this.getCombatTracker() ) ); } - protected void m_6763_(BlockState p_9103_) { -- CriteriaTriggers.f_10570_.m_31269_(this, p_9103_); -+ CriteriaTriggers.f_10570_.m_31269_( this, p_9103_ ); + protected void onInsideBlock(BlockState p_9103_) { +- CriteriaTriggers.ENTER_BLOCK.trigger(this, p_9103_); ++ CriteriaTriggers.ENTER_BLOCK.trigger( this, p_9103_ ); } - protected ItemCooldowns m_7478_() { + protected ItemCooldowns createItemCooldowns() { - return new ServerItemCooldowns(this); + return new ServerItemCooldowns( this ); } - public void m_8119_() { + public void tick() { + //CraftBukkit start + if (this.joining) joining = false; + // CraftBukkit end - this.f_8941_.m_7712_(); - --this.f_8921_; - if (this.f_19802_ > 0) { + this.gameMode.tick(); + --this.spawnInvulnerableTime; + if (this.invulnerableTime > 0) { @@ -405,7 +_,7 @@ } - this.f_36096_.m_38946_(); -- if (!this.f_19853_.f_46443_ && !this.f_36096_.m_6875_(this)) { -+ if (!this.f_19853_.f_46443_ && !this.f_36096_.m_6875_( this )) { - this.m_6915_(); - this.f_36096_ = this.f_36095_; + this.containerMenu.broadcastChanges(); +- if (!this.level.isClientSide && !this.containerMenu.stillValid(this)) { ++ if (!this.level.isClientSide && !this.containerMenu.stillValid( this )) { + this.closeContainer(); + this.containerMenu = this.inventoryMenu; } @@ -413,44 +_,46 @@ - Entity entity = this.m_8954_(); + Entity entity = this.getCamera(); if (entity != this) { - if (entity.m_6084_()) { -- this.m_19890_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_()); -- this.m_183503_().m_7726_().m_8385_(this); -+ this.m_19890_( entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_() ); -+ this.m_183503_().m_7726_().m_8385_( this ); - if (this.m_36342_()) { -- this.m_9213_(this); -+ this.m_9213_( this ); + if (entity.isAlive()) { +- this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); +- this.getLevel().getChunkSource().move(this); ++ this.absMoveTo( entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot() ); ++ this.getLevel().getChunkSource().move( this ); + if (this.wantsToStopRiding()) { +- this.setCamera(this); ++ this.setCamera( this ); } } else { -- this.m_9213_(this); -+ this.m_9213_( this ); +- this.setCamera(this); ++ this.setCamera( this ); } } -- CriteriaTriggers.f_10589_.m_70641_(this); -+ CriteriaTriggers.f_10589_.m_70641_( this ); - if (this.f_8930_ != null) { -- CriteriaTriggers.f_10587_.m_49116_(this, this.f_8930_, this.f_19797_ - this.f_8931_); -+ CriteriaTriggers.f_10587_.m_49116_( this, this.f_8930_, this.f_19797_ - this.f_8931_ ); +- CriteriaTriggers.TICK.trigger(this); ++ CriteriaTriggers.TICK.trigger( this ); + if (this.levitationStartPos != null) { +- CriteriaTriggers.LEVITATION.trigger(this, this.levitationStartPos, this.tickCount - this.levitationStartTime); ++ CriteriaTriggers.LEVITATION.trigger( this, this.levitationStartPos, this.tickCount - this.levitationStartTime ); } - this.m_184139_(); - this.m_184140_(); -- this.f_8909_.m_135992_(this); -+ this.f_8909_.m_135992_( this ); + this.trackStartFallingPosition(); + this.trackEnteredOrExitedLavaOnVehicle(); +- this.advancements.flushDirty(this); ++ this.advancements.flushDirty( this ); } - public void m_9240_() { + public void doTick() { try { -- if (!this.m_5833_() || !this.m_146899_()) { +- if (!this.isSpectator() || !this.touchingUnloadedChunk()) { + //Magma start - spigot calls doTick() once more after the player disconnects, ticking the player after disconnecting is not a good idea -+ if (!m_9232_() && (!this.m_5833_() || !this.m_146899_())) { - super.m_8119_(); ++ if (!hasDisconnected() && (!this.isSpectator() || !this.touchingUnloadedChunk())) { + super.tick(); } + //Magma end -- for(int i = 0; i < this.m_150109_().m_6643_(); ++i) { -- ItemStack itemstack = this.m_150109_().m_8020_(i); -+ for (int i = 0; i < this.m_150109_().m_6643_(); ++i) { -+ ItemStack itemstack = this.m_150109_().m_8020_( i ); - if (itemstack.m_41720_().m_7807_()) { -- Packet packet = ((ComplexItem)itemstack.m_41720_()).m_7233_(itemstack, this.f_19853_, this); -+ Packet packet = ((ComplexItem) itemstack.m_41720_()).m_7233_( itemstack, this.f_19853_, this ); +- for(int i = 0; i < this.getInventory().getContainerSize(); ++i) { +- ItemStack itemstack = this.getInventory().getItem(i); ++ for (int i = 0; i < this.getInventory().getContainerSize(); ++i) { ++ ItemStack itemstack = this.getInventory().getItem( i ); + if (itemstack.getItem().isComplex()) { +- Packet packet = ((ComplexItem)itemstack.getItem()).getUpdatePacket(itemstack, this.level, this); ++ Packet packet = ((ComplexItem) itemstack.getItem()).getUpdatePacket( itemstack, this.level, this ); if (packet != null) { -- this.f_8906_.m_141995_(packet); -+ this.f_8906_.m_141995_( packet ); +- this.connection.send(packet); ++ this.connection.send( packet ); } } } - if (this.m_21223_() != this.f_8917_ || this.f_8918_ != this.f_36097_.m_38702_() || this.f_36097_.m_38722_() == 0.0F != this.f_8919_) { -- this.f_8906_.m_141995_(new ClientboundSetHealthPacket(this.m_21223_(), this.f_36097_.m_38702_(), this.f_36097_.m_38722_())); -+ this.f_8906_.m_141995_( new ClientboundSetHealthPacket( this.getBukkitEntity().getScaledHealth(), this.f_36097_.m_38702_(), this.f_36097_.m_38722_() ) ); //CraftBukkit - this.f_8917_ = this.m_21223_(); - this.f_8918_ = this.f_36097_.m_38702_(); - this.f_8919_ = this.f_36097_.m_38722_() == 0.0F; + if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { +- this.connection.send(new ClientboundSetHealthPacket(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); ++ this.connection.send( new ClientboundSetHealthPacket( this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel() ) ); //CraftBukkit + this.lastSentHealth = this.getHealth(); + this.lastSentFood = this.foodData.getFoodLevel(); + this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; @@ -458,54 +_,75 @@ - if (this.m_21223_() + this.m_6103_() != this.f_8911_) { - this.f_8911_ = this.m_21223_() + this.m_6103_(); -- this.m_9104_(ObjectiveCriteria.f_83593_, Mth.m_14167_(this.f_8911_)); -+ this.m_9104_( ObjectiveCriteria.f_83593_, Mth.m_14167_( this.f_8911_ ) ); + if (this.getHealth() + this.getAbsorptionAmount() != this.lastRecordedHealthAndAbsorption) { + this.lastRecordedHealthAndAbsorption = this.getHealth() + this.getAbsorptionAmount(); +- this.updateScoreForCriteria(ObjectiveCriteria.HEALTH, Mth.ceil(this.lastRecordedHealthAndAbsorption)); ++ this.updateScoreForCriteria( ObjectiveCriteria.HEALTH, Mth.ceil( this.lastRecordedHealthAndAbsorption ) ); } - if (this.f_36097_.m_38702_() != this.f_8912_) { - this.f_8912_ = this.f_36097_.m_38702_(); -- this.m_9104_(ObjectiveCriteria.f_83594_, Mth.m_14167_((float)this.f_8912_)); -+ this.m_9104_( ObjectiveCriteria.f_83594_, Mth.m_14167_( (float) this.f_8912_ ) ); + if (this.foodData.getFoodLevel() != this.lastRecordedFoodLevel) { + this.lastRecordedFoodLevel = this.foodData.getFoodLevel(); +- this.updateScoreForCriteria(ObjectiveCriteria.FOOD, Mth.ceil((float)this.lastRecordedFoodLevel)); ++ this.updateScoreForCriteria( ObjectiveCriteria.FOOD, Mth.ceil( (float) this.lastRecordedFoodLevel ) ); } - if (this.m_20146_() != this.f_8913_) { - this.f_8913_ = this.m_20146_(); -- this.m_9104_(ObjectiveCriteria.f_83595_, Mth.m_14167_((float)this.f_8913_)); -+ this.m_9104_( ObjectiveCriteria.f_83595_, Mth.m_14167_( (float) this.f_8913_ ) ); + if (this.getAirSupply() != this.lastRecordedAirLevel) { + this.lastRecordedAirLevel = this.getAirSupply(); +- this.updateScoreForCriteria(ObjectiveCriteria.AIR, Mth.ceil((float)this.lastRecordedAirLevel)); ++ this.updateScoreForCriteria( ObjectiveCriteria.AIR, Mth.ceil( (float) this.lastRecordedAirLevel ) ); } - if (this.m_21230_() != this.f_8914_) { - this.f_8914_ = this.m_21230_(); -- this.m_9104_(ObjectiveCriteria.f_83596_, Mth.m_14167_((float)this.f_8914_)); -+ this.m_9104_( ObjectiveCriteria.f_83596_, Mth.m_14167_( (float) this.f_8914_ ) ); + if (this.getArmorValue() != this.lastRecordedArmor) { + this.lastRecordedArmor = this.getArmorValue(); +- this.updateScoreForCriteria(ObjectiveCriteria.ARMOR, Mth.ceil((float)this.lastRecordedArmor)); ++ this.updateScoreForCriteria( ObjectiveCriteria.ARMOR, Mth.ceil( (float) this.lastRecordedArmor ) ); } - if (this.f_36079_ != this.f_8916_) { - this.f_8916_ = this.f_36079_; -- this.m_9104_(ObjectiveCriteria.f_83597_, Mth.m_14167_((float)this.f_8916_)); + if (this.totalExperience != this.lastRecordedExperience) { + this.lastRecordedExperience = this.totalExperience; +- this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); - } -+ this.m_9104_( ObjectiveCriteria.f_83597_, Mth.m_14167_( (float) this.f_8916_ ) ); ++ this.updateScoreForCriteria( ObjectiveCriteria.EXPERIENCE, Mth.ceil( (float) this.lastRecordedExperience ) ); + } + + // CraftBukkit start - Force max health updates -+ if (this.maxHealthCache != this.m_21233_()) { ++ if (this.maxHealthCache != this.getMaxHealth()) { + this.getBukkitEntity().updateScaledHealth(); + } + // CraftBukkit end - if (this.f_36078_ != this.f_8915_) { - this.f_8915_ = this.f_36078_; -- this.m_9104_(ObjectiveCriteria.f_83598_, Mth.m_14167_((float)this.f_8915_)); -+ this.m_9104_( ObjectiveCriteria.f_83598_, Mth.m_14167_( (float) this.f_8915_ ) ); + if (this.experienceLevel != this.lastRecordedLevel) { + this.lastRecordedLevel = this.experienceLevel; +- this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); ++ this.updateScoreForCriteria( ObjectiveCriteria.LEVEL, Mth.ceil( (float) this.lastRecordedLevel ) ); } - if (this.f_36079_ != this.f_8920_) { - this.f_8920_ = this.f_36079_; -- this.f_8906_.m_141995_(new ClientboundSetExperiencePacket(this.f_36080_, this.f_36079_, this.f_36078_)); -+ this.f_8906_.m_141995_( new ClientboundSetExperiencePacket( this.f_36080_, this.f_36079_, this.f_36078_ ) ); + if (this.totalExperience != this.lastSentExp) { + this.lastSentExp = this.totalExperience; +- this.connection.send(new ClientboundSetExperiencePacket(this.experienceProgress, this.totalExperience, this.experienceLevel)); ++ this.connection.send( new ClientboundSetExperiencePacket( this.experienceProgress, this.totalExperience, this.experienceLevel ) ); } - if (this.f_19797_ % 20 == 0) { -- CriteriaTriggers.f_10582_.m_53645_(this); + if (this.tickCount % 20 == 0) { +- CriteriaTriggers.LOCATION.trigger(this); - } -+ CriteriaTriggers.f_10582_.m_53645_( this ); ++ CriteriaTriggers.LOCATION.trigger( this ); + } + + + // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent + if (this.oldLevel == -1) { -+ this.oldLevel = this.f_36078_; ++ this.oldLevel = this.experienceLevel; + } + -+ if (this.oldLevel != this.f_36078_) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerLevelChangeEvent( this.getBukkitEntity(), this.oldLevel, this.f_36078_ ); -+ this.oldLevel = this.f_36078_; ++ if (this.oldLevel != this.experienceLevel) { ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerLevelChangeEvent( this.getBukkitEntity(), this.oldLevel, this.experienceLevel ); ++ this.oldLevel = this.experienceLevel; + } + if (this.getBukkitEntity().hasClientWorldBorder()) { -+ ((org.bukkit.craftbukkit.v1_18_R2.CraftWorldBorder) this.getBukkitEntity().getWorldBorder()).getHandle().m_61969_(); ++ ((org.bukkit.craftbukkit.v1_18_R2.CraftWorldBorder) this.getBukkitEntity().getWorldBorder()).getHandle().tick(); + } + // CraftBukkit end } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking player"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Player being ticked"); -- this.m_7976_(crashreportcategory); +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Player being ticked"); +- this.fillCrashReportCategory(crashreportcategory); - throw new ReportedException(crashreport); -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Ticking player" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Player being ticked" ); -+ this.m_7976_( crashreportcategory ); ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Ticking player" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Player being ticked" ); ++ this.fillCrashReportCategory( crashreportcategory ); + throw new ReportedException( crashreport ); } } - public void m_183634_() { - if (this.m_21223_() > 0.0F && this.f_184125_ != null) { -- CriteriaTriggers.f_184759_.m_186165_(this, this.f_184125_); -+ CriteriaTriggers.f_184759_.m_186165_( this, this.f_184125_ ); + public void resetFallDistance() { + if (this.getHealth() > 0.0F && this.startingToFallPosition != null) { +- CriteriaTriggers.FALL_FROM_HEIGHT.trigger(this, this.startingToFallPosition); ++ CriteriaTriggers.FALL_FROM_HEIGHT.trigger( this, this.startingToFallPosition ); } - this.f_184125_ = null; + this.startingToFallPosition = null; @@ -524,7 +_,7 @@ - if (this.f_184126_ == null) { - this.f_184126_ = this.m_20182_(); + if (this.enteredLavaOnVehiclePosition == null) { + this.enteredLavaOnVehiclePosition = this.position(); } else { -- CriteriaTriggers.f_184760_.m_186165_(this, this.f_184126_); -+ CriteriaTriggers.f_184760_.m_186165_( this, this.f_184126_ ); +- CriteriaTriggers.RIDE_ENTITY_IN_LAVA_TRIGGER.trigger(this, this.enteredLavaOnVehiclePosition); ++ CriteriaTriggers.RIDE_ENTITY_IN_LAVA_TRIGGER.trigger( this, this.enteredLavaOnVehiclePosition ); } } @@ -535,36 +_,69 @@ } - private void m_9104_(ObjectiveCriteria p_9105_, int p_9106_) { -- this.m_36329_().m_83427_(p_9105_, this.m_6302_(), (p_9178_) -> { -- p_9178_.m_83402_(p_9106_); + private void updateScoreForCriteria(ObjectiveCriteria p_9105_, int p_9106_) { +- this.getScoreboard().forAllObjectives(p_9105_, this.getScoreboardName(), (p_9178_) -> { +- p_9178_.setScore(p_9106_); - }); + // CraftBukkit - Use our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores( p_9105_, this.m_6302_(), (p_9178_) -> { -+ p_9178_.m_83402_( p_9106_ ); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores( p_9105_, this.getScoreboardName(), (p_9178_) -> { ++ p_9178_.setScore( p_9106_ ); + } ); } + //Magma start - rewrite - public void m_6667_(DamageSource p_9035_) { + public void die(DamageSource p_9035_) { + if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_9035_)) return; - boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46142_); + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); - if (flag) { -- Component component = this.m_21231_().m_19293_(); -- this.f_8906_.m_9831_(new ClientboundPlayerCombatKillPacket(this.m_21231_(), component), (p_9142_) -> { +- Component component = this.getCombatTracker().getDeathMessage(); +- this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), component), (p_9142_) -> { - if (!p_9142_.isSuccess()) { + // CraftBukkit start - fire PlayerDeathEvent -+ if (this.f_20890_) { ++ if (this.dead) { + return; + } -+ boolean keepInventory = this.f_19853_.m_46469_().m_46207_(GameRules.f_46133_); ++ boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY); + + Inventory copy = new Inventory(this); -+ copy.m_36006_(m_150109_()); // Create a deep copy ++ copy.replaceWith(getInventory()); // Create a deep copy + -+ if (!this.m_5833_()) { -+ this.m_6668_(p_9035_); ++ if (!this.isSpectator()) { ++ this.dropAllDeathLoot(p_9035_); + } + + List capturedDrops = new java.util.ArrayList<>(this.drops); + this.drops.clear(); + -+ Component defaultMessage = this.m_21231_().m_19293_(); ++ Component defaultMessage = this.getCombatTracker().getDeathMessage(); + String deathmessage = defaultMessage.getString(); + keepLevel = keepInventory; // SPIGOT-2222: pre-set keepLevel + org.bukkit.event.entity.PlayerDeathEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerDeathEvent(this, capturedDrops, deathmessage, keepInventory); + // SPIGOT-943 - only call if they have an inventory open -+ if (this.f_36096_ != this.f_36095_) { -+ this.m_9230_(); ++ if (this.containerMenu != this.inventoryMenu) { ++ this.doCloseContainer(); + } + String deathMessage = event.getDeathMessage(); + if (deathMessage != null && deathMessage.length() > 0 && flag) { + Component itextcomponent; + if (deathMessage.equals(deathmessage)) { -+ itextcomponent = this.m_21231_().m_19293_(); ++ itextcomponent = this.getCombatTracker().getDeathMessage(); + } else { + itextcomponent = org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromStringOrNull(deathMessage); + } -+ this.f_8906_.m_9831_(new ClientboundPlayerCombatKillPacket(this.m_21231_(), itextcomponent), (future) -> { ++ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), itextcomponent), (future) -> { + if (!future.isSuccess()) { int i = 256; -- String s = component.m_130668_(256); -- Component component1 = new TranslatableComponent("death.attack.message_too_long", (new TextComponent(s)).m_130940_(ChatFormatting.YELLOW)); -- Component component2 = (new TranslatableComponent("death.attack.even_more_magic", this.m_5446_())).m_130938_((p_143420_) -> { -- return p_143420_.m_131144_(new HoverEvent(HoverEvent.Action.f_130831_, component1)); -+ String s = itextcomponent.m_130668_(256); -+ Component itextcomponent1 = new TranslatableComponent("death.attack.message_too_long", (new TextComponent(s)).m_130940_(ChatFormatting.YELLOW)); -+ Component itextcomponent2 = (new TranslatableComponent("death.attack.even_more_magic", this.m_5446_())).m_130938_((p_212357_1_) -> { -+ return p_212357_1_.m_131144_(new HoverEvent(HoverEvent.Action.f_130831_, itextcomponent1)); +- String s = component.getString(256); +- Component component1 = new TranslatableComponent("death.attack.message_too_long", (new TextComponent(s)).withStyle(ChatFormatting.YELLOW)); +- Component component2 = (new TranslatableComponent("death.attack.even_more_magic", this.getDisplayName())).withStyle((p_143420_) -> { +- return p_143420_.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, component1)); ++ String s = itextcomponent.getString(256); ++ Component itextcomponent1 = new TranslatableComponent("death.attack.message_too_long", (new TextComponent(s)).withStyle(ChatFormatting.YELLOW)); ++ Component itextcomponent2 = (new TranslatableComponent("death.attack.even_more_magic", this.getDisplayName())).withStyle((p_212357_1_) -> { ++ return p_212357_1_.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, itextcomponent1)); }); -- this.f_8906_.m_141995_(new ClientboundPlayerCombatKillPacket(this.m_21231_(), component2)); -+ this.f_8906_.m_141995_(new ClientboundPlayerCombatKillPacket(this.m_21231_(), itextcomponent2)); +- this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), component2)); ++ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), itextcomponent2)); } }); -- Team team = this.m_5647_(); -- if (team != null && team.m_7468_() != Team.Visibility.ALWAYS) { -- if (team.m_7468_() == Team.Visibility.HIDE_FOR_OTHER_TEAMS) { -- this.f_8924_.m_6846_().m_11249_(this, component); -- } else if (team.m_7468_() == Team.Visibility.HIDE_FOR_OWN_TEAM) { -- this.f_8924_.m_6846_().m_11278_(this, component); -+ Team scoreboardteambase = this.m_5647_(); -+ if (scoreboardteambase != null && scoreboardteambase.m_7468_() != Team.Visibility.ALWAYS) { -+ if (scoreboardteambase.m_7468_() == Team.Visibility.HIDE_FOR_OTHER_TEAMS) { -+ this.f_8924_.m_6846_().m_11249_(this, itextcomponent); -+ } else if (scoreboardteambase.m_7468_() == Team.Visibility.HIDE_FOR_OWN_TEAM) { -+ this.f_8924_.m_6846_().m_11278_(this, itextcomponent); +- Team team = this.getTeam(); +- if (team != null && team.getDeathMessageVisibility() != Team.Visibility.ALWAYS) { +- if (team.getDeathMessageVisibility() == Team.Visibility.HIDE_FOR_OTHER_TEAMS) { +- this.server.getPlayerList().broadcastToTeam(this, component); +- } else if (team.getDeathMessageVisibility() == Team.Visibility.HIDE_FOR_OWN_TEAM) { +- this.server.getPlayerList().broadcastToAllExceptTeam(this, component); ++ Team scoreboardteambase = this.getTeam(); ++ if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != Team.Visibility.ALWAYS) { ++ if (scoreboardteambase.getDeathMessageVisibility() == Team.Visibility.HIDE_FOR_OTHER_TEAMS) { ++ this.server.getPlayerList().broadcastToTeam(this, itextcomponent); ++ } else if (scoreboardteambase.getDeathMessageVisibility() == Team.Visibility.HIDE_FOR_OWN_TEAM) { ++ this.server.getPlayerList().broadcastToAllExceptTeam(this, itextcomponent); } } else { -- this.f_8924_.m_6846_().m_11264_(component, ChatType.SYSTEM, Util.f_137441_); -+ this.f_8924_.m_6846_().m_11264_(itextcomponent, ChatType.SYSTEM, Util.f_137441_); +- this.server.getPlayerList().broadcastMessage(component, ChatType.SYSTEM, Util.NIL_UUID); ++ this.server.getPlayerList().broadcastMessage(itextcomponent, ChatType.SYSTEM, Util.NIL_UUID); } } else { - this.f_8906_.m_141995_(new ClientboundPlayerCombatKillPacket(this.m_21231_(), TextComponent.f_131282_)); + this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), TextComponent.EMPTY)); @@ -575,11 +_,23 @@ - this.m_9215_(); + this.tellNeutralMobsThatIDied(); } -- if (!this.m_5833_()) { -- this.m_6668_(p_9035_); +- if (!this.isSpectator()) { +- this.dropAllDeathLoot(p_9035_); + // SPIGOT-5478 must be called manually now -+ this.m_21226_(); ++ this.dropExperience(); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { -+ this.m_150109_().m_6211_(); ++ this.getInventory().clearContent(); + } else { //Magma - if keepInventory is modified by a plugin, reset the inventory and clear the forge captures -+ this.m_150109_().m_36006_(copy); ++ this.getInventory().replaceWith(copy); + getForgeCapturesAndClear(); } -- this.m_36329_().m_83427_(ObjectiveCriteria.f_83590_, this.m_6302_(), Score::m_83392_); +- this.getScoreboard().forAllObjectives(ObjectiveCriteria.DEATH_COUNT, this.getScoreboardName(), Score::increment); + // this.getWorldScoreboard().forAllObjectives(ScoreCriteria.DEATH_COUNT, this.getScoreboardName(), Score::incrementScore); -+ this.m_9213_(this); // Remove spectated target ++ this.setCamera(this); // Remove spectated target + // CraftBukkit end + + // CraftBukkit - Get our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores(ObjectiveCriteria.f_83590_, this.m_6302_(), Score::m_83392_); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(ObjectiveCriteria.DEATH_COUNT, this.getScoreboardName(), Score::increment); + - LivingEntity livingentity = this.m_21232_(); + LivingEntity livingentity = this.getKillCredit(); if (livingentity != null) { - this.m_36246_(Stats.f_12987_.m_12902_(livingentity.m_6095_())); + this.awardStat(Stats.ENTITY_KILLED_BY.get(livingentity.getType())); @@ -592,93 +_,105 @@ - this.m_7166_(Stats.f_12988_.m_12902_(Stats.f_12991_)); - this.m_7166_(Stats.f_12988_.m_12902_(Stats.f_12992_)); - this.m_20095_(); -- this.m_146917_(0); -- this.m_146868_(false); -+ this.m_20115_(0, false); - this.m_21231_().m_19296_(); + this.resetStat(Stats.CUSTOM.get(Stats.TIME_SINCE_DEATH)); + this.resetStat(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)); + this.clearFire(); +- this.setTicksFrozen(0); +- this.setSharedFlagOnFire(false); ++ this.setSharedFlag(0, false); + this.getCombatTracker().recheckStatus(); } + //Magma end - private void m_9215_() { -- AABB aabb = (new AABB(this.m_142538_())).m_82377_(32.0D, 10.0D, 32.0D); -- this.f_19853_.m_6443_(Mob.class, aabb, EntitySelector.f_20408_).stream().filter((p_9188_) -> { -+ AABB aabb = (new AABB( this.m_142538_() )).m_82377_( 32.0D, 10.0D, 32.0D ); -+ this.f_19853_.m_6443_( Mob.class, aabb, EntitySelector.f_20408_ ).stream().filter( (p_9188_) -> { + private void tellNeutralMobsThatIDied() { +- AABB aabb = (new AABB(this.blockPosition())).inflate(32.0D, 10.0D, 32.0D); +- this.level.getEntitiesOfClass(Mob.class, aabb, EntitySelector.NO_SPECTATORS).stream().filter((p_9188_) -> { ++ AABB aabb = (new AABB( this.blockPosition() )).inflate( 32.0D, 10.0D, 32.0D ); ++ this.level.getEntitiesOfClass( Mob.class, aabb, EntitySelector.NO_SPECTATORS ).stream().filter( (p_9188_) -> { return p_9188_ instanceof NeutralMob; - }).forEach((p_9057_) -> { -- ((NeutralMob)p_9057_).m_21676_(this); +- ((NeutralMob)p_9057_).playerDied(this); - }); + } ).forEach( (p_9057_) -> { -+ ((NeutralMob) p_9057_).m_21676_( this ); ++ ((NeutralMob) p_9057_).playerDied( this ); + } ); } - public void m_5993_(Entity p_9050_, int p_9051_, DamageSource p_9052_) { + public void awardKillScore(Entity p_9050_, int p_9051_, DamageSource p_9052_) { if (p_9050_ != this) { -- super.m_5993_(p_9050_, p_9051_, p_9052_); -- this.m_36401_(p_9051_); -+ super.m_5993_( p_9050_, p_9051_, p_9052_ ); -+ this.m_36401_( p_9051_ ); - String s = this.m_6302_(); - String s1 = p_9050_.m_6302_(); -- this.m_36329_().m_83427_(ObjectiveCriteria.f_83592_, s, Score::m_83392_); +- super.awardKillScore(p_9050_, p_9051_, p_9052_); +- this.increaseScore(p_9051_); ++ super.awardKillScore( p_9050_, p_9051_, p_9052_ ); ++ this.increaseScore( p_9051_ ); + String s = this.getScoreboardName(); + String s1 = p_9050_.getScoreboardName(); +- this.getScoreboard().forAllObjectives(ObjectiveCriteria.KILL_COUNT_ALL, s, Score::increment); + + // CraftBukkit - Get our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores( ObjectiveCriteria.f_83592_, s, Score::m_83392_ ); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores( ObjectiveCriteria.KILL_COUNT_ALL, s, Score::increment ); if (p_9050_ instanceof Player) { -- this.m_36220_(Stats.f_12938_); -- this.m_36329_().m_83427_(ObjectiveCriteria.f_83591_, s, Score::m_83392_); -+ this.m_36220_( Stats.f_12938_ ); +- this.awardStat(Stats.PLAYER_KILLS); +- this.getScoreboard().forAllObjectives(ObjectiveCriteria.KILL_COUNT_PLAYERS, s, Score::increment); ++ this.awardStat( Stats.PLAYER_KILLS ); + // CraftBukkit - Get our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores( ObjectiveCriteria.f_83591_, s, Score::m_83392_ ); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores( ObjectiveCriteria.KILL_COUNT_PLAYERS, s, Score::increment ); } else { -- this.m_36220_(Stats.f_12936_); -+ this.m_36220_( Stats.f_12936_ ); +- this.awardStat(Stats.MOB_KILLS); ++ this.awardStat( Stats.MOB_KILLS ); } -- this.m_9124_(s, s1, ObjectiveCriteria.f_83599_); -- this.m_9124_(s1, s, ObjectiveCriteria.f_83600_); -- CriteriaTriggers.f_10568_.m_48104_(this, p_9050_, p_9052_); -+ this.m_9124_( s, s1, ObjectiveCriteria.f_83599_ ); -+ this.m_9124_( s1, s, ObjectiveCriteria.f_83600_ ); -+ CriteriaTriggers.f_10568_.m_48104_( this, p_9050_, p_9052_ ); +- this.handleTeamKill(s, s1, ObjectiveCriteria.TEAM_KILL); +- this.handleTeamKill(s1, s, ObjectiveCriteria.KILLED_BY_TEAM); +- CriteriaTriggers.PLAYER_KILLED_ENTITY.trigger(this, p_9050_, p_9052_); ++ this.handleTeamKill( s, s1, ObjectiveCriteria.TEAM_KILL ); ++ this.handleTeamKill( s1, s, ObjectiveCriteria.KILLED_BY_TEAM ); ++ CriteriaTriggers.PLAYER_KILLED_ENTITY.trigger( this, p_9050_, p_9052_ ); } } - private void m_9124_(String p_9125_, String p_9126_, ObjectiveCriteria[] p_9127_) { -- PlayerTeam playerteam = this.m_36329_().m_83500_(p_9126_); -+ PlayerTeam playerteam = this.m_36329_().m_83500_( p_9126_ ); + private void handleTeamKill(String p_9125_, String p_9126_, ObjectiveCriteria[] p_9127_) { +- PlayerTeam playerteam = this.getScoreboard().getPlayersTeam(p_9126_); ++ PlayerTeam playerteam = this.getScoreboard().getPlayersTeam( p_9126_ ); if (playerteam != null) { - int i = playerteam.m_7414_().m_126656_(); + int i = playerteam.getColor().getId(); if (i >= 0 && i < p_9127_.length) { -- this.m_36329_().m_83427_(p_9127_[i], p_9125_, Score::m_83392_); +- this.getScoreboard().forAllObjectives(p_9127_[i], p_9125_, Score::increment); + // CraftBukkit - Get our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores( p_9127_[i], p_9126_, Score::m_83392_ ); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores( p_9127_[i], p_9126_, Score::increment ); } } } - public boolean m_6469_(DamageSource p_9037_, float p_9038_) { -- if (this.m_6673_(p_9037_)) { -+ if (this.m_6673_( p_9037_ )) { + public boolean hurt(DamageSource p_9037_, float p_9038_) { +- if (this.isInvulnerableTo(p_9037_)) { ++ if (this.isInvulnerableTo( p_9037_ )) { return false; } else { -- boolean flag = this.f_8924_.m_6982_() && this.m_9216_() && "fall".equals(p_9037_.f_19326_); -+ boolean flag = this.f_8924_.m_6982_() && this.m_9216_() && "fall".equals( p_9037_.f_19326_ ); - if (!flag && this.f_8921_ > 0 && p_9037_ != DamageSource.f_19317_) { +- boolean flag = this.server.isDedicatedServer() && this.isPvpAllowed() && "fall".equals(p_9037_.msgId); ++ boolean flag = this.server.isDedicatedServer() && this.isPvpAllowed() && "fall".equals( p_9037_.msgId ); + if (!flag && this.spawnInvulnerableTime > 0 && p_9037_ != DamageSource.OUT_OF_WORLD) { return false; } else { if (p_9037_ instanceof EntityDamageSource) { - Entity entity = p_9037_.m_7639_(); -- if (entity instanceof Player && !this.m_7099_((Player)entity)) { -+ if (entity instanceof Player && !this.m_7099_( (Player) entity )) { + Entity entity = p_9037_.getEntity(); +- if (entity instanceof Player && !this.canHarmPlayer((Player)entity)) { ++ if (entity instanceof Player && !this.canHarmPlayer( (Player) entity )) { return false; } if (entity instanceof AbstractArrow) { - AbstractArrow abstractarrow = (AbstractArrow)entity; + AbstractArrow abstractarrow = (AbstractArrow) entity; - Entity entity1 = abstractarrow.m_37282_(); -- if (entity1 instanceof Player && !this.m_7099_((Player)entity1)) { -+ if (entity1 instanceof Player && !this.m_7099_( (Player) entity1 )) { + Entity entity1 = abstractarrow.getOwner(); +- if (entity1 instanceof Player && !this.canHarmPlayer((Player)entity1)) { ++ if (entity1 instanceof Player && !this.canHarmPlayer( (Player) entity1 )) { return false; } } } -- return super.m_6469_(p_9037_, p_9038_); -+ return super.m_6469_( p_9037_, p_9038_ ); +- return super.hurt(p_9037_, p_9038_); ++ return super.hurt( p_9037_, p_9038_ ); } } } - public boolean m_7099_(Player p_9064_) { -- return !this.m_9216_() ? false : super.m_7099_(p_9064_); -+ return !this.m_9216_() ? false : super.m_7099_( p_9064_ ); + public boolean canHarmPlayer(Player p_9064_) { +- return !this.isPvpAllowed() ? false : super.canHarmPlayer(p_9064_); ++ return !this.isPvpAllowed() ? false : super.canHarmPlayer( p_9064_ ); } - private boolean m_9216_() { -- return this.f_8924_.m_129799_(); + private boolean isPvpAllowed() { +- return this.server.isPvpAllowed(); + // CraftBukkit - this.server.isPvpAllowed() -> this.world.pvpMode -+ return this.f_19853_.pvpMode; ++ return this.level.pvpMode; } @Nullable - protected PortalInfo m_7937_(ServerLevel p_8998_) { -- PortalInfo portalinfo = super.m_7937_(p_8998_); -- if (portalinfo != null && this.f_19853_.m_46472_() == Level.f_46428_ && p_8998_.m_46472_() == Level.f_46430_) { -- Vec3 vec3 = portalinfo.f_77676_.m_82520_(0.0D, -1.0D, 0.0D); -- return new PortalInfo(vec3, Vec3.f_82478_, 90.0F, 0.0F); -+ PortalInfo portalinfo = super.m_7937_( p_8998_ ); + protected PortalInfo findDimensionEntryPoint(ServerLevel p_8998_) { +- PortalInfo portalinfo = super.findDimensionEntryPoint(p_8998_); +- if (portalinfo != null && this.level.dimension() == Level.OVERWORLD && p_8998_.dimension() == Level.END) { +- Vec3 vec3 = portalinfo.pos.add(0.0D, -1.0D, 0.0D); +- return new PortalInfo(vec3, Vec3.ZERO, 90.0F, 0.0F); ++ PortalInfo portalinfo = super.findDimensionEntryPoint( p_8998_ ); + //Magma start - fix for null world in PortalInfo + p_8998_ = (portalinfo == null || portalinfo.world == null) ? p_8998_ : portalinfo.world; //CraftBukkit + if (portalinfo != null && portalinfo.world == null) + portalinfo.world = p_8998_; + //Magma end -+ if (portalinfo != null && this.f_19853_.m_46472_() == Level.f_46428_ && p_8998_.m_46472_() == Level.f_46429_) { -+ Vec3 vec3 = portalinfo.f_77676_.m_82520_( 0.0D, 0.0D, 0.0D ); -+ PortalInfo info = new PortalInfo( vec3, Vec3.f_82478_, 90.0F, 0.0F ); ++ if (portalinfo != null && this.level.dimension() == Level.OVERWORLD && p_8998_.dimension() == Level.NETHER) { ++ Vec3 vec3 = portalinfo.pos.add( 0.0D, 0.0D, 0.0D ); ++ PortalInfo info = new PortalInfo( vec3, Vec3.ZERO, 90.0F, 0.0F ); + info.setCBPortalEvent( p_8998_, portalinfo.portalEventInfo ); + return info; } else { @@ -850,13 +850,13 @@ @@ -686,76 +_,149 @@ @Nullable - public Entity m_5489_(ServerLevel p_9180_) { -- this.f_8927_ = true; -- ServerLevel serverlevel = this.m_183503_(); -- ResourceKey resourcekey = serverlevel.m_46472_(); -- if (resourcekey == Level.f_46430_ && p_9180_.m_46472_() == Level.f_46428_) { + public Entity changeDimension(ServerLevel p_9180_) { +- this.isChangingDimension = true; +- ServerLevel serverlevel = this.getLevel(); +- ResourceKey resourcekey = serverlevel.dimension(); +- if (resourcekey == Level.END && p_9180_.dimension() == Level.OVERWORLD) { + // CraftBukkit start -+ return changeDimension( p_9180_, p_9180_.m_8871_(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN ); ++ return changeDimension( p_9180_, p_9180_.getPortalForcer(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN ); + } + + @Nullable @@ -866,83 +866,83 @@ + + @Nullable + public Entity changeDimension(ServerLevel p_9180_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { -+ return changeDimension( p_9180_, p_9180_.m_8871_(), cause ); ++ return changeDimension( p_9180_, p_9180_.getPortalForcer(), cause ); + } + + @Nullable + public Entity changeDimension(ServerLevel p_9180_, net.minecraftforge.common.util.ITeleporter teleporter, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension( this, p_9180_.m_46472_() )) return null; -+ if (this.m_5803_()) return this; // CraftBukkit - SPIGOT-3154 ++ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension( this, p_9180_.dimension() )) return null; ++ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 + // this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension -+ java.util.concurrent.atomic.AtomicReference serverlevel = new java.util.concurrent.atomic.AtomicReference<>( this.m_183503_() ); // For use in lambda -+ ResourceKey resourcekey = serverlevel.get().m_46472_(); -+ if (resourcekey == Level.f_46430_ && p_9180_.m_46472_() == Level.f_46428_ && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits -+ this.f_8927_ = true; - this.m_19877_(); -- this.m_183503_().m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); -+ this.m_183503_().m_143261_( this, Entity.RemovalReason.CHANGED_DIMENSION ); - if (!this.f_8944_) { - this.f_8944_ = true; -- this.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132157_, this.f_8928_ ? 0.0F : 1.0F)); -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132157_, this.f_8928_ ? 0.0F : 1.0F ) ); - this.f_8928_ = true; ++ java.util.concurrent.atomic.AtomicReference serverlevel = new java.util.concurrent.atomic.AtomicReference<>( this.getLevel() ); // For use in lambda ++ ResourceKey resourcekey = serverlevel.get().dimension(); ++ if (resourcekey == Level.END && p_9180_.dimension() == Level.OVERWORLD && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits ++ this.isChangingDimension = true; + this.unRide(); +- this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); ++ this.getLevel().removePlayerImmediately( this, Entity.RemovalReason.CHANGED_DIMENSION ); + if (!this.wonGame) { + this.wonGame = true; +- this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, this.seenCredits ? 0.0F : 1.0F)); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.WIN_GAME, this.seenCredits ? 0.0F : 1.0F ) ); + this.seenCredits = true; } return this; } else { - LevelData leveldata = p_9180_.m_6106_(); -- this.f_8906_.m_141995_(new ClientboundRespawnPacket(p_9180_.m_204156_(), p_9180_.m_46472_(), BiomeManager.m_47877_(p_9180_.m_7328_()), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9180_.m_46659_(), p_9180_.m_8584_(), true)); -- this.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); -+ this.f_8906_.m_141995_( new ClientboundRespawnPacket( p_9180_.m_204156_(), p_9180_.m_46472_(), BiomeManager.m_47877_( p_9180_.m_7328_() ), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9180_.m_46659_(), p_9180_.m_8584_(), true ) ); -+ this.f_8906_.m_141995_( new ClientboundChangeDifficultyPacket( leveldata.m_5472_(), leveldata.m_5474_() ) ); - PlayerList playerlist = this.f_8924_.m_6846_(); -- playerlist.m_11289_(this); -- serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); -- this.m_146912_(); -- PortalInfo portalinfo = this.m_7937_(p_9180_); -+ playerlist.m_11289_( this ); -+ serverlevel.get().m_143261_( this, Entity.RemovalReason.CHANGED_DIMENSION ); + LevelData leveldata = p_9180_.getLevelData(); +- this.connection.send(new ClientboundRespawnPacket(p_9180_.dimensionTypeRegistration(), p_9180_.dimension(), BiomeManager.obfuscateSeed(p_9180_.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), p_9180_.isDebug(), p_9180_.isFlat(), true)); +- this.connection.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); ++ this.connection.send( new ClientboundRespawnPacket( p_9180_.dimensionTypeRegistration(), p_9180_.dimension(), BiomeManager.obfuscateSeed( p_9180_.getSeed() ), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), p_9180_.isDebug(), p_9180_.isFlat(), true ) ); ++ this.connection.send( new ClientboundChangeDifficultyPacket( leveldata.getDifficulty(), leveldata.isDifficultyLocked() ) ); + PlayerList playerlist = this.server.getPlayerList(); +- playerlist.sendPlayerPermissionLevel(this); +- serverlevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); +- this.unsetRemoved(); +- PortalInfo portalinfo = this.findDimensionEntryPoint(p_9180_); ++ playerlist.sendPlayerPermissionLevel( this ); ++ serverlevel.get().removePlayerImmediately( this, Entity.RemovalReason.CHANGED_DIMENSION ); + this.revive(); -+ PortalInfo portalinfo = teleporter.getPortalInfo( this, p_9180_, this::m_7937_ ); ++ PortalInfo portalinfo = teleporter.getPortalInfo( this, p_9180_, this::findDimensionEntryPoint ); if (portalinfo != null) { -- serverlevel.m_46473_().m_6180_("moving"); -- if (resourcekey == Level.f_46428_ && p_9180_.m_46472_() == Level.f_46429_) { -- this.f_8933_ = this.m_20182_(); -- } else if (p_9180_.m_46472_() == Level.f_46430_) { -- this.m_9006_(p_9180_, new BlockPos(portalinfo.f_77676_)); +- serverlevel.getProfiler().push("moving"); +- if (resourcekey == Level.OVERWORLD && p_9180_.dimension() == Level.NETHER) { +- this.enteredNetherPosition = this.position(); +- } else if (p_9180_.dimension() == Level.END) { +- this.createEndPlatform(p_9180_, new BlockPos(portalinfo.pos)); - } - -- serverlevel.m_46473_().m_7238_(); -- serverlevel.m_46473_().m_6180_("placing"); -- this.m_143425_(p_9180_); -- p_9180_.m_8817_(this); -- this.m_19915_(portalinfo.f_77678_, portalinfo.f_77679_); -- this.m_6027_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_); -- serverlevel.m_46473_().m_7238_(); -- this.m_9209_(serverlevel); -- this.f_8906_.m_141995_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); -- playerlist.m_11229_(this, p_9180_); -- playerlist.m_11292_(this); +- serverlevel.getProfiler().pop(); +- serverlevel.getProfiler().push("placing"); +- this.setLevel(p_9180_); +- p_9180_.addDuringPortalTeleport(this); +- this.setRot(portalinfo.yRot, portalinfo.xRot); +- this.moveTo(portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z); +- serverlevel.getProfiler().pop(); +- this.triggerDimensionChangeTriggers(serverlevel); +- this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); +- playerlist.sendLevelInfo(this, p_9180_); +- playerlist.sendAllPlayerInfo(this); - -- for(MobEffectInstance mobeffectinstance : this.m_21220_()) { -- this.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(this.m_142049_(), mobeffectinstance)); +- for(MobEffectInstance mobeffectinstance : this.getActiveEffects()) { +- this.connection.send(new ClientboundUpdateMobEffectPacket(this.getId(), mobeffectinstance)); - } - -- this.f_8906_.m_141995_(new ClientboundLevelEventPacket(1032, BlockPos.f_121853_, 0, false)); +- this.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false)); + serverlevel.set(portalinfo.world == null ? p_9180_ : portalinfo.world); -+ Entity e = teleporter.placeEntity( this, serverlevel.get(), p_9180_, this.m_146908_(), spawnPortal -> {//Forge: Start vanilla logic -+ serverlevel.get().m_46473_().m_6180_( "moving" ); ++ Entity e = teleporter.placeEntity( this, serverlevel.get(), p_9180_, this.getYRot(), spawnPortal -> {//Forge: Start vanilla logic ++ serverlevel.get().getProfiler().push( "moving" ); + if (serverlevel.get() == null) { + } else //CraftBukkit - empty to fall trough to null to event -+ if (resourcekey == Level.f_46428_ && p_9180_.m_46472_() == Level.f_46429_) { -+ this.f_8933_ = this.m_20182_(); -+ } else if (spawnPortal && p_9180_.m_46472_() == Level.f_46430_ && portalinfo.portalEventInfo != null && portalinfo.portalEventInfo.getCanCreatePortal()) { -+ this.m_9006_( p_9180_, new BlockPos( portalinfo.f_77676_ ) ); ++ if (resourcekey == Level.OVERWORLD && p_9180_.dimension() == Level.NETHER) { ++ this.enteredNetherPosition = this.position(); ++ } else if (spawnPortal && p_9180_.dimension() == Level.END && portalinfo.portalEventInfo != null && portalinfo.portalEventInfo.getCanCreatePortal()) { ++ this.createEndPlatform( p_9180_, new BlockPos( portalinfo.pos ) ); + } + + org.bukkit.Location enter = this.getBukkitEntity().getLocation(); -+ org.bukkit.Location exit = (serverlevel.get() == null) ? null : new org.bukkit.Location( p_9180_.getWorld(), portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_, portalinfo.f_77678_, portalinfo.f_77679_ ); ++ org.bukkit.Location exit = (serverlevel.get() == null) ? null : new org.bukkit.Location( p_9180_.getWorld(), portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.yRot, portalinfo.xRot ); + org.bukkit.event.player.PlayerTeleportEvent tpEvent = new org.bukkit.event.player.PlayerTeleportEvent( this.getBukkitEntity(), enter, exit, cause ); + org.bukkit.Bukkit.getServer().getPluginManager().callEvent( tpEvent ); + if (tpEvent.isCancelled() || tpEvent.getTo() == null) { @@ -952,48 +952,48 @@ + serverlevel.set( ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) exit.getWorld()).getHandle() ); + // CraftBukkit end + -+ serverlevel.get().m_46473_().m_7238_(); -+ serverlevel.get().m_46473_().m_6180_( "placing" ); -+ this.f_8927_ = true; ++ serverlevel.get().getProfiler().pop(); ++ serverlevel.get().getProfiler().push( "placing" ); ++ this.isChangingDimension = true; + -+ this.f_8906_.m_141995_( new ClientboundRespawnPacket( serverlevel.get().m_204156_(), serverlevel.get().m_46472_(), BiomeManager.m_47877_( serverlevel.get().m_7328_() ), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), serverlevel.get().m_46659_(), serverlevel.get().m_8584_(), true ) ); -+ this.f_8906_.m_141995_( new ClientboundChangeDifficultyPacket( serverlevel.get().m_6106_().m_5472_(), serverlevel.get().m_6106_().m_5474_() ) ); -+ PlayerList playerList = this.f_8924_.m_6846_(); ++ this.connection.send( new ClientboundRespawnPacket( serverlevel.get().dimensionTypeRegistration(), serverlevel.get().dimension(), BiomeManager.obfuscateSeed( serverlevel.get().getSeed() ), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), serverlevel.get().isDebug(), serverlevel.get().isFlat(), true ) ); ++ this.connection.send( new ClientboundChangeDifficultyPacket( serverlevel.get().getLevelData().getDifficulty(), serverlevel.get().getLevelData().isDifficultyLocked() ) ); ++ PlayerList playerList = this.server.getPlayerList(); + -+ playerList.m_11289_( this ); -+ serverlevel.get().m_143261_( this, Entity.RemovalReason.CHANGED_DIMENSION ); ++ playerList.sendPlayerPermissionLevel( this ); ++ serverlevel.get().removePlayerImmediately( this, Entity.RemovalReason.CHANGED_DIMENSION ); + this.revive(); + -+ this.m_143425_( p_9180_ ); -+ p_9180_.m_8817_( this ); -+ this.f_8906_.teleport( exit ); -+ this.f_8906_.m_9953_(); -+ this.m_19915_( portalinfo.f_77678_, portalinfo.f_77679_ ); -+ serverlevel.get().m_46473_().m_7238_(); -+ this.m_9209_( serverlevel.get() ); ++ this.setLevel( p_9180_ ); ++ p_9180_.addDuringPortalTeleport( this ); ++ this.connection.teleport( exit ); ++ this.connection.resetPosition(); ++ this.setRot( portalinfo.yRot, portalinfo.xRot ); ++ serverlevel.get().getProfiler().pop(); ++ this.triggerDimensionChangeTriggers( serverlevel.get() ); + return this;//forge: this is part of the ITeleporter patch + } );//Forge: End vanilla logic + + + if (e != this) + throw new java.lang.IllegalArgumentException( String.format( java.util.Locale.ENGLISH, "Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this ) ); -+ this.f_8906_.m_141995_( new ClientboundPlayerAbilitiesPacket( this.m_150110_() ) ); -+ playerlist.m_11229_( this, p_9180_ ); -+ playerlist.m_11292_( this ); ++ this.connection.send( new ClientboundPlayerAbilitiesPacket( this.getAbilities() ) ); ++ playerlist.sendLevelInfo( this, p_9180_ ); ++ playerlist.sendAllPlayerInfo( this ); + -+ for (MobEffectInstance mobeffectinstance : this.m_21220_()) { -+ this.f_8906_.m_141995_( new ClientboundUpdateMobEffectPacket( this.m_142049_(), mobeffectinstance ) ); ++ for (MobEffectInstance mobeffectinstance : this.getActiveEffects()) { ++ this.connection.send( new ClientboundUpdateMobEffectPacket( this.getId(), mobeffectinstance ) ); + } + + if (teleporter.playTeleportSound( this, serverlevel.get(), p_9180_ )) -+ this.f_8906_.m_141995_( new ClientboundLevelEventPacket( 1032, BlockPos.f_121853_, 0, false ) ); - this.f_8920_ = -1; - this.f_8917_ = -1.0F; - this.f_8918_ = -1; -+ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent( this, resourcekey, p_9180_.m_46472_() ); ++ this.connection.send( new ClientboundLevelEventPacket( 1032, BlockPos.ZERO, 0, false ) ); + this.lastSentExp = -1; + this.lastSentHealth = -1.0F; + this.lastSentFood = -1; ++ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent( this, resourcekey, p_9180_.dimension() ); + // CraftBukkit start + org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent( this.getBukkitEntity(), serverlevel.get().getWorld() ); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent( changeEvent ); ++ this.level.getCraftServer().getPluginManager().callEvent( changeEvent ); + // CraftBukkit end } @@ -1005,7 +1005,7 @@ + @Override + protected org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent callPortalEvent(Entity entity, ServerLevel exitServerLevel, BlockPos exitPosition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { + org.bukkit.Location enter = this.getBukkitEntity().getLocation(); -+ org.bukkit.Location exit = new org.bukkit.Location( exitServerLevel.getWorld(), exitPosition.m_123341_(), exitPosition.m_123342_(), exitPosition.m_123343_(), m_146908_(), m_146909_() ); ++ org.bukkit.Location exit = new org.bukkit.Location( exitServerLevel.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ(), getYRot(), getXRot() ); + org.bukkit.event.player.PlayerPortalEvent event = new org.bukkit.event.player.PlayerPortalEvent( this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius ); + org.bukkit.Bukkit.getServer().getPluginManager().callEvent( event ); + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) { @@ -1015,8 +1015,8 @@ + } + // CraftBukkit end - private void m_9006_(ServerLevel p_9007_, BlockPos p_9008_) { - BlockPos.MutableBlockPos blockpos$mutableblockpos = p_9008_.m_122032_(); + private void createEndPlatform(ServerLevel p_9007_, BlockPos p_9008_) { + BlockPos.MutableBlockPos blockpos$mutableblockpos = p_9008_.mutable(); - for(int i = -2; i <= 2; ++i) { - for(int j = -2; j <= 2; ++j) { @@ -1024,9 +1024,9 @@ + for (int i = -2; i <= 2; ++i) { + for (int j = -2; j <= 2; ++j) { + for (int k = -1; k < 3; ++k) { - BlockState blockstate = k == -1 ? Blocks.f_50080_.m_49966_() : Blocks.f_50016_.m_49966_(); -- p_9007_.m_46597_(blockpos$mutableblockpos.m_122190_(p_9008_).m_122184_(j, k, i), blockstate); -+ p_9007_.m_46597_( blockpos$mutableblockpos.m_122190_( p_9008_ ).m_122184_( j, k, i ), blockstate ); + BlockState blockstate = k == -1 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); +- p_9007_.setBlockAndUpdate(blockpos$mutableblockpos.set(p_9008_).move(j, k, i), blockstate); ++ p_9007_.setBlockAndUpdate( blockpos$mutableblockpos.set( p_9008_ ).move( j, k, i ), blockstate ); } } } @@ -1034,18 +1034,17 @@ } + //Magma start - add original method - protected Optional m_183318_(ServerLevel p_184131_, BlockPos p_184132_, boolean p_184133_, WorldBorder p_184134_) { - Optional optional = super.m_183318_(p_184131_, p_184132_, p_184133_, p_184134_); + protected Optional getExitPortal(ServerLevel p_184131_, BlockPos p_184132_, boolean p_184133_, WorldBorder p_184134_) { + Optional optional = super.getExitPortal(p_184131_, p_184132_, p_184133_, p_184134_); if (optional.isPresent()) { @@ -763,9 +_,27 @@ } else { - Direction.Axis direction$axis = this.f_19853_.m_8055_(this.f_19819_).m_61145_(NetherPortalBlock.f_54904_).orElse(Direction.Axis.X); - Optional optional1 = p_184131_.m_8871_().m_77666_(p_184132_, direction$axis); + Direction.Axis direction$axis = this.level.getBlockState(this.portalEntrancePos).getOptionalValue(NetherPortalBlock.AXIS).orElse(Direction.Axis.X); + Optional optional1 = p_184131_.getPortalForcer().createPortal(p_184132_, direction$axis); - if (!optional1.isPresent()) { -- f_8907_.error("Unable to create a portal, likely target out of worldborder"); -- } + /*if (!optional1.isPresent()) { -+ LOGGER.error("Unable to create a portal, likely target out of worldborder"); + LOGGER.error("Unable to create a portal, likely target out of worldborder"); +- } + }*/ //CraftBukkit commented this out for some reason, but I'm not sure why. + + return optional1; @@ -1058,8 +1057,8 @@ + if (optional.isPresent() || !canCreatePortal) { // CraftBukkit + return optional; + } else { -+ Direction.Axis direction$axis = this.f_19853_.m_8055_( this.f_19819_ ).m_61145_( NetherPortalBlock.f_54904_ ).orElse( Direction.Axis.X ); -+ Optional optional1 = p_184131_.m_8871_().createPortal( p_184132_, direction$axis, this, createRadius ); ++ Direction.Axis direction$axis = this.level.getBlockState( this.portalEntrancePos ).getOptionalValue( NetherPortalBlock.AXIS ).orElse( Direction.Axis.X ); ++ Optional optional1 = p_184131_.getPortalForcer().createPortal( p_184132_, direction$axis, this, createRadius ); + // CraftBukkit start + /*if (!optional1.isPresent()) { + LOGGER.error( "Unable to create a portal, likely target out of worldborder" ); @@ -1069,93 +1068,93 @@ return optional1; } @@ -774,12 +_,22 @@ - public void m_9209_(ServerLevel p_9210_) { - ResourceKey resourcekey = p_9210_.m_46472_(); - ResourceKey resourcekey1 = this.f_19853_.m_46472_(); -- CriteriaTriggers.f_10588_.m_19757_(this, resourcekey, resourcekey1); -- if (resourcekey == Level.f_46429_ && resourcekey1 == Level.f_46428_ && this.f_8933_ != null) { -- CriteriaTriggers.f_10552_.m_186165_(this, this.f_8933_); + public void triggerDimensionChangeTriggers(ServerLevel p_9210_) { + ResourceKey resourcekey = p_9210_.dimension(); + ResourceKey resourcekey1 = this.level.dimension(); +- CriteriaTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); +- if (resourcekey == Level.NETHER && resourcekey1 == Level.OVERWORLD && this.enteredNetherPosition != null) { +- CriteriaTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition); - } - -- if (resourcekey1 != Level.f_46429_) { +- if (resourcekey1 != Level.NETHER) { + + // CraftBukkit start + ResourceKey maindimensionkey = org.bukkit.craftbukkit.v1_18_R2.util.CraftDimensionUtil.getMainDimensionKey( p_9210_ ); -+ ResourceKey maindimensionkey1 = org.bukkit.craftbukkit.v1_18_R2.util.CraftDimensionUtil.getMainDimensionKey( this.f_19853_ ); ++ ResourceKey maindimensionkey1 = org.bukkit.craftbukkit.v1_18_R2.util.CraftDimensionUtil.getMainDimensionKey( this.level ); + -+ CriteriaTriggers.f_10588_.m_19757_( this, maindimensionkey, maindimensionkey1 ); ++ CriteriaTriggers.CHANGED_DIMENSION.trigger( this, maindimensionkey, maindimensionkey1 ); + if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) { -+ CriteriaTriggers.f_10588_.m_19757_( this, resourcekey, resourcekey1 ); ++ CriteriaTriggers.CHANGED_DIMENSION.trigger( this, resourcekey, resourcekey1 ); + } + -+ if (maindimensionkey == Level.f_46429_ && maindimensionkey1 == Level.f_46428_ && this.f_8933_ != null) { ++ if (maindimensionkey == Level.NETHER && maindimensionkey1 == Level.OVERWORLD && this.enteredNetherPosition != null) { + // CraftBukkit end -+ CriteriaTriggers.f_10552_.m_186165_( this, this.f_8933_ ); ++ CriteriaTriggers.NETHER_TRAVEL.trigger( this, this.enteredNetherPosition ); + } + -+ if (maindimensionkey1 != Level.f_46429_) { // CraftBukkit - this.f_8933_ = null; ++ if (maindimensionkey1 != Level.NETHER) { // CraftBukkit + this.enteredNetherPosition = null; } @@ -789,97 +_,145 @@ - if (p_9014_.m_5833_()) { - return this.m_8954_() == this; + if (p_9014_.isSpectator()) { + return this.getCamera() == this; } else { -- return this.m_5833_() ? false : super.m_6459_(p_9014_); -+ return this.m_5833_() ? false : super.m_6459_( p_9014_ ); +- return this.isSpectator() ? false : super.broadcastToPlayer(p_9014_); ++ return this.isSpectator() ? false : super.broadcastToPlayer( p_9014_ ); } } - public void m_7938_(Entity p_9047_, int p_9048_) { -- super.m_7938_(p_9047_, p_9048_); -+ super.m_7938_( p_9047_, p_9048_ ); - this.f_36096_.m_38946_(); + public void take(Entity p_9047_, int p_9048_) { +- super.take(p_9047_, p_9048_); ++ super.take( p_9047_, p_9048_ ); + this.containerMenu.broadcastChanges(); } + //Magma start - original method (fixes mixin inject) + @Override - public Either m_7720_(BlockPos p_9115_) { -- Direction direction = this.f_19853_.m_8055_(p_9115_).m_61143_(HorizontalDirectionalBlock.f_54117_); + public Either startSleepInBed(BlockPos p_9115_) { +- Direction direction = this.level.getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); + boolean force = startSleepInBed_force; //Magma + startSleepInBed_force = false; //reset + -+ Direction enumdirection = (Direction) this.f_19853_.m_8055_( p_9115_ ).m_61143_( HorizontalDirectionalBlock.f_54117_ ); ++ Direction enumdirection = (Direction) this.level.getBlockState( p_9115_ ).getValue( HorizontalDirectionalBlock.FACING ); + Either bedResult = null; + + java.util.Optional optAt = java.util.Optional.of( p_9115_ ); + Player.BedSleepingProblem ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed( this, optAt ); + if (ret != null) + bedResult = Either.left( ret ); - if (!this.m_5803_() && this.m_6084_()) { - if (!this.f_19853_.m_6042_().m_63956_()) { + if (!this.isSleeping() && this.isAlive()) { + if (!this.level.dimensionType().natural()) { - return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_HERE); -- } else if (!this.m_9116_(p_9115_, direction)) { +- } else if (!this.bedInRange(p_9115_, direction)) { - return Either.left(Player.BedSleepingProblem.TOO_FAR_AWAY); -- } else if (this.m_9191_(p_9115_, direction)) { +- } else if (this.bedBlocked(p_9115_, direction)) { - return Either.left(Player.BedSleepingProblem.OBSTRUCTED); + bedResult = Either.left( Player.BedSleepingProblem.NOT_POSSIBLE_HERE ); -+ } else if (!this.m_9116_( p_9115_, enumdirection )) { ++ } else if (!this.bedInRange( p_9115_, enumdirection )) { + bedResult = Either.left( Player.BedSleepingProblem.TOO_FAR_AWAY ); -+ } else if (this.m_9191_( p_9115_, enumdirection )) { ++ } else if (this.bedBlocked( p_9115_, enumdirection )) { + bedResult = Either.left( Player.BedSleepingProblem.OBSTRUCTED ); } else { -- this.m_9158_(this.f_19853_.m_46472_(), p_9115_, this.m_146908_(), false, true); -- if (this.f_19853_.m_46461_()) { +- this.setRespawnPosition(this.level.dimension(), p_9115_, this.getYRot(), false, true); +- if (this.level.isDay()) { - return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); -+ this.m_9158_( this.f_19853_.m_46472_(), p_9115_, this.m_146908_(), false, true ); ++ this.setRespawnPosition( this.level.dimension(), p_9115_, this.getYRot(), false, true ); + if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck( this, optAt )) { + bedResult = Either.left( Player.BedSleepingProblem.NOT_POSSIBLE_NOW ); } else { - if (!this.m_7500_()) { + if (!this.isCreative()) { double d0 = 8.0D; double d1 = 5.0D; -- Vec3 vec3 = Vec3.m_82539_(p_9115_); -- List list = this.f_19853_.m_6443_(Monster.class, new AABB(vec3.m_7096_() - 8.0D, vec3.m_7098_() - 5.0D, vec3.m_7094_() - 8.0D, vec3.m_7096_() + 8.0D, vec3.m_7098_() + 5.0D, vec3.m_7094_() + 8.0D), (p_9062_) -> { -- return p_9062_.m_6935_(this); +- Vec3 vec3 = Vec3.atBottomCenterOf(p_9115_); +- List list = this.level.getEntitiesOfClass(Monster.class, new AABB(vec3.x() - 8.0D, vec3.y() - 5.0D, vec3.z() - 8.0D, vec3.x() + 8.0D, vec3.y() + 5.0D, vec3.z() + 8.0D), (p_9062_) -> { +- return p_9062_.isPreventingPlayerRest(this); - }); -+ Vec3 vec3 = Vec3.m_82539_( p_9115_ ); -+ List list = this.f_19853_.m_6443_( Monster.class, new AABB( vec3.m_7096_() - 8.0D, vec3.m_7098_() - 5.0D, vec3.m_7094_() - 8.0D, vec3.m_7096_() + 8.0D, vec3.m_7098_() + 5.0D, vec3.m_7094_() + 8.0D ), (p_9062_) -> { -+ return p_9062_.m_6935_( this ); ++ Vec3 vec3 = Vec3.atBottomCenterOf( p_9115_ ); ++ List list = this.level.getEntitiesOfClass( Monster.class, new AABB( vec3.x() - 8.0D, vec3.y() - 5.0D, vec3.z() - 8.0D, vec3.x() + 8.0D, vec3.y() + 5.0D, vec3.z() + 8.0D ), (p_9062_) -> { ++ return p_9062_.isPreventingPlayerRest( this ); + } ); if (!list.isEmpty()) { - return Either.left(Player.BedSleepingProblem.NOT_SAFE); @@ -1163,15 +1162,15 @@ } } -- Either either = super.m_7720_(p_9115_).ifRight((p_9029_) -> { -- this.m_36220_(Stats.f_12969_); -- CriteriaTriggers.f_10583_.m_53645_(this); +- Either either = super.startSleepInBed(p_9115_).ifRight((p_9029_) -> { +- this.awardStat(Stats.SLEEP_IN_BED); +- CriteriaTriggers.SLEPT_IN_BED.trigger(this); - }); -- if (!this.m_183503_().m_143333_()) { -- this.m_5661_(new TranslatableComponent("sleep.not_possible"), true); +- if (!this.getLevel().canSleepThroughNights()) { +- this.displayClientMessage(new TranslatableComponent("sleep.not_possible"), true); - } - -- ((ServerLevel)this.f_19853_).m_8878_(); +- ((ServerLevel)this.level).updateSleepingPlayerList(); - return either; + if (bedResult == null) + bedResult = Either.right( Unit.INSTANCE ); @@ -1197,175 +1196,173 @@ + } + + -+ Either either = super.m_7720_( p_9115_ ).ifRight( (unit) -> { -+ this.m_36220_( Stats.f_12969_ ); -+ CriteriaTriggers.f_10583_.m_53645_( this ); ++ Either either = super.startSleepInBed( p_9115_ ).ifRight( (unit) -> { ++ this.awardStat( Stats.SLEEP_IN_BED ); ++ CriteriaTriggers.SLEPT_IN_BED.trigger( this ); + } ); -+ if (!this.m_183503_().m_143333_()) { -+ this.m_5661_( new TranslatableComponent( "sleep.not_possible" ), true ); ++ if (!this.getLevel().canSleepThroughNights()) { ++ this.displayClientMessage( new TranslatableComponent( "sleep.not_possible" ), true ); + } + -+ ((ServerLevel) this.f_19853_).m_8878_(); ++ ((ServerLevel) this.level).updateSleepingPlayerList(); + return either; } + //Magma end - public void m_5802_(BlockPos p_9190_) { -- this.m_7166_(Stats.f_12988_.m_12902_(Stats.f_12992_)); -- super.m_5802_(p_9190_); -+ this.m_7166_( Stats.f_12988_.m_12902_( Stats.f_12992_ ) ); -+ super.m_5802_( p_9190_ ); + public void startSleeping(BlockPos p_9190_) { +- this.resetStat(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)); +- super.startSleeping(p_9190_); ++ this.resetStat( Stats.CUSTOM.get( Stats.TIME_SINCE_REST ) ); ++ super.startSleeping( p_9190_ ); } - private boolean m_9116_(BlockPos p_9117_, Direction p_9118_) { -- return this.m_9222_(p_9117_) || this.m_9222_(p_9117_.m_142300_(p_9118_.m_122424_())); + private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { +- return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); + if (p_9118_ == null) return false; -+ return this.m_9222_( p_9117_ ) || this.m_9222_( p_9117_.m_142300_( p_9118_.m_122424_() ) ); ++ return this.isReachableBedBlock( p_9117_ ) || this.isReachableBedBlock( p_9117_.relative( p_9118_.getOpposite() ) ); } - private boolean m_9222_(BlockPos p_9223_) { -- Vec3 vec3 = Vec3.m_82539_(p_9223_); -- return Math.abs(this.m_20185_() - vec3.m_7096_()) <= 3.0D && Math.abs(this.m_20186_() - vec3.m_7098_()) <= 2.0D && Math.abs(this.m_20189_() - vec3.m_7094_()) <= 3.0D; -+ Vec3 vec3 = Vec3.m_82539_( p_9223_ ); -+ return Math.abs( this.m_20185_() - vec3.m_7096_() ) <= 3.0D && Math.abs( this.m_20186_() - vec3.m_7098_() ) <= 2.0D && Math.abs( this.m_20189_() - vec3.m_7094_() ) <= 3.0D; + private boolean isReachableBedBlock(BlockPos p_9223_) { +- Vec3 vec3 = Vec3.atBottomCenterOf(p_9223_); +- return Math.abs(this.getX() - vec3.x()) <= 3.0D && Math.abs(this.getY() - vec3.y()) <= 2.0D && Math.abs(this.getZ() - vec3.z()) <= 3.0D; ++ Vec3 vec3 = Vec3.atBottomCenterOf( p_9223_ ); ++ return Math.abs( this.getX() - vec3.x() ) <= 3.0D && Math.abs( this.getY() - vec3.y() ) <= 2.0D && Math.abs( this.getZ() - vec3.z() ) <= 3.0D; } - private boolean m_9191_(BlockPos p_9192_, Direction p_9193_) { - BlockPos blockpos = p_9192_.m_7494_(); -- return !this.m_36350_(blockpos) || !this.m_36350_(blockpos.m_142300_(p_9193_.m_122424_())); -+ return !this.m_36350_( blockpos ) || !this.m_36350_( blockpos.m_142300_( p_9193_.m_122424_() ) ); + private boolean bedBlocked(BlockPos p_9192_, Direction p_9193_) { + BlockPos blockpos = p_9192_.above(); +- return !this.freeAt(blockpos) || !this.freeAt(blockpos.relative(p_9193_.getOpposite())); ++ return !this.freeAt( blockpos ) || !this.freeAt( blockpos.relative( p_9193_.getOpposite() ) ); } - public void m_6145_(boolean p_9165_, boolean p_9166_) { -+ if (!this.m_5803_()) return; // CraftBukkit - Can't leave bed if not in one! + public void stopSleepInBed(boolean p_9165_, boolean p_9166_) { ++ if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one! + // CraftBukkit start - fire PlayerBedLeaveEvent + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer player = this.getBukkitEntity(); -+ BlockPos bedPosition = this.m_21257_().orElse( null ); ++ BlockPos bedPosition = this.getSleepingPos().orElse( null ); + + org.bukkit.block.Block bed; + if (bedPosition != null) { -+ bed = this.f_19853_.getWorld().getBlockAt( bedPosition.m_123341_(), bedPosition.m_123342_(), bedPosition.m_123343_() ); ++ bed = this.level.getWorld().getBlockAt( bedPosition.getX(), bedPosition.getY(), bedPosition.getZ() ); + } else { -+ bed = this.f_19853_.getWorld().getBlockAt( player.getLocation() ); ++ bed = this.level.getWorld().getBlockAt( player.getLocation() ); + } + + org.bukkit.event.player.PlayerBedLeaveEvent event = new org.bukkit.event.player.PlayerBedLeaveEvent( player, bed, true ); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent( event ); ++ this.level.getCraftServer().getPluginManager().callEvent( event ); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - if (this.m_5803_()) { -- this.m_183503_().m_7726_().m_8394_(this, new ClientboundAnimatePacket(this, 2)); -+ this.m_183503_().m_7726_().m_8394_( this, new ClientboundAnimatePacket( this, 2 ) ); + if (this.isSleeping()) { +- this.getLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(this, 2)); ++ this.getLevel().getChunkSource().broadcastAndSend( this, new ClientboundAnimatePacket( this, 2 ) ); } -- super.m_6145_(p_9165_, p_9166_); -+ super.m_6145_( p_9165_, p_9166_ ); - if (this.f_8906_ != null) { -- this.f_8906_.m_9774_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); -+ this.f_8906_.m_9774_( this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_() ); +- super.stopSleepInBed(p_9165_, p_9166_); ++ super.stopSleepInBed( p_9165_, p_9166_ ); + if (this.connection != null) { +- this.connection.teleport(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); ++ this.connection.teleport( this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot() ); } } - public boolean m_7998_(Entity p_9054_, boolean p_9055_) { - Entity entity = this.m_20202_(); -- if (!super.m_7998_(p_9054_, p_9055_)) { -+ if (!super.m_7998_( p_9054_, p_9055_ )) { + public boolean startRiding(Entity p_9054_, boolean p_9055_) { + Entity entity = this.getVehicle(); +- if (!super.startRiding(p_9054_, p_9055_)) { ++ if (!super.startRiding( p_9054_, p_9055_ )) { return false; } else { - Entity entity1 = this.m_20202_(); - if (entity1 != entity && this.f_8906_ != null) { -- this.f_8906_.m_9774_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); -+ this.f_8906_.m_9774_( this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_() ); + Entity entity1 = this.getVehicle(); + if (entity1 != entity && this.connection != null) { +- this.connection.teleport(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); ++ this.connection.teleport( this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot() ); } return true; @@ -891,7 +_,7 @@ - super.m_8127_(); - Entity entity1 = this.m_20202_(); - if (entity1 != entity && this.f_8906_ != null) { -- this.f_8906_.m_143611_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); -+ this.f_8906_.m_143611_( this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_() ); + super.stopRiding(); + Entity entity1 = this.getVehicle(); + if (entity1 != entity && this.connection != null) { +- this.connection.dismount(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); ++ this.connection.dismount( this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot() ); } } @@ -899,13 +_,13 @@ - public void m_142098_(double p_143389_, double p_143390_, double p_143391_) { - this.m_6038_(); - if (this.f_8906_ != null) { -- this.f_8906_.m_143611_(p_143389_, p_143390_, p_143391_, this.m_146908_(), this.m_146909_()); -+ this.f_8906_.m_143611_( p_143389_, p_143390_, p_143391_, this.m_146908_(), this.m_146909_() ); + public void dismountTo(double p_143389_, double p_143390_, double p_143391_) { + this.removeVehicle(); + if (this.connection != null) { +- this.connection.dismount(p_143389_, p_143390_, p_143391_, this.getYRot(), this.getXRot()); ++ this.connection.dismount( p_143389_, p_143390_, p_143391_, this.getYRot(), this.getXRot() ); } } - public boolean m_6673_(DamageSource p_9182_) { -- return super.m_6673_(p_9182_) || this.m_8958_() || this.m_150110_().f_35934_ && p_9182_ == DamageSource.f_19320_; -+ return super.m_6673_( p_9182_ ) || this.m_8958_() || this.m_150110_().f_35934_ && p_9182_ == DamageSource.f_19320_; + public boolean isInvulnerableTo(DamageSource p_9182_) { +- return super.isInvulnerableTo(p_9182_) || this.isChangingDimension() || this.getAbilities().invulnerable && p_9182_ == DamageSource.WITHER; ++ return super.isInvulnerableTo( p_9182_ ) || this.isChangingDimension() || this.getAbilities().invulnerable && p_9182_ == DamageSource.WITHER; } - protected void m_7840_(double p_8976_, boolean p_8977_, BlockState p_8978_, BlockPos p_8979_) { + protected void checkFallDamage(double p_8976_, boolean p_8977_, BlockState p_8978_, BlockPos p_8979_) { @@ -913,7 +_,7 @@ - protected void m_5806_(BlockPos p_9206_) { - if (!this.m_5833_()) { -- super.m_5806_(p_9206_); -+ super.m_5806_( p_9206_ ); + protected void onChangedBlock(BlockPos p_9206_) { + if (!this.isSpectator()) { +- super.onChangedBlock(p_9206_); ++ super.onChangedBlock( p_9206_ ); } } @@ -921,83 +_,140 @@ - public void m_8972_(double p_8973_, boolean p_8974_) { - if (!this.m_146899_()) { - BlockPos blockpos = this.m_20097_(); -- super.m_7840_(p_8973_, p_8974_, this.f_19853_.m_8055_(blockpos), blockpos); -+ super.m_7840_( p_8973_, p_8974_, this.f_19853_.m_8055_( blockpos ), blockpos ); + public void doCheckFallDamage(double p_8973_, boolean p_8974_) { + if (!this.touchingUnloadedChunk()) { + BlockPos blockpos = this.getOnPos(); +- super.checkFallDamage(p_8973_, p_8974_, this.level.getBlockState(blockpos), blockpos); ++ super.checkFallDamage( p_8973_, p_8974_, this.level.getBlockState( blockpos ), blockpos ); } } - public void m_7739_(SignBlockEntity p_9101_) { -- p_9101_.m_155713_(this.m_142081_()); -- this.f_8906_.m_141995_(new ClientboundBlockUpdatePacket(this.f_19853_, p_9101_.m_58899_())); -- this.f_8906_.m_141995_(new ClientboundOpenSignEditorPacket(p_9101_.m_58899_())); -+ p_9101_.m_155713_( this.m_142081_() ); -+ this.f_8906_.m_141995_( new ClientboundBlockUpdatePacket( this.f_19853_, p_9101_.m_58899_() ) ); -+ this.f_8906_.m_141995_( new ClientboundOpenSignEditorPacket( p_9101_.m_58899_() ) ); + public void openTextEdit(SignBlockEntity p_9101_) { +- p_9101_.setAllowedPlayerEditor(this.getUUID()); +- this.connection.send(new ClientboundBlockUpdatePacket(this.level, p_9101_.getBlockPos())); +- this.connection.send(new ClientboundOpenSignEditorPacket(p_9101_.getBlockPos())); ++ p_9101_.setAllowedPlayerEditor( this.getUUID() ); ++ this.connection.send( new ClientboundBlockUpdatePacket( this.level, p_9101_.getBlockPos() ) ); ++ this.connection.send( new ClientboundOpenSignEditorPacket( p_9101_.getBlockPos() ) ); } - public void m_9217_() { - this.f_8940_ = this.f_8940_ % 100 + 1; + public void nextContainerCounter() { + this.containerCounter = this.containerCounter % 100 + 1; } + // CraftBukkit start + public int nextContainerCounterInt() { -+ this.f_8940_ = this.f_8940_ % 100 + 1; -+ return f_8940_; // CraftBukkit ++ this.containerCounter = this.containerCounter % 100 + 1; ++ return containerCounter; // CraftBukkit + } + // CraftBukkit end + - public OptionalInt m_5893_(@Nullable MenuProvider p_9033_) { + public OptionalInt openMenu(@Nullable MenuProvider p_9033_) { if (p_9033_ == null) { return OptionalInt.empty(); } else { -- if (this.f_36096_ != this.f_36095_) { -- this.m_6915_(); + // CraftBukkit start - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEvent(...) + /* -+ if (this.containerMenu != this.inventoryMenu) { -+ this.closeContainer(); + if (this.containerMenu != this.inventoryMenu) { + this.closeContainer(); } + */ + // CraftBukkit end - this.m_9217_(); -- AbstractContainerMenu abstractcontainermenu = p_9033_.m_7208_(this.f_8940_, this.m_150109_(), this); -+ AbstractContainerMenu abstractcontainermenu = p_9033_.m_7208_( this.f_8940_, this.m_150109_(), this ); + this.nextContainerCounter(); +- AbstractContainerMenu abstractcontainermenu = p_9033_.createMenu(this.containerCounter, this.getInventory(), this); ++ AbstractContainerMenu abstractcontainermenu = p_9033_.createMenu( this.containerCounter, this.getInventory(), this ); + + // CraftBukkit start - Inventory open hook + if (abstractcontainermenu != null) { -+ abstractcontainermenu.setTitle( p_9033_.m_5446_() ); ++ abstractcontainermenu.setTitle( p_9033_.getDisplayName() ); + boolean cancelled = false; + // magma start - capture container owner + org.magmafoundation.magma.helpers.InventoryViewHelper.captureContainerOwner(this); @@ -1374,10 +1371,10 @@ + if (abstractcontainermenu == null && !cancelled) { // Let pre-cancelled events fall through + // SPIGOT-5263 - close chest if cancelled + if (p_9033_ instanceof Container) { -+ ((Container) p_9033_).m_5785_( this ); ++ ((Container) p_9033_).stopOpen( this ); + } else if (p_9033_ instanceof net.minecraft.world.level.block.ChestBlock.DoubleInventory) { + // SPIGOT-5355 - double chests too :( -+ ((net.minecraft.world.level.block.ChestBlock.DoubleInventory) p_9033_).inventorylargechest.m_5785_( this ); ++ ((net.minecraft.world.level.block.ChestBlock.DoubleInventory) p_9033_).inventorylargechest.stopOpen( this ); + } + return OptionalInt.empty(); + } @@ -1385,91 +1382,91 @@ + // CraftBukkit end + if (abstractcontainermenu == null) { - if (this.m_5833_()) { -- this.m_5661_((new TranslatableComponent("container.spectatorCantOpen")).m_130940_(ChatFormatting.RED), true); -+ this.m_5661_( (new TranslatableComponent( "container.spectatorCantOpen" )).m_130940_( ChatFormatting.RED ), true ); + if (this.isSpectator()) { +- this.displayClientMessage((new TranslatableComponent("container.spectatorCantOpen")).withStyle(ChatFormatting.RED), true); ++ this.displayClientMessage( (new TranslatableComponent( "container.spectatorCantOpen" )).withStyle( ChatFormatting.RED ), true ); } return OptionalInt.empty(); } else { -- this.f_8906_.m_141995_(new ClientboundOpenScreenPacket(abstractcontainermenu.f_38840_, abstractcontainermenu.m_6772_(), p_9033_.m_5446_())); -- this.m_143399_(abstractcontainermenu); +- this.connection.send(new ClientboundOpenScreenPacket(abstractcontainermenu.containerId, abstractcontainermenu.getType(), p_9033_.getDisplayName())); +- this.initMenu(abstractcontainermenu); + // CraftBukkit start - this.f_36096_ = abstractcontainermenu; -- return OptionalInt.of(this.f_8940_); -+ this.f_8906_.m_141995_( new ClientboundOpenScreenPacket( abstractcontainermenu.f_38840_, abstractcontainermenu.m_6772_(), abstractcontainermenu.getTitle() ) ); + this.containerMenu = abstractcontainermenu; +- return OptionalInt.of(this.containerCounter); ++ this.connection.send( new ClientboundOpenScreenPacket( abstractcontainermenu.containerId, abstractcontainermenu.getType(), abstractcontainermenu.getTitle() ) ); + // CraftBukkit end -+ this.m_143399_( abstractcontainermenu ); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open( this, this.f_36096_ ) ); -+ return OptionalInt.of( this.f_8940_ ); ++ this.initMenu( abstractcontainermenu ); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open( this, this.containerMenu ) ); ++ return OptionalInt.of( this.containerCounter ); } } } - public void m_7662_(int p_8988_, MerchantOffers p_8989_, int p_8990_, int p_8991_, boolean p_8992_, boolean p_8993_) { -- this.f_8906_.m_141995_(new ClientboundMerchantOffersPacket(p_8988_, p_8989_, p_8990_, p_8991_, p_8992_, p_8993_)); -+ this.f_8906_.m_141995_( new ClientboundMerchantOffersPacket( p_8988_, p_8989_, p_8990_, p_8991_, p_8992_, p_8993_ ) ); + public void sendMerchantOffers(int p_8988_, MerchantOffers p_8989_, int p_8990_, int p_8991_, boolean p_8992_, boolean p_8993_) { +- this.connection.send(new ClientboundMerchantOffersPacket(p_8988_, p_8989_, p_8990_, p_8991_, p_8992_, p_8993_)); ++ this.connection.send( new ClientboundMerchantOffersPacket( p_8988_, p_8989_, p_8990_, p_8991_, p_8992_, p_8993_ ) ); } - public void m_6658_(AbstractHorse p_9059_, Container p_9060_) { -- if (this.f_36096_ != this.f_36095_) { -- this.m_6915_(); + public void openHorseInventory(AbstractHorse p_9059_, Container p_9060_) { +- if (this.containerMenu != this.inventoryMenu) { +- this.closeContainer(); - } - + // CraftBukkit start - Inventory open hook - this.m_9217_(); -- this.f_8906_.m_141995_(new ClientboundHorseScreenOpenPacket(this.f_8940_, p_9060_.m_6643_(), p_9059_.m_142049_())); -- this.f_36096_ = new HorseInventoryMenu(this.f_8940_, this.m_150109_(), p_9060_, p_9059_); -- this.m_143399_(this.f_36096_); -+ AbstractContainerMenu container = new HorseInventoryMenu( this.f_8940_, this.m_150109_(), p_9060_, p_9059_ ); -+ container.setTitle( p_9059_.m_5446_() ); + this.nextContainerCounter(); +- this.connection.send(new ClientboundHorseScreenOpenPacket(this.containerCounter, p_9060_.getContainerSize(), p_9059_.getId())); +- this.containerMenu = new HorseInventoryMenu(this.containerCounter, this.getInventory(), p_9060_, p_9059_); +- this.initMenu(this.containerMenu); ++ AbstractContainerMenu container = new HorseInventoryMenu( this.containerCounter, this.getInventory(), p_9060_, p_9059_ ); ++ container.setTitle( p_9059_.getDisplayName() ); + container = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callInventoryOpenEvent( this, container ); + if (container == null) { -+ p_9060_.m_5785_( this ); ++ p_9060_.stopOpen( this ); + return; + } + // CraftBukkit end -+ if (this.f_36096_ != this.f_36095_) { -+ this.m_6915_(); ++ if (this.containerMenu != this.inventoryMenu) { ++ this.closeContainer(); + } + + // this.nextContainerCounter(); // CraftBukkit - moved up -+ this.f_8906_.m_141995_( new ClientboundHorseScreenOpenPacket( this.f_8940_, p_9060_.m_6643_(), p_9059_.m_142049_() ) ); -+ this.f_36096_ = container; // CraftBukkit -+ this.m_143399_( this.f_36096_ ); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open( this, this.f_36096_ ) ); - } - - public void m_6986_(ItemStack p_9082_, InteractionHand p_9083_) { -- if (p_9082_.m_150930_(Items.f_42615_)) { -- if (WrittenBookItem.m_43461_(p_9082_, this.m_20203_(), this)) { -+ if (p_9082_.m_150930_( Items.f_42615_ )) { -+ if (WrittenBookItem.m_43461_( p_9082_, this.m_20203_(), this )) { - this.f_36096_.m_38946_(); ++ this.connection.send( new ClientboundHorseScreenOpenPacket( this.containerCounter, p_9060_.getContainerSize(), p_9059_.getId() ) ); ++ this.containerMenu = container; // CraftBukkit ++ this.initMenu( this.containerMenu ); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open( this, this.containerMenu ) ); + } + + public void openItemGui(ItemStack p_9082_, InteractionHand p_9083_) { +- if (p_9082_.is(Items.WRITTEN_BOOK)) { +- if (WrittenBookItem.resolveBookComponents(p_9082_, this.createCommandSourceStack(), this)) { ++ if (p_9082_.is( Items.WRITTEN_BOOK )) { ++ if (WrittenBookItem.resolveBookComponents( p_9082_, this.createCommandSourceStack(), this )) { + this.containerMenu.broadcastChanges(); } -- this.f_8906_.m_141995_(new ClientboundOpenBookPacket(p_9083_)); -+ this.f_8906_.m_141995_( new ClientboundOpenBookPacket( p_9083_ ) ); +- this.connection.send(new ClientboundOpenBookPacket(p_9083_)); ++ this.connection.send( new ClientboundOpenBookPacket( p_9083_ ) ); } } - public void m_7698_(CommandBlockEntity p_9099_) { -- this.f_8906_.m_141995_(ClientboundBlockEntityDataPacket.m_195642_(p_9099_, BlockEntity::m_187482_)); -+ this.f_8906_.m_141995_( ClientboundBlockEntityDataPacket.m_195642_( p_9099_, BlockEntity::m_187482_ ) ); + public void openCommandBlock(CommandBlockEntity p_9099_) { +- this.connection.send(ClientboundBlockEntityDataPacket.create(p_9099_, BlockEntity::saveWithoutMetadata)); ++ this.connection.send( ClientboundBlockEntityDataPacket.create( p_9099_, BlockEntity::saveWithoutMetadata ) ); } - public void m_6915_() { -- this.f_8906_.m_141995_(new ClientboundContainerClosePacket(this.f_36096_.f_38840_)); -+ this.f_8906_.m_141995_( new ClientboundContainerClosePacket( this.f_36096_.f_38840_ ) ); - this.m_9230_(); + public void closeContainer() { +- this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); ++ this.connection.send( new ClientboundContainerClosePacket( this.containerMenu.containerId ) ); + this.doCloseContainer(); } - public void m_9230_() { -- this.f_36096_.m_6877_(this); -- this.f_36095_.m_150414_(this.f_36096_); + public void doCloseContainer() { +- this.containerMenu.removed(this); +- this.inventoryMenu.transferState(this.containerMenu); + //Magma start - fix inventory closing -+ if (this.f_36096_ != this.f_36095_) { ++ if (this.containerMenu != this.inventoryMenu) { + Player old = org.magmafoundation.magma.helpers.InventoryViewHelper.getContainerOwner(); + org.magmafoundation.magma.helpers.InventoryViewHelper.captureContainerOwner(this); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleInventoryCloseEvent(this); @@ -1477,295 +1474,295 @@ + } + //Magma end + -+ this.f_36096_.m_6877_( this ); -+ this.f_36095_.m_150414_( this.f_36096_ ); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.entity.player.PlayerContainerEvent.Close( this, this.f_36096_ ) ); - this.f_36096_ = this.f_36095_; ++ this.containerMenu.removed( this ); ++ this.inventoryMenu.transferState( this.containerMenu ); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post( new net.minecraftforge.event.entity.player.PlayerContainerEvent.Close( this, this.containerMenu ) ); + this.containerMenu = this.inventoryMenu; } @@ -1012,43 +_,46 @@ } - this.f_20899_ = p_8983_; -- this.m_20260_(p_8984_); -+ this.m_20260_( p_8984_ ); + this.jumping = p_8983_; +- this.setShiftKeyDown(p_8984_); ++ this.setShiftKeyDown( p_8984_ ); } } - public void m_6278_(Stat p_9026_, int p_9027_) { -- this.f_8910_.m_13023_(this, p_9026_, p_9027_); -- this.m_36329_().m_83427_(p_9026_, this.m_6302_(), (p_8996_) -> { -- p_8996_.m_83393_(p_9027_); + public void awardStat(Stat p_9026_, int p_9027_) { +- this.stats.increment(this, p_9026_, p_9027_); +- this.getScoreboard().forAllObjectives(p_9026_, this.getScoreboardName(), (p_8996_) -> { +- p_8996_.add(p_9027_); - }); -+ this.f_8910_.m_13023_( this, p_9026_, p_9027_ ); ++ this.stats.increment( this, p_9026_, p_9027_ ); + // CraftBukkit - Get our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores( p_9026_, this.m_6302_(), (p_8996_) -> { -+ p_8996_.m_83393_( p_9027_ ); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores( p_9026_, this.getScoreboardName(), (p_8996_) -> { ++ p_8996_.add( p_9027_ ); + } ); } - public void m_7166_(Stat p_9024_) { -- this.f_8910_.m_6085_(this, p_9024_, 0); -- this.m_36329_().m_83427_(p_9024_, this.m_6302_(), Score::m_83401_); -+ this.f_8910_.m_6085_( this, p_9024_, 0 ); + public void resetStat(Stat p_9024_) { +- this.stats.setValue(this, p_9024_, 0); +- this.getScoreboard().forAllObjectives(p_9024_, this.getScoreboardName(), Score::reset); ++ this.stats.setValue( this, p_9024_, 0 ); + + // CraftBukkit - Get our scores instead -+ this.f_19853_.getCraftServer().getScoreboardManager().getScoreboardScores( p_9024_, this.m_6302_(), Score::m_83401_ ); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores( p_9024_, this.getScoreboardName(), Score::reset ); } - public int m_7281_(Collection> p_9129_) { -- return this.f_8929_.m_12791_(p_9129_, this); -+ return this.f_8929_.m_12791_( p_9129_, this ); + public int awardRecipes(Collection> p_9129_) { +- return this.recipeBook.addRecipes(p_9129_, this); ++ return this.recipeBook.addRecipes( p_9129_, this ); } - public void m_7902_(ResourceLocation[] p_9168_) { + public void awardRecipesByKey(ResourceLocation[] p_9168_) { List> list = Lists.newArrayList(); - for(ResourceLocation resourcelocation : p_9168_) { -- this.f_8924_.m_129894_().m_44043_(resourcelocation).ifPresent(list::add); +- this.server.getRecipeManager().byKey(resourcelocation).ifPresent(list::add); + for (ResourceLocation resourcelocation : p_9168_) { -+ this.f_8924_.m_129894_().m_44043_( resourcelocation ).ifPresent( list::add ); ++ this.server.getRecipeManager().byKey( resourcelocation ).ifPresent( list::add ); } -- this.m_7281_(list); -+ this.m_7281_( list ); +- this.awardRecipes(list); ++ this.awardRecipes( list ); } - public int m_7279_(Collection> p_9195_) { -- return this.f_8929_.m_12806_(p_9195_, this); -+ return this.f_8929_.m_12806_( p_9195_, this ); + public int resetRecipes(Collection> p_9195_) { +- return this.recipeBook.removeRecipes(p_9195_, this); ++ return this.recipeBook.removeRecipes( p_9195_, this ); } - public void m_6756_(int p_9208_) { -- super.m_6756_(p_9208_); -+ super.m_6756_( p_9208_ ); - this.f_8920_ = -1; + public void giveExperiencePoints(int p_9208_) { +- super.giveExperiencePoints(p_9208_); ++ super.giveExperiencePoints( p_9208_ ); + this.lastSentExp = -1; } @@ -1056,7 +_,7 @@ - this.f_8932_ = true; - this.m_20153_(); - if (this.m_5803_()) { -- this.m_6145_(true, false); -+ this.m_6145_( true, false ); + this.disconnected = true; + this.ejectPassengers(); + if (this.isSleeping()) { +- this.stopSleepInBed(true, false); ++ this.stopSleepInBed( true, false ); } } @@ -1067,129 +_,154 @@ - public void m_9233_() { - this.f_8917_ = -1.0E8F; + public void resetSentInfo() { + this.lastSentHealth = -1.0E8F; - } -+ this.f_8920_ = -1; // CraftBukkit - Added to reset ++ this.lastSentExp = -1; // CraftBukkit - Added to reset + } + + // CraftBukkit start - Support multi-line messages + public void sendMessage(UUID uuid, Component[] components) { + for (Component component : components) { -+ this.m_6352_( component, (uuid == null) ? Util.f_137441_ : uuid ); ++ this.sendMessage( component, (uuid == null) ? Util.NIL_UUID : uuid ); + } + } + // CraftBukkit end + - public void m_5661_(Component p_9154_, boolean p_9155_) { -- this.m_9146_(p_9154_, p_9155_ ? ChatType.GAME_INFO : ChatType.CHAT, Util.f_137441_); -+ this.m_9146_( p_9154_, p_9155_ ? ChatType.GAME_INFO : ChatType.CHAT, Util.f_137441_ ); + public void displayClientMessage(Component p_9154_, boolean p_9155_) { +- this.sendMessage(p_9154_, p_9155_ ? ChatType.GAME_INFO : ChatType.CHAT, Util.NIL_UUID); ++ this.sendMessage( p_9154_, p_9155_ ? ChatType.GAME_INFO : ChatType.CHAT, Util.NIL_UUID ); } - protected void m_8095_() { - if (!this.f_20935_.m_41619_() && this.m_6117_()) { -- this.f_8906_.m_141995_(new ClientboundEntityEventPacket(this, (byte)9)); -+ this.f_8906_.m_141995_( new ClientboundEntityEventPacket( this, (byte) 9 ) ); - super.m_8095_(); + protected void completeUsingItem() { + if (!this.useItem.isEmpty() && this.isUsingItem()) { +- this.connection.send(new ClientboundEntityEventPacket(this, (byte)9)); ++ this.connection.send( new ClientboundEntityEventPacket( this, (byte) 9 ) ); + super.completeUsingItem(); } } - public void m_7618_(EntityAnchorArgument.Anchor p_9112_, Vec3 p_9113_) { -- super.m_7618_(p_9112_, p_9113_); -- this.f_8906_.m_141995_(new ClientboundPlayerLookAtPacket(p_9112_, p_9113_.f_82479_, p_9113_.f_82480_, p_9113_.f_82481_)); -+ super.m_7618_( p_9112_, p_9113_ ); -+ this.f_8906_.m_141995_( new ClientboundPlayerLookAtPacket( p_9112_, p_9113_.f_82479_, p_9113_.f_82480_, p_9113_.f_82481_ ) ); + public void lookAt(EntityAnchorArgument.Anchor p_9112_, Vec3 p_9113_) { +- super.lookAt(p_9112_, p_9113_); +- this.connection.send(new ClientboundPlayerLookAtPacket(p_9112_, p_9113_.x, p_9113_.y, p_9113_.z)); ++ super.lookAt( p_9112_, p_9113_ ); ++ this.connection.send( new ClientboundPlayerLookAtPacket( p_9112_, p_9113_.x, p_9113_.y, p_9113_.z ) ); } - public void m_9107_(EntityAnchorArgument.Anchor p_9108_, Entity p_9109_, EntityAnchorArgument.Anchor p_9110_) { -- Vec3 vec3 = p_9110_.m_90377_(p_9109_); -- super.m_7618_(p_9108_, vec3); -- this.f_8906_.m_141995_(new ClientboundPlayerLookAtPacket(p_9108_, p_9109_, p_9110_)); -+ Vec3 vec3 = p_9110_.m_90377_( p_9109_ ); -+ super.m_7618_( p_9108_, vec3 ); -+ this.f_8906_.m_141995_( new ClientboundPlayerLookAtPacket( p_9108_, p_9109_, p_9110_ ) ); + public void lookAt(EntityAnchorArgument.Anchor p_9108_, Entity p_9109_, EntityAnchorArgument.Anchor p_9110_) { +- Vec3 vec3 = p_9110_.apply(p_9109_); +- super.lookAt(p_9108_, vec3); +- this.connection.send(new ClientboundPlayerLookAtPacket(p_9108_, p_9109_, p_9110_)); ++ Vec3 vec3 = p_9110_.apply( p_9109_ ); ++ super.lookAt( p_9108_, vec3 ); ++ this.connection.send( new ClientboundPlayerLookAtPacket( p_9108_, p_9109_, p_9110_ ) ); } - public void m_9015_(ServerPlayer p_9016_, boolean p_9017_) { - this.f_143378_ = p_9016_.f_143378_; -- this.f_8941_.m_9273_(p_9016_.f_8941_.m_9290_(), p_9016_.f_8941_.m_9293_()); -+ this.f_8941_.m_9273_( p_9016_.f_8941_.m_9290_(), p_9016_.f_8941_.m_9293_() ); + public void restoreFrom(ServerPlayer p_9016_, boolean p_9017_) { + this.textFilteringEnabled = p_9016_.textFilteringEnabled; +- this.gameMode.setGameModeForPlayer(p_9016_.gameMode.getGameModeForPlayer(), p_9016_.gameMode.getPreviousGameModeForPlayer()); ++ this.gameMode.setGameModeForPlayer( p_9016_.gameMode.getGameModeForPlayer(), p_9016_.gameMode.getPreviousGameModeForPlayer() ); if (p_9017_) { -- this.m_150109_().m_36006_(p_9016_.m_150109_()); -- this.m_21153_(p_9016_.m_21223_()); -+ this.m_150109_().m_36006_( p_9016_.m_150109_() ); -+ this.m_21153_( p_9016_.m_21223_() ); - this.f_36097_ = p_9016_.f_36097_; - this.f_36078_ = p_9016_.f_36078_; - this.f_36079_ = p_9016_.f_36079_; - this.f_36080_ = p_9016_.f_36080_; -- this.m_36397_(p_9016_.m_36344_()); -+ this.m_36397_( p_9016_.m_36344_() ); - this.f_19819_ = p_9016_.f_19819_; -- } else if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46133_) || p_9016_.m_5833_()) { -- this.m_150109_().m_36006_(p_9016_.m_150109_()); -+ } else if (this.f_19853_.m_46469_().m_46207_( GameRules.f_46133_ ) || p_9016_.m_5833_()) { -+ this.m_150109_().m_36006_( p_9016_.m_150109_() ); - this.f_36078_ = p_9016_.f_36078_; - this.f_36079_ = p_9016_.f_36079_; - this.f_36080_ = p_9016_.f_36080_; -- this.m_36397_(p_9016_.m_36344_()); -+ this.m_36397_( p_9016_.m_36344_() ); +- this.getInventory().replaceWith(p_9016_.getInventory()); +- this.setHealth(p_9016_.getHealth()); ++ this.getInventory().replaceWith( p_9016_.getInventory() ); ++ this.setHealth( p_9016_.getHealth() ); + this.foodData = p_9016_.foodData; + this.experienceLevel = p_9016_.experienceLevel; + this.totalExperience = p_9016_.totalExperience; + this.experienceProgress = p_9016_.experienceProgress; +- this.setScore(p_9016_.getScore()); ++ this.setScore( p_9016_.getScore() ); + this.portalEntrancePos = p_9016_.portalEntrancePos; +- } else if (this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || p_9016_.isSpectator()) { +- this.getInventory().replaceWith(p_9016_.getInventory()); ++ } else if (this.level.getGameRules().getBoolean( GameRules.RULE_KEEPINVENTORY ) || p_9016_.isSpectator()) { ++ this.getInventory().replaceWith( p_9016_.getInventory() ); + this.experienceLevel = p_9016_.experienceLevel; + this.totalExperience = p_9016_.totalExperience; + this.experienceProgress = p_9016_.experienceProgress; +- this.setScore(p_9016_.getScore()); ++ this.setScore( p_9016_.getScore() ); } + + Inventory forgeCaptures = p_9016_.getForgeCapturesAndClear(); + if (forgeCaptures != null) -+ forgeCaptures.f_35974_.stream().filter(item -> !item.m_41619_()).forEach(item -> this.m_150109_().m_36054_(item)); -+ -+ this.m_150109_().m_6596_(); - - this.f_36081_ = p_9016_.f_36081_; - this.f_36094_ = p_9016_.f_36094_; -- this.m_20088_().m_135381_(f_36089_, p_9016_.m_20088_().m_135370_(f_36089_)); -+ this.m_20088_().m_135381_( f_36089_, p_9016_.m_20088_().m_135370_( f_36089_ ) ); - this.f_8920_ = -1; - this.f_8917_ = -1.0F; - this.f_8918_ = -1; -- this.f_8929_.m_12685_(p_9016_.f_8929_); ++ forgeCaptures.items.stream().filter(item -> !item.isEmpty()).forEach(item -> this.getInventory().add(item)); ++ ++ this.getInventory().setChanged(); + + this.enchantmentSeed = p_9016_.enchantmentSeed; + this.enderChestInventory = p_9016_.enderChestInventory; +- this.getEntityData().set(DATA_PLAYER_MODE_CUSTOMISATION, p_9016_.getEntityData().get(DATA_PLAYER_MODE_CUSTOMISATION)); ++ this.getEntityData().set( DATA_PLAYER_MODE_CUSTOMISATION, p_9016_.getEntityData().get( DATA_PLAYER_MODE_CUSTOMISATION ) ); + this.lastSentExp = -1; + this.lastSentHealth = -1.0F; + this.lastSentFood = -1; +- this.recipeBook.copyOverData(p_9016_.recipeBook); + //this.recipeBook.copyOverData( p_9016_.recipeBook ); // CraftBukkit - this.f_8928_ = p_9016_.f_8928_; - this.f_8933_ = p_9016_.f_8933_; -- this.m_36362_(p_9016_.m_36331_()); -- this.m_36364_(p_9016_.m_36332_()); -+ this.m_36362_( p_9016_.m_36331_() ); -+ this.m_36364_( p_9016_.m_36332_() ); + this.seenCredits = p_9016_.seenCredits; + this.enteredNetherPosition = p_9016_.enteredNetherPosition; +- this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); +- this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); ++ this.setShoulderEntityLeft( p_9016_.getShoulderEntityLeft() ); ++ this.setShoulderEntityRight( p_9016_.getShoulderEntityRight() ); + + //Copy over a section of the Entity Data from the old player. + //Allows mods to specify data that persists after players respawn. + CompoundTag old = p_9016_.getPersistentData(); -+ if (old.m_128441_( PERSISTED_NBT_TAG )) -+ getPersistentData().m_128365_( PERSISTED_NBT_TAG, old.m_128423_( PERSISTED_NBT_TAG ) ); ++ if (old.contains( PERSISTED_NBT_TAG )) ++ getPersistentData().put( PERSISTED_NBT_TAG, old.get( PERSISTED_NBT_TAG ) ); + net.minecraftforge.event.ForgeEventFactory.onPlayerClone( this, p_9016_, !p_9017_ ); } - protected void m_142540_(MobEffectInstance p_143393_, @Nullable Entity p_143394_) { -- super.m_142540_(p_143393_, p_143394_); -- this.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(this.m_142049_(), p_143393_)); -+ super.m_142540_( p_143393_, p_143394_ ); -+ this.f_8906_.m_141995_( new ClientboundUpdateMobEffectPacket( this.m_142049_(), p_143393_ ) ); - if (p_143393_.m_19544_() == MobEffects.f_19620_) { - this.f_8931_ = this.f_19797_; - this.f_8930_ = this.m_20182_(); + protected void onEffectAdded(MobEffectInstance p_143393_, @Nullable Entity p_143394_) { +- super.onEffectAdded(p_143393_, p_143394_); +- this.connection.send(new ClientboundUpdateMobEffectPacket(this.getId(), p_143393_)); ++ super.onEffectAdded( p_143393_, p_143394_ ); ++ this.connection.send( new ClientboundUpdateMobEffectPacket( this.getId(), p_143393_ ) ); + if (p_143393_.getEffect() == MobEffects.LEVITATION) { + this.levitationStartTime = this.tickCount; + this.levitationStartPos = this.position(); } -- CriteriaTriggers.f_10550_.m_149262_(this, p_143394_); -+ CriteriaTriggers.f_10550_.m_149262_( this, p_143394_ ); +- CriteriaTriggers.EFFECTS_CHANGED.trigger(this, p_143394_); ++ CriteriaTriggers.EFFECTS_CHANGED.trigger( this, p_143394_ ); } - protected void m_141973_(MobEffectInstance p_143396_, boolean p_143397_, @Nullable Entity p_143398_) { -- super.m_141973_(p_143396_, p_143397_, p_143398_); -- this.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(this.m_142049_(), p_143396_)); -- CriteriaTriggers.f_10550_.m_149262_(this, p_143398_); -+ super.m_141973_( p_143396_, p_143397_, p_143398_ ); -+ this.f_8906_.m_141995_( new ClientboundUpdateMobEffectPacket( this.m_142049_(), p_143396_ ) ); -+ CriteriaTriggers.f_10550_.m_149262_( this, p_143398_ ); + protected void onEffectUpdated(MobEffectInstance p_143396_, boolean p_143397_, @Nullable Entity p_143398_) { +- super.onEffectUpdated(p_143396_, p_143397_, p_143398_); +- this.connection.send(new ClientboundUpdateMobEffectPacket(this.getId(), p_143396_)); +- CriteriaTriggers.EFFECTS_CHANGED.trigger(this, p_143398_); ++ super.onEffectUpdated( p_143396_, p_143397_, p_143398_ ); ++ this.connection.send( new ClientboundUpdateMobEffectPacket( this.getId(), p_143396_ ) ); ++ CriteriaTriggers.EFFECTS_CHANGED.trigger( this, p_143398_ ); } - protected void m_7285_(MobEffectInstance p_9184_) { -- super.m_7285_(p_9184_); -- this.f_8906_.m_141995_(new ClientboundRemoveMobEffectPacket(this.m_142049_(), p_9184_.m_19544_())); -+ super.m_7285_( p_9184_ ); -+ this.f_8906_.m_141995_( new ClientboundRemoveMobEffectPacket( this.m_142049_(), p_9184_.m_19544_() ) ); - if (p_9184_.m_19544_() == MobEffects.f_19620_) { - this.f_8930_ = null; + protected void onEffectRemoved(MobEffectInstance p_9184_) { +- super.onEffectRemoved(p_9184_); +- this.connection.send(new ClientboundRemoveMobEffectPacket(this.getId(), p_9184_.getEffect())); ++ super.onEffectRemoved( p_9184_ ); ++ this.connection.send( new ClientboundRemoveMobEffectPacket( this.getId(), p_9184_.getEffect() ) ); + if (p_9184_.getEffect() == MobEffects.LEVITATION) { + this.levitationStartPos = null; } -- CriteriaTriggers.f_10550_.m_149262_(this, (Entity)null); -+ CriteriaTriggers.f_10550_.m_149262_( this, (Entity) null ); +- CriteriaTriggers.EFFECTS_CHANGED.trigger(this, (Entity)null); ++ CriteriaTriggers.EFFECTS_CHANGED.trigger( this, (Entity) null ); } - public void m_6021_(double p_8969_, double p_8970_, double p_8971_) { -- this.f_8906_.m_9774_(p_8969_, p_8970_, p_8971_, this.m_146908_(), this.m_146909_()); -+ this.f_8906_.m_9774_( p_8969_, p_8970_, p_8971_, this.m_146908_(), this.m_146909_() ); + public void teleportTo(double p_8969_, double p_8970_, double p_8971_) { +- this.connection.teleport(p_8969_, p_8970_, p_8971_, this.getYRot(), this.getXRot()); ++ this.connection.teleport( p_8969_, p_8970_, p_8971_, this.getYRot(), this.getXRot() ); } - public void m_6027_(double p_9171_, double p_9172_, double p_9173_) { -- this.m_6021_(p_9171_, p_9172_, p_9173_); -+ this.m_6021_( p_9171_, p_9172_, p_9173_ ); - this.f_8906_.m_9953_(); + public void moveTo(double p_9171_, double p_9172_, double p_9173_) { +- this.teleportTo(p_9171_, p_9172_, p_9173_); ++ this.teleportTo( p_9171_, p_9172_, p_9173_ ); + this.connection.resetPosition(); } - public void m_5704_(Entity p_9045_) { -- this.m_183503_().m_7726_().m_8394_(this, new ClientboundAnimatePacket(p_9045_, 4)); -+ this.m_183503_().m_7726_().m_8394_( this, new ClientboundAnimatePacket( p_9045_, 4 ) ); + public void crit(Entity p_9045_) { +- this.getLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(p_9045_, 4)); ++ this.getLevel().getChunkSource().broadcastAndSend( this, new ClientboundAnimatePacket( p_9045_, 4 ) ); } - public void m_5700_(Entity p_9186_) { -- this.m_183503_().m_7726_().m_8394_(this, new ClientboundAnimatePacket(p_9186_, 5)); -+ this.m_183503_().m_7726_().m_8394_( this, new ClientboundAnimatePacket( p_9186_, 5 ) ); + public void magicCrit(Entity p_9186_) { +- this.getLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(p_9186_, 5)); ++ this.getLevel().getChunkSource().broadcastAndSend( this, new ClientboundAnimatePacket( p_9186_, 5 ) ); } - public void m_6885_() { - if (this.f_8906_ != null) { -- this.f_8906_.m_141995_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); -+ this.f_8906_.m_141995_( new ClientboundPlayerAbilitiesPacket( this.m_150110_() ) ); - this.m_8034_(); + public void onUpdateAbilities() { + if (this.connection != null) { +- this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); ++ this.connection.send( new ClientboundPlayerAbilitiesPacket( this.getAbilities() ) ); + this.updateInvisibilityStatus(); } } - public ServerLevel m_183503_() { -- return (ServerLevel)this.f_19853_; -+ return (ServerLevel) this.f_19853_; + public ServerLevel getLevel() { +- return (ServerLevel)this.level; ++ return (ServerLevel) this.level; } - public boolean m_143403_(GameType p_143404_) { -- if (!this.f_8941_.m_143473_(p_143404_)) { -+ p_143404_ = net.minecraftforge.common.ForgeHooks.onChangeGameType( this, this.f_8941_.m_9290_(), p_143404_ ); + public boolean setGameMode(GameType p_143404_) { +- if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { ++ p_143404_ = net.minecraftforge.common.ForgeHooks.onChangeGameType( this, this.gameMode.getGameModeForPlayer(), p_143404_ ); + if (p_143404_ == null) return false; -+ if (!this.f_8941_.m_143473_( p_143404_ )) { ++ if (!this.gameMode.changeGameModeForPlayer( p_143404_ )) { return false; } else { -- this.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132156_, (float)p_143404_.m_46392_())); -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132156_, (float) p_143404_.m_46392_() ) ); +- this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float)p_143404_.getId())); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) p_143404_.getId() ) ); if (p_143404_ == GameType.SPECTATOR) { - this.m_36328_(); - this.m_8127_(); + this.removeEntitiesOnShoulder(); + this.stopRiding(); } else { -- this.m_9213_(this); -+ this.m_9213_( this ); +- this.setCamera(this); ++ this.setCamera( this ); } - this.m_6885_(); + this.onUpdateAbilities(); @@ -1207,36 +_,49 @@ } - public void m_6352_(Component p_9144_, UUID p_9145_) { -- this.m_9146_(p_9144_, ChatType.SYSTEM, p_9145_); -+ this.m_9146_( p_9144_, ChatType.SYSTEM, p_9145_ ); + public void sendMessage(Component p_9144_, UUID p_9145_) { +- this.sendMessage(p_9144_, ChatType.SYSTEM, p_9145_); ++ this.sendMessage( p_9144_, ChatType.SYSTEM, p_9145_ ); } - public void m_9146_(Component p_9147_, ChatType p_9148_, UUID p_9149_) { -- if (this.m_143416_(p_9148_)) { -- this.f_8906_.m_9831_(new ClientboundChatPacket(p_9147_, p_9148_, p_9149_), (p_9139_) -> { -- if (!p_9139_.isSuccess() && (p_9148_ == ChatType.GAME_INFO || p_9148_ == ChatType.SYSTEM) && this.m_143416_(ChatType.SYSTEM)) { -+ if (this.m_143416_( p_9148_ )) { -+ this.f_8906_.m_9831_( new ClientboundChatPacket( p_9147_, p_9148_, p_9149_ ), (p_9139_) -> { -+ if (!p_9139_.isSuccess() && (p_9148_ == ChatType.GAME_INFO || p_9148_ == ChatType.SYSTEM) && this.m_143416_( ChatType.SYSTEM )) { + public void sendMessage(Component p_9147_, ChatType p_9148_, UUID p_9149_) { +- if (this.acceptsChat(p_9148_)) { +- this.connection.send(new ClientboundChatPacket(p_9147_, p_9148_, p_9149_), (p_9139_) -> { +- if (!p_9139_.isSuccess() && (p_9148_ == ChatType.GAME_INFO || p_9148_ == ChatType.SYSTEM) && this.acceptsChat(ChatType.SYSTEM)) { ++ if (this.acceptsChat( p_9148_ )) { ++ this.connection.send( new ClientboundChatPacket( p_9147_, p_9148_, p_9149_ ), (p_9139_) -> { ++ if (!p_9139_.isSuccess() && (p_9148_ == ChatType.GAME_INFO || p_9148_ == ChatType.SYSTEM) && this.acceptsChat( ChatType.SYSTEM )) { int i = 256; -- String s = p_9147_.m_130668_(256); -- Component component = (new TextComponent(s)).m_130940_(ChatFormatting.YELLOW); -- this.f_8906_.m_141995_(new ClientboundChatPacket((new TranslatableComponent("multiplayer.message_not_delivered", component)).m_130940_(ChatFormatting.RED), ChatType.SYSTEM, p_9149_)); -+ String s = p_9147_.m_130668_( 256 ); -+ Component component = (new TextComponent( s )).m_130940_( ChatFormatting.YELLOW ); -+ this.f_8906_.m_141995_( new ClientboundChatPacket( (new TranslatableComponent( "multiplayer.message_not_delivered", component )).m_130940_( ChatFormatting.RED ), ChatType.SYSTEM, p_9149_ ) ); +- String s = p_9147_.getString(256); +- Component component = (new TextComponent(s)).withStyle(ChatFormatting.YELLOW); +- this.connection.send(new ClientboundChatPacket((new TranslatableComponent("multiplayer.message_not_delivered", component)).withStyle(ChatFormatting.RED), ChatType.SYSTEM, p_9149_)); ++ String s = p_9147_.getString( 256 ); ++ Component component = (new TextComponent( s )).withStyle( ChatFormatting.YELLOW ); ++ this.connection.send( new ClientboundChatPacket( (new TranslatableComponent( "multiplayer.message_not_delivered", component )).withStyle( ChatFormatting.RED ), ChatType.SYSTEM, p_9149_ ) ); } - }); @@ -1773,44 +1770,44 @@ } } - public String m_9239_() { - String s = this.f_8906_.f_9742_.m_129523_().toString(); + public String getIpAddress() { + String s = this.connection.connection.getRemoteAddress().toString(); - s = s.substring(s.indexOf("/") + 1); - return s.substring(0, s.indexOf(":")); + s = s.substring( s.indexOf( "/" ) + 1 ); + return s.substring( 0, s.indexOf( ":" ) ); } - public void m_9156_(ServerboundClientInformationPacket p_9157_) { + public void updateOptions(ServerboundClientInformationPacket p_9157_) { + // CraftBukkit start -+ if (m_5737_() != p_9157_.f_133868_()) { -+ org.bukkit.event.player.PlayerChangedMainHandEvent event = new org.bukkit.event.player.PlayerChangedMainHandEvent( getBukkitEntity(), m_5737_() == HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT ); -+ this.f_8924_.server.getPluginManager().callEvent( event ); ++ if (getMainArm() != p_9157_.mainHand()) { ++ org.bukkit.event.player.PlayerChangedMainHandEvent event = new org.bukkit.event.player.PlayerChangedMainHandEvent( getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT ); ++ this.server.server.getPluginManager().callEvent( event ); + } -+ if (!this.locale.equals( p_9157_.f_133863_() )) { -+ org.bukkit.event.player.PlayerLocaleChangeEvent event = new org.bukkit.event.player.PlayerLocaleChangeEvent( getBukkitEntity(), p_9157_.f_133863_() ); -+ this.f_8924_.server.getPluginManager().callEvent( event ); ++ if (!this.locale.equals( p_9157_.language() )) { ++ org.bukkit.event.player.PlayerLocaleChangeEvent event = new org.bukkit.event.player.PlayerLocaleChangeEvent( getBukkitEntity(), p_9157_.language() ); ++ this.server.server.getPluginManager().callEvent( event ); + } -+ this.locale = p_9157_.f_133863_(); -+ this.clientViewDistance = p_9157_.f_133864_(); ++ this.locale = p_9157_.language(); ++ this.clientViewDistance = p_9157_.viewDistance(); + // CraftBukkit end - this.f_8922_ = p_9157_.f_133865_(); - this.f_8923_ = p_9157_.f_133866_(); - this.f_143378_ = p_9157_.f_179550_(); - this.f_184127_ = p_9157_.f_195812_(); -- this.m_20088_().m_135381_(f_36089_, (byte)p_9157_.f_133867_()); -- this.m_20088_().m_135381_(f_36090_, (byte)(p_9157_.f_133868_() == HumanoidArm.LEFT ? 0 : 1)); -+ this.m_20088_().m_135381_( f_36089_, (byte) p_9157_.f_133867_() ); -+ this.m_20088_().m_135381_( f_36090_, (byte) (p_9157_.f_133868_() == HumanoidArm.LEFT ? 0 : 1) ); -+ this.language = p_9157_.f_133863_(); - } - - public boolean m_143432_() { + this.chatVisibility = p_9157_.chatVisibility(); + this.canChatColor = p_9157_.chatColors(); + this.textFilteringEnabled = p_9157_.textFilteringEnabled(); + this.allowsListing = p_9157_.allowsListing(); +- this.getEntityData().set(DATA_PLAYER_MODE_CUSTOMISATION, (byte)p_9157_.modelCustomisation()); +- this.getEntityData().set(DATA_PLAYER_MAIN_HAND, (byte)(p_9157_.mainHand() == HumanoidArm.LEFT ? 0 : 1)); ++ this.getEntityData().set( DATA_PLAYER_MODE_CUSTOMISATION, (byte) p_9157_.modelCustomisation() ); ++ this.getEntityData().set( DATA_PLAYER_MAIN_HAND, (byte) (p_9157_.mainHand() == HumanoidArm.LEFT ? 0 : 1) ); ++ this.language = p_9157_.language(); + } + + public boolean canChatInColor() { @@ -1248,23 +_,23 @@ } - private boolean m_143416_(ChatType p_143417_) { -- switch(this.f_8922_) { + private boolean acceptsChat(ChatType p_143417_) { +- switch(this.chatVisibility) { - case HIDDEN: - return p_143417_ == ChatType.GAME_INFO; - case SYSTEM: @@ -1818,7 +1815,7 @@ - case FULL: - default: - return true; -+ switch (this.f_8922_) { ++ switch (this.chatVisibility) { + case HIDDEN: + return p_143417_ == ChatType.GAME_INFO; + case SYSTEM: @@ -1829,64 +1826,64 @@ } } - public void m_143408_(String p_143409_, String p_143410_, boolean p_143411_, @Nullable Component p_143412_) { -- this.f_8906_.m_141995_(new ClientboundResourcePackPacket(p_143409_, p_143410_, p_143411_, p_143412_)); -+ this.f_8906_.m_141995_( new ClientboundResourcePackPacket( p_143409_, p_143410_, p_143411_, p_143412_ ) ); + public void sendTexturePack(String p_143409_, String p_143410_, boolean p_143411_, @Nullable Component p_143412_) { +- this.connection.send(new ClientboundResourcePackPacket(p_143409_, p_143410_, p_143411_, p_143412_)); ++ this.connection.send( new ClientboundResourcePackPacket( p_143409_, p_143410_, p_143411_, p_143412_ ) ); } - protected int m_8088_() { -- return this.f_8924_.m_129944_(this.m_36316_()); -+ return this.f_8924_.m_129944_( this.m_36316_() ); + protected int getPermissionLevel() { +- return this.server.getProfilePermissions(this.getGameProfile()); ++ return this.server.getProfilePermissions( this.getGameProfile() ); } - public void m_9243_() { + public void resetLastActionTime() { @@ -1282,7 +_,7 @@ - protected void m_8034_() { - if (this.m_5833_()) { - this.m_21218_(); -- this.m_6842_(true); -+ this.m_6842_( true ); + protected void updateInvisibilityStatus() { + if (this.isSpectator()) { + this.removeEffectParticles(); +- this.setInvisible(true); ++ this.setInvisible( true ); } else { - super.m_8034_(); + super.updateInvisibilityStatus(); } @@ -1290,15 +_,17 @@ } - public Entity m_8954_() { -- return (Entity)(this.f_8926_ == null ? this : this.f_8926_); -+ return (Entity) (this.f_8926_ == null ? this : this.f_8926_); + public Entity getCamera() { +- return (Entity)(this.camera == null ? this : this.camera); ++ return (Entity) (this.camera == null ? this : this.camera); } - public void m_9213_(@Nullable Entity p_9214_) { - Entity entity = this.m_8954_(); -- this.f_8926_ = (Entity)(p_9214_ == null ? this : p_9214_); -+ this.f_8926_ = (Entity) (p_9214_ == null ? this : p_9214_); -+ while (this.f_8926_ instanceof net.minecraftforge.entity.PartEntity partEntity) -+ this.f_8926_ = partEntity.getParent(); // FORGE: fix MC-46486 - if (entity != this.f_8926_) { -- this.f_8906_.m_141995_(new ClientboundSetCameraPacket(this.f_8926_)); -- this.m_6021_(this.f_8926_.m_20185_(), this.f_8926_.m_20186_(), this.f_8926_.m_20189_()); -+ this.f_8906_.m_141995_( new ClientboundSetCameraPacket( this.f_8926_ ) ); -+ this.f_8906_.teleport( this.f_8926_.m_20185_(), this.f_8926_.m_20186_(), this.f_8926_.m_20189_(), this.f_8926_.m_146908_(), this.f_8926_.m_146909_(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE ); // CraftBukkit + public void setCamera(@Nullable Entity p_9214_) { + Entity entity = this.getCamera(); +- this.camera = (Entity)(p_9214_ == null ? this : p_9214_); ++ this.camera = (Entity) (p_9214_ == null ? this : p_9214_); ++ while (this.camera instanceof net.minecraftforge.entity.PartEntity partEntity) ++ this.camera = partEntity.getParent(); // FORGE: fix MC-46486 + if (entity != this.camera) { +- this.connection.send(new ClientboundSetCameraPacket(this.camera)); +- this.teleportTo(this.camera.getX(), this.camera.getY(), this.camera.getZ()); ++ this.connection.send( new ClientboundSetCameraPacket( this.camera ) ); ++ this.connection.teleport( this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.camera.getYRot(), this.camera.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE ); // CraftBukkit } } @@ -1312,9 +_,9 @@ - public void m_5706_(Entity p_9220_) { - if (this.f_8941_.m_9290_() == GameType.SPECTATOR) { -- this.m_9213_(p_9220_); -+ this.m_9213_( p_9220_ ); + public void attack(Entity p_9220_) { + if (this.gameMode.getGameModeForPlayer() == GameType.SPECTATOR) { +- this.setCamera(p_9220_); ++ this.setCamera( p_9220_ ); } else { -- super.m_5706_(p_9220_); -+ super.m_5706_( p_9220_ ); +- super.attack(p_9220_); ++ super.attack( p_9220_ ); } } @@ -1325,11 +_,17 @@ @Nullable - public Component m_8957_() { + public Component getTabListDisplayName() { - return null; + if (!this.hasTabListName) { + this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName( this ); @@ -1897,25 +1894,25 @@ + return this.tabListDisplayName; } - public void m_6674_(InteractionHand p_9031_) { -- super.m_6674_(p_9031_); -+ super.m_6674_( p_9031_ ); - this.m_36334_(); + public void swing(InteractionHand p_9031_) { +- super.swing(p_9031_); ++ super.swing( p_9031_ ); + this.resetAttackStrengthTicker(); } @@ -1345,26 +_,42 @@ - return this.f_8909_; + return this.advancements; } + // CraftBukkit start - public void m_8999_(ServerLevel p_9000_, double p_9001_, double p_9002_, double p_9003_, float p_9004_, float p_9005_) { + public void teleportTo(ServerLevel p_9000_, double p_9001_, double p_9002_, double p_9003_, float p_9004_, float p_9005_) { + this.teleportTo(p_9000_, p_9001_, p_9002_, p_9003_, p_9004_, p_9005_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + + public void teleportTo(ServerLevel p_9000_, double p_9001_, double p_9002_, double p_9003_, float p_9004_, float p_9005_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end - this.m_9213_(this); - this.m_8127_(); + this.setCamera(this); + this.stopRiding(); + + //Magma start - use bukkit teleporting if not caused by a mod calling teleportTo + if (cause != org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN) { @@ -1924,92 +1921,92 @@ + } + //Magma end + - if (p_9000_ == this.f_19853_) { - this.f_8906_.m_9774_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); + if (p_9000_ == this.level) { + this.connection.teleport(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); - } else { -+ } else if (net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9000_.m_46472_())) { - ServerLevel serverlevel = this.m_183503_(); - LevelData leveldata = p_9000_.m_6106_(); - this.f_8906_.m_141995_(new ClientboundRespawnPacket(p_9000_.m_204156_(), p_9000_.m_46472_(), BiomeManager.m_47877_(p_9000_.m_7328_()), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9000_.m_46659_(), p_9000_.m_8584_(), true)); - this.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); - this.f_8924_.m_6846_().m_11289_(this); - serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); -- this.m_146912_(); ++ } else if (net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9000_.dimension())) { + ServerLevel serverlevel = this.getLevel(); + LevelData leveldata = p_9000_.getLevelData(); + this.connection.send(new ClientboundRespawnPacket(p_9000_.dimensionTypeRegistration(), p_9000_.dimension(), BiomeManager.obfuscateSeed(p_9000_.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), p_9000_.isDebug(), p_9000_.isFlat(), true)); + this.connection.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); + this.server.getPlayerList().sendPlayerPermissionLevel(this); + serverlevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); +- this.unsetRemoved(); + this.revive(); - this.m_7678_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); - this.m_143425_(p_9000_); - p_9000_.m_8622_(this); - this.m_9209_(serverlevel); - this.f_8906_.m_9774_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); -+ this.f_8941_.m_9260_(p_9000_); - this.f_8924_.m_6846_().m_11229_(this, p_9000_); - this.f_8924_.m_6846_().m_11292_(this); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(this, serverlevel.m_46472_(), p_9000_.m_46472_()); + this.moveTo(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); + this.setLevel(p_9000_); + p_9000_.addDuringCommandTeleport(this); + this.triggerDimensionChangeTriggers(serverlevel); + this.connection.teleport(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); ++ this.gameMode.setLevel(p_9000_); + this.server.getPlayerList().sendLevelInfo(this, p_9000_); + this.server.getPlayerList().sendAllPlayerInfo(this); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(this, serverlevel.dimension(), p_9000_.dimension()); } } @@ -1387,10 +_,12 @@ } - public void m_9158_(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet( this, p_9160_ == null ? Level.f_46428_ : p_9159_, p_9160_, p_9162_ )) + public void setRespawnPosition(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet( this, p_9160_ == null ? Level.OVERWORLD : p_9159_, p_9160_, p_9162_ )) + return; if (p_9160_ != null) { -- boolean flag = p_9160_.equals(this.f_8936_) && p_9159_.equals(this.f_8935_); -+ boolean flag = p_9160_.equals( this.f_8936_ ) && p_9159_.equals( this.f_8935_ ); +- boolean flag = p_9160_.equals(this.respawnPosition) && p_9159_.equals(this.respawnDimension); ++ boolean flag = p_9160_.equals( this.respawnPosition ) && p_9159_.equals( this.respawnDimension ); if (p_9163_ && !flag) { -- this.m_6352_(new TranslatableComponent("block.minecraft.set_spawn"), Util.f_137441_); -+ this.m_6352_( new TranslatableComponent( "block.minecraft.set_spawn" ), Util.f_137441_ ); +- this.sendMessage(new TranslatableComponent("block.minecraft.set_spawn"), Util.NIL_UUID); ++ this.sendMessage( new TranslatableComponent( "block.minecraft.set_spawn" ), Util.NIL_UUID ); } - this.f_8936_ = p_9160_; + this.respawnPosition = p_9160_; @@ -1407,12 +_,12 @@ } - public void m_184135_(ChunkPos p_184136_, Packet p_184137_) { -- this.f_8906_.m_141995_(p_184137_); -+ this.f_8906_.m_141995_( p_184137_ ); + public void trackChunk(ChunkPos p_184136_, Packet p_184137_) { +- this.connection.send(p_184137_); ++ this.connection.send( p_184137_ ); } - public void m_9088_(ChunkPos p_9089_) { - if (this.m_6084_()) { -- this.f_8906_.m_141995_(new ClientboundForgetLevelChunkPacket(p_9089_.f_45578_, p_9089_.f_45579_)); -+ this.f_8906_.m_141995_( new ClientboundForgetLevelChunkPacket( p_9089_.f_45578_, p_9089_.f_45579_ ) ); + public void untrackChunk(ChunkPos p_9089_) { + if (this.isAlive()) { +- this.connection.send(new ClientboundForgetLevelChunkPacket(p_9089_.x, p_9089_.z)); ++ this.connection.send( new ClientboundForgetLevelChunkPacket( p_9089_.x, p_9089_.z ) ); } } @@ -1426,44 +_,71 @@ } - public void m_6330_(SoundEvent p_9019_, SoundSource p_9020_, float p_9021_, float p_9022_) { -- this.f_8906_.m_141995_(new ClientboundSoundPacket(p_9019_, p_9020_, this.m_20185_(), this.m_20186_(), this.m_20189_(), p_9021_, p_9022_)); -+ this.f_8906_.m_141995_( new ClientboundSoundPacket( p_9019_, p_9020_, this.m_20185_(), this.m_20186_(), this.m_20189_(), p_9021_, p_9022_ ) ); + public void playNotifySound(SoundEvent p_9019_, SoundSource p_9020_, float p_9021_, float p_9022_) { +- this.connection.send(new ClientboundSoundPacket(p_9019_, p_9020_, this.getX(), this.getY(), this.getZ(), p_9021_, p_9022_)); ++ this.connection.send( new ClientboundSoundPacket( p_9019_, p_9020_, this.getX(), this.getY(), this.getZ(), p_9021_, p_9022_ ) ); } - public Packet m_5654_() { + public Packet getAddEntityPacket() { - return new ClientboundAddPlayerPacket(this); + return new ClientboundAddPlayerPacket( this ); } - public ItemEntity m_7197_(ItemStack p_9085_, boolean p_9086_, boolean p_9087_) { -- ItemEntity itementity = super.m_7197_(p_9085_, p_9086_, p_9087_); -+ ItemEntity itementity = super.m_7197_( p_9085_, p_9086_, p_9087_ ); + public ItemEntity drop(ItemStack p_9085_, boolean p_9086_, boolean p_9087_) { +- ItemEntity itementity = super.drop(p_9085_, p_9086_, p_9087_); ++ ItemEntity itementity = super.drop( p_9085_, p_9086_, p_9087_ ); if (itementity == null) { return null; } else { -- this.f_19853_.m_7967_(itementity); +- this.level.addFreshEntity(itementity); + if (captureDrops() != null) captureDrops().add( itementity ); + else -+ this.f_19853_.m_7967_( itementity ); - ItemStack itemstack = itementity.m_32055_(); ++ this.level.addFreshEntity( itementity ); + ItemStack itemstack = itementity.getItem(); if (p_9087_) { - if (!itemstack.m_41619_()) { -- this.m_6278_(Stats.f_12985_.m_12902_(itemstack.m_41720_()), p_9085_.m_41613_()); -+ this.m_6278_( Stats.f_12985_.m_12902_( itemstack.m_41720_() ), p_9085_.m_41613_() ); + if (!itemstack.isEmpty()) { +- this.awardStat(Stats.ITEM_DROPPED.get(itemstack.getItem()), p_9085_.getCount()); ++ this.awardStat( Stats.ITEM_DROPPED.get( itemstack.getItem() ), p_9085_.getCount() ); } -- this.m_36220_(Stats.f_12927_); -+ this.m_36220_( Stats.f_12927_ ); +- this.awardStat(Stats.DROP); ++ this.awardStat( Stats.DROP ); } return itementity; @@ -2037,78 +2034,78 @@ + Component oldName = this.tabListDisplayName; + this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName( this ); + if (!java.util.Objects.equals( oldName, this.tabListDisplayName )) { -+ this.m_20194_().m_6846_().m_11268_( new net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket( net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, this ) ); ++ this.getServer().getPlayerList().broadcastAll( new net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket( net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, this ) ); + } + } + - public TextFilter m_8967_() { - return this.f_8939_; + public TextFilter getTextFilter() { + return this.textFilter; } - public void m_143425_(ServerLevel p_143426_) { - this.f_19853_ = p_143426_; -- this.f_8941_.m_9260_(p_143426_); -+ this.f_8941_.m_9260_( p_143426_ ); + public void setLevel(ServerLevel p_143426_) { + this.level = p_143426_; +- this.gameMode.setLevel(p_143426_); ++ this.gameMode.setLevel( p_143426_ ); } @Nullable - private static GameType m_143413_(@Nullable CompoundTag p_143414_, String p_143415_) { -- return p_143414_ != null && p_143414_.m_128425_(p_143415_, 99) ? GameType.m_46393_(p_143414_.m_128451_(p_143415_)) : null; -+ return p_143414_ != null && p_143414_.m_128425_( p_143415_, 99 ) ? GameType.m_46393_( p_143414_.m_128451_( p_143415_ ) ) : null; + private static GameType readPlayerMode(@Nullable CompoundTag p_143414_, String p_143415_) { +- return p_143414_ != null && p_143414_.contains(p_143415_, 99) ? GameType.byId(p_143414_.getInt(p_143415_)) : null; ++ return p_143414_ != null && p_143414_.contains( p_143415_, 99 ) ? GameType.byId( p_143414_.getInt( p_143415_ ) ) : null; } - private GameType m_143423_(@Nullable GameType p_143424_) { + private GameType calculateGameModeForNewPlayer(@Nullable GameType p_143424_) { @@ -1476,14 +_,14 @@ } - public void m_143427_(@Nullable CompoundTag p_143428_) { -- this.f_8941_.m_9273_(this.m_143423_(m_143413_(p_143428_, "playerGameType")), m_143413_(p_143428_, "previousPlayerGameType")); -+ this.f_8941_.m_9273_( this.m_143423_( m_143413_( p_143428_, "playerGameType" ) ), m_143413_( p_143428_, "previousPlayerGameType" ) ); + public void loadGameTypes(@Nullable CompoundTag p_143428_) { +- this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(p_143428_, "playerGameType")), readPlayerMode(p_143428_, "previousPlayerGameType")); ++ this.gameMode.setGameModeForPlayer( this.calculateGameModeForNewPlayer( readPlayerMode( p_143428_, "playerGameType" ) ), readPlayerMode( p_143428_, "previousPlayerGameType" ) ); } - private void m_143430_(CompoundTag p_143431_) { -- p_143431_.m_128405_("playerGameType", this.f_8941_.m_9290_().m_46392_()); -+ p_143431_.m_128405_( "playerGameType", this.f_8941_.m_9290_().m_46392_() ); - GameType gametype = this.f_8941_.m_9293_(); + private void storeGameTypes(CompoundTag p_143431_) { +- p_143431_.putInt("playerGameType", this.gameMode.getGameModeForPlayer().getId()); ++ p_143431_.putInt( "playerGameType", this.gameMode.getGameModeForPlayer().getId() ); + GameType gametype = this.gameMode.getPreviousGameModeForPlayer(); if (gametype != null) { -- p_143431_.m_128405_("previousPlayerGameType", gametype.m_46392_()); -+ p_143431_.m_128405_( "previousPlayerGameType", gametype.m_46392_() ); +- p_143431_.putInt("previousPlayerGameType", gametype.getId()); ++ p_143431_.putInt( "previousPlayerGameType", gametype.getId() ); } } @@ -1501,24 +_,158 @@ } - public boolean m_142265_(Level p_143406_, BlockPos p_143407_) { -- return super.m_142265_(p_143406_, p_143407_) && p_143406_.m_7966_(this, p_143407_); -+ return super.m_142265_( p_143406_, p_143407_ ) && p_143406_.m_7966_( this, p_143407_ ); + public boolean mayInteract(Level p_143406_, BlockPos p_143407_) { +- return super.mayInteract(p_143406_, p_143407_) && p_143406_.mayInteract(this, p_143407_); ++ return super.mayInteract( p_143406_, p_143407_ ) && p_143406_.mayInteract( this, p_143407_ ); } - protected void m_142106_(ItemStack p_143402_) { -- CriteriaTriggers.f_145090_.m_163865_(this, p_143402_); -- super.m_142106_(p_143402_); -+ CriteriaTriggers.f_145090_.m_163865_( this, p_143402_ ); -+ super.m_142106_( p_143402_ ); + protected void updateUsingItem(ItemStack p_143402_) { +- CriteriaTriggers.USING_ITEM.trigger(this, p_143402_); +- super.updateUsingItem(p_143402_); ++ CriteriaTriggers.USING_ITEM.trigger( this, p_143402_ ); ++ super.updateUsingItem( p_143402_ ); } - public boolean m_182294_(boolean p_182295_) { - Inventory inventory = this.m_150109_(); -- ItemStack itemstack = inventory.m_182403_(p_182295_); -- this.f_36096_.m_182417_(inventory, inventory.f_35977_).ifPresent((p_182293_) -> { -- this.f_36096_.m_150404_(p_182293_, inventory.m_36056_()); + public boolean drop(boolean p_182295_) { + Inventory inventory = this.getInventory(); +- ItemStack itemstack = inventory.removeFromSelected(p_182295_); +- this.containerMenu.findSlot(inventory, inventory.selected).ifPresent((p_182293_) -> { +- this.containerMenu.setRemoteSlot(p_182293_, inventory.getSelected()); - }); -- return this.m_7197_(itemstack, false, true) != null; -+ ItemStack selected = inventory.m_36056_(); -+ if (selected.m_41619_() || !selected.onDroppedByPlayer( this )) return false; -+ ItemStack itemstack = inventory.m_182403_( p_182295_ ); -+ this.f_36096_.m_182417_( inventory, inventory.f_35977_ ).ifPresent( (p_182293_) -> { -+ this.f_36096_.m_150404_( p_182293_, inventory.m_36056_() ); +- return this.drop(itemstack, false, true) != null; ++ ItemStack selected = inventory.getSelected(); ++ if (selected.isEmpty() || !selected.onDroppedByPlayer( this )) return false; ++ ItemStack itemstack = inventory.removeFromSelected( p_182295_ ); ++ this.containerMenu.findSlot( inventory, inventory.selected ).ifPresent( (p_182293_) -> { ++ this.containerMenu.setRemoteSlot( p_182293_, inventory.getSelected() ); + } ); + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent( this, itemstack, true ) != null; } - public boolean m_184128_() { - return this.f_184127_; + public boolean allowsListing() { + return this.allowsListing; } + + // CraftBukkit start - Add per-player time and weather. @@ -2118,10 +2115,10 @@ + public long getPlayerTime() { + if (this.relativeTime) { + // Adds timeOffset to the current server time. -+ return this.f_19853_.m_46468_() + this.timeOffset; ++ return this.level.getDayTime() + this.timeOffset; + } else { + // Adds timeOffset to the beginning of this day. -+ return this.f_19853_.m_46468_() - (this.f_19853_.m_46468_() % 24000) + this.timeOffset; ++ return this.level.getDayTime() - (this.level.getDayTime() % 24000) + this.timeOffset; + } + } + @@ -2141,15 +2138,15 @@ + } + + if (type == org.bukkit.WeatherType.DOWNFALL) { -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132155_, 0 ) ); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.STOP_RAINING, 0 ) ); + } else { -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132154_, 0 ) ); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.START_RAINING, 0 ) ); + } + } + + public void resetPlayerWeather() { + this.weather = null; -+ this.setPlayerWeather( this.f_19853_.m_6106_().m_6533_() ? org.bukkit.WeatherType.DOWNFALL : org.bukkit.WeatherType.CLEAR, false ); ++ this.setPlayerWeather( this.level.getLevelData().isRaining() ? org.bukkit.WeatherType.DOWNFALL : org.bukkit.WeatherType.CLEAR, false ); + } + + private float pluginRainPosition; @@ -2159,20 +2156,20 @@ + if (this.weather == null) { + // Vanilla + if (oldRain != newRain) { -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132160_, newRain ) ); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, newRain ) ); + } + } else { + // Plugin + if (pluginRainPositionPrevious != pluginRainPosition) { -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132160_, pluginRainPosition ) ); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, pluginRainPosition ) ); + } + } + + if (oldThunder != newThunder) { + if (weather == org.bukkit.WeatherType.DOWNFALL || weather == null) { -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132161_, newThunder ) ); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, newThunder ) ); + } else { -+ this.f_8906_.m_141995_( new ClientboundGameEventPacket( ClientboundGameEventPacket.f_132161_, 0 ) ); ++ this.connection.send( new ClientboundGameEventPacket( ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, 0 ) ); + } + } + } @@ -2187,59 +2184,59 @@ + pluginRainPosition -= 0.01; + } + -+ pluginRainPosition = Mth.m_14036_( pluginRainPosition, 0.0F, 1.0F ); ++ pluginRainPosition = Mth.clamp( pluginRainPosition, 0.0F, 1.0F ); + } + + // SPIGOT-1903, MC-98153 + public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) { -+ this.m_7678_( x, y, z, yaw, pitch ); -+ this.f_8906_.m_9953_(); ++ this.moveTo( x, y, z, yaw, pitch ); ++ this.connection.resetPosition(); + } + + @Override -+ public boolean m_6107_() { -+ return super.m_6107_() || !getBukkitEntity().isOnline(); ++ public boolean isImmobile() { ++ return super.isImmobile() || !getBukkitEntity().isOnline(); + } + + @Override -+ public net.minecraft.world.scores.Scoreboard m_36329_() { ++ public net.minecraft.world.scores.Scoreboard getScoreboard() { + return getBukkitEntity().getScoreboard().getHandle(); + } + + public void reset() { + float exp = 0; -+ boolean keepInventory = this.f_19853_.m_46469_().m_46207_( GameRules.f_46133_ ); ++ boolean keepInventory = this.level.getGameRules().getBoolean( GameRules.RULE_KEEPINVENTORY ); + + if (this.keepLevel) { // CraftBukkit - SPIGOT-6687: Only use keepLevel (was pre-set with RULE_KEEPINVENTORY value in PlayerDeathEvent) -+ exp = this.f_36080_; -+ this.newTotalExp = this.f_36079_; -+ this.newLevel = this.f_36078_; ++ exp = this.experienceProgress; ++ this.newTotalExp = this.totalExperience; ++ this.newLevel = this.experienceLevel; + } + -+ this.m_21153_( this.m_21233_() ); -+ this.m_5810_(); // CraftBukkit - SPIGOT-6682: Clear active item on reset -+ this.f_19831_ = 0; -+ this.f_19789_ = 0; -+ this.f_36097_ = new net.minecraft.world.food.FoodData( this ); -+ this.f_36078_ = this.newLevel; -+ this.f_36079_ = this.newTotalExp; -+ this.f_36080_ = 0; -+ this.f_20919_ = 0; ++ this.setHealth( this.getMaxHealth() ); ++ this.stopUsingItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset ++ this.remainingFireTicks = 0; ++ this.fallDistance = 0; ++ this.foodData = new net.minecraft.world.food.FoodData( this ); ++ this.experienceLevel = this.newLevel; ++ this.totalExperience = this.newTotalExp; ++ this.experienceProgress = 0; ++ this.deathTime = 0; + this.setArrowCount( 0, true ); // CraftBukkit - ArrowBodyCountChangeEvent + this.removeAllEffects( org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH ); -+ this.f_20948_ = true; -+ this.f_36096_ = this.f_36095_; -+ this.f_20888_ = null; -+ this.f_20949_ = null; -+ this.f_20944_ = new net.minecraft.world.damagesource.CombatTracker( this ); -+ this.f_8920_ = -1; ++ this.effectsDirty = true; ++ this.containerMenu = this.inventoryMenu; ++ this.lastHurtByPlayer = null; ++ this.lastHurtByMob = null; ++ this.combatTracker = new net.minecraft.world.damagesource.CombatTracker( this ); ++ this.lastSentExp = -1; + if (this.keepLevel) { // CraftBukkit - SPIGOT-6687: Only use keepLevel (was pre-set with RULE_KEEPINVENTORY value in PlayerDeathEvent) -+ this.f_36080_ = exp; ++ this.experienceProgress = exp; + } else { -+ this.m_6756_( this.newExp ); ++ this.giveExperiencePoints( this.newExp ); + } + this.keepLevel = false; -+ this.m_20334_(0, 0, 0); // CraftBukkit - SPIGOT-6948: Reset velocity on death ++ this.setDeltaMovement(0, 0, 0); // CraftBukkit - SPIGOT-6948: Reset velocity on death + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 61aa0f48..0e81e950 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,121 +1,121 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java @@ -51,6 +_,13 @@ - if (p_143474_ == this.f_9247_) { + if (p_143474_ == this.gameModeForPlayer) { return false; } else { + // CraftBukkit start -+ org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent(f_9245_.getBukkitEntity(), org.bukkit.GameMode.getByValue(p_143474_.m_46392_())); -+ f_9244_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent(player.getBukkitEntity(), org.bukkit.GameMode.getByValue(p_143474_.getId())); ++ level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } + // CraftBukkit end - this.m_9273_(p_143474_, this.f_9247_); + this.setGameModeForPlayer(p_143474_, this.gameModeForPlayer); return true; } @@ -61,7 +_,7 @@ - this.f_9247_ = p_9274_; - p_9274_.m_46398_(this.f_9245_.m_150110_()); - this.f_9245_.m_6885_(); -- this.f_9245_.f_8924_.m_6846_().m_11268_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_GAME_MODE, this.f_9245_)); -+ this.f_9245_.f_8924_.m_6846_().broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_GAME_MODE, this.f_9245_), this.f_9245_); // CraftBukkit - this.f_9244_.m_8878_(); + this.gameModeForPlayer = p_9274_; + p_9274_.updatePlayerAbilities(this.player.getAbilities()); + this.player.onUpdateAbilities(); +- this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_GAME_MODE, this.player)); ++ this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit + this.level.updateSleepingPlayerList(); } @@ -83,7 +_,7 @@ } - public void m_7712_() { -- ++this.f_9252_; -+ this.f_9252_ = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit; - if (this.f_9253_) { - BlockState blockstate = this.f_9244_.m_8055_(this.f_9254_); - if (blockstate.m_60795_()) { + public void tick() { +- ++this.gameTicks; ++ this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit; + if (this.hasDelayedDestroy) { + BlockState blockstate = this.level.getBlockState(this.delayedDestroyPos); + if (blockstate.isAir()) { @@ -125,7 +_,13 @@ - double d1 = this.f_9245_.m_20186_() - ((double)p_9282_.m_123342_() + 0.5D) + 1.5D; - double d2 = this.f_9245_.m_20189_() - ((double)p_9282_.m_123343_() + 0.5D); + double d1 = this.player.getY() - ((double)p_9282_.getY() + 0.5D) + 1.5D; + double d2 = this.player.getZ() - ((double)p_9282_.getZ() + 0.5D); double d3 = d0 * d0 + d1 * d1 + d2 * d2; - if (d3 > 36.0D) { -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(f_9245_, p_9282_, p_9284_); -+ if (event.isCanceled() || (!this.m_9295_() && event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data -+ f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, f_9244_.m_8055_(p_9282_), p_9283_, false, "mod canceled")); -+ f_9244_.m_7260_(p_9282_, f_9244_.m_8055_(p_9282_), f_9244_.m_8055_(p_9282_), 3); ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(player, p_9282_, p_9284_); ++ if (event.isCanceled() || (!this.isCreative() && event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data ++ player.connection.send(new ClientboundBlockBreakAckPacket(p_9282_, level.getBlockState(p_9282_), p_9283_, false, "mod canceled")); ++ level.sendBlockUpdated(p_9282_, level.getBlockState(p_9282_), level.getBlockState(p_9282_), 3); + return; + } -+ if (!this.f_9245_.canInteractWith(p_9282_, 1)) { ++ if (!this.player.canInteractWith(p_9282_, 1)) { BlockState blockstate1; - if (this.f_9245_.f_19853_.m_142572_() != null && this.f_9245_.m_146902_().m_45594_(new ChunkPos(p_9282_)) < this.f_9245_.f_19853_.m_142572_().m_6846_().m_11312_()) { - blockstate1 = this.f_9244_.m_8055_(p_9282_); + if (this.player.level.getServer() != null && this.player.chunkPosition().getChessboardDistance(new ChunkPos(p_9282_)) < this.player.level.getServer().getPlayerList().getViewDistance()) { + blockstate1 = this.level.getBlockState(p_9282_); @@ -139,9 +_,31 @@ } else { if (p_9283_ == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) { - if (!this.f_9244_.m_7966_(this.f_9245_, p_9282_)) { + if (!this.level.mayInteract(this.player, p_9282_)) { + // CraftBukkit start - fire PlayerInteractEvent -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.f_9245_, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, p_9282_, p_9284_, this.f_9245_.m_150109_().m_36056_(), InteractionHand.MAIN_HAND); - this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, this.f_9244_.m_8055_(p_9282_), p_9283_, false, "may not interact")); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, p_9282_, p_9284_, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); + this.player.connection.send(new ClientboundBlockBreakAckPacket(p_9282_, this.level.getBlockState(p_9282_), p_9283_, false, "may not interact")); - return; - } + // Update any tile entity data for this block -+ BlockEntity tileentity = f_9244_.m_7702_(p_9282_); ++ BlockEntity tileentity = level.getBlockEntity(p_9282_); + if (tileentity != null) { -+ this.f_9245_.f_8906_.m_141995_(tileentity.m_183216_()); ++ this.player.connection.send(tileentity.getUpdatePacket()); + } + // CraftBukkit end + return; + } + + // CraftBukkit start -+ org.bukkit.event.player.PlayerInteractEvent eventCB = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.f_9245_, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, p_9282_, p_9284_, this.f_9245_.m_150109_().m_36056_(), InteractionHand.MAIN_HAND); ++ org.bukkit.event.player.PlayerInteractEvent eventCB = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, p_9282_, p_9284_, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); + if (eventCB.isCancelled()) { + // Let the client know the block still exists -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9282_)); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9282_)); + // Update any tile entity data for this block -+ BlockEntity tileentity = this.f_9244_.m_7702_(p_9282_); ++ BlockEntity tileentity = this.level.getBlockEntity(p_9282_); + if (tileentity != null) { -+ this.f_9245_.f_8906_.m_141995_(tileentity.m_183216_()); ++ this.player.connection.send(tileentity.getUpdatePacket()); + } + return; + } + // CraftBukkit end - if (this.m_9295_()) { - this.m_9286_(p_9282_, p_9283_, "creative destroy"); + if (this.isCreative()) { + this.destroyAndAck(p_9282_, p_9283_, "creative destroy"); @@ -156,11 +_,44 @@ - this.f_9250_ = this.f_9252_; + this.destroyProgressStart = this.gameTicks; float f = 1.0F; - BlockState blockstate = this.f_9244_.m_8055_(p_9282_); -- if (!blockstate.m_60795_()) { + BlockState blockstate = this.level.getBlockState(p_9282_); +- if (!blockstate.isAir()) { + // CraftBukkit start - Swings at air do *NOT* exist. + if (eventCB.useInteractedBlock() == org.bukkit.event.Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. -+ BlockState data = this.f_9244_.m_8055_(p_9282_); -+ if (data.m_60734_() instanceof net.minecraft.world.level.block.DoorBlock) { ++ BlockState data = this.level.getBlockState(p_9282_); ++ if (data.getBlock() instanceof net.minecraft.world.level.block.DoorBlock) { + // For some reason *BOTH* the bottom/top part have to be marked updated. -+ boolean bottom = data.m_61143_(net.minecraft.world.level.block.DoorBlock.f_52730_) == net.minecraft.world.level.block.state.properties.DoubleBlockHalf.LOWER; -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9282_)); -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, bottom ? p_9282_.m_7494_() : p_9282_.m_7495_())); -+ } else if (data.m_60734_() instanceof net.minecraft.world.level.block.TrapDoorBlock) { -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9282_)); ++ boolean bottom = data.getValue(net.minecraft.world.level.block.DoorBlock.HALF) == net.minecraft.world.level.block.state.properties.DoubleBlockHalf.LOWER; ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9282_)); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, bottom ? p_9282_.above() : p_9282_.below())); ++ } else if (data.getBlock() instanceof net.minecraft.world.level.block.TrapDoorBlock) { ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9282_)); + } -+ } else if (!blockstate.m_60795_()) { ++ } else if (!blockstate.isAir()) { + if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) - blockstate.m_60686_(this.f_9244_, p_9282_, this.f_9245_); - f = blockstate.m_60625_(this.f_9245_, this.f_9245_.f_19853_, p_9282_); + blockstate.attack(this.level, p_9282_, this.player); + f = blockstate.getDestroyProgress(this.player, this.player.level, p_9282_); } + if (eventCB.useItemInHand() == org.bukkit.event.Event.Result.DENY) { + // If we 'insta destroyed' then the client needs to be informed. + if (f > 1.0f) { -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9282_)); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9282_)); + } + return; + } -+ org.bukkit.event.block.BlockDamageEvent blockEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockDamageEvent(this.f_9245_, p_9282_, this.f_9245_.m_150109_().m_36056_(), f >= 1.0f); ++ org.bukkit.event.block.BlockDamageEvent blockEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockDamageEvent(this.player, p_9282_, this.player.getInventory().getSelected(), f >= 1.0f); + + if (blockEvent.isCancelled()) { + // Let the client know the block still exists -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9282_)); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9282_)); + return; + } + @@ -124,31 +124,31 @@ + } + // CraftBukkit end + - if (!blockstate.m_60795_() && f >= 1.0F) { - this.m_9286_(p_9282_, p_9283_, "insta mine"); + if (!blockstate.isAir() && f >= 1.0F) { + this.destroyAndAck(p_9282_, p_9283_, "insta mine"); } else { @@ -201,13 +_,14 @@ } else if (p_9283_ == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { - this.f_9249_ = false; - if (!Objects.equals(this.f_9251_, p_9282_)) { -- f_9246_.warn("Mismatch in destroy block pos: {} {}", this.f_9251_, p_9282_); -+ f_9246_.debug("Mismatch in destroy block pos: {} {}", this.f_9251_, p_9282_); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled - this.f_9244_.m_6801_(this.f_9245_.m_142049_(), this.f_9251_, -1); - this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(this.f_9251_, this.f_9244_.m_8055_(this.f_9251_), p_9283_, true, "aborted mismatched destroying")); + this.isDestroyingBlock = false; + if (!Objects.equals(this.destroyPos, p_9282_)) { +- LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, p_9282_); ++ LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, p_9282_); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled + this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); + this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, this.level.getBlockState(this.destroyPos), p_9283_, true, "aborted mismatched destroying")); } - this.f_9244_.m_6801_(this.f_9245_.m_142049_(), p_9282_, -1); - this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, this.f_9244_.m_8055_(p_9282_), p_9283_, true, "aborted destroying")); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockDamageAbortEvent(this.f_9245_, p_9282_, this.f_9245_.m_150109_().m_36056_()); // CraftBukkit + this.level.destroyBlockProgress(this.player.getId(), p_9282_, -1); + this.player.connection.send(new ClientboundBlockBreakAckPacket(p_9282_, this.level.getBlockState(p_9282_), p_9283_, true, "aborted destroying")); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, p_9282_, this.player.getInventory().getSelected()); // CraftBukkit } } @@ -217,45 +_,154 @@ - if (this.m_9280_(p_9287_)) { - this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9287_, this.f_9244_.m_8055_(p_9287_), p_9288_, true, p_9289_)); + if (this.destroyBlock(p_9287_)) { + this.player.connection.send(new ClientboundBlockBreakAckPacket(p_9287_, this.level.getBlockState(p_9287_), p_9288_, true, p_9289_)); } else { -- this.f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9287_, this.f_9244_.m_8055_(p_9287_), p_9288_, false, p_9289_)); -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9287_)); // CraftBukkit - SPIGOT-5196 +- this.player.connection.send(new ClientboundBlockBreakAckPacket(p_9287_, this.level.getBlockState(p_9287_), p_9288_, false, p_9289_)); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9287_)); // CraftBukkit - SPIGOT-5196 } } @@ -157,65 +157,65 @@ + private @Nullable org.bukkit.block.Block destroyBlock_bblock; + private @Nullable java.util.Optional destroyBlock_event; + private @Nullable org.bukkit.block.BlockState destroyBlock_state; - public boolean m_9280_(BlockPos p_9281_) { -- BlockState blockstate = this.f_9244_.m_8055_(p_9281_); -- if (!this.f_9245_.m_21205_().m_41720_().m_6777_(blockstate, this.f_9244_, p_9281_, this.f_9245_)) { -+ BlockState blockState = this.f_9244_.m_8055_(p_9281_); + public boolean destroyBlock(BlockPos p_9281_) { +- BlockState blockstate = this.level.getBlockState(p_9281_); +- if (!this.player.getMainHandItem().getItem().canAttackBlock(blockstate, this.level, p_9281_, this.player)) { ++ BlockState blockState = this.level.getBlockState(p_9281_); + // CraftBukkit start - fire BlockBreakEvent -+ destroyBlock_bblock = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(f_9244_, p_9281_); ++ destroyBlock_bblock = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, p_9281_); + destroyBlock_event = isSwordNoBreak(p_9281_, blockState, destroyBlock_bblock); + + if (destroyBlock_event.isEmpty()) + return false; + // CraftBukkit end + -+ if (false && !this.f_9245_.m_21205_().m_41720_().m_6777_(blockState, this.f_9244_, p_9281_, this.f_9245_)) { // CraftBukkit - false ++ if (false && !this.player.getMainHandItem().getItem().canAttackBlock(blockState, this.level, p_9281_, this.player)) { // CraftBukkit - false return false; } else { -- BlockEntity blockentity = this.f_9244_.m_7702_(p_9281_); -- Block block = blockstate.m_60734_(); -+ blockState = this.f_9244_.m_8055_(p_9281_); // CraftBukkit - update state from plugins -+ if (blockState.m_60795_()) return false; // CraftBukkit - A plugin set block to air without cancelling -+ BlockEntity tileentity = this.f_9244_.m_7702_(p_9281_); -+ Block block = blockState.m_60734_(); -+ - if (block instanceof GameMasterBlock && !this.f_9245_.m_36337_()) { -- this.f_9244_.m_7260_(p_9281_, blockstate, blockstate, 3); -+ this.f_9244_.m_7260_(p_9281_, blockState, blockState, 3); +- BlockEntity blockentity = this.level.getBlockEntity(p_9281_); +- Block block = blockstate.getBlock(); ++ blockState = this.level.getBlockState(p_9281_); // CraftBukkit - update state from plugins ++ if (blockState.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling ++ BlockEntity tileentity = this.level.getBlockEntity(p_9281_); ++ Block block = blockState.getBlock(); ++ + if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { +- this.level.sendBlockUpdated(p_9281_, blockstate, blockstate, 3); ++ this.level.sendBlockUpdated(p_9281_, blockState, blockState, 3); + return false; -+ } else if (f_9245_.m_21205_().onBlockStartBreak(p_9281_, f_9245_)) { //Magma - add missing if statement ++ } else if (player.getMainHandItem().onBlockStartBreak(p_9281_, player)) { //Magma - add missing if statement return false; - } else if (this.f_9245_.m_36187_(this.f_9244_, p_9281_, this.f_9247_)) { + } else if (this.player.blockActionRestricted(this.level, p_9281_, this.gameModeForPlayer)) { return false; } else { -- block.m_5707_(this.f_9244_, p_9281_, blockstate, this.f_9245_); -- boolean flag = this.f_9244_.m_7471_(p_9281_, false); +- block.playerWillDestroy(this.level, p_9281_, blockstate, this.player); +- boolean flag = this.level.removeBlock(p_9281_, false); + // CraftBukkit start + destroyBlock_state = destroyBlock_bblock.getState(); -+ f_9244_.captureDrops = new java.util.ArrayList<>(); ++ level.captureDrops = new java.util.ArrayList<>(); + // CraftBukkit end + boolean flag = removeBlock(p_9281_, false); + if (flag) { -- block.m_6786_(this.f_9244_, p_9281_, blockstate); -+ block.m_6786_(this.f_9244_, p_9281_, blockState); +- block.destroy(this.level, p_9281_, blockstate); ++ block.destroy(this.level, p_9281_, blockState); } - if (this.m_9295_()) { + if (this.isCreative()) { - return true; + // return true; // CraftBukkit } else { - ItemStack itemstack = this.f_9245_.m_21205_(); - ItemStack itemstack1 = itemstack.m_41777_(); -- boolean flag1 = this.f_9245_.m_36298_(blockstate); -- itemstack.m_41686_(this.f_9244_, blockstate, p_9281_, this.f_9245_); + ItemStack itemstack = this.player.getMainHandItem(); + ItemStack itemstack1 = itemstack.copy(); +- boolean flag1 = this.player.hasCorrectToolForDrops(blockstate); +- itemstack.mineBlock(this.level, blockstate, p_9281_, this.player); - if (flag && flag1) { -- block.m_6240_(this.f_9244_, this.f_9245_, p_9281_, blockstate, blockentity, itemstack1); -+ boolean flag1 = this.f_9245_.m_36298_(blockState); +- block.playerDestroy(this.level, this.player, p_9281_, blockstate, blockentity, itemstack1); ++ boolean flag1 = this.player.hasCorrectToolForDrops(blockState); + -+ itemstack.m_41686_(this.f_9244_, blockState, p_9281_, this.f_9245_); ++ itemstack.mineBlock(this.level, blockState, p_9281_, this.player); + if (flag && flag1 && destroyBlock_event.get().isDropItems()) { // CraftBukkit - Check if block should drop items -+ block.m_6240_(this.f_9244_, this.f_9245_, p_9281_, blockState, tileentity, itemstack1); ++ block.playerDestroy(this.level, this.player, p_9281_, blockState, tileentity, itemstack1); } - return true; @@ -226,13 +226,13 @@ + } + // CraftBukkit start + if (destroyBlock_event.get().isDropItems()) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockDropItemEvent(destroyBlock_bblock, destroyBlock_state, this.f_9245_, f_9244_.captureDrops); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockDropItemEvent(destroyBlock_bblock, destroyBlock_state, this.player, level.captureDrops); + } -+ f_9244_.captureDrops = null; ++ level.captureDrops = null; + + // Drop event experience + if (flag && destroyBlock_event != null) { -+ blockState.m_60734_().m_49805_(this.f_9244_, p_9281_, destroyBlock_event.get().getExpToDrop()); ++ blockState.getBlock().popExperience(this.level, p_9281_, destroyBlock_event.get().getExpToDrop()); + } + + org.magmafoundation.magma.util.LogUtils.removeHolder(p_9281_); @@ -245,60 +245,60 @@ + + private java.util.Optional isSwordNoBreak(BlockPos p_9281_, BlockState blockState, org.bukkit.block.Block bblock) { + org.bukkit.event.block.BlockBreakEvent event = null; -+ if (this.f_9245_ instanceof ServerPlayer) { ++ if (this.player instanceof ServerPlayer) { + // Sword + Creative mode pre-cancel -+ boolean isSwordNoBreak = !this.f_9245_.m_21205_().m_41720_().m_6777_(blockState, this.f_9244_, p_9281_, this.f_9245_); ++ boolean isSwordNoBreak = !this.player.getMainHandItem().getItem().canAttackBlock(blockState, this.level, p_9281_, this.player); + + // Tell client the block is gone immediately then process events + // Don't tell the client if its a creative sword break because its not broken! -+ if (f_9244_.m_7702_(p_9281_) == null && !isSwordNoBreak) { -+ net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket packet = new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9281_, Blocks.f_50016_.m_49966_()); -+ this.f_9245_.f_8906_.m_141995_(packet); ++ if (level.getBlockEntity(p_9281_) == null && !isSwordNoBreak) { ++ net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket packet = new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9281_, Blocks.AIR.defaultBlockState()); ++ this.player.connection.send(packet); + } + -+ event = new org.bukkit.event.block.BlockBreakEvent(bblock, this.f_9245_.getBukkitEntity()); ++ event = new org.bukkit.event.block.BlockBreakEvent(bblock, this.player.getBukkitEntity()); + + //Magma start -+ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(f_9244_, f_9247_, f_9245_, p_9281_); ++ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(level, gameModeForPlayer, player, p_9281_); + + if (exp == -1) { + return java.util.Optional.empty(); + } + -+ if(this.f_9245_.m_7500_() && ((org.bukkit.entity.Player) this.f_9245_.getBukkitEntity()).getInventory().getItemInMainHand().getType().toString().contains("SWORD") || ((org.bukkit.entity.Player) this.f_9245_.getBukkitEntity()).getInventory().getItemInMainHand().getType().toString().contains("TRIDENT")){ ++ if(this.player.isCreative() && ((org.bukkit.entity.Player) this.player.getBukkitEntity()).getInventory().getItemInMainHand().getType().toString().contains("SWORD") || ((org.bukkit.entity.Player) this.player.getBukkitEntity()).getInventory().getItemInMainHand().getType().toString().contains("TRIDENT")){ + event.setCancelled(true); + isSwordNoBreak = true; + } + //Magma end + + // Calculate default block experience -+ BlockState nmsData = this.f_9244_.m_8055_(p_9281_); -+ Block nmsBlock = nmsData.m_60734_(); ++ BlockState nmsData = this.level.getBlockState(p_9281_); ++ Block nmsBlock = nmsData.getBlock(); + -+ ItemStack itemstack = this.f_9245_.m_6844_(net.minecraft.world.entity.EquipmentSlot.MAINHAND); ++ ItemStack itemstack = this.player.getItemBySlot(net.minecraft.world.entity.EquipmentSlot.MAINHAND); + -+ if (nmsBlock != null && !event.isCancelled() && !this.m_9295_() && this.f_9245_.m_36298_(nmsBlock.m_49966_())) { -+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.f_9244_, p_9281_, itemstack)); ++ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasCorrectToolForDrops(nmsBlock.defaultBlockState())) { ++ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, p_9281_, itemstack)); + } + -+ this.f_9244_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + if (isSwordNoBreak) { + return java.util.Optional.empty(); + } + // Let the client know the block still exists -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.f_9244_, p_9281_)); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(this.level, p_9281_)); + + // Brute force all possible updates + for (Direction dir : Direction.values()) { -+ this.f_9245_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(f_9244_, p_9281_.m_142300_(dir))); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(level, p_9281_.relative(dir))); + } + + // Update any tile entity data for this block -+ BlockEntity tileentity = this.f_9244_.m_7702_(p_9281_); ++ BlockEntity tileentity = this.level.getBlockEntity(p_9281_); + if (tileentity != null) { -+ this.f_9245_.f_8906_.m_141995_(tileentity.m_183216_()); ++ this.player.connection.send(tileentity.getUpdatePacket()); + } + return java.util.Optional.empty(); + } @@ -308,23 +308,23 @@ + //Magma end + + private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) { -+ BlockState state = this.f_9244_.m_8055_(p_180235_1_); -+ boolean removed = state.onDestroyedByPlayer(this.f_9244_, p_180235_1_, this.f_9245_, canHarvest, this.f_9244_.m_6425_(p_180235_1_)); ++ BlockState state = this.level.getBlockState(p_180235_1_); ++ boolean removed = state.onDestroyedByPlayer(this.level, p_180235_1_, this.player, canHarvest, this.level.getFluidState(p_180235_1_)); + if (removed) -+ state.m_60734_().m_6786_(this.f_9244_, p_180235_1_, state); ++ state.getBlock().destroy(this.level, p_180235_1_, state); + return removed; } - public InteractionResult m_6261_(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { + public InteractionResult useItem(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { @@ -264,6 +_,8 @@ - } else if (p_9262_.m_36335_().m_41519_(p_9264_.m_41720_())) { + } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_.getItem())) { return InteractionResult.PASS; } else { + InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_9262_, p_9265_); + if (cancelResult != null) return cancelResult; - int i = p_9264_.m_41613_(); - int j = p_9264_.m_41773_(); - InteractionResultHolder interactionresultholder = p_9264_.m_41682_(p_9263_, p_9262_, p_9265_); + int i = p_9264_.getCount(); + int j = p_9264_.getDamageValue(); + InteractionResultHolder interactionresultholder = p_9264_.use(p_9263_, p_9262_, p_9265_); @@ -294,50 +_,106 @@ } } @@ -338,72 +338,72 @@ + public BlockPos interactPosition; + public InteractionHand interactHand; + public ItemStack interactItemStack; - public InteractionResult m_7179_(ServerPlayer p_9266_, Level p_9267_, ItemStack p_9268_, InteractionHand p_9269_, BlockHitResult p_9270_) { -- BlockPos blockpos = p_9270_.m_82425_(); -- BlockState blockstate = p_9267_.m_8055_(blockpos); -- if (this.f_9247_ == GameType.SPECTATOR) { -- MenuProvider menuprovider = blockstate.m_60750_(p_9267_, blockpos); + public InteractionResult useItemOn(ServerPlayer p_9266_, Level p_9267_, ItemStack p_9268_, InteractionHand p_9269_, BlockHitResult p_9270_) { +- BlockPos blockpos = p_9270_.getBlockPos(); +- BlockState blockstate = p_9267_.getBlockState(blockpos); +- if (this.gameModeForPlayer == GameType.SPECTATOR) { +- MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); - if (menuprovider != null) { -- p_9266_.m_5893_(menuprovider); +- p_9266_.openMenu(menuprovider); - return InteractionResult.SUCCESS; - } else { - return InteractionResult.PASS; - } - } else { -- boolean flag = !p_9266_.m_21205_().m_41619_() || !p_9266_.m_21206_().m_41619_(); -- boolean flag1 = p_9266_.m_36341_() && flag; -- ItemStack itemstack = p_9268_.m_41777_(); +- boolean flag = !p_9266_.getMainHandItem().isEmpty() || !p_9266_.getOffhandItem().isEmpty(); +- boolean flag1 = p_9266_.isSecondaryUseActive() && flag; +- ItemStack itemstack = p_9268_.copy(); - if (!flag1) { -- InteractionResult interactionresult = blockstate.m_60664_(p_9267_, p_9266_, p_9269_, p_9270_); -- if (interactionresult.m_19077_()) { -- CriteriaTriggers.f_10562_.m_45482_(p_9266_, blockpos, itemstack); +- InteractionResult interactionresult = blockstate.use(p_9267_, p_9266_, p_9269_, p_9270_); +- if (interactionresult.consumesAction()) { +- CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); - return interactionresult; + try { -+ BlockPos blockpos = p_9270_.m_82425_(); -+ BlockState blockstate = p_9267_.m_8055_(blockpos); ++ BlockPos blockpos = p_9270_.getBlockPos(); ++ BlockState blockstate = p_9267_.getBlockState(blockpos); + + net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks.onRightClickBlock(p_9266_, p_9269_, blockpos, p_9270_); + if (event.isCanceled()) + return event.getCancellationResult(); + -+ if (this.f_9247_ == GameType.SPECTATOR) -+ useItemOn_cancelledBlock = !(blockstate.m_60750_(p_9267_, blockpos) instanceof MenuProvider); ++ if (this.gameModeForPlayer == GameType.SPECTATOR) ++ useItemOn_cancelledBlock = !(blockstate.getMenuProvider(p_9267_, blockpos) instanceof MenuProvider); + -+ if (p_9266_.m_36335_().m_41519_(p_9268_.m_41720_())) ++ if (p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem())) + useItemOn_cancelledBlock = true; + -+ eventCB = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(p_9266_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, blockpos, p_9270_.m_82434_(), p_9268_, useItemOn_cancelledBlock, p_9269_); ++ eventCB = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(p_9266_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, blockpos, p_9270_.getDirection(), p_9268_, useItemOn_cancelledBlock, p_9269_); + firedInteract = true; + interactResult = eventCB.useItemInHand() == org.bukkit.event.Event.Result.DENY; -+ interactPosition = blockpos.m_7949_(); ++ interactPosition = blockpos.immutable(); + interactHand = p_9269_; -+ interactItemStack = p_9268_.m_41777_(); ++ interactItemStack = p_9268_.copy(); + if (eventCB.useInteractedBlock() == org.bukkit.event.Event.Result.DENY) + bukkit_useItemOn(p_9266_, p_9267_, p_9268_, p_9269_, p_9270_, blockpos, blockstate); -+ else if (this.f_9247_ == GameType.SPECTATOR) { -+ MenuProvider menuprovider = blockstate.m_60750_(p_9267_, blockpos); ++ else if (this.gameModeForPlayer == GameType.SPECTATOR) { ++ MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); + if (menuprovider != null) { -+ p_9266_.m_5893_(menuprovider); ++ p_9266_.openMenu(menuprovider); + return InteractionResult.SUCCESS; + } else { + return InteractionResult.PASS; } - } - -- if (!p_9268_.m_41619_() && !p_9266_.m_36335_().m_41519_(p_9268_.m_41720_())) { +- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem())) { + } else { UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_); - InteractionResult interactionresult1; -- if (this.m_9295_()) { -- int i = p_9268_.m_41613_(); -- interactionresult1 = p_9268_.m_41661_(useoncontext); -- p_9268_.m_41764_(i); +- if (this.isCreative()) { +- int i = p_9268_.getCount(); +- interactionresult1 = p_9268_.useOn(useoncontext); +- p_9268_.setCount(i); - } else { -- interactionresult1 = p_9268_.m_41661_(useoncontext); +- interactionresult1 = p_9268_.useOn(useoncontext); - } - -- if (interactionresult1.m_19077_()) { -- CriteriaTriggers.f_10562_.m_45482_(p_9266_, blockpos, itemstack); +- if (interactionresult1.consumesAction()) { +- CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); - } - - return interactionresult1; @@ -413,30 +413,30 @@ + InteractionResult result = p_9268_.onItemUseFirst(useoncontext); + if (result != InteractionResult.PASS) return result; + } -+ boolean flag = !p_9266_.m_21205_().m_41619_() || !p_9266_.m_21206_().m_41619_(); -+ boolean flag1 = (p_9266_.m_36341_() && flag) && !(p_9266_.m_21205_().doesSneakBypassUse(p_9267_, blockpos, p_9266_) && p_9266_.m_21206_().doesSneakBypassUse(p_9267_, blockpos, p_9266_)); -+ ItemStack itemstack = p_9268_.m_41777_(); ++ boolean flag = !p_9266_.getMainHandItem().isEmpty() || !p_9266_.getOffhandItem().isEmpty(); ++ boolean flag1 = (p_9266_.isSecondaryUseActive() && flag) && !(p_9266_.getMainHandItem().doesSneakBypassUse(p_9267_, blockpos, p_9266_) && p_9266_.getOffhandItem().doesSneakBypassUse(p_9267_, blockpos, p_9266_)); ++ ItemStack itemstack = p_9268_.copy(); + if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { -+ InteractionResult interactionResult = blockstate.m_60664_(p_9267_, p_9266_, p_9269_, p_9270_); -+ if (interactionResult.m_19077_()) { -+ CriteriaTriggers.f_10562_.m_45482_(p_9266_, blockpos, itemstack); ++ InteractionResult interactionResult = blockstate.use(p_9267_, p_9266_, p_9269_, p_9270_); ++ if (interactionResult.consumesAction()) { ++ CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); + return interactionResult; + } + } + -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.m_41619_() && !p_9266_.m_36335_().m_41519_(p_9268_.m_41720_()))) { ++ 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.DENY) return InteractionResult.PASS; + InteractionResult interactionresult1; -+ if (this.m_9295_()) { -+ int i = p_9268_.m_41613_(); -+ interactionresult1 = p_9268_.m_41661_(useoncontext); -+ p_9268_.m_41764_(i); ++ if (this.isCreative()) { ++ int i = p_9268_.getCount(); ++ interactionresult1 = p_9268_.useOn(useoncontext); ++ p_9268_.setCount(i); + } else { -+ interactionresult1 = p_9268_.m_41661_(useoncontext); ++ interactionresult1 = p_9268_.useOn(useoncontext); + } + -+ if (interactionresult1.m_19077_()) { -+ CriteriaTriggers.f_10562_.m_45482_(p_9266_, blockpos, itemstack); ++ if (interactionresult1.consumesAction()) { ++ CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); + } + + return interactionresult1; @@ -454,21 +454,21 @@ + + private void bukkit_useItemOn(ServerPlayer p_9266_, Level p_9267_, ItemStack p_9268_, InteractionHand p_9269_, BlockHitResult p_9270_, BlockPos blockpos, BlockState blockstate) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. -+ if (blockstate.m_60734_() instanceof net.minecraft.world.level.block.DoorBlock) { -+ boolean bottom = blockstate.m_61143_(net.minecraft.world.level.block.DoorBlock.f_52730_) == net.minecraft.world.level.block.state.properties.DoubleBlockHalf.LOWER; -+ p_9266_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9267_, bottom ? blockpos.m_7494_() : blockpos.m_7495_())); -+ } else if (blockstate.m_60734_() instanceof net.minecraft.world.level.block.CakeBlock) { ++ if (blockstate.getBlock() instanceof net.minecraft.world.level.block.DoorBlock) { ++ boolean bottom = blockstate.getValue(net.minecraft.world.level.block.DoorBlock.HALF) == net.minecraft.world.level.block.state.properties.DoubleBlockHalf.LOWER; ++ p_9266_.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9267_, bottom ? blockpos.above() : blockpos.below())); ++ } else if (blockstate.getBlock() instanceof net.minecraft.world.level.block.CakeBlock) { + p_9266_.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake -+ } else if (interactItemStack.m_41720_() instanceof net.minecraft.world.item.DoubleHighBlockItem) { ++ } else if (interactItemStack.getItem() instanceof net.minecraft.world.item.DoubleHighBlockItem) { + // send a correcting update to the client, as it already placed the upper half of the bisected item -+ p_9266_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9267_, blockpos.m_142300_(p_9270_.m_82434_()).m_7494_())); ++ p_9266_.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9267_, blockpos.relative(p_9270_.getDirection()).above())); + // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc) -+ p_9266_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9267_, blockpos.m_7494_())); ++ p_9266_.connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_9267_, blockpos.above())); + } + p_9266_.getBukkitEntity().updateInventory(); // SPIGOT-2867 + useItemOn_result = (eventCB.useItemInHand() != org.bukkit.event.Event.Result.ALLOW) ? InteractionResult.SUCCESS : InteractionResult.PASS; + } + //Magma end - public void m_9260_(ServerLevel p_9261_) { - this.f_9244_ = p_9261_; + public void setLevel(ServerLevel p_9261_) { + this.level = p_9261_; diff --git a/patches/minecraft/net/minecraft/server/level/Ticket.java.patch b/patches/minecraft/net/minecraft/server/level/Ticket.java.patch index 375623fc..56f19329 100644 --- a/patches/minecraft/net/minecraft/server/level/Ticket.java.patch +++ b/patches/minecraft/net/minecraft/server/level/Ticket.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/level/Ticket.java +++ b/net/minecraft/server/level/Ticket.java @@ -9,9 +_,14 @@ - private long f_9423_; + private long createdTick; protected Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { + this(p_9425_, p_9426_, p_9427_, false); + } + + public Ticket(TicketType p_9425_, int p_9426_, T p_9427_, boolean forceTicks) { - this.f_9420_ = p_9425_; - this.f_9421_ = p_9426_; - this.f_9422_ = p_9427_; + this.type = p_9425_; + this.ticketLevel = p_9426_; + this.key = p_9427_; + this.forceTicks = forceTicks; } @@ -19,26 +19,26 @@ return false; } else { Ticket ticket = (Ticket)p_9439_; -- return this.f_9421_ == ticket.f_9421_ && Objects.equals(this.f_9420_, ticket.f_9420_) && Objects.equals(this.f_9422_, ticket.f_9422_); -+ return this.f_9421_ == ticket.f_9421_ && Objects.equals(this.f_9420_, ticket.f_9420_) && Objects.equals(this.f_9422_, ticket.f_9422_) && this.forceTicks == ticket.forceTicks; +- return this.ticketLevel == ticket.ticketLevel && Objects.equals(this.type, ticket.type) && Objects.equals(this.key, ticket.key); ++ return this.ticketLevel == ticket.ticketLevel && Objects.equals(this.type, ticket.type) && Objects.equals(this.key, ticket.key) && this.forceTicks == ticket.forceTicks; } } public int hashCode() { -- return Objects.hash(this.f_9420_, this.f_9421_, this.f_9422_); -+ return Objects.hash(this.f_9420_, this.f_9421_, this.f_9422_, forceTicks); +- return Objects.hash(this.type, this.ticketLevel, this.key); ++ return Objects.hash(this.type, this.ticketLevel, this.key, forceTicks); } public String toString() { -- return "Ticket[" + this.f_9420_ + " " + this.f_9421_ + " (" + this.f_9422_ + ")] at " + this.f_9423_; -+ return "Ticket[" + this.f_9420_ + " " + this.f_9421_ + " (" + this.f_9422_ + ")] at " + this.f_9423_ + " force ticks " + forceTicks; +- return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] at " + this.createdTick; ++ return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] at " + this.createdTick + " force ticks " + forceTicks; } - public TicketType m_9428_() { + public TicketType getType() { @@ -58,5 +_,12 @@ - protected boolean m_9434_(long p_9435_) { - long i = this.f_9420_.m_9469_(); - return i != 0L && p_9435_ - this.f_9423_ > i; + protected boolean timedOut(long p_9435_) { + long i = this.type.timeout(); + return i != 0L && p_9435_ - this.createdTick > i; + } + + /* ======================================== FORGE START =====================================*/ diff --git a/patches/minecraft/net/minecraft/server/level/TicketType.java.patch b/patches/minecraft/net/minecraft/server/level/TicketType.java.patch index b1418271..2aad2ac4 100644 --- a/patches/minecraft/net/minecraft/server/level/TicketType.java.patch +++ b/patches/minecraft/net/minecraft/server/level/TicketType.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java @@ -22,6 +_,8 @@ - public static final TicketType f_9447_ = m_9465_("portal", Vec3i::compareTo, 300); - public static final TicketType f_9448_ = m_9465_("post_teleport", Integer::compareTo, 5); - public static final TicketType f_9449_ = m_9465_("unknown", Comparator.comparingLong(ChunkPos::m_45588_), 1); -+ public static final TicketType PLUGIN = m_9462_("plugin", (a, b) -> 0); // CraftBukkit -+ public static final TicketType PLUGIN_TICKET = m_9462_("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit + public static final TicketType PORTAL = create("portal", Vec3i::compareTo, 300); + public static final TicketType POST_TELEPORT = create("post_teleport", Integer::compareTo, 5); + public static final TicketType UNKNOWN = create("unknown", Comparator.comparingLong(ChunkPos::toLong), 1); ++ public static final TicketType PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit ++ public static final TicketType PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit - public static TicketType m_9462_(String p_9463_, Comparator p_9464_) { + public static TicketType create(String p_9463_, Comparator p_9464_) { return new TicketType<>(p_9463_, p_9464_, 0L); diff --git a/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch b/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch index 195c9f56..cc2abfeb 100644 --- a/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/patches/minecraft/net/minecraft/server/level/WorldGenRegion.java.patch @@ -3,7 +3,7 @@ @@ -288,6 +_,13 @@ } - public boolean m_7967_(Entity p_9580_) { + public boolean addFreshEntity(Entity p_9580_) { + // CraftBukkit start + return addFreshEntity(p_9580_, p_9580_.spawnReason); + } @@ -11,6 +11,6 @@ + @Override + public boolean addFreshEntity(Entity p_9580_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end - int i = SectionPos.m_123171_(p_9580_.m_146903_()); - int j = SectionPos.m_123171_(p_9580_.m_146907_()); - this.m_6325_(i, j).m_6286_(p_9580_); + int i = SectionPos.blockToSectionCoord(p_9580_.getBlockX()); + int j = SectionPos.blockToSectionCoord(p_9580_.getBlockZ()); + this.getChunk(i, j).addEntity(p_9580_); diff --git a/patches/minecraft/net/minecraft/server/network/LegacyQueryHandler.java.patch b/patches/minecraft/net/minecraft/server/network/LegacyQueryHandler.java.patch index b3c4f7de..5e16e5ec 100644 --- a/patches/minecraft/net/minecraft/server/network/LegacyQueryHandler.java.patch +++ b/patches/minecraft/net/minecraft/server/network/LegacyQueryHandler.java.patch @@ -2,32 +2,32 @@ +++ b/net/minecraft/server/network/LegacyQueryHandler.java @@ -30,10 +_,11 @@ InetSocketAddress inetsocketaddress = (InetSocketAddress)p_9686_.channel().remoteAddress(); - MinecraftServer minecraftserver = this.f_9676_.m_9722_(); + MinecraftServer minecraftserver = this.serverConnectionListener.getServer(); int i = bytebuf.readableBytes(); -+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.m_129916_(), minecraftserver.m_7416_(), minecraftserver.m_7418_()); // CraftBukkit ++ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit switch(i) { case 0: - f_9675_.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); -- String s2 = String.format("%s\u00a7%d\u00a7%d", minecraftserver.m_129916_(), minecraftserver.m_7416_(), minecraftserver.m_7418_()); + LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); +- String s2 = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); + String s2 = String.format("%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit - this.m_9680_(p_9686_, this.m_9683_(s2)); + this.sendFlushAndClose(p_9686_, this.createReply(s2)); break; case 1: @@ -42,7 +_,7 @@ } - f_9675_.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); -- String s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.m_7630_(), minecraftserver.m_129916_(), minecraftserver.m_7416_(), minecraftserver.m_7418_()); -+ String s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.m_7630_(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit - this.m_9680_(p_9686_, this.m_9683_(s)); + LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); +- String s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); ++ String s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit + this.sendFlushAndClose(p_9686_, this.createReply(s)); break; default: @@ -59,7 +_,7 @@ } - f_9675_.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); -- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.m_7630_(), minecraftserver.m_129916_(), minecraftserver.m_7416_(), minecraftserver.m_7418_()); -+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.m_7630_(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit - ByteBuf bytebuf1 = this.m_9683_(s1); + LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); +- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); ++ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit + ByteBuf bytebuf1 = this.createReply(s1); try { diff --git a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch index 841d455e..1298e9e5 100644 --- a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch @@ -3,8 +3,8 @@ @@ -16,6 +_,7 @@ } - public void m_7322_(ClientIntentionPacket p_9697_) { -+ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9697_, this.f_9689_)) return; - this.f_9689_.m_129498_(p_9697_.m_134735_()); - this.f_9689_.m_129505_(new ServerLoginPacketListenerImpl(this.f_9688_, this.f_9689_)); + public void handleIntention(ClientIntentionPacket p_9697_) { ++ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9697_, this.connection)) return; + this.connection.setProtocol(p_9697_.getIntention()); + this.connection.setListener(new ServerLoginPacketListenerImpl(this.server, this.connection)); } diff --git a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch index d06e46fe..04f8df92 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -3,25 +3,25 @@ @@ -50,11 +_,12 @@ public class ServerConnectionListener { - private static final Logger f_9701_ = LogUtils.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); + private static final int READ_TIMEOUT = Integer.parseInt(System.getProperty("forge.readTimeout", "30")); - public static final LazyLoadedValue f_9698_ = new LazyLoadedValue<>(() -> { + public static final LazyLoadedValue SERVER_EVENT_GROUP = new LazyLoadedValue<>(() -> { - return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).build()); -+ return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(f_9701_)).build()); ++ return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); }); - public static final LazyLoadedValue f_9699_ = new LazyLoadedValue<>(() -> { + public static final LazyLoadedValue SERVER_EPOLL_EVENT_GROUP = new LazyLoadedValue<>(() -> { - return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build()); -+ return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(f_9701_)).build()); ++ return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); }); - final MinecraftServer f_9702_; - public volatile boolean f_9700_; + final MinecraftServer server; + public volatile boolean running; @@ -67,6 +_,8 @@ } - public void m_9711_(@Nullable InetAddress p_9712_, int p_9713_) throws IOException { + public void startTcpServerListener(@Nullable InetAddress p_9712_, int p_9713_) throws IOException { + if (p_9712_ == null) p_9712_ = new java.net.InetSocketAddress(p_9713_).getAddress(); + net.minecraftforge.network.DualStackUtils.checkIPv6(p_9712_); - synchronized(this.f_9703_) { + synchronized(this.channels) { Class oclass; LazyLoadedValue lazyloadedvalue; @@ -87,16 +_,26 @@ @@ -30,47 +30,47 @@ - p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this)).addLast("splitter", new Varint21FrameDecoder()).addLast("decoder", new PacketDecoder(PacketFlow.SERVERBOUND)).addLast("prepender", new Varint21LengthFieldPrepender()).addLast("encoder", new PacketEncoder(PacketFlow.CLIENTBOUND)); + p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(READ_TIMEOUT)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this)).addLast("splitter", new Varint21FrameDecoder()).addLast("decoder", new PacketDecoder(PacketFlow.SERVERBOUND)).addLast("prepender", new Varint21LengthFieldPrepender()).addLast("encoder", new PacketEncoder(PacketFlow.CLIENTBOUND)); - int i = ServerConnectionListener.this.f_9702_.m_7032_(); + int i = ServerConnectionListener.this.server.getRateLimitPacketsPerSecond(); Connection connection = (Connection)(i > 0 ? new RateKickingConnection(i) : new Connection(PacketFlow.SERVERBOUND)); - ServerConnectionListener.this.f_9704_.add(connection); + ServerConnectionListener.this.connections.add(connection); p_9729_.pipeline().addLast("packet_handler", connection); - connection.m_129505_(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.f_9702_, connection)); + connection.setListener(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, connection)); } -- }).group(lazyloadedvalue.m_13971_()).localAddress(p_9712_, p_9713_).bind().syncUninterruptibly()); +- }).group(lazyloadedvalue.get()).localAddress(p_9712_, p_9713_).bind().syncUninterruptibly()); - } - } -+ }).group(lazyloadedvalue.m_13971_()).localAddress(p_9712_, p_9713_).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit ++ }).group(lazyloadedvalue.get()).localAddress(p_9712_, p_9713_).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit + } + } + + // CraftBukkit start + public void acceptConnections() { -+ synchronized (this.f_9703_) { -+ for (ChannelFuture future : this.f_9703_) { ++ synchronized (this.channels) { ++ for (ChannelFuture future : this.channels) { + future.channel().config().setAutoRead(true); + } + } + } + // CraftBukkit end - public SocketAddress m_9708_() { + public SocketAddress startMemoryChannel() { ChannelFuture channelfuture; @@ -130,6 +_,13 @@ - public void m_9721_() { - synchronized(this.f_9704_) { + public void tick() { + synchronized(this.connections) { + // Spigot Start + // This prevents players from 'gaming' the server, and strategically relogging to increase their position in the tick order + if ( org.spigotmc.SpigotConfig.playerShuffle > 0 && MinecraftServer.currentTick % org.spigotmc.SpigotConfig.playerShuffle == 0 ) + { -+ Collections.shuffle( this.f_9704_ ); ++ Collections.shuffle( this.connections ); + } + // Spigot End - Iterator iterator = this.f_9704_.iterator(); + Iterator iterator = this.connections.iterator(); while(iterator.hasNext()) { @@ -151,6 +_,10 @@ - connection.m_129540_(); + connection.setReadOnly(); } } else { + // Spigot Start @@ -78,5 +78,5 @@ + if (connection.preparing) continue; + // Spigot End iterator.remove(); - connection.m_129541_(); + connection.handleDisconnection(); } diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 542ca191..63aa7b6f 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -4,134 +4,134 @@ import org.slf4j.Logger; public class ServerGamePacketListenerImpl implements ServerPlayerConnection, ServerGamePacketListener { -- static final Logger f_9744_ = LogUtils.getLogger(); -- private static final int f_143608_ = 15000; -- public final Connection f_9742_; -- private final MinecraftServer f_9745_; -- public ServerPlayer f_9743_; -- private int f_9746_; -- private long f_9747_; -- private boolean f_9748_; -- private long f_9749_; -- private int f_9750_; -- private int f_9751_; -- private double f_9753_; -- private double f_9754_; -- private double f_9755_; -- private double f_9756_; -- private double f_9757_; -- private double f_9758_; +- static final Logger LOGGER = LogUtils.getLogger(); +- private static final int LATENCY_CHECK_INTERVAL = 15000; +- public final Connection connection; +- private final MinecraftServer server; +- public ServerPlayer player; +- private int tickCount; +- private long keepAliveTime; +- private boolean keepAlivePending; +- private long keepAliveChallenge; +- private int chatSpamTickCount; +- private int dropSpamTickCount; +- private double firstGoodX; +- private double firstGoodY; +- private double firstGoodZ; +- private double lastGoodX; +- private double lastGoodY; +- private double lastGoodZ; - @Nullable -- private Entity f_9759_; -- private double f_9760_; -- private double f_9761_; -- private double f_9762_; -- private double f_9763_; -- private double f_9764_; -- private double f_9765_; +- private Entity lastVehicle; +- private double vehicleFirstGoodX; +- private double vehicleFirstGoodY; +- private double vehicleFirstGoodZ; +- private double vehicleLastGoodX; +- private double vehicleLastGoodY; +- private double vehicleLastGoodZ; - @Nullable -- private Vec3 f_9766_; -- private int f_9767_; -- private int f_9735_; -- private boolean f_9736_; -- private int f_9737_; -- private boolean f_9738_; -- private int f_9739_; -- private int f_9740_; -- private int f_9741_; +- private Vec3 awaitingPositionFromClient; +- private int awaitingTeleport; +- private int awaitingTeleportTime; +- private boolean clientIsFloating; +- private int aboveGroundTickCount; +- private boolean clientVehicleIsFloating; +- private int aboveGroundVehicleTickCount; +- private int receivedMovePacketCount; +- private int knownMovePacketCount; - - public ServerGamePacketListenerImpl(MinecraftServer p_9770_, Connection p_9771_, ServerPlayer p_9772_) { -- this.f_9745_ = p_9770_; -- this.f_9742_ = p_9771_; -- p_9771_.m_129505_(this); -- this.f_9743_ = p_9772_; -- p_9772_.f_8906_ = this; -- this.f_9747_ = Util.m_137550_(); -- p_9772_.m_8967_().m_7674_(); -- } -- -- public void m_9933_() { -- this.m_9953_(); -- this.f_9743_.f_19854_ = this.f_9743_.m_20185_(); -- this.f_9743_.f_19855_ = this.f_9743_.m_20186_(); -- this.f_9743_.f_19856_ = this.f_9743_.m_20189_(); -- this.f_9743_.m_9240_(); -- this.f_9743_.m_19890_(this.f_9753_, this.f_9754_, this.f_9755_, this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); -- ++this.f_9746_; -- this.f_9741_ = this.f_9740_; -- if (this.f_9736_ && !this.f_9743_.m_5803_() && !this.f_9743_.m_20159_()) { -- if (++this.f_9737_ > 80) { -- f_9744_.warn("{} was kicked for floating too long!", (Object)this.f_9743_.m_7755_().getString()); -- this.m_9942_(new TranslatableComponent("multiplayer.disconnect.flying")); +- this.server = p_9770_; +- this.connection = p_9771_; +- p_9771_.setListener(this); +- this.player = p_9772_; +- p_9772_.connection = this; +- this.keepAliveTime = Util.getMillis(); +- p_9772_.getTextFilter().join(); +- } +- +- public void tick() { +- this.resetPosition(); +- this.player.xo = this.player.getX(); +- this.player.yo = this.player.getY(); +- this.player.zo = this.player.getZ(); +- this.player.doTick(); +- this.player.absMoveTo(this.firstGoodX, this.firstGoodY, this.firstGoodZ, this.player.getYRot(), this.player.getXRot()); +- ++this.tickCount; +- this.knownMovePacketCount = this.receivedMovePacketCount; +- if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger()) { +- if (++this.aboveGroundTickCount > 80) { +- LOGGER.warn("{} was kicked for floating too long!", (Object)this.player.getName().getString()); +- this.disconnect(new TranslatableComponent("multiplayer.disconnect.flying")); - return; - } - } else { -- this.f_9736_ = false; -- this.f_9737_ = 0; +- this.clientIsFloating = false; +- this.aboveGroundTickCount = 0; - } - -- this.f_9759_ = this.f_9743_.m_20201_(); -- if (this.f_9759_ != this.f_9743_ && this.f_9759_.m_6688_() == this.f_9743_) { -- this.f_9760_ = this.f_9759_.m_20185_(); -- this.f_9761_ = this.f_9759_.m_20186_(); -- this.f_9762_ = this.f_9759_.m_20189_(); -- this.f_9763_ = this.f_9759_.m_20185_(); -- this.f_9764_ = this.f_9759_.m_20186_(); -- this.f_9765_ = this.f_9759_.m_20189_(); -- if (this.f_9738_ && this.f_9743_.m_20201_().m_6688_() == this.f_9743_) { -- if (++this.f_9739_ > 80) { -- f_9744_.warn("{} was kicked for floating a vehicle too long!", (Object)this.f_9743_.m_7755_().getString()); -- this.m_9942_(new TranslatableComponent("multiplayer.disconnect.flying")); +- this.lastVehicle = this.player.getRootVehicle(); +- if (this.lastVehicle != this.player && this.lastVehicle.getControllingPassenger() == this.player) { +- this.vehicleFirstGoodX = this.lastVehicle.getX(); +- this.vehicleFirstGoodY = this.lastVehicle.getY(); +- this.vehicleFirstGoodZ = this.lastVehicle.getZ(); +- this.vehicleLastGoodX = this.lastVehicle.getX(); +- this.vehicleLastGoodY = this.lastVehicle.getY(); +- this.vehicleLastGoodZ = this.lastVehicle.getZ(); +- if (this.clientVehicleIsFloating && this.player.getRootVehicle().getControllingPassenger() == this.player) { +- if (++this.aboveGroundVehicleTickCount > 80) { +- LOGGER.warn("{} was kicked for floating a vehicle too long!", (Object)this.player.getName().getString()); +- this.disconnect(new TranslatableComponent("multiplayer.disconnect.flying")); - return; - } - } else { -+ static final Logger f_9744_ = LogUtils.getLogger(); -+ private static final int f_143608_ = 15000; -+ public final Connection f_9742_; -+ private final MinecraftServer f_9745_; -+ public ServerPlayer f_9743_; -+ private int f_9746_; -+ private long f_9747_; -+ private boolean f_9748_; -+ private long f_9749_; ++ static final Logger LOGGER = LogUtils.getLogger(); ++ private static final int LATENCY_CHECK_INTERVAL = 15000; ++ public final Connection connection; ++ private final MinecraftServer server; ++ public ServerPlayer player; ++ private int tickCount; ++ private long keepAliveTime; ++ private boolean keepAlivePending; ++ private long keepAliveChallenge; + //Magma start - remove craftbukkit multithreading -+ public int f_9750_; ++ public int chatSpamTickCount; + //Magma end -+ private int f_9751_; -+ private double f_9753_; -+ private double f_9754_; -+ private double f_9755_; -+ private double f_9756_; -+ private double f_9757_; -+ private double f_9758_; ++ private int dropSpamTickCount; ++ private double firstGoodX; ++ private double firstGoodY; ++ private double firstGoodZ; ++ private double lastGoodX; ++ private double lastGoodY; ++ private double lastGoodZ; + @Nullable -+ private Entity f_9759_; -+ private double f_9760_; -+ private double f_9761_; -+ private double f_9762_; -+ private double f_9763_; -+ private double f_9764_; -+ private double f_9765_; ++ private Entity lastVehicle; ++ private double vehicleFirstGoodX; ++ private double vehicleFirstGoodY; ++ private double vehicleFirstGoodZ; ++ private double vehicleLastGoodX; ++ private double vehicleLastGoodY; ++ private double vehicleLastGoodZ; + @Nullable -+ private Vec3 f_9766_; -+ private int f_9767_; -+ private int f_9735_; -+ private boolean f_9736_; -+ private int f_9737_; -+ private boolean f_9738_; -+ private int f_9739_; -+ private int f_9740_; -+ private int f_9741_; ++ private Vec3 awaitingPositionFromClient; ++ private int awaitingTeleport; ++ private int awaitingTeleportTime; ++ private boolean clientIsFloating; ++ private int aboveGroundTickCount; ++ private boolean clientVehicleIsFloating; ++ private int aboveGroundVehicleTickCount; ++ private int receivedMovePacketCount; ++ private int knownMovePacketCount; + + + public ServerGamePacketListenerImpl(MinecraftServer p_9770_, Connection p_9771_, ServerPlayer p_9772_) { -+ this.f_9745_ = p_9770_; -+ this.f_9742_ = p_9771_; -+ p_9771_.m_129505_( this ); -+ this.f_9743_ = p_9772_; -+ p_9772_.f_8906_ = this; -+ this.f_9747_ = Util.m_137550_(); -+ p_9772_.m_8967_().m_7674_(); ++ this.server = p_9770_; ++ this.connection = p_9771_; ++ p_9771_.setListener( this ); ++ this.player = p_9772_; ++ p_9772_.connection = this; ++ this.keepAliveTime = Util.getMillis(); ++ p_9772_.getTextFilter().join(); + + // CraftBukkit start - add fields and methods + this.cserver = p_9770_.server; @@ -155,212 +155,212 @@ + private boolean hasMoved; // Spigot + + public org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer getCraftPlayer() { -+ return (this.f_9743_ == null) ? null : (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) this.f_9743_.getBukkitEntity(); ++ return (this.player == null) ? null : (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) this.player.getBukkitEntity(); + } + // CraftBukkit end + -+ public void m_9933_() { -+ this.m_9953_(); -+ this.f_9743_.f_19854_ = this.f_9743_.m_20185_(); -+ this.f_9743_.f_19855_ = this.f_9743_.m_20186_(); -+ this.f_9743_.f_19856_ = this.f_9743_.m_20189_(); -+ this.f_9743_.m_9240_(); -+ this.f_9743_.m_19890_( this.f_9753_, this.f_9754_, this.f_9755_, this.f_9743_.m_146908_(), this.f_9743_.m_146909_() ); -+ ++this.f_9746_; -+ this.f_9741_ = this.f_9740_; -+ if (this.f_9736_ && !this.f_9743_.m_5803_() && !this.f_9743_.m_20159_()) { -+ if (++this.f_9737_ > 80) { -+ f_9744_.warn( "{} was kicked for floating too long!", (Object) this.f_9743_.m_7755_().getString() ); -+ this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.flying" ) ); ++ public void tick() { ++ this.resetPosition(); ++ this.player.xo = this.player.getX(); ++ this.player.yo = this.player.getY(); ++ this.player.zo = this.player.getZ(); ++ this.player.doTick(); ++ this.player.absMoveTo( this.firstGoodX, this.firstGoodY, this.firstGoodZ, this.player.getYRot(), this.player.getXRot() ); ++ ++this.tickCount; ++ this.knownMovePacketCount = this.receivedMovePacketCount; ++ if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger()) { ++ if (++this.aboveGroundTickCount > 80) { ++ LOGGER.warn( "{} was kicked for floating too long!", (Object) this.player.getName().getString() ); ++ this.disconnect( new TranslatableComponent( "multiplayer.disconnect.flying" ) ); + return; + } + } else { -+ this.f_9736_ = false; -+ this.f_9737_ = 0; -+ } -+ -+ this.f_9759_ = this.f_9743_.m_20201_(); -+ if (this.f_9759_ != this.f_9743_ && this.f_9759_.m_6688_() == this.f_9743_) { -+ this.f_9760_ = this.f_9759_.m_20185_(); -+ this.f_9761_ = this.f_9759_.m_20186_(); -+ this.f_9762_ = this.f_9759_.m_20189_(); -+ this.f_9763_ = this.f_9759_.m_20185_(); -+ this.f_9764_ = this.f_9759_.m_20186_(); -+ this.f_9765_ = this.f_9759_.m_20189_(); -+ if (this.f_9738_ && this.f_9743_.m_20201_().m_6688_() == this.f_9743_) { -+ if (++this.f_9739_ > 80) { -+ f_9744_.warn( "{} was kicked for floating a vehicle too long!", (Object) this.f_9743_.m_7755_().getString() ); -+ this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.flying" ) ); ++ this.clientIsFloating = false; ++ this.aboveGroundTickCount = 0; ++ } ++ ++ this.lastVehicle = this.player.getRootVehicle(); ++ if (this.lastVehicle != this.player && this.lastVehicle.getControllingPassenger() == this.player) { ++ this.vehicleFirstGoodX = this.lastVehicle.getX(); ++ this.vehicleFirstGoodY = this.lastVehicle.getY(); ++ this.vehicleFirstGoodZ = this.lastVehicle.getZ(); ++ this.vehicleLastGoodX = this.lastVehicle.getX(); ++ this.vehicleLastGoodY = this.lastVehicle.getY(); ++ this.vehicleLastGoodZ = this.lastVehicle.getZ(); ++ if (this.clientVehicleIsFloating && this.player.getRootVehicle().getControllingPassenger() == this.player) { ++ if (++this.aboveGroundVehicleTickCount > 80) { ++ LOGGER.warn( "{} was kicked for floating a vehicle too long!", (Object) this.player.getName().getString() ); ++ this.disconnect( new TranslatableComponent( "multiplayer.disconnect.flying" ) ); + return; + } + } else { -+ this.f_9738_ = false; -+ this.f_9739_ = 0; ++ this.clientVehicleIsFloating = false; ++ this.aboveGroundVehicleTickCount = 0; + } + } else { -+ this.f_9759_ = null; - this.f_9738_ = false; - this.f_9739_ = 0; ++ this.lastVehicle = null; + this.clientVehicleIsFloating = false; + this.aboveGroundVehicleTickCount = 0; - } - } else { -- this.f_9759_ = null; -- this.f_9738_ = false; -- this.f_9739_ = 0; +- this.lastVehicle = null; +- this.clientVehicleIsFloating = false; +- this.aboveGroundVehicleTickCount = 0; - } - -- this.f_9745_.m_129905_().m_6180_("keepAlive"); -- long i = Util.m_137550_(); -- if (i - this.f_9747_ >= 15000L) { -- if (this.f_9748_) { -- this.m_9942_(new TranslatableComponent("disconnect.timeout")); +- this.server.getProfiler().push("keepAlive"); +- long i = Util.getMillis(); +- if (i - this.keepAliveTime >= 15000L) { +- if (this.keepAlivePending) { +- this.disconnect(new TranslatableComponent("disconnect.timeout")); - } else { -- this.f_9748_ = true; -- this.f_9747_ = i; -- this.f_9749_ = i; -- this.m_141995_(new ClientboundKeepAlivePacket(this.f_9749_)); +- this.keepAlivePending = true; +- this.keepAliveTime = i; +- this.keepAliveChallenge = i; +- this.send(new ClientboundKeepAlivePacket(this.keepAliveChallenge)); - } - } - -- this.f_9745_.m_129905_().m_7238_(); -- if (this.f_9750_ > 0) { -- --this.f_9750_; +- this.server.getProfiler().pop(); +- if (this.chatSpamTickCount > 0) { +- --this.chatSpamTickCount; - } - -- if (this.f_9751_ > 0) { -- --this.f_9751_; +- if (this.dropSpamTickCount > 0) { +- --this.dropSpamTickCount; - } - -- if (this.f_9743_.m_8956_() > 0L && this.f_9745_.m_129924_() > 0 && Util.m_137550_() - this.f_9743_.m_8956_() > (long)(this.f_9745_.m_129924_() * 1000 * 60)) { -- this.m_9942_(new TranslatableComponent("multiplayer.disconnect.idling")); +- if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long)(this.server.getPlayerIdleTimeout() * 1000 * 60)) { +- this.disconnect(new TranslatableComponent("multiplayer.disconnect.idling")); - } - - } - -- public void m_9953_() { -- this.f_9753_ = this.f_9743_.m_20185_(); -- this.f_9754_ = this.f_9743_.m_20186_(); -- this.f_9755_ = this.f_9743_.m_20189_(); -- this.f_9756_ = this.f_9743_.m_20185_(); -- this.f_9757_ = this.f_9743_.m_20186_(); -- this.f_9758_ = this.f_9743_.m_20189_(); +- public void resetPosition() { +- this.firstGoodX = this.player.getX(); +- this.firstGoodY = this.player.getY(); +- this.firstGoodZ = this.player.getZ(); +- this.lastGoodX = this.player.getX(); +- this.lastGoodY = this.player.getY(); +- this.lastGoodZ = this.player.getZ(); - } - -- public Connection m_6198_() { -- return this.f_9742_; +- public Connection getConnection() { +- return this.connection; - } - -- private boolean m_9956_() { -- return this.f_9745_.m_7779_(this.f_9743_.m_36316_()); +- private boolean isSingleplayerOwner() { +- return this.server.isSingleplayerOwner(this.player.getGameProfile()); - } - -- public void m_9942_(Component p_9943_) { -- this.f_9742_.m_129514_(new ClientboundDisconnectPacket(p_9943_), (p_9828_) -> { -- this.f_9742_.m_129507_(p_9943_); +- public void disconnect(Component p_9943_) { +- this.connection.send(new ClientboundDisconnectPacket(p_9943_), (p_9828_) -> { +- this.connection.disconnect(p_9943_); - }); -- this.f_9742_.m_129540_(); -- this.f_9745_.m_18709_(this.f_9742_::m_129541_); +- this.connection.setReadOnly(); +- this.server.executeBlocking(this.connection::handleDisconnection); - } - -- private void m_9801_(T p_9802_, Consumer p_9803_, BiFunction> p_9804_) { -- BlockableEventLoop blockableeventloop = this.f_9743_.m_183503_().m_142572_(); +- private void filterTextPacket(T p_9802_, Consumer p_9803_, BiFunction> p_9804_) { +- BlockableEventLoop blockableeventloop = this.player.getLevel().getServer(); - Consumer consumer = (p_201923_) -> { -- if (this.m_6198_().m_129536_()) { +- if (this.getConnection().isConnected()) { - try { - p_9803_.accept(p_201923_); - } catch (Exception exception) { -- f_9744_.error("Failed to handle chat packet {}, suppressing error", p_9802_, exception); +- LOGGER.error("Failed to handle chat packet {}, suppressing error", p_9802_, exception); - } - } else { -- f_9744_.debug("Ignoring packet due to disconnection"); +- LOGGER.debug("Ignoring packet due to disconnection"); - } - - }; -- p_9804_.apply(this.f_9743_.m_8967_(), p_9802_).thenAcceptAsync(consumer, blockableeventloop); +- p_9804_.apply(this.player.getTextFilter(), p_9802_).thenAcceptAsync(consumer, blockableeventloop); - } - -- private void m_9809_(String p_9810_, Consumer p_9811_) { -- this.m_9801_(p_9810_, p_9811_, TextFilter::m_6770_); +- private void filterTextPacket(String p_9810_, Consumer p_9811_) { +- this.filterTextPacket(p_9810_, p_9811_, TextFilter::processStreamMessage); - } - -- private void m_9815_(List p_9816_, Consumer> p_9817_) { -- this.m_9801_(p_9816_, p_9817_, TextFilter::m_5925_); +- private void filterTextPacket(List p_9816_, Consumer> p_9817_) { +- this.filterTextPacket(p_9816_, p_9817_, TextFilter::processMessageBundle); - } - -- public void m_5918_(ServerboundPlayerInputPacket p_9893_) { -- PacketUtils.m_131359_(p_9893_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_8980_(p_9893_.m_134355_(), p_9893_.m_134358_(), p_9893_.m_134359_(), p_9893_.m_134360_()); +- public void handlePlayerInput(ServerboundPlayerInputPacket p_9893_) { +- PacketUtils.ensureRunningOnSameThread(p_9893_, this, this.player.getLevel()); +- this.player.setPlayerInput(p_9893_.getXxa(), p_9893_.getZza(), p_9893_.isJumping(), p_9893_.isShiftKeyDown()); - } - -- private static boolean m_143663_(double p_143664_, double p_143665_, double p_143666_, float p_143667_, float p_143668_) { +- private static boolean containsInvalidValues(double p_143664_, double p_143665_, double p_143666_, float p_143667_, float p_143668_) { - return Double.isNaN(p_143664_) || Double.isNaN(p_143665_) || Double.isNaN(p_143666_) || !Floats.isFinite(p_143668_) || !Floats.isFinite(p_143667_); - } - -- private static double m_143609_(double p_143610_) { -- return Mth.m_14008_(p_143610_, -3.0E7D, 3.0E7D); +- private static double clampHorizontal(double p_143610_) { +- return Mth.clamp(p_143610_, -3.0E7D, 3.0E7D); - } - -- private static double m_143653_(double p_143654_) { -- return Mth.m_14008_(p_143654_, -2.0E7D, 2.0E7D); +- private static double clampVertical(double p_143654_) { +- return Mth.clamp(p_143654_, -2.0E7D, 2.0E7D); - } - -- public void m_5659_(ServerboundMoveVehiclePacket p_9876_) { -- PacketUtils.m_131359_(p_9876_, this, this.f_9743_.m_183503_()); -- if (m_143663_(p_9876_.m_134199_(), p_9876_.m_134202_(), p_9876_.m_134203_(), p_9876_.m_134204_(), p_9876_.m_134205_())) { -- this.m_9942_(new TranslatableComponent("multiplayer.disconnect.invalid_vehicle_movement")); +- public void handleMoveVehicle(ServerboundMoveVehiclePacket p_9876_) { +- PacketUtils.ensureRunningOnSameThread(p_9876_, this, this.player.getLevel()); +- if (containsInvalidValues(p_9876_.getX(), p_9876_.getY(), p_9876_.getZ(), p_9876_.getYRot(), p_9876_.getXRot())) { +- this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_vehicle_movement")); - } else { -- Entity entity = this.f_9743_.m_20201_(); -- if (entity != this.f_9743_ && entity.m_6688_() == this.f_9743_ && entity == this.f_9759_) { +- Entity entity = this.player.getRootVehicle(); +- if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { + } + -+ this.f_9745_.m_129905_().m_6180_( "keepAlive" ); -+ long i = Util.m_137550_(); -+ if (i - this.f_9747_ >= 25000L) { // CraftBukkit -+ if (this.f_9748_) { -+ this.m_9942_( new TranslatableComponent( "disconnect.timeout" ) ); ++ this.server.getProfiler().push( "keepAlive" ); ++ long i = Util.getMillis(); ++ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit ++ if (this.keepAlivePending) { ++ this.disconnect( new TranslatableComponent( "disconnect.timeout" ) ); + } else { -+ this.f_9748_ = true; -+ this.f_9747_ = i; -+ this.f_9749_ = i; -+ this.m_141995_( new ClientboundKeepAlivePacket( this.f_9749_ ) ); ++ this.keepAlivePending = true; ++ this.keepAliveTime = i; ++ this.keepAliveChallenge = i; ++ this.send( new ClientboundKeepAlivePacket( this.keepAliveChallenge ) ); + } + } + -+ this.f_9745_.m_129905_().m_7238_(); -+ if (this.f_9750_ > 0) { -+ --this.f_9750_; ++ this.server.getProfiler().pop(); ++ if (this.chatSpamTickCount > 0) { ++ --this.chatSpamTickCount; + } + -+ if (this.f_9751_ > 0) { -+ --this.f_9751_; ++ if (this.dropSpamTickCount > 0) { ++ --this.dropSpamTickCount; + } + -+ if (this.f_9743_.m_8956_() > 0L && this.f_9745_.m_129924_() > 0 && Util.m_137550_() - this.f_9743_.m_8956_() > (long) (this.f_9745_.m_129924_() * 1000 * 60)) { -+ this.f_9743_.m_9243_(); // CraftBukkit - SPIGOT-854 -+ this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.idling" ) ); ++ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) { ++ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 ++ this.disconnect( new TranslatableComponent( "multiplayer.disconnect.idling" ) ); + } + + } + -+ public void m_9953_() { -+ this.f_9753_ = this.f_9743_.m_20185_(); -+ this.f_9754_ = this.f_9743_.m_20186_(); -+ this.f_9755_ = this.f_9743_.m_20189_(); -+ this.f_9756_ = this.f_9743_.m_20185_(); -+ this.f_9757_ = this.f_9743_.m_20186_(); -+ this.f_9758_ = this.f_9743_.m_20189_(); ++ public void resetPosition() { ++ this.firstGoodX = this.player.getX(); ++ this.firstGoodY = this.player.getY(); ++ this.firstGoodZ = this.player.getZ(); ++ this.lastGoodX = this.player.getX(); ++ this.lastGoodY = this.player.getY(); ++ this.lastGoodZ = this.player.getZ(); + } + -+ public Connection m_6198_() { -+ return this.f_9742_; ++ public Connection getConnection() { ++ return this.connection; + } + -+ private boolean m_9956_() { -+ return this.f_9745_.m_7779_( this.f_9743_.m_36316_() ); ++ private boolean isSingleplayerOwner() { ++ return this.server.isSingleplayerOwner( this.player.getGameProfile() ); + } + + // CraftBukkit start + @Deprecated -+ public void m_9942_(Component p_9943_) { ++ public void disconnect(Component p_9943_) { + disconnect(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(p_9943_)); + } + @@ -370,11 +370,11 @@ + if (this.processedDisconnect) { + return; + } -+ String leaveMessage = ChatFormatting.YELLOW + this.f_9743_.m_6302_() + " left the game"; ++ String leaveMessage = ChatFormatting.YELLOW + this.player.getScoreboardName() + " left the game"; + -+ org.bukkit.event.player.PlayerKickEvent event = new org.bukkit.event.player.PlayerKickEvent(this.f_9743_.getBukkitEntity(), s, leaveMessage); ++ org.bukkit.event.player.PlayerKickEvent event = new org.bukkit.event.player.PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage); + -+ if (this.cserver.getServer().m_130010_()) { ++ if (this.cserver.getServer().isRunning()) { + this.cserver.getPluginManager().callEvent(event); + } + @@ -382,7 +382,7 @@ + // Do not kick the player + return; + } -+ this.f_9743_.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent ++ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent + // Send the possibly modified leave message + doDisconnect(event.getReason());//Magma extract actual disconnect into seperate method + } @@ -393,77 +393,77 @@ + final Component p_9943_ = org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(s, true)[0]; + // CraftBukkit end + -+ this.f_9742_.m_129514_( new ClientboundDisconnectPacket( p_9943_ ), (p_9828_) -> { -+ this.f_9742_.m_129507_( p_9943_ ); ++ this.connection.send( new ClientboundDisconnectPacket( p_9943_ ), (p_9828_) -> { ++ this.connection.disconnect( p_9943_ ); + } ); -+ this.m_7026_(p_9943_); // CraftBukkit - fire quit instantly -+ this.f_9742_.m_129540_(); ++ this.onDisconnect(p_9943_); // CraftBukkit - fire quit instantly ++ this.connection.setReadOnly(); + // CraftBukkit - Don't wait -+ this.f_9745_.m_6681_(this.f_9742_::m_129541_); ++ this.server.wrapRunnable(this.connection::handleDisconnection); + } + -+ private void m_9801_(T p_9802_, Consumer p_9803_, BiFunction> p_9804_) { -+ BlockableEventLoop blockableeventloop = this.f_9743_.m_183503_().m_142572_(); ++ private void filterTextPacket(T p_9802_, Consumer p_9803_, BiFunction> p_9804_) { ++ BlockableEventLoop blockableeventloop = this.player.getLevel().getServer(); + Consumer consumer = (p_201923_) -> { -+ if (this.m_6198_().m_129536_()) { ++ if (this.getConnection().isConnected()) { + try { + p_9803_.accept( p_201923_ ); + } catch (Exception exception) { -+ f_9744_.error( "Failed to handle chat packet {}, suppressing error", p_9802_, exception ); ++ LOGGER.error( "Failed to handle chat packet {}, suppressing error", p_9802_, exception ); + } + } else { -+ f_9744_.debug( "Ignoring packet due to disconnection" ); ++ LOGGER.debug( "Ignoring packet due to disconnection" ); + } + + }; -+ p_9804_.apply( this.f_9743_.m_8967_(), p_9802_ ).thenAcceptAsync( consumer, blockableeventloop ); ++ p_9804_.apply( this.player.getTextFilter(), p_9802_ ).thenAcceptAsync( consumer, blockableeventloop ); + } + -+ private void m_9809_(String p_9810_, Consumer p_9811_) { -+ this.m_9801_( p_9810_, p_9811_, TextFilter::m_6770_ ); ++ private void filterTextPacket(String p_9810_, Consumer p_9811_) { ++ this.filterTextPacket( p_9810_, p_9811_, TextFilter::processStreamMessage ); + } + -+ private void m_9815_(List p_9816_, Consumer> p_9817_) { -+ this.m_9801_( p_9816_, p_9817_, TextFilter::m_5925_ ); ++ private void filterTextPacket(List p_9816_, Consumer> p_9817_) { ++ this.filterTextPacket( p_9816_, p_9817_, TextFilter::processMessageBundle ); + } + -+ public void m_5918_(ServerboundPlayerInputPacket p_9893_) { -+ PacketUtils.m_131359_( p_9893_, this, this.f_9743_.m_183503_() ); -+ this.f_9743_.m_8980_( p_9893_.m_134355_(), p_9893_.m_134358_(), p_9893_.m_134359_(), p_9893_.m_134360_() ); ++ public void handlePlayerInput(ServerboundPlayerInputPacket p_9893_) { ++ PacketUtils.ensureRunningOnSameThread( p_9893_, this, this.player.getLevel() ); ++ this.player.setPlayerInput( p_9893_.getXxa(), p_9893_.getZza(), p_9893_.isJumping(), p_9893_.isShiftKeyDown() ); + } + -+ private static boolean m_143663_(double p_143664_, double p_143665_, double p_143666_, float p_143667_, float p_143668_) { ++ private static boolean containsInvalidValues(double p_143664_, double p_143665_, double p_143666_, float p_143667_, float p_143668_) { + return Double.isNaN( p_143664_ ) || Double.isNaN( p_143665_ ) || Double.isNaN( p_143666_ ) || !Floats.isFinite( p_143668_ ) || !Floats.isFinite( p_143667_ ); + } + -+ private static double m_143609_(double p_143610_) { -+ return Mth.m_14008_( p_143610_, -3.0E7D, 3.0E7D ); ++ private static double clampHorizontal(double p_143610_) { ++ return Mth.clamp( p_143610_, -3.0E7D, 3.0E7D ); + } + -+ private static double m_143653_(double p_143654_) { -+ return Mth.m_14008_( p_143654_, -2.0E7D, 2.0E7D ); ++ private static double clampVertical(double p_143654_) { ++ return Mth.clamp( p_143654_, -2.0E7D, 2.0E7D ); + } + -+ public void m_5659_(ServerboundMoveVehiclePacket p_9876_) { -+ PacketUtils.m_131359_( p_9876_, this, this.f_9743_.m_183503_() ); -+ if (m_143663_( p_9876_.m_134199_(), p_9876_.m_134202_(), p_9876_.m_134203_(), p_9876_.m_134204_(), p_9876_.m_134205_() )) { -+ this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.invalid_vehicle_movement" ) ); ++ public void handleMoveVehicle(ServerboundMoveVehiclePacket p_9876_) { ++ PacketUtils.ensureRunningOnSameThread( p_9876_, this, this.player.getLevel() ); ++ if (containsInvalidValues( p_9876_.getX(), p_9876_.getY(), p_9876_.getZ(), p_9876_.getYRot(), p_9876_.getXRot() )) { ++ this.disconnect( new TranslatableComponent( "multiplayer.disconnect.invalid_vehicle_movement" ) ); + } else { -+ Entity entity = this.f_9743_.m_20201_(); -+ if (entity != this.f_9743_ && entity.m_6688_() == this.f_9743_ && entity == this.f_9759_) { -+ ServerLevel serverlevel = this.f_9743_.m_183503_(); -+ double d0 = entity.m_20185_(); -+ double d1 = entity.m_20186_(); -+ double d2 = entity.m_20189_(); -+ double d3 = m_143609_( p_9876_.m_134199_() ); -+ double d4 = m_143653_( p_9876_.m_134202_() ); -+ double d5 = m_143609_( p_9876_.m_134203_() ); -+ float f = Mth.m_14177_( p_9876_.m_134204_() ); -+ float f1 = Mth.m_14177_( p_9876_.m_134205_() ); -+ double d6 = d3 - this.f_9760_; -+ double d7 = d4 - this.f_9761_; -+ double d8 = d5 - this.f_9762_; -+ double d9 = entity.m_20184_().m_82556_(); ++ Entity entity = this.player.getRootVehicle(); ++ if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { ++ ServerLevel serverlevel = this.player.getLevel(); ++ double d0 = entity.getX(); ++ double d1 = entity.getY(); ++ double d2 = entity.getZ(); ++ double d3 = clampHorizontal( p_9876_.getX() ); ++ double d4 = clampVertical( p_9876_.getY() ); ++ double d5 = clampHorizontal( p_9876_.getZ() ); ++ float f = Mth.wrapDegrees( p_9876_.getYRot() ); ++ float f1 = Mth.wrapDegrees( p_9876_.getXRot() ); ++ double d6 = d3 - this.vehicleFirstGoodX; ++ double d7 = d4 - this.vehicleFirstGoodY; ++ double d8 = d5 - this.vehicleFirstGoodZ; ++ double d9 = entity.getDeltaMovement().lengthSqr(); + double d10 = d6 * d6 + d7 * d7 + d8 * d8; + + // CraftBukkit start - handle custom speeds and skipped ticks @@ -471,10 +471,10 @@ + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); + this.lastTick = (int) (System.currentTimeMillis() / 50); + -+ ++this.f_9740_; -+ int i = this.f_9740_ - this.f_9741_; ++ ++this.receivedMovePacketCount; ++ int i = this.receivedMovePacketCount - this.knownMovePacketCount; + if (i > Math.max(this.allowedPlayerTicks, 5)) { -+ ServerGamePacketListenerImpl.f_9744_.debug(this.f_9743_.m_6302_() + " is sending move packets too frequently (" + i + " packets since last tick)"); ++ ServerGamePacketListenerImpl.LOGGER.debug(this.player.getScoreboardName() + " is sending move packets too frequently (" + i + " packets since last tick)"); + i = 1; + } + @@ -484,51 +484,51 @@ + allowedPlayerTicks = 20; + } + double speed; -+ if (f_9743_.m_150110_().f_35935_) { -+ speed = f_9743_.m_150110_().f_35939_ * 20f; ++ if (player.getAbilities().flying) { ++ speed = player.getAbilities().flyingSpeed * 20f; + } else { -+ speed = f_9743_.m_150110_().f_35940_ * 10f; ++ speed = player.getAbilities().walkingSpeed * 10f; + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + -+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.m_9956_()) { ++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { + // CraftBukkit end -+ f_9744_.warn( "{} (vehicle of {}) moved too quickly! {},{},{}", entity.m_7755_().getString(), this.f_9743_.m_7755_().getString(), d6, d7, d8 ); -+ this.f_9742_.m_129512_( new ClientboundMoveVehiclePacket( entity ) ); ++ LOGGER.warn( "{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8 ); ++ this.connection.send( new ClientboundMoveVehiclePacket( entity ) ); + return; + } + -+ boolean flag = serverlevel.m_45756_( entity, entity.m_142469_().m_82406_( 0.0625D ) ); -+ d6 = d3 - this.f_9763_; -+ d7 = d4 - this.f_9764_ - 1.0E-6D; -+ d8 = d5 - this.f_9765_; -+ boolean flag1 = entity.f_201939_; -+ entity.m_6478_( MoverType.PLAYER, new Vec3( d6, d7, d8 ) ); -+ d6 = d3 - entity.m_20185_(); -+ d7 = d4 - entity.m_20186_(); ++ boolean flag = serverlevel.noCollision( entity, entity.getBoundingBox().deflate( 0.0625D ) ); ++ d6 = d3 - this.vehicleLastGoodX; ++ d7 = d4 - this.vehicleLastGoodY - 1.0E-6D; ++ d8 = d5 - this.vehicleLastGoodZ; ++ boolean flag1 = entity.verticalCollisionBelow; ++ entity.move( MoverType.PLAYER, new Vec3( d6, d7, d8 ) ); ++ d6 = d3 - entity.getX(); ++ d7 = d4 - entity.getY(); + if (d7 > -0.5D || d7 < 0.5D) { + d7 = 0.0D; + } + -+ d8 = d5 - entity.m_20189_(); ++ d8 = d5 - entity.getZ(); + d10 = d6 * d6 + d7 * d7 + d8 * d8; + boolean flag2 = false; + + if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot + flag2 = true; -+ f_9744_.warn( "{} (vehicle of {}) moved wrongly! {}", entity.m_7755_().getString(), this.f_9743_.m_7755_().getString(), Math.sqrt( d10 ) ); ++ LOGGER.warn( "{} (vehicle of {}) moved wrongly! {}", entity.getName().getString(), this.player.getName().getString(), Math.sqrt( d10 ) ); + } + org.bukkit.Location curPos = this.getCraftPlayer().getLocation(); // Spigot + -+ entity.m_19890_( d3, d4, d5, f, f1 ); -+ f_9743_.m_19890_(d3, d4, d5, this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); // CraftBukkit -+ this.f_9743_.m_19890_( d3, d4, d5, this.f_9743_.m_146908_(), this.f_9743_.m_146909_() ); // Forge - Resync player position on vehicle moving -+ boolean flag3 = serverlevel.m_45756_( entity, entity.m_142469_().m_82406_( 0.0625D ) ); ++ entity.absMoveTo( d3, d4, d5, f, f1 ); ++ player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit ++ this.player.absMoveTo( d3, d4, d5, this.player.getYRot(), this.player.getXRot() ); // Forge - Resync player position on vehicle moving ++ boolean flag3 = serverlevel.noCollision( entity, entity.getBoundingBox().deflate( 0.0625D ) ); + if (flag && (flag2 || !flag3)) { -+ entity.m_19890_( d0, d1, d2, f, f1 ); -+ f_9743_.m_19890_(d0, d1, d2, this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); // CraftBukkit -+ this.f_9743_.m_19890_( d3, d4, d5, this.f_9743_.m_146908_(), this.f_9743_.m_146909_() ); // Forge - Resync player position on vehicle moving -+ this.f_9742_.m_129512_( new ClientboundMoveVehiclePacket( entity ) ); ++ entity.absMoveTo( d0, d1, d2, f, f1 ); ++ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit ++ this.player.absMoveTo( d3, d4, d5, this.player.getYRot(), this.player.getXRot() ); // Forge - Resync player position on vehicle moving ++ this.connection.send( new ClientboundMoveVehiclePacket( entity ) ); + return; + } + @@ -549,19 +549,19 @@ + org.bukkit.Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + + // If the packet contains movement information then we update the To location with the correct XYZ. -+ to.setX(p_9876_.m_134199_()); -+ to.setY(p_9876_.m_134202_()); -+ to.setZ(p_9876_.m_134203_()); ++ to.setX(p_9876_.getX()); ++ to.setY(p_9876_.getY()); ++ to.setZ(p_9876_.getZ()); + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ to.setYaw(p_9876_.m_134204_()); -+ to.setPitch(p_9876_.m_134205_()); ++ to.setYaw(p_9876_.getYRot()); ++ to.setPitch(p_9876_.getXRot()); + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.f_9743_.m_6107_()) { ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); @@ -584,7 +584,7 @@ + // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. + // We only do this if the org.bukkit.event.Event was not cancelled. + if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { -+ this.f_9743_.getBukkitEntity().teleport(event.getTo(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.PLUGIN); ++ this.player.getBukkitEntity().teleport(event.getTo(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.PLUGIN); + return; + } + @@ -598,303 +598,303 @@ + } + // CraftBukkit end + -+ this.f_9743_.m_183503_().m_7726_().m_8385_( this.f_9743_ ); -+ this.f_9743_.m_36378_( this.f_9743_.m_20185_() - d0, this.f_9743_.m_20186_() - d1, this.f_9743_.m_20189_() - d2 ); -+ this.f_9738_ = d7 >= -0.03125D && !flag1 && !this.f_9745_.m_129915_() && !entity.m_20068_() && this.m_9793_( entity ); -+ this.f_9763_ = entity.m_20185_(); -+ this.f_9764_ = entity.m_20186_(); -+ this.f_9765_ = entity.m_20189_(); ++ this.player.getLevel().getChunkSource().move( this.player ); ++ this.player.checkMovementStatistics( this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2 ); ++ this.clientVehicleIsFloating = d7 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround( entity ); ++ this.vehicleLastGoodX = entity.getX(); ++ this.vehicleLastGoodY = entity.getY(); ++ this.vehicleLastGoodZ = entity.getZ(); + } + + } + } + -+ private boolean m_9793_(Entity p_9794_) { -+ return BlockPos.m_121921_( p_9794_.m_142469_().m_82400_( 0.0625D ).m_82363_( 0.0D, -0.55D, 0.0D ) ).allMatch( b -> p_9794_.f_19853_.m_8055_( b ).m_60795_() ); ++ private boolean noBlocksAround(Entity p_9794_) { ++ return BlockPos.betweenClosedStream( p_9794_.getBoundingBox().inflate( 0.0625D ).expandTowards( 0.0D, -0.55D, 0.0D ) ).allMatch( b -> p_9794_.level.getBlockState( b ).isAir() ); + } + -+ public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) { -+ PacketUtils.m_131359_( p_9835_, this, this.f_9743_.m_183503_() ); -+ if (p_9835_.m_133795_() == this.f_9767_ && this.f_9766_ != null) { // CraftBukkit -+ this.f_9743_.m_19890_( this.f_9766_.f_82479_, this.f_9766_.f_82480_, this.f_9766_.f_82481_, this.f_9743_.m_146908_(), this.f_9743_.m_146909_() ); -+ this.f_9756_ = this.f_9766_.f_82479_; -+ this.f_9757_ = this.f_9766_.f_82480_; -+ this.f_9758_ = this.f_9766_.f_82481_; -+ if (this.f_9743_.m_8958_()) { -+ this.f_9743_.m_8959_(); ++ public void handleAcceptTeleportPacket(ServerboundAcceptTeleportationPacket p_9835_) { ++ PacketUtils.ensureRunningOnSameThread( p_9835_, this, this.player.getLevel() ); ++ if (p_9835_.getId() == this.awaitingTeleport && this.awaitingPositionFromClient != null) { // CraftBukkit ++ this.player.absMoveTo( this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot() ); ++ this.lastGoodX = this.awaitingPositionFromClient.x; ++ this.lastGoodY = this.awaitingPositionFromClient.y; ++ this.lastGoodZ = this.awaitingPositionFromClient.z; ++ if (this.player.isChangingDimension()) { ++ this.player.hasChangedDimension(); + } + -+ this.f_9766_ = null; -+ if (this.f_9743_.valid) //Magma -+ this.f_9743_.m_183503_().m_7726_().m_8385_(this.f_9743_); // CraftBukkit ++ this.awaitingPositionFromClient = null; ++ if (this.player.valid) //Magma ++ this.player.getLevel().getChunkSource().move(this.player); // CraftBukkit + } + + } + -+ public void m_7411_(ServerboundRecipeBookSeenRecipePacket p_9897_) { -+ PacketUtils.m_131359_( p_9897_, this, this.f_9743_.m_183503_() ); -+ this.f_9745_.m_129894_().m_44043_( p_9897_.m_134390_() ).ifPresent( this.f_9743_.m_8952_()::m_12721_ ); ++ public void handleRecipeBookSeenRecipePacket(ServerboundRecipeBookSeenRecipePacket p_9897_) { ++ PacketUtils.ensureRunningOnSameThread( p_9897_, this, this.player.getLevel() ); ++ this.server.getRecipeManager().byKey( p_9897_.getRecipe() ).ifPresent( this.player.getRecipeBook()::removeHighlight ); + } + -+ public void m_7982_(ServerboundRecipeBookChangeSettingsPacket p_9895_) { -+ PacketUtils.m_131359_( p_9895_, this, this.f_9743_.m_183503_() ); -+ this.f_9743_.m_8952_().m_12696_( p_9895_.m_134375_(), p_9895_.m_134378_(), p_9895_.m_134379_() ); ++ public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket p_9895_) { ++ PacketUtils.ensureRunningOnSameThread( p_9895_, this, this.player.getLevel() ); ++ this.player.getRecipeBook().setBookSetting( p_9895_.getBookType(), p_9895_.isOpen(), p_9895_.isFiltering() ); + } + -+ public void m_6947_(ServerboundSeenAdvancementsPacket p_9903_) { -+ PacketUtils.m_131359_( p_9903_, this, this.f_9743_.m_183503_() ); -+ if (p_9903_.m_134447_() == ServerboundSeenAdvancementsPacket.Action.OPENED_TAB) { -+ ResourceLocation resourcelocation = p_9903_.m_134448_(); -+ Advancement advancement = this.f_9745_.m_129889_().m_136041_( resourcelocation ); ++ public void handleSeenAdvancements(ServerboundSeenAdvancementsPacket p_9903_) { ++ PacketUtils.ensureRunningOnSameThread( p_9903_, this, this.player.getLevel() ); ++ if (p_9903_.getAction() == ServerboundSeenAdvancementsPacket.Action.OPENED_TAB) { ++ ResourceLocation resourcelocation = p_9903_.getTab(); ++ Advancement advancement = this.server.getAdvancements().getAdvancement( resourcelocation ); + if (advancement != null) { -+ this.f_9743_.m_8960_().m_135983_( advancement ); ++ this.player.getAdvancements().setSelectedTab( advancement ); + } + } + + } + -+ public void m_7741_(ServerboundCommandSuggestionPacket p_9847_) { -+ PacketUtils.m_131359_( p_9847_, this, this.f_9743_.m_183503_() ); ++ public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket p_9847_) { ++ PacketUtils.ensureRunningOnSameThread( p_9847_, this, this.player.getLevel() ); + // CraftBukkit start -+ this.f_9750_ += 1; -+ if (f_9750_ > 500 && !this.f_9745_.m_6846_().m_11303_(this.f_9743_.m_36316_())) { -+ this.m_9942_(new TranslatableComponent("disconnect.spam", new Object[0])); ++ this.chatSpamTickCount += 1; ++ if (chatSpamTickCount > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { ++ this.disconnect(new TranslatableComponent("disconnect.spam", new Object[0])); + return; + } + // CraftBukkit end -+ StringReader stringreader = new StringReader( p_9847_.m_133904_() ); ++ StringReader stringreader = new StringReader( p_9847_.getCommand() ); + if (stringreader.canRead() && stringreader.peek() == '/') { + stringreader.skip(); + } + -+ ParseResults parseresults = this.f_9745_.m_129892_().m_82094_().parse( stringreader, this.f_9743_.m_20203_() ); -+ this.f_9745_.m_129892_().m_82094_().getCompletionSuggestions( parseresults ).thenAccept( (p_143647_) -> { ++ ParseResults parseresults = this.server.getCommands().getDispatcher().parse( stringreader, this.player.createCommandSourceStack() ); ++ this.server.getCommands().getDispatcher().getCompletionSuggestions( parseresults ).thenAccept( (p_143647_) -> { + if (p_143647_.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [] from showing for plugins with nothing more to offer -+ this.f_9742_.m_129512_( new ClientboundCommandSuggestionsPacket( p_9847_.m_133901_(), p_143647_ ) ); ++ this.connection.send( new ClientboundCommandSuggestionsPacket( p_9847_.getId(), p_143647_ ) ); + } ); + } + -+ public void m_7192_(ServerboundSetCommandBlockPacket p_9911_) { -+ PacketUtils.m_131359_( p_9911_, this, this.f_9743_.m_183503_() ); -+ if (!this.f_9745_.m_6993_()) { -+ this.f_9743_.m_6352_( new TranslatableComponent( "advMode.notEnabled" ), Util.f_137441_ ); -+ } else if (!this.f_9743_.m_36337_()) { -+ this.f_9743_.m_6352_( new TranslatableComponent( "advMode.notAllowed" ), Util.f_137441_ ); ++ public void handleSetCommandBlock(ServerboundSetCommandBlockPacket p_9911_) { ++ PacketUtils.ensureRunningOnSameThread( p_9911_, this, this.player.getLevel() ); ++ if (!this.server.isCommandBlockEnabled()) { ++ this.player.sendMessage( new TranslatableComponent( "advMode.notEnabled" ), Util.NIL_UUID ); ++ } else if (!this.player.canUseGameMasterBlocks()) { ++ this.player.sendMessage( new TranslatableComponent( "advMode.notAllowed" ), Util.NIL_UUID ); + } else { + BaseCommandBlock basecommandblock = null; + CommandBlockEntity commandblockentity = null; -+ BlockPos blockpos = p_9911_.m_134521_(); -+ BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_( blockpos ); ++ BlockPos blockpos = p_9911_.getPos(); ++ BlockEntity blockentity = this.player.level.getBlockEntity( blockpos ); + if (blockentity instanceof CommandBlockEntity) { + commandblockentity = (CommandBlockEntity) blockentity; -+ basecommandblock = commandblockentity.m_59141_(); ++ basecommandblock = commandblockentity.getCommandBlock(); + } + -+ String s = p_9911_.m_134524_(); -+ boolean flag = p_9911_.m_134525_(); ++ String s = p_9911_.getCommand(); ++ boolean flag = p_9911_.isTrackOutput(); + if (basecommandblock != null) { -+ CommandBlockEntity.Mode commandblockentity$mode = commandblockentity.m_59148_(); -+ BlockState blockstate = this.f_9743_.f_19853_.m_8055_( blockpos ); -+ Direction direction = blockstate.m_61143_( CommandBlock.f_51793_ ); ++ CommandBlockEntity.Mode commandblockentity$mode = commandblockentity.getMode(); ++ BlockState blockstate = this.player.level.getBlockState( blockpos ); ++ Direction direction = blockstate.getValue( CommandBlock.FACING ); + BlockState blockstate1; -+ switch (p_9911_.m_134528_()) { ++ switch (p_9911_.getMode()) { + case SEQUENCE: -+ blockstate1 = Blocks.f_50448_.m_49966_(); ++ blockstate1 = Blocks.CHAIN_COMMAND_BLOCK.defaultBlockState(); + break; + case AUTO: -+ blockstate1 = Blocks.f_50447_.m_49966_(); ++ blockstate1 = Blocks.REPEATING_COMMAND_BLOCK.defaultBlockState(); + break; + case REDSTONE: + default: -+ blockstate1 = Blocks.f_50272_.m_49966_(); ++ blockstate1 = Blocks.COMMAND_BLOCK.defaultBlockState(); + } + -+ BlockState blockstate2 = blockstate1.m_61124_( CommandBlock.f_51793_, direction ).m_61124_( CommandBlock.f_51794_, Boolean.valueOf( p_9911_.m_134526_() ) ); ++ BlockState blockstate2 = blockstate1.setValue( CommandBlock.FACING, direction ).setValue( CommandBlock.CONDITIONAL, Boolean.valueOf( p_9911_.isConditional() ) ); + if (blockstate2 != blockstate) { -+ this.f_9743_.f_19853_.m_7731_( blockpos, blockstate2, 2 ); -+ blockentity.m_155250_( blockstate2 ); -+ this.f_9743_.f_19853_.m_46745_( blockpos ).m_142169_( blockentity ); ++ this.player.level.setBlock( blockpos, blockstate2, 2 ); ++ blockentity.setBlockState( blockstate2 ); ++ this.player.level.getChunkAt( blockpos ).setBlockEntity( blockentity ); + } + -+ basecommandblock.m_6590_( s ); -+ basecommandblock.m_45428_( flag ); ++ basecommandblock.setCommand( s ); ++ basecommandblock.setTrackOutput( flag ); + if (!flag) { -+ basecommandblock.m_45433_( (Component) null ); ++ basecommandblock.setLastOutput( (Component) null ); + } + -+ commandblockentity.m_59137_( p_9911_.m_134527_() ); -+ if (commandblockentity$mode != p_9911_.m_134528_()) { -+ commandblockentity.m_59144_(); ++ commandblockentity.setAutomatic( p_9911_.isAutomatic() ); ++ if (commandblockentity$mode != p_9911_.getMode()) { ++ commandblockentity.onModeSwitch(); + } + -+ basecommandblock.m_7368_(); -+ if (!StringUtil.m_14408_( s )) { -+ this.f_9743_.m_6352_( new TranslatableComponent( "advMode.setCommand.success", s ), Util.f_137441_ ); ++ basecommandblock.onUpdated(); ++ if (!StringUtil.isNullOrEmpty( s )) { ++ this.player.sendMessage( new TranslatableComponent( "advMode.setCommand.success", s ), Util.NIL_UUID ); + } + } + + } + } + -+ public void m_6629_(ServerboundSetCommandMinecartPacket p_9913_) { -+ PacketUtils.m_131359_( p_9913_, this, this.f_9743_.m_183503_() ); -+ if (!this.f_9745_.m_6993_()) { -+ this.f_9743_.m_6352_( new TranslatableComponent( "advMode.notEnabled" ), Util.f_137441_ ); -+ } else if (!this.f_9743_.m_36337_()) { -+ this.f_9743_.m_6352_( new TranslatableComponent( "advMode.notAllowed" ), Util.f_137441_ ); ++ public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket p_9913_) { ++ PacketUtils.ensureRunningOnSameThread( p_9913_, this, this.player.getLevel() ); ++ if (!this.server.isCommandBlockEnabled()) { ++ this.player.sendMessage( new TranslatableComponent( "advMode.notEnabled" ), Util.NIL_UUID ); ++ } else if (!this.player.canUseGameMasterBlocks()) { ++ this.player.sendMessage( new TranslatableComponent( "advMode.notAllowed" ), Util.NIL_UUID ); + } else { -+ BaseCommandBlock basecommandblock = p_9913_.m_134537_( this.f_9743_.f_19853_ ); ++ BaseCommandBlock basecommandblock = p_9913_.getCommandBlock( this.player.level ); + if (basecommandblock != null) { -+ basecommandblock.m_6590_( p_9913_.m_134545_() ); -+ basecommandblock.m_45428_( p_9913_.m_134548_() ); -+ if (!p_9913_.m_134548_()) { -+ basecommandblock.m_45433_( (Component) null ); ++ basecommandblock.setCommand( p_9913_.getCommand() ); ++ basecommandblock.setTrackOutput( p_9913_.isTrackOutput() ); ++ if (!p_9913_.isTrackOutput()) { ++ basecommandblock.setLastOutput( (Component) null ); + } + -+ basecommandblock.m_7368_(); -+ this.f_9743_.m_6352_( new TranslatableComponent( "advMode.setCommand.success", p_9913_.m_134545_() ), Util.f_137441_ ); ++ basecommandblock.onUpdated(); ++ this.player.sendMessage( new TranslatableComponent( "advMode.setCommand.success", p_9913_.getCommand() ), Util.NIL_UUID ); + } + + } + } + -+ public void m_7965_(ServerboundPickItemPacket p_9880_) { -+ PacketUtils.m_131359_( p_9880_, this, this.f_9743_.m_183503_() ); -+ this.f_9743_.m_150109_().m_36038_( p_9880_.m_134232_() ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( -2, 0, this.f_9743_.m_150109_().f_35977_, this.f_9743_.m_150109_().m_8020_( this.f_9743_.m_150109_().f_35977_ ) ) ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( -2, 0, p_9880_.m_134232_(), this.f_9743_.m_150109_().m_8020_( p_9880_.m_134232_() ) ) ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundSetCarriedItemPacket( this.f_9743_.m_150109_().f_35977_ ) ); ++ public void handlePickItem(ServerboundPickItemPacket p_9880_) { ++ PacketUtils.ensureRunningOnSameThread( p_9880_, this, this.player.getLevel() ); ++ this.player.getInventory().pickSlot( p_9880_.getSlot() ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( -2, 0, this.player.getInventory().selected, this.player.getInventory().getItem( this.player.getInventory().selected ) ) ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( -2, 0, p_9880_.getSlot(), this.player.getInventory().getItem( p_9880_.getSlot() ) ) ); ++ this.player.connection.send( new ClientboundSetCarriedItemPacket( this.player.getInventory().selected ) ); + } + -+ public void m_5591_(ServerboundRenameItemPacket p_9899_) { -+ PacketUtils.m_131359_( p_9899_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.f_36096_ instanceof AnvilMenu) { -+ AnvilMenu anvilmenu = (AnvilMenu) this.f_9743_.f_36096_; -+ String s = SharedConstants.m_136190_( p_9899_.m_134403_() ); ++ public void handleRenameItem(ServerboundRenameItemPacket p_9899_) { ++ PacketUtils.ensureRunningOnSameThread( p_9899_, this, this.player.getLevel() ); ++ if (this.player.containerMenu instanceof AnvilMenu) { ++ AnvilMenu anvilmenu = (AnvilMenu) this.player.containerMenu; ++ String s = SharedConstants.filterText( p_9899_.getName() ); + if (s.length() <= 50) { -+ anvilmenu.m_39020_( s ); ++ anvilmenu.setItemName( s ); + } + } + + } + -+ public void m_5712_(ServerboundSetBeaconPacket p_9907_) { -+ PacketUtils.m_131359_( p_9907_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.f_36096_ instanceof BeaconMenu) { -+ ((BeaconMenu) this.f_9743_.f_36096_).m_39053_( p_9907_.m_134484_(), p_9907_.m_134487_() ); ++ public void handleSetBeaconPacket(ServerboundSetBeaconPacket p_9907_) { ++ PacketUtils.ensureRunningOnSameThread( p_9907_, this, this.player.getLevel() ); ++ if (this.player.containerMenu instanceof BeaconMenu) { ++ ((BeaconMenu) this.player.containerMenu).updateEffects( p_9907_.getPrimary(), p_9907_.getSecondary() ); + } + + } + -+ public void m_7424_(ServerboundSetStructureBlockPacket p_9919_) { -+ PacketUtils.m_131359_( p_9919_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_36337_()) { -+ BlockPos blockpos = p_9919_.m_134629_(); -+ BlockState blockstate = this.f_9743_.f_19853_.m_8055_( blockpos ); -+ BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_( blockpos ); ++ public void handleSetStructureBlock(ServerboundSetStructureBlockPacket p_9919_) { ++ PacketUtils.ensureRunningOnSameThread( p_9919_, this, this.player.getLevel() ); ++ if (this.player.canUseGameMasterBlocks()) { ++ BlockPos blockpos = p_9919_.getPos(); ++ BlockState blockstate = this.player.level.getBlockState( blockpos ); ++ BlockEntity blockentity = this.player.level.getBlockEntity( blockpos ); + if (blockentity instanceof StructureBlockEntity) { + StructureBlockEntity structureblockentity = (StructureBlockEntity) blockentity; -+ structureblockentity.m_59860_( p_9919_.m_134633_() ); -+ structureblockentity.m_59868_( p_9919_.m_134634_() ); -+ structureblockentity.m_59885_( p_9919_.m_134635_() ); -+ structureblockentity.m_155797_( p_9919_.m_179787_() ); -+ structureblockentity.m_59881_( p_9919_.m_134637_() ); -+ structureblockentity.m_59883_( p_9919_.m_134638_() ); -+ structureblockentity.m_59887_( p_9919_.m_134639_() ); -+ structureblockentity.m_59876_( p_9919_.m_134640_() ); -+ structureblockentity.m_59896_( p_9919_.m_134641_() ); -+ structureblockentity.m_59898_( p_9919_.m_134642_() ); -+ structureblockentity.m_59838_( p_9919_.m_134643_() ); -+ structureblockentity.m_59840_( p_9919_.m_134644_() ); -+ if (structureblockentity.m_59901_()) { -+ String s = structureblockentity.m_59895_(); -+ if (p_9919_.m_134632_() == StructureBlockEntity.UpdateType.SAVE_AREA) { -+ if (structureblockentity.m_59830_()) { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.save_success", s ), false ); ++ structureblockentity.setMode( p_9919_.getMode() ); ++ structureblockentity.setStructureName( p_9919_.getName() ); ++ structureblockentity.setStructurePos( p_9919_.getOffset() ); ++ structureblockentity.setStructureSize( p_9919_.getSize() ); ++ structureblockentity.setMirror( p_9919_.getMirror() ); ++ structureblockentity.setRotation( p_9919_.getRotation() ); ++ structureblockentity.setMetaData( p_9919_.getData() ); ++ structureblockentity.setIgnoreEntities( p_9919_.isIgnoreEntities() ); ++ structureblockentity.setShowAir( p_9919_.isShowAir() ); ++ structureblockentity.setShowBoundingBox( p_9919_.isShowBoundingBox() ); ++ structureblockentity.setIntegrity( p_9919_.getIntegrity() ); ++ structureblockentity.setSeed( p_9919_.getSeed() ); ++ if (structureblockentity.hasStructureName()) { ++ String s = structureblockentity.getStructureName(); ++ if (p_9919_.getUpdateType() == StructureBlockEntity.UpdateType.SAVE_AREA) { ++ if (structureblockentity.saveStructure()) { ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.save_success", s ), false ); + } else { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.save_failure", s ), false ); ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.save_failure", s ), false ); + } -+ } else if (p_9919_.m_134632_() == StructureBlockEntity.UpdateType.LOAD_AREA) { -+ if (!structureblockentity.m_59832_()) { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.load_not_found", s ), false ); -+ } else if (structureblockentity.m_59842_( this.f_9743_.m_183503_() )) { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.load_success", s ), false ); ++ } else if (p_9919_.getUpdateType() == StructureBlockEntity.UpdateType.LOAD_AREA) { ++ if (!structureblockentity.isStructureLoadable()) { ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.load_not_found", s ), false ); ++ } else if (structureblockentity.loadStructure( this.player.getLevel() )) { ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.load_success", s ), false ); + } else { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.load_prepare", s ), false ); ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.load_prepare", s ), false ); + } -+ } else if (p_9919_.m_134632_() == StructureBlockEntity.UpdateType.SCAN_AREA) { -+ if (structureblockentity.m_59829_()) { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.size_success", s ), false ); ++ } else if (p_9919_.getUpdateType() == StructureBlockEntity.UpdateType.SCAN_AREA) { ++ if (structureblockentity.detectSize()) { ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.size_success", s ), false ); + } else { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.size_failure" ), false ); ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.size_failure" ), false ); + } + } + } else { -+ this.f_9743_.m_5661_( new TranslatableComponent( "structure_block.invalid_structure_name", p_9919_.m_134634_() ), false ); ++ this.player.displayClientMessage( new TranslatableComponent( "structure_block.invalid_structure_name", p_9919_.getName() ), false ); + } + -+ structureblockentity.m_6596_(); -+ this.f_9743_.f_19853_.m_7260_( blockpos, blockstate, blockstate, 3 ); ++ structureblockentity.setChanged(); ++ this.player.level.sendBlockUpdated( blockpos, blockstate, blockstate, 3 ); + } + + } + } + -+ public void m_8019_(ServerboundSetJigsawBlockPacket p_9917_) { -+ PacketUtils.m_131359_( p_9917_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_36337_()) { -+ BlockPos blockpos = p_9917_.m_134585_(); -+ BlockState blockstate = this.f_9743_.f_19853_.m_8055_( blockpos ); -+ BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_( blockpos ); ++ public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket p_9917_) { ++ PacketUtils.ensureRunningOnSameThread( p_9917_, this, this.player.getLevel() ); ++ if (this.player.canUseGameMasterBlocks()) { ++ BlockPos blockpos = p_9917_.getPos(); ++ BlockState blockstate = this.player.level.getBlockState( blockpos ); ++ BlockEntity blockentity = this.player.level.getBlockEntity( blockpos ); + if (blockentity instanceof JigsawBlockEntity) { + JigsawBlockEntity jigsawblockentity = (JigsawBlockEntity) blockentity; -+ jigsawblockentity.m_59435_( p_9917_.m_134588_() ); -+ jigsawblockentity.m_59438_( p_9917_.m_134589_() ); -+ jigsawblockentity.m_59440_( p_9917_.m_134590_() ); -+ jigsawblockentity.m_59431_( p_9917_.m_134591_() ); -+ jigsawblockentity.m_59424_( p_9917_.m_134592_() ); -+ jigsawblockentity.m_6596_(); -+ this.f_9743_.f_19853_.m_7260_( blockpos, blockstate, blockstate, 3 ); ++ jigsawblockentity.setName( p_9917_.getName() ); ++ jigsawblockentity.setTarget( p_9917_.getTarget() ); ++ jigsawblockentity.setPool( p_9917_.getPool() ); ++ jigsawblockentity.setFinalState( p_9917_.getFinalState() ); ++ jigsawblockentity.setJoint( p_9917_.getJoint() ); ++ jigsawblockentity.setChanged(); ++ this.player.level.sendBlockUpdated( blockpos, blockstate, blockstate, 3 ); + } + + } + } + -+ public void m_6449_(ServerboundJigsawGeneratePacket p_9868_) { -+ PacketUtils.m_131359_( p_9868_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_36337_()) { -+ BlockPos blockpos = p_9868_.m_134087_(); -+ BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_( blockpos ); ++ public void handleJigsawGenerate(ServerboundJigsawGeneratePacket p_9868_) { ++ PacketUtils.ensureRunningOnSameThread( p_9868_, this, this.player.getLevel() ); ++ if (this.player.canUseGameMasterBlocks()) { ++ BlockPos blockpos = p_9868_.getPos(); ++ BlockEntity blockentity = this.player.level.getBlockEntity( blockpos ); + if (blockentity instanceof JigsawBlockEntity) { + JigsawBlockEntity jigsawblockentity = (JigsawBlockEntity) blockentity; -+ jigsawblockentity.m_59420_( this.f_9743_.m_183503_(), p_9868_.m_134090_(), p_9868_.m_134091_() ); ++ jigsawblockentity.generate( this.player.getLevel(), p_9868_.levels(), p_9868_.keepJigsaws() ); + } + + } + } + -+ public void m_6321_(ServerboundSelectTradePacket p_9905_) { -+ PacketUtils.m_131359_( p_9905_, this, this.f_9743_.m_183503_() ); -+ int i = p_9905_.m_134469_(); -+ AbstractContainerMenu abstractcontainermenu = this.f_9743_.f_36096_; ++ public void handleSelectTrade(ServerboundSelectTradePacket p_9905_) { ++ PacketUtils.ensureRunningOnSameThread( p_9905_, this, this.player.getLevel() ); ++ int i = p_9905_.getItem(); ++ AbstractContainerMenu abstractcontainermenu = this.player.containerMenu; + if (abstractcontainermenu instanceof MerchantMenu) { + MerchantMenu merchantmenu = (MerchantMenu) abstractcontainermenu; + + // CraftBukkit start -+ final org.bukkit.event.inventory.TradeSelectEvent tradeSelectEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callTradeSelectEvent(this.f_9743_, i, merchantmenu); ++ final org.bukkit.event.inventory.TradeSelectEvent tradeSelectEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callTradeSelectEvent(this.player, i, merchantmenu); + if (tradeSelectEvent.isCancelled()) { -+ this.f_9743_.getBukkitEntity().updateInventory(); ++ this.player.getBukkitEntity().updateInventory(); + return; + } + // CraftBukkit end + -+ merchantmenu.m_40063_( i ); -+ merchantmenu.m_40072_( i ); ++ merchantmenu.setSelectionHint( i ); ++ merchantmenu.tryMoveItems( i ); + } + + } + -+ public void m_6829_(ServerboundEditBookPacket p_9862_) { ++ public void handleEditBook(ServerboundEditBookPacket p_9862_) { + // CraftBukkit start + if (this.lastBookTick + 20 > MinecraftServer.currentTick) { + this.disconnect("Book edited too quickly!"); @@ -902,56 +902,56 @@ + } + this.lastBookTick = MinecraftServer.currentTick; + // CraftBukkit end -+ int i = p_9862_.m_134013_(); -+ if (Inventory.m_36045_( i ) || i == 40) { ++ int i = p_9862_.getSlot(); ++ if (Inventory.isHotbarSlot( i ) || i == 40) { + List list = Lists.newArrayList(); -+ Optional optional = p_9862_.m_182761_(); ++ Optional optional = p_9862_.getTitle(); + optional.ifPresent( list::add ); -+ p_9862_.m_182755_().stream().limit( 100L ).forEach( list::add ); -+ this.m_9815_( list, optional.isPresent() ? (p_143657_) -> { -+ this.m_143630_( p_143657_.get( 0 ), p_143657_.subList( 1, p_143657_.size() ), i ); ++ p_9862_.getPages().stream().limit( 100L ).forEach( list::add ); ++ this.filterTextPacket( list, optional.isPresent() ? (p_143657_) -> { ++ this.signBook( p_143657_.get( 0 ), p_143657_.subList( 1, p_143657_.size() ), i ); + } : (p_143627_) -> { -+ this.m_9812_( p_143627_, i ); ++ this.updateBookContents( p_143627_, i ); + } ); + } + } + -+ private void m_9812_(List p_9813_, int p_9814_) { -+ ItemStack itemstack = this.f_9743_.m_150109_().m_8020_( p_9814_ ); -+ if (itemstack.m_150930_( Items.f_42614_ )) { -+ this.updateBookPages(p_9813_, UnaryOperator.identity(), itemstack.m_41777_(), p_9814_, itemstack); // CraftBukkit ++ private void updateBookContents(List p_9813_, int p_9814_) { ++ ItemStack itemstack = this.player.getInventory().getItem( p_9814_ ); ++ if (itemstack.is( Items.WRITABLE_BOOK )) { ++ this.updateBookPages(p_9813_, UnaryOperator.identity(), itemstack.copy(), p_9814_, itemstack); // CraftBukkit + } + } + -+ private void m_143630_(TextFilter.FilteredText p_143631_, List p_143632_, int p_143633_) { -+ ItemStack itemstack = this.f_9743_.m_150109_().m_8020_( p_143633_ ); -+ if (itemstack.m_150930_( Items.f_42614_ )) { -+ ItemStack itemstack1 = new ItemStack( Items.f_42615_ ); -+ CompoundTag compoundtag = itemstack.m_41783_(); ++ private void signBook(TextFilter.FilteredText p_143631_, List p_143632_, int p_143633_) { ++ ItemStack itemstack = this.player.getInventory().getItem( p_143633_ ); ++ if (itemstack.is( Items.WRITABLE_BOOK )) { ++ ItemStack itemstack1 = new ItemStack( Items.WRITTEN_BOOK ); ++ CompoundTag compoundtag = itemstack.getTag(); + if (compoundtag != null) { -+ itemstack1.m_41751_( compoundtag.m_6426_() ); ++ itemstack1.setTag( compoundtag.copy() ); + } + -+ itemstack1.m_41700_( "author", StringTag.m_129297_( this.f_9743_.m_7755_().getString() ) ); -+ if (this.f_9743_.m_143387_()) { -+ itemstack1.m_41700_( "title", StringTag.m_129297_( p_143631_.m_143722_() ) ); ++ itemstack1.addTagElement( "author", StringTag.valueOf( this.player.getName().getString() ) ); ++ if (this.player.isTextFilteringEnabled()) { ++ itemstack1.addTagElement( "title", StringTag.valueOf( p_143631_.getFiltered() ) ); + } else { -+ itemstack1.m_41700_( "filtered_title", StringTag.m_129297_( p_143631_.m_143722_() ) ); -+ itemstack1.m_41700_( "title", StringTag.m_129297_( p_143631_.m_143719_() ) ); ++ itemstack1.addTagElement( "filtered_title", StringTag.valueOf( p_143631_.getFiltered() ) ); ++ itemstack1.addTagElement( "title", StringTag.valueOf( p_143631_.getRaw() ) ); + } + + this.updateBookPages( p_143632_, (p_143659_) -> { -+ return Component.Serializer.m_130703_( new TextComponent( p_143659_ ) ); ++ return Component.Serializer.toJson( new TextComponent( p_143659_ ) ); + }, itemstack1, p_143633_, itemstack); // CraftBukkit -+ this.f_9743_.m_150109_().m_6836_(p_143633_, itemstack); // CraftBukkit - event factory updates the hand book ++ this.player.getInventory().setItem(p_143633_, itemstack); // CraftBukkit - event factory updates the hand book + } + } + + private void updateBookPages(List p_143635_, UnaryOperator p_143636_, ItemStack p_143637_, int slot, ItemStack handItem) { // CraftBukkit + ListTag listtag = new ListTag(); -+ if (this.f_9743_.m_143387_()) { ++ if (this.player.isTextFilteringEnabled()) { + p_143635_.stream().map( (p_143640_) -> { -+ return StringTag.m_129297_( p_143636_.apply( p_143640_.m_143722_() ) ); ++ return StringTag.valueOf( p_143636_.apply( p_143640_.getFiltered() ) ); + } ).forEach( listtag::add ); + } else { + CompoundTag compoundtag = new CompoundTag(); @@ -959,327 +959,327 @@ + + for (int j = p_143635_.size(); i < j; ++i) { + TextFilter.FilteredText textfilter$filteredtext = p_143635_.get( i ); -+ String s = textfilter$filteredtext.m_143719_(); -+ listtag.add( StringTag.m_129297_( p_143636_.apply( s ) ) ); -+ String s1 = textfilter$filteredtext.m_143722_(); ++ String s = textfilter$filteredtext.getRaw(); ++ listtag.add( StringTag.valueOf( p_143636_.apply( s ) ) ); ++ String s1 = textfilter$filteredtext.getFiltered(); + if (!s.equals( s1 )) { -+ compoundtag.m_128359_( String.valueOf( i ), p_143636_.apply( s1 ) ); ++ compoundtag.putString( String.valueOf( i ), p_143636_.apply( s1 ) ); + } + } + -+ if (!compoundtag.m_128456_()) { -+ p_143637_.m_41700_( "filtered_pages", compoundtag ); ++ if (!compoundtag.isEmpty()) { ++ p_143637_.addTagElement( "filtered_pages", compoundtag ); + } + } + -+ p_143637_.m_41700_( "pages", listtag ); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleEditBookEvent(f_9743_, slot, handItem, p_143637_); // CraftBukkit ++ p_143637_.addTagElement( "pages", listtag ); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleEditBookEvent(player, slot, handItem, p_143637_); // CraftBukkit + } + -+ public void m_7548_(ServerboundEntityTagQuery p_9864_) { -+ PacketUtils.m_131359_( p_9864_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_20310_( 2 )) { -+ Entity entity = this.f_9743_.m_183503_().m_6815_( p_9864_.m_134029_() ); ++ public void handleEntityTagQuery(ServerboundEntityTagQuery p_9864_) { ++ PacketUtils.ensureRunningOnSameThread( p_9864_, this, this.player.getLevel() ); ++ if (this.player.hasPermissions( 2 )) { ++ Entity entity = this.player.getLevel().getEntity( p_9864_.getEntityId() ); + if (entity != null) { -+ CompoundTag compoundtag = entity.m_20240_( new CompoundTag() ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundTagQueryPacket( p_9864_.m_134026_(), compoundtag ) ); ++ CompoundTag compoundtag = entity.saveWithoutId( new CompoundTag() ); ++ this.player.connection.send( new ClientboundTagQueryPacket( p_9864_.getTransactionId(), compoundtag ) ); + } + + } + } + -+ public void m_6780_(ServerboundBlockEntityTagQuery p_9837_) { -+ PacketUtils.m_131359_( p_9837_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_20310_( 2 )) { -+ BlockEntity blockentity = this.f_9743_.m_183503_().m_7702_( p_9837_.m_133813_() ); -+ CompoundTag compoundtag = blockentity != null ? blockentity.m_187482_() : null; -+ this.f_9743_.f_8906_.m_141995_( new ClientboundTagQueryPacket( p_9837_.m_133810_(), compoundtag ) ); ++ public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery p_9837_) { ++ PacketUtils.ensureRunningOnSameThread( p_9837_, this, this.player.getLevel() ); ++ if (this.player.hasPermissions( 2 )) { ++ BlockEntity blockentity = this.player.getLevel().getBlockEntity( p_9837_.getPos() ); ++ CompoundTag compoundtag = blockentity != null ? blockentity.saveWithoutMetadata() : null; ++ this.player.connection.send( new ClientboundTagQueryPacket( p_9837_.getTransactionId(), compoundtag ) ); + } + } + -+ public void m_7185_(ServerboundMovePlayerPacket p_9874_) { -+ PacketUtils.m_131359_( p_9874_, this, this.f_9743_.m_183503_() ); -+ if (m_143663_( p_9874_.m_134129_( 0.0D ), p_9874_.m_134140_( 0.0D ), p_9874_.m_134146_( 0.0D ), p_9874_.m_134131_( 0.0F ), p_9874_.m_134142_( 0.0F ) )) { -+ this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.invalid_player_movement" ) ); ++ public void handleMovePlayer(ServerboundMovePlayerPacket p_9874_) { ++ PacketUtils.ensureRunningOnSameThread( p_9874_, this, this.player.getLevel() ); ++ if (containsInvalidValues( p_9874_.getX( 0.0D ), p_9874_.getY( 0.0D ), p_9874_.getZ( 0.0D ), p_9874_.getYRot( 0.0F ), p_9874_.getXRot( 0.0F ) )) { ++ this.disconnect( new TranslatableComponent( "multiplayer.disconnect.invalid_player_movement" ) ); + } else { - ServerLevel serverlevel = this.f_9743_.m_183503_(); -- double d0 = entity.m_20185_(); -- double d1 = entity.m_20186_(); -- double d2 = entity.m_20189_(); -- double d3 = m_143609_(p_9876_.m_134199_()); -- double d4 = m_143653_(p_9876_.m_134202_()); -- double d5 = m_143609_(p_9876_.m_134203_()); -- float f = Mth.m_14177_(p_9876_.m_134204_()); -- float f1 = Mth.m_14177_(p_9876_.m_134205_()); -- double d6 = d3 - this.f_9760_; -- double d7 = d4 - this.f_9761_; -- double d8 = d5 - this.f_9762_; -- double d9 = entity.m_20184_().m_82556_(); + ServerLevel serverlevel = this.player.getLevel(); +- double d0 = entity.getX(); +- double d1 = entity.getY(); +- double d2 = entity.getZ(); +- double d3 = clampHorizontal(p_9876_.getX()); +- double d4 = clampVertical(p_9876_.getY()); +- double d5 = clampHorizontal(p_9876_.getZ()); +- float f = Mth.wrapDegrees(p_9876_.getYRot()); +- float f1 = Mth.wrapDegrees(p_9876_.getXRot()); +- double d6 = d3 - this.vehicleFirstGoodX; +- double d7 = d4 - this.vehicleFirstGoodY; +- double d8 = d5 - this.vehicleFirstGoodZ; +- double d9 = entity.getDeltaMovement().lengthSqr(); - double d10 = d6 * d6 + d7 * d7 + d8 * d8; -- if (d10 - d9 > 100.0D && !this.m_9956_()) { -- f_9744_.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.m_7755_().getString(), this.f_9743_.m_7755_().getString(), d6, d7, d8); -- this.f_9742_.m_129512_(new ClientboundMoveVehiclePacket(entity)); +- if (d10 - d9 > 100.0D && !this.isSingleplayerOwner()) { +- LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8); +- this.connection.send(new ClientboundMoveVehiclePacket(entity)); - return; - } - -- boolean flag = serverlevel.m_45756_(entity, entity.m_142469_().m_82406_(0.0625D)); -- d6 = d3 - this.f_9763_; -- d7 = d4 - this.f_9764_ - 1.0E-6D; -- d8 = d5 - this.f_9765_; -- boolean flag1 = entity.f_201939_; -- entity.m_6478_(MoverType.PLAYER, new Vec3(d6, d7, d8)); -- d6 = d3 - entity.m_20185_(); -- d7 = d4 - entity.m_20186_(); +- boolean flag = serverlevel.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); +- d6 = d3 - this.vehicleLastGoodX; +- d7 = d4 - this.vehicleLastGoodY - 1.0E-6D; +- d8 = d5 - this.vehicleLastGoodZ; +- boolean flag1 = entity.verticalCollisionBelow; +- entity.move(MoverType.PLAYER, new Vec3(d6, d7, d8)); +- d6 = d3 - entity.getX(); +- d7 = d4 - entity.getY(); - if (d7 > -0.5D || d7 < 0.5D) { - d7 = 0.0D; - } - -- d8 = d5 - entity.m_20189_(); +- d8 = d5 - entity.getZ(); - d10 = d6 * d6 + d7 * d7 + d8 * d8; - boolean flag2 = false; - if (d10 > 0.0625D) { - flag2 = true; -- f_9744_.warn("{} (vehicle of {}) moved wrongly! {}", entity.m_7755_().getString(), this.f_9743_.m_7755_().getString(), Math.sqrt(d10)); +- LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", entity.getName().getString(), this.player.getName().getString(), Math.sqrt(d10)); - } - -- entity.m_19890_(d3, d4, d5, f, f1); -- boolean flag3 = serverlevel.m_45756_(entity, entity.m_142469_().m_82406_(0.0625D)); +- entity.absMoveTo(d3, d4, d5, f, f1); +- boolean flag3 = serverlevel.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); - if (flag && (flag2 || !flag3)) { -- entity.m_19890_(d0, d1, d2, f, f1); -- this.f_9742_.m_129512_(new ClientboundMoveVehiclePacket(entity)); +- entity.absMoveTo(d0, d1, d2, f, f1); +- this.connection.send(new ClientboundMoveVehiclePacket(entity)); - return; - } - -- this.f_9743_.m_183503_().m_7726_().m_8385_(this.f_9743_); -- this.f_9743_.m_36378_(this.f_9743_.m_20185_() - d0, this.f_9743_.m_20186_() - d1, this.f_9743_.m_20189_() - d2); -- this.f_9738_ = d7 >= -0.03125D && !flag1 && !this.f_9745_.m_129915_() && !entity.m_20068_() && this.m_9793_(entity); -- this.f_9763_ = entity.m_20185_(); -- this.f_9764_ = entity.m_20186_(); -- this.f_9765_ = entity.m_20189_(); +- this.player.getLevel().getChunkSource().move(this.player); +- this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); +- this.clientVehicleIsFloating = d7 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); +- this.vehicleLastGoodX = entity.getX(); +- this.vehicleLastGoodY = entity.getY(); +- this.vehicleLastGoodZ = entity.getZ(); - } - - } - } - -- private boolean m_9793_(Entity p_9794_) { -- return p_9794_.f_19853_.m_45556_(p_9794_.m_142469_().m_82400_(0.0625D).m_82363_(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::m_60795_); +- private boolean noBlocksAround(Entity p_9794_) { +- return p_9794_.level.getBlockStates(p_9794_.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::isAir); - } - -- public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) { -- PacketUtils.m_131359_(p_9835_, this, this.f_9743_.m_183503_()); -- if (p_9835_.m_133795_() == this.f_9767_) { -- this.f_9743_.m_19890_(this.f_9766_.f_82479_, this.f_9766_.f_82480_, this.f_9766_.f_82481_, this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); -- this.f_9756_ = this.f_9766_.f_82479_; -- this.f_9757_ = this.f_9766_.f_82480_; -- this.f_9758_ = this.f_9766_.f_82481_; -- if (this.f_9743_.m_8958_()) { -- this.f_9743_.m_8959_(); +- public void handleAcceptTeleportPacket(ServerboundAcceptTeleportationPacket p_9835_) { +- PacketUtils.ensureRunningOnSameThread(p_9835_, this, this.player.getLevel()); +- if (p_9835_.getId() == this.awaitingTeleport) { +- this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); +- this.lastGoodX = this.awaitingPositionFromClient.x; +- this.lastGoodY = this.awaitingPositionFromClient.y; +- this.lastGoodZ = this.awaitingPositionFromClient.z; +- if (this.player.isChangingDimension()) { +- this.player.hasChangedDimension(); - } - -- this.f_9766_ = null; +- this.awaitingPositionFromClient = null; - } - - } - -- public void m_7411_(ServerboundRecipeBookSeenRecipePacket p_9897_) { -- PacketUtils.m_131359_(p_9897_, this, this.f_9743_.m_183503_()); -- this.f_9745_.m_129894_().m_44043_(p_9897_.m_134390_()).ifPresent(this.f_9743_.m_8952_()::m_12721_); +- public void handleRecipeBookSeenRecipePacket(ServerboundRecipeBookSeenRecipePacket p_9897_) { +- PacketUtils.ensureRunningOnSameThread(p_9897_, this, this.player.getLevel()); +- this.server.getRecipeManager().byKey(p_9897_.getRecipe()).ifPresent(this.player.getRecipeBook()::removeHighlight); - } - -- public void m_7982_(ServerboundRecipeBookChangeSettingsPacket p_9895_) { -- PacketUtils.m_131359_(p_9895_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_8952_().m_12696_(p_9895_.m_134375_(), p_9895_.m_134378_(), p_9895_.m_134379_()); +- public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket p_9895_) { +- PacketUtils.ensureRunningOnSameThread(p_9895_, this, this.player.getLevel()); +- this.player.getRecipeBook().setBookSetting(p_9895_.getBookType(), p_9895_.isOpen(), p_9895_.isFiltering()); - } - -- public void m_6947_(ServerboundSeenAdvancementsPacket p_9903_) { -- PacketUtils.m_131359_(p_9903_, this, this.f_9743_.m_183503_()); -- if (p_9903_.m_134447_() == ServerboundSeenAdvancementsPacket.Action.OPENED_TAB) { -- ResourceLocation resourcelocation = p_9903_.m_134448_(); -- Advancement advancement = this.f_9745_.m_129889_().m_136041_(resourcelocation); +- public void handleSeenAdvancements(ServerboundSeenAdvancementsPacket p_9903_) { +- PacketUtils.ensureRunningOnSameThread(p_9903_, this, this.player.getLevel()); +- if (p_9903_.getAction() == ServerboundSeenAdvancementsPacket.Action.OPENED_TAB) { +- ResourceLocation resourcelocation = p_9903_.getTab(); +- Advancement advancement = this.server.getAdvancements().getAdvancement(resourcelocation); - if (advancement != null) { -- this.f_9743_.m_8960_().m_135983_(advancement); +- this.player.getAdvancements().setSelectedTab(advancement); - } - } - - } - -- public void m_7741_(ServerboundCommandSuggestionPacket p_9847_) { -- PacketUtils.m_131359_(p_9847_, this, this.f_9743_.m_183503_()); -- StringReader stringreader = new StringReader(p_9847_.m_133904_()); +- public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket p_9847_) { +- PacketUtils.ensureRunningOnSameThread(p_9847_, this, this.player.getLevel()); +- StringReader stringreader = new StringReader(p_9847_.getCommand()); - if (stringreader.canRead() && stringreader.peek() == '/') { - stringreader.skip(); - } - -- ParseResults parseresults = this.f_9745_.m_129892_().m_82094_().parse(stringreader, this.f_9743_.m_20203_()); -- this.f_9745_.m_129892_().m_82094_().getCompletionSuggestions(parseresults).thenAccept((p_143647_) -> { -- this.f_9742_.m_129512_(new ClientboundCommandSuggestionsPacket(p_9847_.m_133901_(), p_143647_)); +- ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); +- this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((p_143647_) -> { +- this.connection.send(new ClientboundCommandSuggestionsPacket(p_9847_.getId(), p_143647_)); - }); - } - -- public void m_7192_(ServerboundSetCommandBlockPacket p_9911_) { -- PacketUtils.m_131359_(p_9911_, this, this.f_9743_.m_183503_()); -- if (!this.f_9745_.m_6993_()) { -- this.f_9743_.m_6352_(new TranslatableComponent("advMode.notEnabled"), Util.f_137441_); -- } else if (!this.f_9743_.m_36337_()) { -- this.f_9743_.m_6352_(new TranslatableComponent("advMode.notAllowed"), Util.f_137441_); +- public void handleSetCommandBlock(ServerboundSetCommandBlockPacket p_9911_) { +- PacketUtils.ensureRunningOnSameThread(p_9911_, this, this.player.getLevel()); +- if (!this.server.isCommandBlockEnabled()) { +- this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID); +- } else if (!this.player.canUseGameMasterBlocks()) { +- this.player.sendMessage(new TranslatableComponent("advMode.notAllowed"), Util.NIL_UUID); - } else { - BaseCommandBlock basecommandblock = null; - CommandBlockEntity commandblockentity = null; -- BlockPos blockpos = p_9911_.m_134521_(); -- BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_(blockpos); +- BlockPos blockpos = p_9911_.getPos(); +- BlockEntity blockentity = this.player.level.getBlockEntity(blockpos); - if (blockentity instanceof CommandBlockEntity) { - commandblockentity = (CommandBlockEntity)blockentity; -- basecommandblock = commandblockentity.m_59141_(); +- basecommandblock = commandblockentity.getCommandBlock(); - } - -- String s = p_9911_.m_134524_(); -- boolean flag = p_9911_.m_134525_(); +- String s = p_9911_.getCommand(); +- boolean flag = p_9911_.isTrackOutput(); - if (basecommandblock != null) { -- CommandBlockEntity.Mode commandblockentity$mode = commandblockentity.m_59148_(); -- BlockState blockstate = this.f_9743_.f_19853_.m_8055_(blockpos); -- Direction direction = blockstate.m_61143_(CommandBlock.f_51793_); +- CommandBlockEntity.Mode commandblockentity$mode = commandblockentity.getMode(); +- BlockState blockstate = this.player.level.getBlockState(blockpos); +- Direction direction = blockstate.getValue(CommandBlock.FACING); - BlockState blockstate1; -- switch(p_9911_.m_134528_()) { +- switch(p_9911_.getMode()) { - case SEQUENCE: -- blockstate1 = Blocks.f_50448_.m_49966_(); +- blockstate1 = Blocks.CHAIN_COMMAND_BLOCK.defaultBlockState(); - break; - case AUTO: -- blockstate1 = Blocks.f_50447_.m_49966_(); +- blockstate1 = Blocks.REPEATING_COMMAND_BLOCK.defaultBlockState(); - break; - case REDSTONE: -+ if (!this.f_9743_.f_8944_ && !this.f_9743_.m_6107_()) { // CraftBukkit -+ if (this.f_9746_ == 0) { -+ this.m_9953_(); ++ if (!this.player.wonGame && !this.player.isImmobile()) { // CraftBukkit ++ if (this.tickCount == 0) { ++ this.resetPosition(); + } + -+ if (this.f_9766_ != null) { -+ if (this.f_9746_ - this.f_9735_ > 20) { -+ this.f_9735_ = this.f_9746_; -+ this.m_9774_( this.f_9766_.f_82479_, this.f_9766_.f_82480_, this.f_9766_.f_82481_, this.f_9743_.m_146908_(), this.f_9743_.m_146909_() ); ++ if (this.awaitingPositionFromClient != null) { ++ if (this.tickCount - this.awaitingTeleportTime > 20) { ++ this.awaitingTeleportTime = this.tickCount; ++ this.teleport( this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot() ); + } + + this.allowedPlayerTicks = 20; // CraftBukkit + } else { -+ this.f_9735_ = this.f_9746_; -+ double d0 = m_143609_( p_9874_.m_134129_( this.f_9743_.m_20185_() ) ); -+ double d1 = m_143653_( p_9874_.m_134140_( this.f_9743_.m_20186_() ) ); -+ double d2 = m_143609_( p_9874_.m_134146_( this.f_9743_.m_20189_() ) ); -+ float f = Mth.m_14177_( p_9874_.m_134131_( this.f_9743_.m_146908_() ) ); -+ float f1 = Mth.m_14177_( p_9874_.m_134142_( this.f_9743_.m_146909_() ) ); -+ if (this.f_9743_.m_20159_()) { -+ this.f_9743_.m_19890_( this.f_9743_.m_20185_(), this.f_9743_.m_20186_(), this.f_9743_.m_20189_(), f, f1 ); -+ this.f_9743_.m_183503_().m_7726_().m_8385_( this.f_9743_ ); ++ this.awaitingTeleportTime = this.tickCount; ++ double d0 = clampHorizontal( p_9874_.getX( this.player.getX() ) ); ++ double d1 = clampVertical( p_9874_.getY( this.player.getY() ) ); ++ double d2 = clampHorizontal( p_9874_.getZ( this.player.getZ() ) ); ++ float f = Mth.wrapDegrees( p_9874_.getYRot( this.player.getYRot() ) ); ++ float f1 = Mth.wrapDegrees( p_9874_.getXRot( this.player.getXRot() ) ); ++ if (this.player.isPassenger()) { ++ this.player.absMoveTo( this.player.getX(), this.player.getY(), this.player.getZ(), f, f1 ); ++ this.player.getLevel().getChunkSource().move( this.player ); + this.allowedPlayerTicks = 20; // CraftBukkit + } else { -+ double d3 = this.f_9743_.m_20185_(); -+ double d4 = this.f_9743_.m_20186_(); -+ double d5 = this.f_9743_.m_20189_(); -+ double d6 = this.f_9743_.m_20186_(); -+ double d7 = d0 - this.f_9753_; -+ double d8 = d1 - this.f_9754_; -+ double d9 = d2 - this.f_9755_; -+ double d10 = this.f_9743_.m_20184_().m_82556_(); ++ double d3 = this.player.getX(); ++ double d4 = this.player.getY(); ++ double d5 = this.player.getZ(); ++ double d6 = this.player.getY(); ++ double d7 = d0 - this.firstGoodX; ++ double d8 = d1 - this.firstGoodY; ++ double d9 = d2 - this.firstGoodZ; ++ double d10 = this.player.getDeltaMovement().lengthSqr(); + double d11 = d7 * d7 + d8 * d8 + d9 * d9; + // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify -+ double prevX = f_9743_.m_20185_(); -+ double prevY = f_9743_.m_20186_(); -+ double prevZ = f_9743_.m_20189_(); -+ float prevYaw = f_9743_.m_146908_(); -+ float prevPitch = f_9743_.m_146909_(); ++ double prevX = player.getX(); ++ double prevY = player.getY(); ++ double prevZ = player.getZ(); ++ float prevYaw = player.getYRot(); ++ float prevPitch = player.getXRot(); + // CraftBukkit end -+ if (this.f_9743_.m_5803_()) { ++ if (this.player.isSleeping()) { + if (d11 > 1.0D) { -+ this.m_9774_( this.f_9743_.m_20185_(), this.f_9743_.m_20186_(), this.f_9743_.m_20189_(), f, f1 ); ++ this.teleport( this.player.getX(), this.player.getY(), this.player.getZ(), f, f1 ); + } + + } else { -+ ++this.f_9740_; -+ int i = this.f_9740_ - this.f_9741_; ++ ++this.receivedMovePacketCount; ++ int i = this.receivedMovePacketCount - this.knownMovePacketCount; + + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); + this.lastTick = (int) (System.currentTimeMillis() / 50); + if (i > Math.max(this.allowedPlayerTicks, 5)) { -+ f_9744_.debug( "{} is sending move packets too frequently ({} packets since last tick)", this.f_9743_.m_7755_().getString(), i ); ++ LOGGER.debug( "{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i ); + i = 1; + } + -+ if (p_9874_.f_134125_ || d11 > 0) { ++ if (p_9874_.hasRot || d11 > 0) { + allowedPlayerTicks -= 1; + } else { + allowedPlayerTicks = 20; + } + double speed; -+ if (f_9743_.m_150110_().f_35935_) { -+ speed = f_9743_.m_150110_().f_35939_ * 20f; ++ if (player.getAbilities().flying) { ++ speed = player.getAbilities().flyingSpeed * 20f; + } else { -+ speed = f_9743_.m_150110_().f_35940_ * 10f; ++ speed = player.getAbilities().walkingSpeed * 10f; + } + -+ if (!this.f_9743_.m_8958_() && (!this.f_9743_.m_183503_().m_46469_().m_46207_( GameRules.f_46148_ ) || !this.f_9743_.m_21255_())) { -+ float f2 = this.f_9743_.m_21255_() ? 300.0F : 100.0F; -+ if (d11 - d10 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.m_9956_()) { // CraftBukkit end -+ f_9744_.warn( "{} moved too quickly! {},{},{}", this.f_9743_.m_7755_().getString(), d7, d8, d9 ); -+ this.m_9774_( this.f_9743_.m_20185_(), this.f_9743_.m_20186_(), this.f_9743_.m_20189_(), this.f_9743_.m_146908_(), this.f_9743_.m_146909_() ); ++ if (!this.player.isChangingDimension() && (!this.player.getLevel().getGameRules().getBoolean( GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK ) || !this.player.isFallFlying())) { ++ float f2 = this.player.isFallFlying() ? 300.0F : 100.0F; ++ if (d11 - d10 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // CraftBukkit end ++ LOGGER.warn( "{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9 ); ++ this.teleport( this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot() ); + return; + } + } + -+ AABB aabb = this.f_9743_.m_142469_(); -+ d7 = d0 - this.f_9756_; -+ d8 = d1 - this.f_9757_; -+ d9 = d2 - this.f_9758_; ++ AABB aabb = this.player.getBoundingBox(); ++ d7 = d0 - this.lastGoodX; ++ d8 = d1 - this.lastGoodY; ++ d9 = d2 - this.lastGoodZ; + boolean flag = d8 > 0.0D; -+ if (this.f_9743_.m_20096_() && !p_9874_.m_134139_() && flag) { -+ this.f_9743_.m_6135_(); ++ if (this.player.isOnGround() && !p_9874_.isOnGround() && flag) { ++ this.player.jumpFromGround(); + } + -+ boolean flag1 = this.f_9743_.f_201939_; -+ this.f_9743_.m_6478_( MoverType.PLAYER, new Vec3( d7, d8, d9 ) ); -+ this.f_9743_.f_19861_ = p_9874_.m_134139_(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move -+ d7 = d0 - this.f_9743_.m_20185_(); -+ d8 = d1 - this.f_9743_.m_20186_(); ++ boolean flag1 = this.player.verticalCollisionBelow; ++ this.player.move( MoverType.PLAYER, new Vec3( d7, d8, d9 ) ); ++ this.player.onGround = p_9874_.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move ++ d7 = d0 - this.player.getX(); ++ d8 = d1 - this.player.getY(); + if (d8 > -0.5D || d8 < 0.5D) { + d8 = 0.0D; + } + -+ d9 = d2 - this.f_9743_.m_20189_(); ++ d9 = d2 - this.player.getZ(); + d11 = d7 * d7 + d8 * d8 + d9 * d9; + boolean flag2 = false; -+ if (!this.f_9743_.m_8958_() && d11 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.f_9743_.m_5803_() && !this.f_9743_.f_8941_.m_9295_() && this.f_9743_.f_8941_.m_9290_() != GameType.SPECTATOR) { // Spigot ++ if (!this.player.isChangingDimension() && d11 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot + flag2 = true; -+ f_9744_.warn( "{} moved wrongly!", (Object) this.f_9743_.m_7755_().getString() ); ++ LOGGER.warn( "{} moved wrongly!", (Object) this.player.getName().getString() ); + } + -+ this.f_9743_.m_19890_( d0, d1, d2, f, f1 ); -+ if (this.f_9743_.f_19794_ || this.f_9743_.m_5803_() || (!flag2 || !serverlevel.m_45756_( this.f_9743_, aabb )) && !this.m_9795_( serverlevel, aabb )) { ++ this.player.absMoveTo( d0, d1, d2, f, f1 ); ++ if (this.player.noPhysics || this.player.isSleeping() || (!flag2 || !serverlevel.noCollision( this.player, aabb )) && !this.isPlayerCollidingWithAnythingNew( serverlevel, aabb )) { + // CraftBukkit start - fire PlayerMoveEvent + // Rest to old location first -+ this.f_9743_.m_19890_(prevX, prevY, prevZ, prevYaw, prevPitch); ++ this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); + + org.bukkit.entity.Player player = this.getCraftPlayer(); + org.bukkit.Location from = new org.bukkit.Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous org.bukkit.event.Event location. + org.bukkit.Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + + // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (p_9874_.f_134124_) { -+ to.setX(p_9874_.f_134118_); -+ to.setY(p_9874_.f_134119_); -+ to.setZ(p_9874_.f_134120_); ++ if (p_9874_.hasPos) { ++ to.setX(p_9874_.x); ++ to.setY(p_9874_.y); ++ to.setZ(p_9874_.z); + } + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (p_9874_.f_134125_) { -+ to.setYaw(p_9874_.f_134121_); -+ to.setPitch(p_9874_.f_134122_); ++ if (p_9874_.hasRot) { ++ to.setYaw(p_9874_.yRot); ++ to.setPitch(p_9874_.xRot); + } + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.f_9743_.m_6107_()) { ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); @@ -1302,7 +1302,7 @@ + // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. + // We only do this if the org.bukkit.event.Event was not cancelled. + if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { -+ this.f_9743_.getBukkitEntity().teleport(event.getTo(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.PLUGIN); ++ this.player.getBukkitEntity().teleport(event.getTo(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.PLUGIN); + return; + } + @@ -1314,23 +1314,23 @@ + } + } + } -+ this.f_9743_.m_19890_(d0, d1, d2, f, f1); // Copied from above ++ this.player.absMoveTo(d0, d1, d2, f, f1); // Copied from above + // CraftBukkit end + -+ this.f_9736_ = d8 >= -0.03125D && !flag1 && this.f_9743_.f_8941_.m_9290_() != GameType.SPECTATOR && !this.f_9745_.m_129915_() && !this.f_9743_.m_150110_().f_35936_ && !this.f_9743_.m_21023_( MobEffects.f_19620_ ) && !this.f_9743_.m_21255_() && !this.f_9743_.m_21209_() && this.m_9793_( this.f_9743_ ); -+ this.f_9743_.m_183503_().m_7726_().m_8385_( this.f_9743_ ); -+ this.f_9743_.m_8972_( this.f_9743_.m_20186_() - d6, p_9874_.m_134139_() ); -+ this.f_9743_.m_6853_( p_9874_.m_134139_() ); ++ this.clientIsFloating = d8 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect( MobEffects.LEVITATION ) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround( this.player ); ++ this.player.getLevel().getChunkSource().move( this.player ); ++ this.player.doCheckFallDamage( this.player.getY() - d6, p_9874_.isOnGround() ); ++ this.player.setOnGround( p_9874_.isOnGround() ); + if (flag) { -+ this.f_9743_.m_183634_(); ++ this.player.resetFallDistance(); + } + -+ this.f_9743_.m_36378_( this.f_9743_.m_20185_() - d3, this.f_9743_.m_20186_() - d4, this.f_9743_.m_20189_() - d5 ); -+ this.f_9756_ = this.f_9743_.m_20185_(); -+ this.f_9757_ = this.f_9743_.m_20186_(); -+ this.f_9758_ = this.f_9743_.m_20189_(); ++ this.player.checkMovementStatistics( this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5 ); ++ this.lastGoodX = this.player.getX(); ++ this.lastGoodY = this.player.getY(); ++ this.lastGoodZ = this.player.getZ(); + } else { -+ this.m_9774_( d3, d4, d5, f, f1 ); ++ this.teleport( d3, d4, d5, f, f1 ); + } + } + } @@ -1339,12 +1339,12 @@ + } + } + -+ private boolean m_9795_(LevelReader p_9796_, AABB p_9797_) { -+ Iterable iterable = p_9796_.m_186431_( this.f_9743_, this.f_9743_.m_142469_().m_82406_( (double) 1.0E-5F ) ); -+ VoxelShape voxelshape = Shapes.m_83064_( p_9797_.m_82406_( (double) 1.0E-5F ) ); ++ private boolean isPlayerCollidingWithAnythingNew(LevelReader p_9796_, AABB p_9797_) { ++ Iterable iterable = p_9796_.getCollisions( this.player, this.player.getBoundingBox().deflate( (double) 1.0E-5F ) ); ++ VoxelShape voxelshape = Shapes.create( p_9797_.deflate( (double) 1.0E-5F ) ); + + for (VoxelShape voxelshape1 : iterable) { -+ if (!Shapes.m_83157_( voxelshape1, voxelshape, BooleanOp.f_82689_ )) { ++ if (!Shapes.joinIsNotEmpty( voxelshape1, voxelshape, BooleanOp.AND )) { + return true; + } + } @@ -1353,34 +1353,34 @@ + } + + // CraftBukkit start - Delegate to teleport(org.bukkit.Location) -+ public void m_143611_(double p_143612_, double p_143613_, double p_143614_, float p_143615_, float p_143616_) { ++ public void dismount(double p_143612_, double p_143613_, double p_143614_, float p_143615_, float p_143616_) { + this.dismount( p_143612_, p_143613_, p_143614_, p_143615_, p_143616_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN ); + } + + public void dismount(double p_143612_, double p_143613_, double p_143614_, float p_143615_, float p_143616_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + this.prepareTeleport(cause); -+ this.m_143617_( p_143612_, p_143613_, p_143614_, p_143615_, p_143616_, Collections.emptySet(), true ); ++ this.teleport( p_143612_, p_143613_, p_143614_, p_143615_, p_143616_, Collections.emptySet(), true ); + } + + //Magma start - move bukkit teleport to its own method -+ public void m_9774_(double p_9775_, double p_9776_, double p_9777_, float p_9778_, float p_9779_) { ++ public void teleport(double p_9775_, double p_9776_, double p_9777_, float p_9778_, float p_9779_) { + this.teleport( p_9775_, p_9776_, p_9777_, p_9778_, p_9779_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN ); + } + + public void teleport(double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + this.prepareTeleport(cause); -+ this.m_143617_( d0, d1, d2, f, f1, Collections.emptySet(), false ); ++ this.teleport( d0, d1, d2, f, f1, Collections.emptySet(), false ); + } + + + public void teleport(double p_9781_, double p_9782_, double p_9783_, float p_9784_, float p_9785_, Set p_9786_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + this.prepareTeleport(cause); -+ this.m_143617_( p_9781_, p_9782_, p_9783_, p_9784_, p_9785_, p_9786_, false ); ++ this.teleport( p_9781_, p_9782_, p_9783_, p_9784_, p_9785_, p_9786_, false ); + } + -+ public void m_9780_(double p_9781_, double p_9782_, double p_9783_, float p_9784_, float p_9785_, Set p_9786_) { ++ public void teleport(double p_9781_, double p_9782_, double p_9783_, float p_9784_, float p_9785_, Set p_9786_) { + resetCause(); -+ this.m_143617_( p_9781_, p_9782_, p_9783_, p_9784_, p_9785_, p_9786_, false ); ++ this.teleport( p_9781_, p_9782_, p_9783_, p_9784_, p_9785_, p_9786_, false ); + } + + org.bukkit.event.player.PlayerTeleportEvent.TeleportCause teleportCause = org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN; @@ -1394,7 +1394,7 @@ + } + + private boolean teleportResult = true; //assume that the player teleported successfully -+ public void m_143617_(double p_143618_, double p_143619_, double p_143620_, float p_143621_, float p_143622_, Set p_143623_, boolean p_143624_) { ++ public void teleport(double p_143618_, double p_143619_, double p_143620_, float p_143621_, float p_143622_, Set p_143623_, boolean p_143624_) { + org.bukkit.event.player.PlayerTeleportEvent.TeleportCause tmp = teleportCause; + resetCause(); + teleportResult = true; @@ -1434,7 +1434,7 @@ + + public boolean teleport(double p_143618_, double p_143619_, double p_143620_, float p_143621_, float p_143622_, Set p_143623_, boolean p_143624_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + this.prepareTeleport(cause); -+ this.m_143617_( p_143618_, p_143619_, p_143620_, p_143621_, p_143622_, p_143623_, p_143624_ ); ++ this.teleport( p_143618_, p_143619_, p_143620_, p_143621_, p_143622_, p_143623_, p_143624_ ); + boolean result = teleportResult; + teleportResult = true; //reset + return result; @@ -1452,64 +1452,64 @@ + } + + this.justTeleported = true; -+ double d0 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.X ) ? this.f_9743_.m_20185_() : 0.0D; -+ double d1 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.Y ) ? this.f_9743_.m_20186_() : 0.0D; -+ double d2 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.Z ) ? this.f_9743_.m_20189_() : 0.0D; -+ float f = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.Y_ROT ) ? this.f_9743_.m_146908_() : 0.0F; -+ float f1 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.X_ROT ) ? this.f_9743_.m_146909_() : 0.0F; -+ this.f_9766_ = new Vec3( p_143618_, p_143619_, p_143620_ ); -+ if (++this.f_9767_ == Integer.MAX_VALUE) { -+ this.f_9767_ = 0; ++ double d0 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.X ) ? this.player.getX() : 0.0D; ++ double d1 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.Y ) ? this.player.getY() : 0.0D; ++ double d2 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.Z ) ? this.player.getZ() : 0.0D; ++ float f = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.Y_ROT ) ? this.player.getYRot() : 0.0F; ++ float f1 = p_143623_.contains( ClientboundPlayerPositionPacket.RelativeArgument.X_ROT ) ? this.player.getXRot() : 0.0F; ++ this.awaitingPositionFromClient = new Vec3( p_143618_, p_143619_, p_143620_ ); ++ if (++this.awaitingTeleport == Integer.MAX_VALUE) { ++ this.awaitingTeleport = 0; + } + + // CraftBukkit start - update last location -+ this.lastPosX = this.f_9766_.f_82479_; -+ this.lastPosY = this.f_9766_.f_82480_; -+ this.lastPosZ = this.f_9766_.f_82481_; ++ this.lastPosX = this.awaitingPositionFromClient.x; ++ this.lastPosY = this.awaitingPositionFromClient.y; ++ this.lastPosZ = this.awaitingPositionFromClient.z; + this.lastYaw = f; + this.lastPitch = f1; + // CraftBukkit end + -+ this.f_9735_ = this.f_9746_; -+ this.f_9743_.m_19890_( p_143618_, p_143619_, p_143620_, p_143621_, p_143622_ ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundPlayerPositionPacket( p_143618_ - d0, p_143619_ - d1, p_143620_ - d2, p_143621_ - f, p_143622_ - f1, p_143623_, this.f_9767_, p_143624_ ) ); ++ this.awaitingTeleportTime = this.tickCount; ++ this.player.absMoveTo( p_143618_, p_143619_, p_143620_, p_143621_, p_143622_ ); ++ this.player.connection.send( new ClientboundPlayerPositionPacket( p_143618_ - d0, p_143619_ - d1, p_143620_ - d2, p_143621_ - f, p_143622_ - f1, p_143623_, this.awaitingTeleport, p_143624_ ) ); + } + -+ public void m_7502_(ServerboundPlayerActionPacket p_9889_) { -+ PacketUtils.m_131359_( p_9889_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ BlockPos blockpos = p_9889_.m_134281_(); -+ this.f_9743_.m_9243_(); -+ ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_9889_.m_134285_(); ++ public void handlePlayerAction(ServerboundPlayerActionPacket p_9889_) { ++ PacketUtils.ensureRunningOnSameThread( p_9889_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit ++ BlockPos blockpos = p_9889_.getPos(); ++ this.player.resetLastActionTime(); ++ ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_9889_.getAction(); + switch (serverboundplayeractionpacket$action) { + case SWAP_ITEM_WITH_OFFHAND: -+ if (!this.f_9743_.m_5833_()) { -+ ItemStack itemstack = this.f_9743_.m_21120_( InteractionHand.OFF_HAND ); ++ if (!this.player.isSpectator()) { ++ ItemStack itemstack = this.player.getItemInHand( InteractionHand.OFF_HAND ); + // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack mainHand = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack offHand = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_9743_.m_21120_(InteractionHand.MAIN_HAND)); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack offHand = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.player.getItemInHand(InteractionHand.MAIN_HAND)); + org.bukkit.event.player.PlayerSwapHandItemsEvent swapItemsEvent = new org.bukkit.event.player.PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone()); + this.cserver.getPluginManager().callEvent(swapItemsEvent); + if (swapItemsEvent.isCancelled()) { + return; + } + if (swapItemsEvent.getOffHandItem().equals(offHand)) { -+ this.f_9743_.m_21008_(InteractionHand.OFF_HAND, this.f_9743_.m_21120_(InteractionHand.MAIN_HAND)); ++ this.player.setItemInHand(InteractionHand.OFF_HAND, this.player.getItemInHand(InteractionHand.MAIN_HAND)); + } else { -+ this.f_9743_.m_21008_(InteractionHand.OFF_HAND, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); ++ this.player.setItemInHand(InteractionHand.OFF_HAND, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); + } + if (swapItemsEvent.getMainHandItem().equals(mainHand)) { -+ this.f_9743_.m_21008_(InteractionHand.MAIN_HAND, itemstack); ++ this.player.setItemInHand(InteractionHand.MAIN_HAND, itemstack); + } else { -+ this.f_9743_.m_21008_(InteractionHand.MAIN_HAND, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); ++ this.player.setItemInHand(InteractionHand.MAIN_HAND, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); + } + // CraftBukkit end -+ this.f_9743_.m_5810_(); ++ this.player.stopUsingItem(); + } + + return; + case DROP_ITEM: -+ if (!this.f_9743_.m_5833_()) { ++ if (!this.player.isSpectator()) { + // limit how quickly items can be dropped + // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. + if (this.lastDropTick != MinecraftServer.currentTick) { @@ -1519,261 +1519,261 @@ + // Else we increment the drop count and check the amount. + this.dropCount++; + if (this.dropCount >= 20) { -+ f_9744_.warn(this.f_9743_.m_6302_() + " dropped their items too quickly!"); ++ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!"); + this.disconnect("You dropped your items too quickly (Hacking?)"); + return; + } + } + // CraftBukkit end -+ this.f_9743_.m_182294_(false); ++ this.player.drop(false); + } + + return; + case DROP_ALL_ITEMS: -+ if (!this.f_9743_.m_5833_()) { -+ this.f_9743_.m_182294_( true ); ++ if (!this.player.isSpectator()) { ++ this.player.drop( true ); + } + + return; + case RELEASE_USE_ITEM: -+ this.f_9743_.m_21253_(); ++ this.player.releaseUsingItem(); + return; + case START_DESTROY_BLOCK: + case ABORT_DESTROY_BLOCK: + case STOP_DESTROY_BLOCK: -+ this.f_9743_.f_8941_.m_7391_( blockpos, serverboundplayeractionpacket$action, p_9889_.m_134284_(), this.f_9743_.f_19853_.m_151558_() ); ++ this.player.gameMode.handleBlockBreakAction( blockpos, serverboundplayeractionpacket$action, p_9889_.getDirection(), this.player.level.getMaxBuildHeight() ); + return; default: -- blockstate1 = Blocks.f_50272_.m_49966_(); +- blockstate1 = Blocks.COMMAND_BLOCK.defaultBlockState(); - } - -- BlockState blockstate2 = blockstate1.m_61124_(CommandBlock.f_51793_, direction).m_61124_(CommandBlock.f_51794_, Boolean.valueOf(p_9911_.m_134526_())); +- BlockState blockstate2 = blockstate1.setValue(CommandBlock.FACING, direction).setValue(CommandBlock.CONDITIONAL, Boolean.valueOf(p_9911_.isConditional())); - if (blockstate2 != blockstate) { -- this.f_9743_.f_19853_.m_7731_(blockpos, blockstate2, 2); -- blockentity.m_155250_(blockstate2); -- this.f_9743_.f_19853_.m_46745_(blockpos).m_142169_(blockentity); +- this.player.level.setBlock(blockpos, blockstate2, 2); +- blockentity.setBlockState(blockstate2); +- this.player.level.getChunkAt(blockpos).setBlockEntity(blockentity); - } - -- basecommandblock.m_6590_(s); -- basecommandblock.m_45428_(flag); +- basecommandblock.setCommand(s); +- basecommandblock.setTrackOutput(flag); - if (!flag) { -- basecommandblock.m_45433_((Component)null); +- basecommandblock.setLastOutput((Component)null); - } - -- commandblockentity.m_59137_(p_9911_.m_134527_()); -- if (commandblockentity$mode != p_9911_.m_134528_()) { -- commandblockentity.m_59144_(); +- commandblockentity.setAutomatic(p_9911_.isAutomatic()); +- if (commandblockentity$mode != p_9911_.getMode()) { +- commandblockentity.onModeSwitch(); - } - -- basecommandblock.m_7368_(); -- if (!StringUtil.m_14408_(s)) { -- this.f_9743_.m_6352_(new TranslatableComponent("advMode.setCommand.success", s), Util.f_137441_); +- basecommandblock.onUpdated(); +- if (!StringUtil.isNullOrEmpty(s)) { +- this.player.sendMessage(new TranslatableComponent("advMode.setCommand.success", s), Util.NIL_UUID); - } - } - - } - } - -- public void m_6629_(ServerboundSetCommandMinecartPacket p_9913_) { -- PacketUtils.m_131359_(p_9913_, this, this.f_9743_.m_183503_()); -- if (!this.f_9745_.m_6993_()) { -- this.f_9743_.m_6352_(new TranslatableComponent("advMode.notEnabled"), Util.f_137441_); -- } else if (!this.f_9743_.m_36337_()) { -- this.f_9743_.m_6352_(new TranslatableComponent("advMode.notAllowed"), Util.f_137441_); +- public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket p_9913_) { +- PacketUtils.ensureRunningOnSameThread(p_9913_, this, this.player.getLevel()); +- if (!this.server.isCommandBlockEnabled()) { +- this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID); +- } else if (!this.player.canUseGameMasterBlocks()) { +- this.player.sendMessage(new TranslatableComponent("advMode.notAllowed"), Util.NIL_UUID); - } else { -- BaseCommandBlock basecommandblock = p_9913_.m_134537_(this.f_9743_.f_19853_); +- BaseCommandBlock basecommandblock = p_9913_.getCommandBlock(this.player.level); - if (basecommandblock != null) { -- basecommandblock.m_6590_(p_9913_.m_134545_()); -- basecommandblock.m_45428_(p_9913_.m_134548_()); -- if (!p_9913_.m_134548_()) { -- basecommandblock.m_45433_((Component)null); +- basecommandblock.setCommand(p_9913_.getCommand()); +- basecommandblock.setTrackOutput(p_9913_.isTrackOutput()); +- if (!p_9913_.isTrackOutput()) { +- basecommandblock.setLastOutput((Component)null); - } - -- basecommandblock.m_7368_(); -- this.f_9743_.m_6352_(new TranslatableComponent("advMode.setCommand.success", p_9913_.m_134545_()), Util.f_137441_); +- basecommandblock.onUpdated(); +- this.player.sendMessage(new TranslatableComponent("advMode.setCommand.success", p_9913_.getCommand()), Util.NIL_UUID); - } - - } - } - -- public void m_7965_(ServerboundPickItemPacket p_9880_) { -- PacketUtils.m_131359_(p_9880_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_150109_().m_36038_(p_9880_.m_134232_()); -- this.f_9743_.f_8906_.m_141995_(new ClientboundContainerSetSlotPacket(-2, 0, this.f_9743_.m_150109_().f_35977_, this.f_9743_.m_150109_().m_8020_(this.f_9743_.m_150109_().f_35977_))); -- this.f_9743_.f_8906_.m_141995_(new ClientboundContainerSetSlotPacket(-2, 0, p_9880_.m_134232_(), this.f_9743_.m_150109_().m_8020_(p_9880_.m_134232_()))); -- this.f_9743_.f_8906_.m_141995_(new ClientboundSetCarriedItemPacket(this.f_9743_.m_150109_().f_35977_)); +- public void handlePickItem(ServerboundPickItemPacket p_9880_) { +- PacketUtils.ensureRunningOnSameThread(p_9880_, this, this.player.getLevel()); +- this.player.getInventory().pickSlot(p_9880_.getSlot()); +- this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, this.player.getInventory().selected, this.player.getInventory().getItem(this.player.getInventory().selected))); +- this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, p_9880_.getSlot(), this.player.getInventory().getItem(p_9880_.getSlot()))); +- this.player.connection.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected)); - } - -- public void m_5591_(ServerboundRenameItemPacket p_9899_) { -- PacketUtils.m_131359_(p_9899_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.f_36096_ instanceof AnvilMenu) { -- AnvilMenu anvilmenu = (AnvilMenu)this.f_9743_.f_36096_; -- String s = SharedConstants.m_136190_(p_9899_.m_134403_()); +- public void handleRenameItem(ServerboundRenameItemPacket p_9899_) { +- PacketUtils.ensureRunningOnSameThread(p_9899_, this, this.player.getLevel()); +- if (this.player.containerMenu instanceof AnvilMenu) { +- AnvilMenu anvilmenu = (AnvilMenu)this.player.containerMenu; +- String s = SharedConstants.filterText(p_9899_.getName()); - if (s.length() <= 50) { -- anvilmenu.m_39020_(s); +- anvilmenu.setItemName(s); - } - } - - } - -- public void m_5712_(ServerboundSetBeaconPacket p_9907_) { -- PacketUtils.m_131359_(p_9907_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.f_36096_ instanceof BeaconMenu) { -- ((BeaconMenu)this.f_9743_.f_36096_).m_39053_(p_9907_.m_134484_(), p_9907_.m_134487_()); +- public void handleSetBeaconPacket(ServerboundSetBeaconPacket p_9907_) { +- PacketUtils.ensureRunningOnSameThread(p_9907_, this, this.player.getLevel()); +- if (this.player.containerMenu instanceof BeaconMenu) { +- ((BeaconMenu)this.player.containerMenu).updateEffects(p_9907_.getPrimary(), p_9907_.getSecondary()); - } - - } - -- public void m_7424_(ServerboundSetStructureBlockPacket p_9919_) { -- PacketUtils.m_131359_(p_9919_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_36337_()) { -- BlockPos blockpos = p_9919_.m_134629_(); -- BlockState blockstate = this.f_9743_.f_19853_.m_8055_(blockpos); -- BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_(blockpos); +- public void handleSetStructureBlock(ServerboundSetStructureBlockPacket p_9919_) { +- PacketUtils.ensureRunningOnSameThread(p_9919_, this, this.player.getLevel()); +- if (this.player.canUseGameMasterBlocks()) { +- BlockPos blockpos = p_9919_.getPos(); +- BlockState blockstate = this.player.level.getBlockState(blockpos); +- BlockEntity blockentity = this.player.level.getBlockEntity(blockpos); - if (blockentity instanceof StructureBlockEntity) { - StructureBlockEntity structureblockentity = (StructureBlockEntity)blockentity; -- structureblockentity.m_59860_(p_9919_.m_134633_()); -- structureblockentity.m_59868_(p_9919_.m_134634_()); -- structureblockentity.m_59885_(p_9919_.m_134635_()); -- structureblockentity.m_155797_(p_9919_.m_179787_()); -- structureblockentity.m_59881_(p_9919_.m_134637_()); -- structureblockentity.m_59883_(p_9919_.m_134638_()); -- structureblockentity.m_59887_(p_9919_.m_134639_()); -- structureblockentity.m_59876_(p_9919_.m_134640_()); -- structureblockentity.m_59896_(p_9919_.m_134641_()); -- structureblockentity.m_59898_(p_9919_.m_134642_()); -- structureblockentity.m_59838_(p_9919_.m_134643_()); -- structureblockentity.m_59840_(p_9919_.m_134644_()); -- if (structureblockentity.m_59901_()) { -- String s = structureblockentity.m_59895_(); -- if (p_9919_.m_134632_() == StructureBlockEntity.UpdateType.SAVE_AREA) { -- if (structureblockentity.m_59830_()) { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.save_success", s), false); +- structureblockentity.setMode(p_9919_.getMode()); +- structureblockentity.setStructureName(p_9919_.getName()); +- structureblockentity.setStructurePos(p_9919_.getOffset()); +- structureblockentity.setStructureSize(p_9919_.getSize()); +- structureblockentity.setMirror(p_9919_.getMirror()); +- structureblockentity.setRotation(p_9919_.getRotation()); +- structureblockentity.setMetaData(p_9919_.getData()); +- structureblockentity.setIgnoreEntities(p_9919_.isIgnoreEntities()); +- structureblockentity.setShowAir(p_9919_.isShowAir()); +- structureblockentity.setShowBoundingBox(p_9919_.isShowBoundingBox()); +- structureblockentity.setIntegrity(p_9919_.getIntegrity()); +- structureblockentity.setSeed(p_9919_.getSeed()); +- if (structureblockentity.hasStructureName()) { +- String s = structureblockentity.getStructureName(); +- if (p_9919_.getUpdateType() == StructureBlockEntity.UpdateType.SAVE_AREA) { +- if (structureblockentity.saveStructure()) { +- this.player.displayClientMessage(new TranslatableComponent("structure_block.save_success", s), false); - } else { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.save_failure", s), false); +- this.player.displayClientMessage(new TranslatableComponent("structure_block.save_failure", s), false); - } -- } else if (p_9919_.m_134632_() == StructureBlockEntity.UpdateType.LOAD_AREA) { -- if (!structureblockentity.m_59832_()) { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.load_not_found", s), false); -- } else if (structureblockentity.m_59842_(this.f_9743_.m_183503_())) { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.load_success", s), false); +- } else if (p_9919_.getUpdateType() == StructureBlockEntity.UpdateType.LOAD_AREA) { +- if (!structureblockentity.isStructureLoadable()) { +- this.player.displayClientMessage(new TranslatableComponent("structure_block.load_not_found", s), false); +- } else if (structureblockentity.loadStructure(this.player.getLevel())) { +- this.player.displayClientMessage(new TranslatableComponent("structure_block.load_success", s), false); - } else { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.load_prepare", s), false); +- this.player.displayClientMessage(new TranslatableComponent("structure_block.load_prepare", s), false); - } -- } else if (p_9919_.m_134632_() == StructureBlockEntity.UpdateType.SCAN_AREA) { -- if (structureblockentity.m_59829_()) { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.size_success", s), false); +- } else if (p_9919_.getUpdateType() == StructureBlockEntity.UpdateType.SCAN_AREA) { +- if (structureblockentity.detectSize()) { +- this.player.displayClientMessage(new TranslatableComponent("structure_block.size_success", s), false); - } else { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.size_failure"), false); +- this.player.displayClientMessage(new TranslatableComponent("structure_block.size_failure"), false); - } - } - } else { -- this.f_9743_.m_5661_(new TranslatableComponent("structure_block.invalid_structure_name", p_9919_.m_134634_()), false); +- this.player.displayClientMessage(new TranslatableComponent("structure_block.invalid_structure_name", p_9919_.getName()), false); - } - -- structureblockentity.m_6596_(); -- this.f_9743_.f_19853_.m_7260_(blockpos, blockstate, blockstate, 3); +- structureblockentity.setChanged(); +- this.player.level.sendBlockUpdated(blockpos, blockstate, blockstate, 3); - } - - } - } - -- public void m_8019_(ServerboundSetJigsawBlockPacket p_9917_) { -- PacketUtils.m_131359_(p_9917_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_36337_()) { -- BlockPos blockpos = p_9917_.m_134585_(); -- BlockState blockstate = this.f_9743_.f_19853_.m_8055_(blockpos); -- BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_(blockpos); +- public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket p_9917_) { +- PacketUtils.ensureRunningOnSameThread(p_9917_, this, this.player.getLevel()); +- if (this.player.canUseGameMasterBlocks()) { +- BlockPos blockpos = p_9917_.getPos(); +- BlockState blockstate = this.player.level.getBlockState(blockpos); +- BlockEntity blockentity = this.player.level.getBlockEntity(blockpos); - if (blockentity instanceof JigsawBlockEntity) { - JigsawBlockEntity jigsawblockentity = (JigsawBlockEntity)blockentity; -- jigsawblockentity.m_59435_(p_9917_.m_134588_()); -- jigsawblockentity.m_59438_(p_9917_.m_134589_()); -- jigsawblockentity.m_59440_(p_9917_.m_134590_()); -- jigsawblockentity.m_59431_(p_9917_.m_134591_()); -- jigsawblockentity.m_59424_(p_9917_.m_134592_()); -- jigsawblockentity.m_6596_(); -- this.f_9743_.f_19853_.m_7260_(blockpos, blockstate, blockstate, 3); +- jigsawblockentity.setName(p_9917_.getName()); +- jigsawblockentity.setTarget(p_9917_.getTarget()); +- jigsawblockentity.setPool(p_9917_.getPool()); +- jigsawblockentity.setFinalState(p_9917_.getFinalState()); +- jigsawblockentity.setJoint(p_9917_.getJoint()); +- jigsawblockentity.setChanged(); +- this.player.level.sendBlockUpdated(blockpos, blockstate, blockstate, 3); - } - - } - } - -- public void m_6449_(ServerboundJigsawGeneratePacket p_9868_) { -- PacketUtils.m_131359_(p_9868_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_36337_()) { -- BlockPos blockpos = p_9868_.m_134087_(); -- BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_(blockpos); +- public void handleJigsawGenerate(ServerboundJigsawGeneratePacket p_9868_) { +- PacketUtils.ensureRunningOnSameThread(p_9868_, this, this.player.getLevel()); +- if (this.player.canUseGameMasterBlocks()) { +- BlockPos blockpos = p_9868_.getPos(); +- BlockEntity blockentity = this.player.level.getBlockEntity(blockpos); - if (blockentity instanceof JigsawBlockEntity) { - JigsawBlockEntity jigsawblockentity = (JigsawBlockEntity)blockentity; -- jigsawblockentity.m_59420_(this.f_9743_.m_183503_(), p_9868_.m_134090_(), p_9868_.m_134091_()); +- jigsawblockentity.generate(this.player.getLevel(), p_9868_.levels(), p_9868_.keepJigsaws()); - } - - } - } - -- public void m_6321_(ServerboundSelectTradePacket p_9905_) { -- PacketUtils.m_131359_(p_9905_, this, this.f_9743_.m_183503_()); -- int i = p_9905_.m_134469_(); -- AbstractContainerMenu abstractcontainermenu = this.f_9743_.f_36096_; +- public void handleSelectTrade(ServerboundSelectTradePacket p_9905_) { +- PacketUtils.ensureRunningOnSameThread(p_9905_, this, this.player.getLevel()); +- int i = p_9905_.getItem(); +- AbstractContainerMenu abstractcontainermenu = this.player.containerMenu; - if (abstractcontainermenu instanceof MerchantMenu) { - MerchantMenu merchantmenu = (MerchantMenu)abstractcontainermenu; -- merchantmenu.m_40063_(i); -- merchantmenu.m_40072_(i); +- merchantmenu.setSelectionHint(i); +- merchantmenu.tryMoveItems(i); - } - - } - -- public void m_6829_(ServerboundEditBookPacket p_9862_) { -- int i = p_9862_.m_134013_(); -- if (Inventory.m_36045_(i) || i == 40) { +- public void handleEditBook(ServerboundEditBookPacket p_9862_) { +- int i = p_9862_.getSlot(); +- if (Inventory.isHotbarSlot(i) || i == 40) { - List list = Lists.newArrayList(); -- Optional optional = p_9862_.m_182761_(); +- Optional optional = p_9862_.getTitle(); - optional.ifPresent(list::add); -- p_9862_.m_182755_().stream().limit(100L).forEach(list::add); -- this.m_9815_(list, optional.isPresent() ? (p_143657_) -> { -- this.m_143630_(p_143657_.get(0), p_143657_.subList(1, p_143657_.size()), i); +- p_9862_.getPages().stream().limit(100L).forEach(list::add); +- this.filterTextPacket(list, optional.isPresent() ? (p_143657_) -> { +- this.signBook(p_143657_.get(0), p_143657_.subList(1, p_143657_.size()), i); - } : (p_143627_) -> { -- this.m_9812_(p_143627_, i); +- this.updateBookContents(p_143627_, i); - }); - } - } - -- private void m_9812_(List p_9813_, int p_9814_) { -- ItemStack itemstack = this.f_9743_.m_150109_().m_8020_(p_9814_); -- if (itemstack.m_150930_(Items.f_42614_)) { -- this.m_143634_(p_9813_, UnaryOperator.identity(), itemstack); +- private void updateBookContents(List p_9813_, int p_9814_) { +- ItemStack itemstack = this.player.getInventory().getItem(p_9814_); +- if (itemstack.is(Items.WRITABLE_BOOK)) { +- this.updateBookPages(p_9813_, UnaryOperator.identity(), itemstack); - } - } - -- private void m_143630_(TextFilter.FilteredText p_143631_, List p_143632_, int p_143633_) { -- ItemStack itemstack = this.f_9743_.m_150109_().m_8020_(p_143633_); -- if (itemstack.m_150930_(Items.f_42614_)) { -- ItemStack itemstack1 = new ItemStack(Items.f_42615_); -- CompoundTag compoundtag = itemstack.m_41783_(); +- private void signBook(TextFilter.FilteredText p_143631_, List p_143632_, int p_143633_) { +- ItemStack itemstack = this.player.getInventory().getItem(p_143633_); +- if (itemstack.is(Items.WRITABLE_BOOK)) { +- ItemStack itemstack1 = new ItemStack(Items.WRITTEN_BOOK); +- CompoundTag compoundtag = itemstack.getTag(); - if (compoundtag != null) { -- itemstack1.m_41751_(compoundtag.m_6426_()); +- itemstack1.setTag(compoundtag.copy()); - } - -- itemstack1.m_41700_("author", StringTag.m_129297_(this.f_9743_.m_7755_().getString())); -- if (this.f_9743_.m_143387_()) { -- itemstack1.m_41700_("title", StringTag.m_129297_(p_143631_.m_143722_())); +- itemstack1.addTagElement("author", StringTag.valueOf(this.player.getName().getString())); +- if (this.player.isTextFilteringEnabled()) { +- itemstack1.addTagElement("title", StringTag.valueOf(p_143631_.getFiltered())); - } else { -- itemstack1.m_41700_("filtered_title", StringTag.m_129297_(p_143631_.m_143722_())); -- itemstack1.m_41700_("title", StringTag.m_129297_(p_143631_.m_143719_())); +- itemstack1.addTagElement("filtered_title", StringTag.valueOf(p_143631_.getFiltered())); +- itemstack1.addTagElement("title", StringTag.valueOf(p_143631_.getRaw())); - } - -- this.m_143634_(p_143632_, (p_143659_) -> { -- return Component.Serializer.m_130703_(new TextComponent(p_143659_)); +- this.updateBookPages(p_143632_, (p_143659_) -> { +- return Component.Serializer.toJson(new TextComponent(p_143659_)); - }, itemstack1); -- this.f_9743_.m_150109_().m_6836_(p_143633_, itemstack1); +- this.player.getInventory().setItem(p_143633_, itemstack1); - } - } - -- private void m_143634_(List p_143635_, UnaryOperator p_143636_, ItemStack p_143637_) { +- private void updateBookPages(List p_143635_, UnaryOperator p_143636_, ItemStack p_143637_) { - ListTag listtag = new ListTag(); -- if (this.f_9743_.m_143387_()) { +- if (this.player.isTextFilteringEnabled()) { - p_143635_.stream().map((p_143640_) -> { -- return StringTag.m_129297_(p_143636_.apply(p_143640_.m_143722_())); +- return StringTag.valueOf(p_143636_.apply(p_143640_.getFiltered())); - }).forEach(listtag::add); - } else { - CompoundTag compoundtag = new CompoundTag(); @@ -1781,143 +1781,143 @@ - - for(int j = p_143635_.size(); i < j; ++i) { - TextFilter.FilteredText textfilter$filteredtext = p_143635_.get(i); -- String s = textfilter$filteredtext.m_143719_(); -- listtag.add(StringTag.m_129297_(p_143636_.apply(s))); -- String s1 = textfilter$filteredtext.m_143722_(); +- String s = textfilter$filteredtext.getRaw(); +- listtag.add(StringTag.valueOf(p_143636_.apply(s))); +- String s1 = textfilter$filteredtext.getFiltered(); - if (!s.equals(s1)) { -- compoundtag.m_128359_(String.valueOf(i), p_143636_.apply(s1)); +- compoundtag.putString(String.valueOf(i), p_143636_.apply(s1)); - } - } - -- if (!compoundtag.m_128456_()) { -- p_143637_.m_41700_("filtered_pages", compoundtag); +- if (!compoundtag.isEmpty()) { +- p_143637_.addTagElement("filtered_pages", compoundtag); - } - } - -- p_143637_.m_41700_("pages", listtag); +- p_143637_.addTagElement("pages", listtag); - } - -- public void m_7548_(ServerboundEntityTagQuery p_9864_) { -- PacketUtils.m_131359_(p_9864_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_20310_(2)) { -- Entity entity = this.f_9743_.m_183503_().m_6815_(p_9864_.m_134029_()); +- public void handleEntityTagQuery(ServerboundEntityTagQuery p_9864_) { +- PacketUtils.ensureRunningOnSameThread(p_9864_, this, this.player.getLevel()); +- if (this.player.hasPermissions(2)) { +- Entity entity = this.player.getLevel().getEntity(p_9864_.getEntityId()); - if (entity != null) { -- CompoundTag compoundtag = entity.m_20240_(new CompoundTag()); -- this.f_9743_.f_8906_.m_141995_(new ClientboundTagQueryPacket(p_9864_.m_134026_(), compoundtag)); +- CompoundTag compoundtag = entity.saveWithoutId(new CompoundTag()); +- this.player.connection.send(new ClientboundTagQueryPacket(p_9864_.getTransactionId(), compoundtag)); - } - - } - } - -- public void m_6780_(ServerboundBlockEntityTagQuery p_9837_) { -- PacketUtils.m_131359_(p_9837_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_20310_(2)) { -- BlockEntity blockentity = this.f_9743_.m_183503_().m_7702_(p_9837_.m_133813_()); -- CompoundTag compoundtag = blockentity != null ? blockentity.m_187482_() : null; -- this.f_9743_.f_8906_.m_141995_(new ClientboundTagQueryPacket(p_9837_.m_133810_(), compoundtag)); +- public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery p_9837_) { +- PacketUtils.ensureRunningOnSameThread(p_9837_, this, this.player.getLevel()); +- if (this.player.hasPermissions(2)) { +- BlockEntity blockentity = this.player.getLevel().getBlockEntity(p_9837_.getPos()); +- CompoundTag compoundtag = blockentity != null ? blockentity.saveWithoutMetadata() : null; +- this.player.connection.send(new ClientboundTagQueryPacket(p_9837_.getTransactionId(), compoundtag)); - } - } - -- public void m_7185_(ServerboundMovePlayerPacket p_9874_) { -- PacketUtils.m_131359_(p_9874_, this, this.f_9743_.m_183503_()); -- if (m_143663_(p_9874_.m_134129_(0.0D), p_9874_.m_134140_(0.0D), p_9874_.m_134146_(0.0D), p_9874_.m_134131_(0.0F), p_9874_.m_134142_(0.0F))) { -- this.m_9942_(new TranslatableComponent("multiplayer.disconnect.invalid_player_movement")); +- public void handleMovePlayer(ServerboundMovePlayerPacket p_9874_) { +- PacketUtils.ensureRunningOnSameThread(p_9874_, this, this.player.getLevel()); +- if (containsInvalidValues(p_9874_.getX(0.0D), p_9874_.getY(0.0D), p_9874_.getZ(0.0D), p_9874_.getYRot(0.0F), p_9874_.getXRot(0.0F))) { +- this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_player_movement")); - } else { -- ServerLevel serverlevel = this.f_9743_.m_183503_(); -- if (!this.f_9743_.f_8944_) { -- if (this.f_9746_ == 0) { -- this.m_9953_(); +- ServerLevel serverlevel = this.player.getLevel(); +- if (!this.player.wonGame) { +- if (this.tickCount == 0) { +- this.resetPosition(); - } - -- if (this.f_9766_ != null) { -- if (this.f_9746_ - this.f_9735_ > 20) { -- this.f_9735_ = this.f_9746_; -- this.m_9774_(this.f_9766_.f_82479_, this.f_9766_.f_82480_, this.f_9766_.f_82481_, this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); +- if (this.awaitingPositionFromClient != null) { +- if (this.tickCount - this.awaitingTeleportTime > 20) { +- this.awaitingTeleportTime = this.tickCount; +- this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); - } - - } else { -- this.f_9735_ = this.f_9746_; -- double d0 = m_143609_(p_9874_.m_134129_(this.f_9743_.m_20185_())); -- double d1 = m_143653_(p_9874_.m_134140_(this.f_9743_.m_20186_())); -- double d2 = m_143609_(p_9874_.m_134146_(this.f_9743_.m_20189_())); -- float f = Mth.m_14177_(p_9874_.m_134131_(this.f_9743_.m_146908_())); -- float f1 = Mth.m_14177_(p_9874_.m_134142_(this.f_9743_.m_146909_())); -- if (this.f_9743_.m_20159_()) { -- this.f_9743_.m_19890_(this.f_9743_.m_20185_(), this.f_9743_.m_20186_(), this.f_9743_.m_20189_(), f, f1); -- this.f_9743_.m_183503_().m_7726_().m_8385_(this.f_9743_); +- this.awaitingTeleportTime = this.tickCount; +- double d0 = clampHorizontal(p_9874_.getX(this.player.getX())); +- double d1 = clampVertical(p_9874_.getY(this.player.getY())); +- double d2 = clampHorizontal(p_9874_.getZ(this.player.getZ())); +- float f = Mth.wrapDegrees(p_9874_.getYRot(this.player.getYRot())); +- float f1 = Mth.wrapDegrees(p_9874_.getXRot(this.player.getXRot())); +- if (this.player.isPassenger()) { +- this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); +- this.player.getLevel().getChunkSource().move(this.player); - } else { -- double d3 = this.f_9743_.m_20185_(); -- double d4 = this.f_9743_.m_20186_(); -- double d5 = this.f_9743_.m_20189_(); -- double d6 = this.f_9743_.m_20186_(); -- double d7 = d0 - this.f_9753_; -- double d8 = d1 - this.f_9754_; -- double d9 = d2 - this.f_9755_; -- double d10 = this.f_9743_.m_20184_().m_82556_(); +- double d3 = this.player.getX(); +- double d4 = this.player.getY(); +- double d5 = this.player.getZ(); +- double d6 = this.player.getY(); +- double d7 = d0 - this.firstGoodX; +- double d8 = d1 - this.firstGoodY; +- double d9 = d2 - this.firstGoodZ; +- double d10 = this.player.getDeltaMovement().lengthSqr(); - double d11 = d7 * d7 + d8 * d8 + d9 * d9; -- if (this.f_9743_.m_5803_()) { +- if (this.player.isSleeping()) { - if (d11 > 1.0D) { -- this.m_9774_(this.f_9743_.m_20185_(), this.f_9743_.m_20186_(), this.f_9743_.m_20189_(), f, f1); +- this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); - } - - } else { -- ++this.f_9740_; -- int i = this.f_9740_ - this.f_9741_; +- ++this.receivedMovePacketCount; +- int i = this.receivedMovePacketCount - this.knownMovePacketCount; - if (i > 5) { -- f_9744_.debug("{} is sending move packets too frequently ({} packets since last tick)", this.f_9743_.m_7755_().getString(), i); +- LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i); - i = 1; - } - -- if (!this.f_9743_.m_8958_() && (!this.f_9743_.m_183503_().m_46469_().m_46207_(GameRules.f_46148_) || !this.f_9743_.m_21255_())) { -- float f2 = this.f_9743_.m_21255_() ? 300.0F : 100.0F; -- if (d11 - d10 > (double)(f2 * (float)i) && !this.m_9956_()) { -- f_9744_.warn("{} moved too quickly! {},{},{}", this.f_9743_.m_7755_().getString(), d7, d8, d9); -- this.m_9774_(this.f_9743_.m_20185_(), this.f_9743_.m_20186_(), this.f_9743_.m_20189_(), this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); +- if (!this.player.isChangingDimension() && (!this.player.getLevel().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) { +- float f2 = this.player.isFallFlying() ? 300.0F : 100.0F; +- if (d11 - d10 > (double)(f2 * (float)i) && !this.isSingleplayerOwner()) { +- LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9); +- this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); - return; - } - } - -- AABB aabb = this.f_9743_.m_142469_(); -- d7 = d0 - this.f_9756_; -- d8 = d1 - this.f_9757_; -- d9 = d2 - this.f_9758_; +- AABB aabb = this.player.getBoundingBox(); +- d7 = d0 - this.lastGoodX; +- d8 = d1 - this.lastGoodY; +- d9 = d2 - this.lastGoodZ; - boolean flag = d8 > 0.0D; -- if (this.f_9743_.m_20096_() && !p_9874_.m_134139_() && flag) { -- this.f_9743_.m_6135_(); +- if (this.player.isOnGround() && !p_9874_.isOnGround() && flag) { +- this.player.jumpFromGround(); - } - -- boolean flag1 = this.f_9743_.f_201939_; -- this.f_9743_.m_6478_(MoverType.PLAYER, new Vec3(d7, d8, d9)); -- d7 = d0 - this.f_9743_.m_20185_(); -- d8 = d1 - this.f_9743_.m_20186_(); +- boolean flag1 = this.player.verticalCollisionBelow; +- this.player.move(MoverType.PLAYER, new Vec3(d7, d8, d9)); +- d7 = d0 - this.player.getX(); +- d8 = d1 - this.player.getY(); - if (d8 > -0.5D || d8 < 0.5D) { - d8 = 0.0D; - } - -- d9 = d2 - this.f_9743_.m_20189_(); +- d9 = d2 - this.player.getZ(); - d11 = d7 * d7 + d8 * d8 + d9 * d9; - boolean flag2 = false; -- if (!this.f_9743_.m_8958_() && d11 > 0.0625D && !this.f_9743_.m_5803_() && !this.f_9743_.f_8941_.m_9295_() && this.f_9743_.f_8941_.m_9290_() != GameType.SPECTATOR) { +- if (!this.player.isChangingDimension() && d11 > 0.0625D && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { - flag2 = true; -- f_9744_.warn("{} moved wrongly!", (Object)this.f_9743_.m_7755_().getString()); +- LOGGER.warn("{} moved wrongly!", (Object)this.player.getName().getString()); - } - -- this.f_9743_.m_19890_(d0, d1, d2, f, f1); -- if (this.f_9743_.f_19794_ || this.f_9743_.m_5803_() || (!flag2 || !serverlevel.m_45756_(this.f_9743_, aabb)) && !this.m_9795_(serverlevel, aabb)) { -- this.f_9736_ = d8 >= -0.03125D && !flag1 && this.f_9743_.f_8941_.m_9290_() != GameType.SPECTATOR && !this.f_9745_.m_129915_() && !this.f_9743_.m_150110_().f_35936_ && !this.f_9743_.m_21023_(MobEffects.f_19620_) && !this.f_9743_.m_21255_() && !this.f_9743_.m_21209_() && this.m_9793_(this.f_9743_); -- this.f_9743_.m_183503_().m_7726_().m_8385_(this.f_9743_); -- this.f_9743_.m_8972_(this.f_9743_.m_20186_() - d6, p_9874_.m_134139_()); -- this.f_9743_.m_6853_(p_9874_.m_134139_()); +- this.player.absMoveTo(d0, d1, d2, f, f1); +- if (this.player.noPhysics || this.player.isSleeping() || (!flag2 || !serverlevel.noCollision(this.player, aabb)) && !this.isPlayerCollidingWithAnythingNew(serverlevel, aabb)) { +- this.clientIsFloating = d8 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player); +- this.player.getLevel().getChunkSource().move(this.player); +- this.player.doCheckFallDamage(this.player.getY() - d6, p_9874_.isOnGround()); +- this.player.setOnGround(p_9874_.isOnGround()); - if (flag) { -- this.f_9743_.m_183634_(); +- this.player.resetFallDistance(); - } - -- this.f_9743_.m_36378_(this.f_9743_.m_20185_() - d3, this.f_9743_.m_20186_() - d4, this.f_9743_.m_20189_() - d5); -- this.f_9756_ = this.f_9743_.m_20185_(); -- this.f_9757_ = this.f_9743_.m_20186_(); -- this.f_9758_ = this.f_9743_.m_20189_(); +- this.player.checkMovementStatistics(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5); +- this.lastGoodX = this.player.getX(); +- this.lastGoodY = this.player.getY(); +- this.lastGoodZ = this.player.getZ(); - } else { -- this.m_9774_(d3, d4, d5, f, f1); +- this.teleport(d3, d4, d5, f, f1); - } - } - } @@ -1926,65 +1926,65 @@ - } - } - -- private boolean m_9795_(LevelReader p_9796_, AABB p_9797_) { -- Iterable iterable = p_9796_.m_186431_(this.f_9743_, this.f_9743_.m_142469_().m_82406_((double)1.0E-5F)); -- VoxelShape voxelshape = Shapes.m_83064_(p_9797_.m_82406_((double)1.0E-5F)); +- private boolean isPlayerCollidingWithAnythingNew(LevelReader p_9796_, AABB p_9797_) { +- Iterable iterable = p_9796_.getCollisions(this.player, this.player.getBoundingBox().deflate((double)1.0E-5F)); +- VoxelShape voxelshape = Shapes.create(p_9797_.deflate((double)1.0E-5F)); - - for(VoxelShape voxelshape1 : iterable) { -- if (!Shapes.m_83157_(voxelshape1, voxelshape, BooleanOp.f_82689_)) { +- if (!Shapes.joinIsNotEmpty(voxelshape1, voxelshape, BooleanOp.AND)) { + throw new IllegalArgumentException( "Invalid player action" ); + } + } + -+ private static boolean m_9790_(ServerPlayer p_9791_, ItemStack p_9792_) { -+ if (p_9792_.m_41619_()) { ++ private static boolean wasBlockPlacementAttempt(ServerPlayer p_9791_, ItemStack p_9792_) { ++ if (p_9792_.isEmpty()) { + return false; + } else { -+ Item item = p_9792_.m_41720_(); -+ return (item instanceof BlockItem || item instanceof BucketItem) && !p_9791_.m_36335_().m_41519_( item ); ++ Item item = p_9792_.getItem(); ++ return (item instanceof BlockItem || item instanceof BucketItem) && !p_9791_.getCooldowns().isOnCooldown( item ); + } + } + -+ public void m_6371_(ServerboundUseItemOnPacket p_9930_) { -+ PacketUtils.m_131359_(p_9930_, this, this.f_9743_.m_183503_()); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit ++ public void handleUseItemOn(ServerboundUseItemOnPacket p_9930_) { ++ PacketUtils.ensureRunningOnSameThread(p_9930_, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + if (!checkLimit(p_9930_.timestamp)) return; // Spigot - check limit -+ ServerLevel serverlevel = this.f_9743_.m_183503_(); -+ InteractionHand interactionhand = p_9930_.m_134703_(); -+ ItemStack itemstack = this.f_9743_.m_21120_(interactionhand); -+ BlockHitResult blockhitresult = p_9930_.m_134706_(); -+ Vec3 vec3 = blockhitresult.m_82450_(); -+ BlockPos blockpos = blockhitresult.m_82425_(); -+ Vec3 vec31 = vec3.m_82546_(Vec3.m_82512_(blockpos)); -+ if (this.f_9743_.f_19853_.m_142572_() != null && this.f_9743_.m_146902_().m_45594_(new ChunkPos(blockpos)) < this.f_9743_.f_19853_.spigotConfig.viewDistance) { // Spigot ++ ServerLevel serverlevel = this.player.getLevel(); ++ InteractionHand interactionhand = p_9930_.getHand(); ++ ItemStack itemstack = this.player.getItemInHand(interactionhand); ++ BlockHitResult blockhitresult = p_9930_.getHitResult(); ++ Vec3 vec3 = blockhitresult.getLocation(); ++ BlockPos blockpos = blockhitresult.getBlockPos(); ++ Vec3 vec31 = vec3.subtract(Vec3.atCenterOf(blockpos)); ++ if (this.player.level.getServer() != null && this.player.chunkPosition().getChessboardDistance(new ChunkPos(blockpos)) < this.player.level.spigotConfig.viewDistance) { // Spigot + double d0 = 1.0000001D; -+ if (Math.abs(vec31.m_7096_()) < 1.0000001D && Math.abs(vec31.m_7098_()) < 1.0000001D && Math.abs(vec31.m_7094_()) < 1.0000001D) { -+ Direction direction = blockhitresult.m_82434_(); -+ this.f_9743_.m_9243_(); -+ int i = this.f_9743_.f_19853_.m_151558_(); -+ if (blockpos.m_123342_() < i) { -+ if (this.f_9766_ == null && this.f_9743_.canInteractWith(blockpos, 3) && serverlevel.m_7966_(this.f_9743_, blockpos)) { ++ if (Math.abs(vec31.x()) < 1.0000001D && Math.abs(vec31.y()) < 1.0000001D && Math.abs(vec31.z()) < 1.0000001D) { ++ Direction direction = blockhitresult.getDirection(); ++ this.player.resetLastActionTime(); ++ int i = this.player.level.getMaxBuildHeight(); ++ if (blockpos.getY() < i) { ++ if (this.awaitingPositionFromClient == null && this.player.canInteractWith(blockpos, 3) && serverlevel.mayInteract(this.player, blockpos)) { + //this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706 //Magma - NO! This breaks item holding with specific mods -+ InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); -+ if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { -+ Component component = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED); -+ this.f_9743_.m_9146_(component, ChatType.GAME_INFO, Util.f_137441_); -+ } else if (interactionresult.m_19080_()) { -+ this.f_9743_.m_21011_(interactionhand, true); ++ InteractionResult interactionresult = this.player.gameMode.useItemOn(this.player, serverlevel, itemstack, interactionhand, blockhitresult); ++ if (direction == Direction.UP && !interactionresult.consumesAction() && blockpos.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { ++ Component component = (new TranslatableComponent("build.tooHigh", i - 1)).withStyle(ChatFormatting.RED); ++ this.player.sendMessage(component, ChatType.GAME_INFO, Util.NIL_UUID); ++ } else if (interactionresult.shouldSwing()) { ++ this.player.swing(interactionhand, true); + } + } + } else { -+ Component component1 = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED); -+ this.f_9743_.m_9146_(component1, ChatType.GAME_INFO, Util.f_137441_); ++ Component component1 = (new TranslatableComponent("build.tooHigh", i - 1)).withStyle(ChatFormatting.RED); ++ this.player.sendMessage(component1, ChatType.GAME_INFO, Util.NIL_UUID); + } + -+ this.f_9743_.f_8906_.m_141995_(new ClientboundBlockUpdatePacket(serverlevel, blockpos)); -+ this.f_9743_.f_8906_.m_141995_(new ClientboundBlockUpdatePacket(serverlevel, blockpos.m_142300_(direction))); ++ this.player.connection.send(new ClientboundBlockUpdatePacket(serverlevel, blockpos)); ++ this.player.connection.send(new ClientboundBlockUpdatePacket(serverlevel, blockpos.relative(direction))); + } else { -+ f_9744_.warn("Ignoring UseItemOnPacket from {}: org.bukkit.Location {} too far away from hit block {}.", this.f_9743_.m_36316_().getName(), vec3, blockpos); ++ LOGGER.warn("Ignoring UseItemOnPacket from {}: org.bukkit.Location {} too far away from hit block {}.", this.player.getGameProfile().getName(), vec3, blockpos); + } + } else { -+ f_9744_.warn("Ignoring UseItemOnPacket from {}: hit position {} too far away from player {}.", this.f_9743_.m_36316_().getName(), blockpos, this.f_9743_.m_142538_()); ++ LOGGER.warn("Ignoring UseItemOnPacket from {}: hit position {} too far away from player {}.", this.player.getGameProfile().getName(), blockpos, this.player.blockPosition()); + } + } + @@ -2007,145 +2007,145 @@ - return false; - } - -- public void m_143611_(double p_143612_, double p_143613_, double p_143614_, float p_143615_, float p_143616_) { -- this.m_143617_(p_143612_, p_143613_, p_143614_, p_143615_, p_143616_, Collections.emptySet(), true); +- public void dismount(double p_143612_, double p_143613_, double p_143614_, float p_143615_, float p_143616_) { +- this.teleport(p_143612_, p_143613_, p_143614_, p_143615_, p_143616_, Collections.emptySet(), true); - } - -- public void m_9774_(double p_9775_, double p_9776_, double p_9777_, float p_9778_, float p_9779_) { -- this.m_143617_(p_9775_, p_9776_, p_9777_, p_9778_, p_9779_, Collections.emptySet(), false); +- public void teleport(double p_9775_, double p_9776_, double p_9777_, float p_9778_, float p_9779_) { +- this.teleport(p_9775_, p_9776_, p_9777_, p_9778_, p_9779_, Collections.emptySet(), false); - } - -- public void m_9780_(double p_9781_, double p_9782_, double p_9783_, float p_9784_, float p_9785_, Set p_9786_) { -- this.m_143617_(p_9781_, p_9782_, p_9783_, p_9784_, p_9785_, p_9786_, false); +- public void teleport(double p_9781_, double p_9782_, double p_9783_, float p_9784_, float p_9785_, Set p_9786_) { +- this.teleport(p_9781_, p_9782_, p_9783_, p_9784_, p_9785_, p_9786_, false); - } - -- public void m_143617_(double p_143618_, double p_143619_, double p_143620_, float p_143621_, float p_143622_, Set p_143623_, boolean p_143624_) { -- double d0 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.X) ? this.f_9743_.m_20185_() : 0.0D; -- double d1 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.Y) ? this.f_9743_.m_20186_() : 0.0D; -- double d2 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.Z) ? this.f_9743_.m_20189_() : 0.0D; -- float f = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.Y_ROT) ? this.f_9743_.m_146908_() : 0.0F; -- float f1 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.X_ROT) ? this.f_9743_.m_146909_() : 0.0F; -- this.f_9766_ = new Vec3(p_143618_, p_143619_, p_143620_); -- if (++this.f_9767_ == Integer.MAX_VALUE) { -- this.f_9767_ = 0; +- public void teleport(double p_143618_, double p_143619_, double p_143620_, float p_143621_, float p_143622_, Set p_143623_, boolean p_143624_) { +- double d0 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.X) ? this.player.getX() : 0.0D; +- double d1 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.Y) ? this.player.getY() : 0.0D; +- double d2 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.Z) ? this.player.getZ() : 0.0D; +- float f = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.Y_ROT) ? this.player.getYRot() : 0.0F; +- float f1 = p_143623_.contains(ClientboundPlayerPositionPacket.RelativeArgument.X_ROT) ? this.player.getXRot() : 0.0F; +- this.awaitingPositionFromClient = new Vec3(p_143618_, p_143619_, p_143620_); +- if (++this.awaitingTeleport == Integer.MAX_VALUE) { +- this.awaitingTeleport = 0; - } - -- this.f_9735_ = this.f_9746_; -- this.f_9743_.m_19890_(p_143618_, p_143619_, p_143620_, p_143621_, p_143622_); -- this.f_9743_.f_8906_.m_141995_(new ClientboundPlayerPositionPacket(p_143618_ - d0, p_143619_ - d1, p_143620_ - d2, p_143621_ - f, p_143622_ - f1, p_143623_, this.f_9767_, p_143624_)); +- this.awaitingTeleportTime = this.tickCount; +- this.player.absMoveTo(p_143618_, p_143619_, p_143620_, p_143621_, p_143622_); +- this.player.connection.send(new ClientboundPlayerPositionPacket(p_143618_ - d0, p_143619_ - d1, p_143620_ - d2, p_143621_ - f, p_143622_ - f1, p_143623_, this.awaitingTeleport, p_143624_)); - } - -- public void m_7502_(ServerboundPlayerActionPacket p_9889_) { -- PacketUtils.m_131359_(p_9889_, this, this.f_9743_.m_183503_()); -- BlockPos blockpos = p_9889_.m_134281_(); -- this.f_9743_.m_9243_(); -- ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_9889_.m_134285_(); +- public void handlePlayerAction(ServerboundPlayerActionPacket p_9889_) { +- PacketUtils.ensureRunningOnSameThread(p_9889_, this, this.player.getLevel()); +- BlockPos blockpos = p_9889_.getPos(); +- this.player.resetLastActionTime(); +- ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_9889_.getAction(); - switch(serverboundplayeractionpacket$action) { - case SWAP_ITEM_WITH_OFFHAND: -- if (!this.f_9743_.m_5833_()) { -- ItemStack itemstack = this.f_9743_.m_21120_(InteractionHand.OFF_HAND); -- this.f_9743_.m_21008_(InteractionHand.OFF_HAND, this.f_9743_.m_21120_(InteractionHand.MAIN_HAND)); -- this.f_9743_.m_21008_(InteractionHand.MAIN_HAND, itemstack); -- this.f_9743_.m_5810_(); +- if (!this.player.isSpectator()) { +- ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND); +- this.player.setItemInHand(InteractionHand.OFF_HAND, this.player.getItemInHand(InteractionHand.MAIN_HAND)); +- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemstack); +- this.player.stopUsingItem(); - } - - return; - case DROP_ITEM: -- if (!this.f_9743_.m_5833_()) { -- this.f_9743_.m_182294_(false); +- if (!this.player.isSpectator()) { +- this.player.drop(false); - } - - return; - case DROP_ALL_ITEMS: -- if (!this.f_9743_.m_5833_()) { -- this.f_9743_.m_182294_(true); +- if (!this.player.isSpectator()) { +- this.player.drop(true); - } - - return; - case RELEASE_USE_ITEM: -- this.f_9743_.m_21253_(); +- this.player.releaseUsingItem(); - return; - case START_DESTROY_BLOCK: - case ABORT_DESTROY_BLOCK: - case STOP_DESTROY_BLOCK: -- this.f_9743_.f_8941_.m_7391_(blockpos, serverboundplayeractionpacket$action, p_9889_.m_134284_(), this.f_9743_.f_19853_.m_151558_()); +- this.player.gameMode.handleBlockBreakAction(blockpos, serverboundplayeractionpacket$action, p_9889_.getDirection(), this.player.level.getMaxBuildHeight()); - return; - default: - throw new IllegalArgumentException("Invalid player action"); - } - } - -- private static boolean m_9790_(ServerPlayer p_9791_, ItemStack p_9792_) { -- if (p_9792_.m_41619_()) { +- private static boolean wasBlockPlacementAttempt(ServerPlayer p_9791_, ItemStack p_9792_) { +- if (p_9792_.isEmpty()) { - return false; - } else { -- Item item = p_9792_.m_41720_(); -- return (item instanceof BlockItem || item instanceof BucketItem) && !p_9791_.m_36335_().m_41519_(item); +- Item item = p_9792_.getItem(); +- return (item instanceof BlockItem || item instanceof BucketItem) && !p_9791_.getCooldowns().isOnCooldown(item); - } - } - -- public void m_6371_(ServerboundUseItemOnPacket p_9930_) { -- PacketUtils.m_131359_(p_9930_, this, this.f_9743_.m_183503_()); -- ServerLevel serverlevel = this.f_9743_.m_183503_(); -- InteractionHand interactionhand = p_9930_.m_134703_(); -- ItemStack itemstack = this.f_9743_.m_21120_(interactionhand); -- BlockHitResult blockhitresult = p_9930_.m_134706_(); -- Vec3 vec3 = blockhitresult.m_82450_(); -- BlockPos blockpos = blockhitresult.m_82425_(); -- Vec3 vec31 = vec3.m_82546_(Vec3.m_82512_(blockpos)); -- if (this.f_9743_.f_19853_.m_142572_() != null && this.f_9743_.m_146902_().m_45594_(new ChunkPos(blockpos)) < this.f_9743_.f_19853_.m_142572_().m_6846_().m_11312_()) { +- public void handleUseItemOn(ServerboundUseItemOnPacket p_9930_) { +- PacketUtils.ensureRunningOnSameThread(p_9930_, this, this.player.getLevel()); +- ServerLevel serverlevel = this.player.getLevel(); +- InteractionHand interactionhand = p_9930_.getHand(); +- ItemStack itemstack = this.player.getItemInHand(interactionhand); +- BlockHitResult blockhitresult = p_9930_.getHitResult(); +- Vec3 vec3 = blockhitresult.getLocation(); +- BlockPos blockpos = blockhitresult.getBlockPos(); +- Vec3 vec31 = vec3.subtract(Vec3.atCenterOf(blockpos)); +- if (this.player.level.getServer() != null && this.player.chunkPosition().getChessboardDistance(new ChunkPos(blockpos)) < this.player.level.getServer().getPlayerList().getViewDistance()) { - double d0 = 1.0000001D; -- if (Math.abs(vec31.m_7096_()) < 1.0000001D && Math.abs(vec31.m_7098_()) < 1.0000001D && Math.abs(vec31.m_7094_()) < 1.0000001D) { -- Direction direction = blockhitresult.m_82434_(); -- this.f_9743_.m_9243_(); -- int i = this.f_9743_.f_19853_.m_151558_(); -- if (blockpos.m_123342_() < i) { -- if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < 64.0D && serverlevel.m_7966_(this.f_9743_, blockpos)) { -- InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); -- if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { -- Component component = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED); -- this.f_9743_.m_9146_(component, ChatType.GAME_INFO, Util.f_137441_); -- } else if (interactionresult.m_19080_()) { -- this.f_9743_.m_21011_(interactionhand, true); +- if (Math.abs(vec31.x()) < 1.0000001D && Math.abs(vec31.y()) < 1.0000001D && Math.abs(vec31.z()) < 1.0000001D) { +- Direction direction = blockhitresult.getDirection(); +- this.player.resetLastActionTime(); +- int i = this.player.level.getMaxBuildHeight(); +- if (blockpos.getY() < i) { +- if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && serverlevel.mayInteract(this.player, blockpos)) { +- InteractionResult interactionresult = this.player.gameMode.useItemOn(this.player, serverlevel, itemstack, interactionhand, blockhitresult); +- if (direction == Direction.UP && !interactionresult.consumesAction() && blockpos.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { +- Component component = (new TranslatableComponent("build.tooHigh", i - 1)).withStyle(ChatFormatting.RED); +- this.player.sendMessage(component, ChatType.GAME_INFO, Util.NIL_UUID); +- } else if (interactionresult.shouldSwing()) { +- this.player.swing(interactionhand, true); - } - } - } else { -- Component component1 = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED); -- this.f_9743_.m_9146_(component1, ChatType.GAME_INFO, Util.f_137441_); +- Component component1 = (new TranslatableComponent("build.tooHigh", i - 1)).withStyle(ChatFormatting.RED); +- this.player.sendMessage(component1, ChatType.GAME_INFO, Util.NIL_UUID); - } - -- this.f_9743_.f_8906_.m_141995_(new ClientboundBlockUpdatePacket(serverlevel, blockpos)); -- this.f_9743_.f_8906_.m_141995_(new ClientboundBlockUpdatePacket(serverlevel, blockpos.m_142300_(direction))); +- this.player.connection.send(new ClientboundBlockUpdatePacket(serverlevel, blockpos)); +- this.player.connection.send(new ClientboundBlockUpdatePacket(serverlevel, blockpos.relative(direction))); - } else { -- f_9744_.warn("Ignoring UseItemOnPacket from {}: Location {} too far away from hit block {}.", this.f_9743_.m_36316_().getName(), vec3, blockpos); +- LOGGER.warn("Ignoring UseItemOnPacket from {}: Location {} too far away from hit block {}.", this.player.getGameProfile().getName(), vec3, blockpos); - } - } else { -- f_9744_.warn("Ignoring UseItemOnPacket from {}: hit position {} too far away from player {}.", this.f_9743_.m_36316_().getName(), blockpos, this.f_9743_.m_142538_()); +- LOGGER.warn("Ignoring UseItemOnPacket from {}: hit position {} too far away from player {}.", this.player.getGameProfile().getName(), blockpos, this.player.blockPosition()); - } - } - -- public void m_5760_(ServerboundUseItemPacket p_9932_) { -- PacketUtils.m_131359_(p_9932_, this, this.f_9743_.m_183503_()); -- ServerLevel serverlevel = this.f_9743_.m_183503_(); -- InteractionHand interactionhand = p_9932_.m_134717_(); -- ItemStack itemstack = this.f_9743_.m_21120_(interactionhand); -- this.f_9743_.m_9243_(); -- if (!itemstack.m_41619_()) { -- InteractionResult interactionresult = this.f_9743_.f_8941_.m_6261_(this.f_9743_, serverlevel, itemstack, interactionhand); -- if (interactionresult.m_19080_()) { -- this.f_9743_.m_21011_(interactionhand, true); +- public void handleUseItem(ServerboundUseItemPacket p_9932_) { +- PacketUtils.ensureRunningOnSameThread(p_9932_, this, this.player.getLevel()); +- ServerLevel serverlevel = this.player.getLevel(); +- InteractionHand interactionhand = p_9932_.getHand(); +- ItemStack itemstack = this.player.getItemInHand(interactionhand); +- this.player.resetLastActionTime(); +- if (!itemstack.isEmpty()) { +- InteractionResult interactionresult = this.player.gameMode.useItem(this.player, serverlevel, itemstack, interactionhand); +- if (interactionresult.shouldSwing()) { +- this.player.swing(interactionhand, true); - } - - } - } - -- public void m_6936_(ServerboundTeleportToEntityPacket p_9928_) { -- PacketUtils.m_131359_(p_9928_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_5833_()) { -- for(ServerLevel serverlevel : this.f_9745_.m_129785_()) { -- Entity entity = p_9928_.m_134681_(serverlevel); +- public void handleTeleportToEntityPacket(ServerboundTeleportToEntityPacket p_9928_) { +- PacketUtils.ensureRunningOnSameThread(p_9928_, this, this.player.getLevel()); +- if (this.player.isSpectator()) { +- for(ServerLevel serverlevel : this.server.getAllLevels()) { +- Entity entity = p_9928_.getEntity(serverlevel); - if (entity != null) { -- this.f_9743_.m_8999_(serverlevel, entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_()); +- this.player.teleportTo(serverlevel, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); - return; - } - } @@ -2153,97 +2153,97 @@ - - } - -- public void m_7529_(ServerboundResourcePackPacket p_9901_) { -- PacketUtils.m_131359_(p_9901_, this, this.f_9743_.m_183503_()); -- if (p_9901_.m_179741_() == ServerboundResourcePackPacket.Action.DECLINED && this.f_9745_.m_142205_()) { -- f_9744_.info("Disconnecting {} due to resource pack rejection", (Object)this.f_9743_.m_7755_()); -- this.m_9942_(new TranslatableComponent("multiplayer.requiredTexturePrompt.disconnect")); +- public void handleResourcePackResponse(ServerboundResourcePackPacket p_9901_) { +- PacketUtils.ensureRunningOnSameThread(p_9901_, this, this.player.getLevel()); +- if (p_9901_.getAction() == ServerboundResourcePackPacket.Action.DECLINED && this.server.isResourcePackRequired()) { +- LOGGER.info("Disconnecting {} due to resource pack rejection", (Object)this.player.getName()); +- this.disconnect(new TranslatableComponent("multiplayer.requiredTexturePrompt.disconnect")); - } - - } - -- public void m_5938_(ServerboundPaddleBoatPacket p_9878_) { -- PacketUtils.m_131359_(p_9878_, this, this.f_9743_.m_183503_()); -- Entity entity = this.f_9743_.m_20202_(); +- public void handlePaddleBoat(ServerboundPaddleBoatPacket p_9878_) { +- PacketUtils.ensureRunningOnSameThread(p_9878_, this, this.player.getLevel()); +- Entity entity = this.player.getVehicle(); - if (entity instanceof Boat) { -- ((Boat)entity).m_38339_(p_9878_.m_134218_(), p_9878_.m_134221_()); +- ((Boat)entity).setPaddleState(p_9878_.getLeft(), p_9878_.getRight()); - } - - } - -- public void m_142110_(ServerboundPongPacket p_143652_) { +- public void handlePong(ServerboundPongPacket p_143652_) { - } - -- public void m_7026_(Component p_9825_) { -- f_9744_.info("{} lost connection: {}", this.f_9743_.m_7755_().getString(), p_9825_.getString()); -- this.f_9745_.m_129929_(); -- this.f_9745_.m_6846_().m_11264_((new TranslatableComponent("multiplayer.player.left", this.f_9743_.m_5446_())).m_130940_(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.f_137441_); -- this.f_9743_.m_9231_(); -- this.f_9745_.m_6846_().m_11286_(this.f_9743_); -- this.f_9743_.m_8967_().m_7670_(); -- if (this.m_9956_()) { -- f_9744_.info("Stopping singleplayer server as player logged out"); -- this.f_9745_.m_7570_(false); +- public void onDisconnect(Component p_9825_) { +- LOGGER.info("{} lost connection: {}", this.player.getName().getString(), p_9825_.getString()); +- this.server.invalidateStatus(); +- this.server.getPlayerList().broadcastMessage((new TranslatableComponent("multiplayer.player.left", this.player.getDisplayName())).withStyle(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.NIL_UUID); +- this.player.disconnect(); +- this.server.getPlayerList().remove(this.player); +- this.player.getTextFilter().leave(); +- if (this.isSingleplayerOwner()) { +- LOGGER.info("Stopping singleplayer server as player logged out"); +- this.server.halt(false); - } - - } - -- public void m_141995_(Packet p_9830_) { -- this.m_9831_(p_9830_, (GenericFutureListener>)null); +- public void send(Packet p_9830_) { +- this.send(p_9830_, (GenericFutureListener>)null); - } - -- public void m_9831_(Packet p_9832_, @Nullable GenericFutureListener> p_9833_) { +- public void send(Packet p_9832_, @Nullable GenericFutureListener> p_9833_) { - try { -- this.f_9742_.m_129514_(p_9832_, p_9833_); +- this.connection.send(p_9832_, p_9833_); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Sending packet"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Packet being sent"); -- crashreportcategory.m_128165_("Packet class", () -> { +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Sending packet"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Packet being sent"); +- crashreportcategory.setDetail("Packet class", () -> { - return p_9832_.getClass().getCanonicalName(); - }); - throw new ReportedException(crashreport); - } - } - -- public void m_7798_(ServerboundSetCarriedItemPacket p_9909_) { -- PacketUtils.m_131359_(p_9909_, this, this.f_9743_.m_183503_()); -- if (p_9909_.m_134498_() >= 0 && p_9909_.m_134498_() < Inventory.m_36059_()) { -- if (this.f_9743_.m_150109_().f_35977_ != p_9909_.m_134498_() && this.f_9743_.m_7655_() == InteractionHand.MAIN_HAND) { -- this.f_9743_.m_5810_(); +- public void handleSetCarriedItem(ServerboundSetCarriedItemPacket p_9909_) { +- PacketUtils.ensureRunningOnSameThread(p_9909_, this, this.player.getLevel()); +- if (p_9909_.getSlot() >= 0 && p_9909_.getSlot() < Inventory.getSelectionSize()) { +- if (this.player.getInventory().selected != p_9909_.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) { +- this.player.stopUsingItem(); - } - -- this.f_9743_.m_150109_().f_35977_ = p_9909_.m_134498_(); -- this.f_9743_.m_9243_(); +- this.player.getInventory().selected = p_9909_.getSlot(); +- this.player.resetLastActionTime(); - } else { -- f_9744_.warn("{} tried to set an invalid carried item", (Object)this.f_9743_.m_7755_().getString()); +- LOGGER.warn("{} tried to set an invalid carried item", (Object)this.player.getName().getString()); - } - } - -- public void m_7388_(ServerboundChatPacket p_9841_) { -- String s = StringUtils.normalizeSpace(p_9841_.m_133837_()); +- public void handleChat(ServerboundChatPacket p_9841_) { +- String s = StringUtils.normalizeSpace(p_9841_.getMessage()); - - for(int i = 0; i < s.length(); ++i) { -- if (!SharedConstants.m_136188_(s.charAt(i))) { -- this.m_9942_(new TranslatableComponent("multiplayer.disconnect.illegal_characters")); +- if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { +- this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters")); - return; - } - } - - if (s.startsWith("/")) { -- PacketUtils.m_131359_(p_9841_, this, this.f_9743_.m_183503_()); -- this.m_143628_(TextFilter.FilteredText.m_143720_(s)); +- PacketUtils.ensureRunningOnSameThread(p_9841_, this, this.player.getLevel()); +- this.handleChat(TextFilter.FilteredText.passThrough(s)); - } else { -- this.m_9809_(s, this::m_143628_); +- this.filterTextPacket(s, this::handleChat); - } - - } - -- private void m_143628_(TextFilter.FilteredText p_143629_) { -- if (this.f_9743_.m_9241_() == ChatVisiblity.HIDDEN) { -- this.m_141995_(new ClientboundChatPacket((new TranslatableComponent("chat.disabled.options")).m_130940_(ChatFormatting.RED), ChatType.SYSTEM, Util.f_137441_)); +- private void handleChat(TextFilter.FilteredText p_143629_) { +- if (this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { +- this.send(new ClientboundChatPacket((new TranslatableComponent("chat.disabled.options")).withStyle(ChatFormatting.RED), ChatType.SYSTEM, Util.NIL_UUID)); - } else { -- this.f_9743_.m_9243_(); -- String s = p_143629_.m_143719_(); +- this.player.resetLastActionTime(); +- String s = p_143629_.getRaw(); - if (s.startsWith("/")) { + } + @@ -2252,66 +2252,66 @@ + // Spigot end + + -+ public void m_5760_(ServerboundUseItemPacket p_9932_) { -+ PacketUtils.m_131359_( p_9932_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit ++ public void handleUseItem(ServerboundUseItemPacket p_9932_) { ++ PacketUtils.ensureRunningOnSameThread( p_9932_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit + if (!checkLimit(p_9932_.timestamp)) return; // Spigot - check limit -+ ServerLevel serverlevel = this.f_9743_.m_183503_(); -+ InteractionHand interactionhand = p_9932_.m_134717_(); -+ ItemStack itemstack = this.f_9743_.m_21120_( interactionhand ); -+ this.f_9743_.m_9243_(); -+ if (!itemstack.m_41619_()) { ++ ServerLevel serverlevel = this.player.getLevel(); ++ InteractionHand interactionhand = p_9932_.getHand(); ++ ItemStack itemstack = this.player.getItemInHand( interactionhand ); ++ this.player.resetLastActionTime(); ++ if (!itemstack.isEmpty()) { + // CraftBukkit start + // Raytrace to look for 'rogue armswings' -+ float f1 = this.f_9743_.m_146909_(); -+ float f2 = this.f_9743_.m_146908_(); -+ double d0 = this.f_9743_.m_20185_(); -+ double d1 = this.f_9743_.m_20186_() + (double) this.f_9743_.m_20192_(); -+ double d2 = this.f_9743_.m_20189_(); ++ float f1 = this.player.getXRot(); ++ float f2 = this.player.getYRot(); ++ double d0 = this.player.getX(); ++ double d1 = this.player.getY() + (double) this.player.getEyeHeight(); ++ double d2 = this.player.getZ(); + Vec3 vec3d = new Vec3(d0, d1, d2); -+ float f3 = Mth.m_14089_(-f2 * 0.017453292F - 3.1415927F); -+ float f4 = Mth.m_14031_(-f2 * 0.017453292F - 3.1415927F); -+ float f5 = -Mth.m_14089_(-f1 * 0.017453292F); -+ float f6 = Mth.m_14031_(-f1 * 0.017453292F); ++ float f3 = Mth.cos(-f2 * 0.017453292F - 3.1415927F); ++ float f4 = Mth.sin(-f2 * 0.017453292F - 3.1415927F); ++ float f5 = -Mth.cos(-f1 * 0.017453292F); ++ float f6 = Mth.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; -+ double d3 = f_9743_.f_8941_.m_9290_()== GameType.CREATIVE ? 5.0D : 4.5D; -+ Vec3 vec3d1 = vec3d.m_82520_((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ net.minecraft.world.phys.HitResult movingobjectposition = this.f_9743_.f_19853_.m_45547_(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.OUTLINE, net.minecraft.world.level.ClipContext.Fluid.NONE, f_9743_)); ++ double d3 = player.gameMode.getGameModeForPlayer()== GameType.CREATIVE ? 5.0D : 4.5D; ++ Vec3 vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); ++ net.minecraft.world.phys.HitResult movingobjectposition = this.player.level.clip(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.OUTLINE, net.minecraft.world.level.ClipContext.Fluid.NONE, player)); + + boolean cancelled; -+ if (movingobjectposition == null || movingobjectposition.m_6662_() != net.minecraft.world.phys.HitResult.Type.BLOCK) { -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.f_9743_, org.bukkit.event.block.Action.RIGHT_CLICK_AIR, itemstack, interactionhand); ++ if (movingobjectposition == null || movingobjectposition.getType() != net.minecraft.world.phys.HitResult.Type.BLOCK) { ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.RIGHT_CLICK_AIR, itemstack, interactionhand); + cancelled = event.useItemInHand() == org.bukkit.event.Event.Result.DENY; + } else { + BlockHitResult movingobjectpositionblock = (BlockHitResult) movingobjectposition; -+ if (f_9743_.f_8941_.firedInteract && f_9743_.f_8941_.interactPosition.equals(movingobjectpositionblock.m_82425_()) && f_9743_.f_8941_.interactHand == interactionhand && ItemStack.m_41658_(f_9743_.f_8941_.interactItemStack, itemstack)) { -+ cancelled = f_9743_.f_8941_.interactResult; ++ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == interactionhand && ItemStack.tagMatches(player.gameMode.interactItemStack, itemstack)) { ++ cancelled = player.gameMode.interactResult; + } else { -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(f_9743_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.m_82425_(), movingobjectpositionblock.m_82434_(), itemstack, true, interactionhand); ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, interactionhand); + cancelled = event.useItemInHand() == org.bukkit.event.Event.Result.DENY; + } -+ f_9743_.f_8941_.firedInteract = false; ++ player.gameMode.firedInteract = false; + } + if (cancelled) { -+ this.f_9743_.getBukkitEntity().updateInventory(); // SPIGOT-2524 ++ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 + return; + } -+ InteractionResult interactionresult = this.f_9743_.f_8941_.m_6261_( this.f_9743_, serverlevel, itemstack, interactionhand ); -+ if (interactionresult.m_19080_()) { -+ this.f_9743_.m_21011_( interactionhand, true ); ++ InteractionResult interactionresult = this.player.gameMode.useItem( this.player, serverlevel, itemstack, interactionhand ); ++ if (interactionresult.shouldSwing()) { ++ this.player.swing( interactionhand, true ); + } + + } + } + -+ public void m_6936_(ServerboundTeleportToEntityPacket p_9928_) { -+ PacketUtils.m_131359_( p_9928_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_5833_()) { -+ for (ServerLevel serverlevel : this.f_9745_.m_129785_()) { -+ Entity entity = p_9928_.m_134681_( serverlevel ); ++ public void handleTeleportToEntityPacket(ServerboundTeleportToEntityPacket p_9928_) { ++ PacketUtils.ensureRunningOnSameThread( p_9928_, this, this.player.getLevel() ); ++ if (this.player.isSpectator()) { ++ for (ServerLevel serverlevel : this.server.getAllLevels()) { ++ Entity entity = p_9928_.getEntity( serverlevel ); + if (entity != null) { -+ this.f_9743_.teleportTo( serverlevel, entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_() , org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit ++ this.player.teleportTo( serverlevel, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot() , org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit + return; + } + } @@ -2319,28 +2319,28 @@ + + } + -+ public void m_7529_(ServerboundResourcePackPacket p_9901_) { -+ PacketUtils.m_131359_( p_9901_, this, this.f_9743_.m_183503_() ); -+ if (p_9901_.m_179741_() == ServerboundResourcePackPacket.Action.DECLINED && this.f_9745_.m_142205_()) { -+ f_9744_.info( "Disconnecting {} due to resource pack rejection", (Object) this.f_9743_.m_7755_() ); -+ this.m_9942_( new TranslatableComponent( "multiplayer.requiredTexturePrompt.disconnect" ) ); ++ public void handleResourcePackResponse(ServerboundResourcePackPacket p_9901_) { ++ PacketUtils.ensureRunningOnSameThread( p_9901_, this, this.player.getLevel() ); ++ if (p_9901_.getAction() == ServerboundResourcePackPacket.Action.DECLINED && this.server.isResourcePackRequired()) { ++ LOGGER.info( "Disconnecting {} due to resource pack rejection", (Object) this.player.getName() ); ++ this.disconnect( new TranslatableComponent( "multiplayer.requiredTexturePrompt.disconnect" ) ); + } +// this.cserver.getPluginManager().callEvent(new org.bukkit.event.player.PlayerResourcePackStatusEvent(getCraftPlayer(), org.bukkit.event.player.PlayerResourcePackStatusEvent.Status.values()[p_9901_.action.ordinal()])); // CraftBukkit + } + -+ public void m_5938_(ServerboundPaddleBoatPacket p_9878_) { -+ PacketUtils.m_131359_( p_9878_, this, this.f_9743_.m_183503_() ); -+ Entity entity = this.f_9743_.m_20202_(); ++ public void handlePaddleBoat(ServerboundPaddleBoatPacket p_9878_) { ++ PacketUtils.ensureRunningOnSameThread( p_9878_, this, this.player.getLevel() ); ++ Entity entity = this.player.getVehicle(); + if (entity instanceof Boat) { -+ ((Boat) entity).m_38339_( p_9878_.m_134218_(), p_9878_.m_134221_() ); ++ ((Boat) entity).setPaddleState( p_9878_.getLeft(), p_9878_.getRight() ); + } + + } + -+ public void m_142110_(ServerboundPongPacket p_143652_) { ++ public void handlePong(ServerboundPongPacket p_143652_) { + } + -+ public void m_7026_(Component p_9825_) { ++ public void onDisconnect(Component p_9825_) { + // CraftBukkit start - Rarely it would send a disconnect line twice + if (this.processedDisconnect) { + return; @@ -2348,51 +2348,51 @@ + this.processedDisconnect = true; + } + // CraftBukkit end -+ f_9744_.info( "{} lost connection: {}", this.f_9743_.m_7755_().getString(), p_9825_.getString() ); ++ LOGGER.info( "{} lost connection: {}", this.player.getName().getString(), p_9825_.getString() ); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* + this.server.invalidateStatus(); + this.server.getPlayerList().broadcastMessage( (new TranslatableComponent( "multiplayer.player.left", this.player.getDisplayName() )).withStyle( ChatFormatting.YELLOW ), ChatType.SYSTEM, Util.NIL_UUID ); + */ -+ this.f_9743_.m_9231_(); -+ String defaultQuitMessage = ChatFormatting.YELLOW + this.f_9743_.m_7755_().getString() + " left the game"; -+ String quitMessage = this.f_9745_.m_6846_().removeAndReturn(this.f_9743_); ++ this.player.disconnect(); ++ String defaultQuitMessage = ChatFormatting.YELLOW + this.player.getName().getString() + " left the game"; ++ String quitMessage = this.server.getPlayerList().removeAndReturn(this.player); + if (((quitMessage != null) && (quitMessage.length() > 0))) { //Check if bukkit hasn't cancelled the quit message + if (!java.util.Objects.equals(quitMessage, defaultQuitMessage)) //If the message is not the default one, broadcast it, otherwise we let mixins handle it -+ this.f_9745_.m_6846_().broadcastMessage(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(quitMessage)); ++ this.server.getPlayerList().broadcastMessage(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(quitMessage)); + else -+ this.f_9745_.m_6846_().m_11264_((new TranslatableComponent("multiplayer.player.left", this.f_9743_.m_5446_())).m_130940_(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.f_137441_); ++ this.server.getPlayerList().broadcastMessage((new TranslatableComponent("multiplayer.player.left", this.player.getDisplayName())).withStyle(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.NIL_UUID); + } + // CraftBukkit end -+ this.f_9743_.m_8967_().m_7670_(); -+ if (this.m_9956_()) { -+ f_9744_.info( "Stopping singleplayer server as player logged out" ); -+ this.f_9745_.m_7570_( false ); ++ this.player.getTextFilter().leave(); ++ if (this.isSingleplayerOwner()) { ++ LOGGER.info( "Stopping singleplayer server as player logged out" ); ++ this.server.halt( false ); + } + + } + -+ public void m_141995_(Packet p_9830_) { -+ this.m_9831_( p_9830_, (GenericFutureListener>) null ); ++ public void send(Packet p_9830_) { ++ this.send( p_9830_, (GenericFutureListener>) null ); + } + -+ public void m_9831_(Packet p_9832_, @Nullable GenericFutureListener> p_9833_) { ++ public void send(Packet p_9832_, @Nullable GenericFutureListener> p_9833_) { + // CraftBukkit start + if (p_9832_ == null || this.processedDisconnect) { // Spigot + return; + } else if (p_9832_ instanceof net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket) { + net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket packet6 = (net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket) p_9832_; -+ this.f_9743_.compassTarget = new org.bukkit.Location(this.getCraftPlayer().getWorld(), packet6.f_133111_.m_123341_(), packet6.f_133111_.m_123342_(), packet6.f_133111_.m_123343_()); ++ this.player.compassTarget = new org.bukkit.Location(this.getCraftPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ()); + } + // CraftBukkit end + //Magma start - capture dimension packets -+ org.magmafoundation.magma.helpers.BorderHelper.captureBorderPacket(p_9832_, this.f_9743_); ++ org.magmafoundation.magma.helpers.BorderHelper.captureBorderPacket(p_9832_, this.player); + try { -+ this.f_9742_.m_129514_( p_9832_, p_9833_ ); ++ this.connection.send( p_9832_, p_9833_ ); + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Sending packet" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Packet being sent" ); -+ crashreportcategory.m_128165_( "Packet class", () -> { ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Sending packet" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Packet being sent" ); ++ crashreportcategory.setDetail( "Packet class", () -> { + return p_9832_.getClass().getCanonicalName(); + } ); + throw new ReportedException( crashreport ); @@ -2402,77 +2402,77 @@ + } + } + -+ public void m_7798_(ServerboundSetCarriedItemPacket p_9909_) { -+ PacketUtils.m_131359_( p_9909_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ if (p_9909_.m_134498_() >= 0 && p_9909_.m_134498_() < Inventory.m_36059_()) { -+ org.bukkit.event.player.PlayerItemHeldEvent event = new org.bukkit.event.player.PlayerItemHeldEvent(this.getCraftPlayer(), this.f_9743_.m_150109_().f_35977_, p_9909_.m_134498_()); ++ public void handleSetCarriedItem(ServerboundSetCarriedItemPacket p_9909_) { ++ PacketUtils.ensureRunningOnSameThread( p_9909_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit ++ if (p_9909_.getSlot() >= 0 && p_9909_.getSlot() < Inventory.getSelectionSize()) { ++ org.bukkit.event.player.PlayerItemHeldEvent event = new org.bukkit.event.player.PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().selected, p_9909_.getSlot()); + this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.m_141995_(new ClientboundSetCarriedItemPacket(this.f_9743_.m_150109_().f_35977_)); -+ this.f_9743_.m_9243_(); ++ this.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected)); ++ this.player.resetLastActionTime(); + return; + } + // CraftBukkit end -+ if (this.f_9743_.m_150109_().f_35977_ != p_9909_.m_134498_() && this.f_9743_.m_7655_() == InteractionHand.MAIN_HAND) { -+ this.f_9743_.m_5810_(); ++ if (this.player.getInventory().selected != p_9909_.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) { ++ this.player.stopUsingItem(); + } + -+ this.f_9743_.m_150109_().f_35977_ = p_9909_.m_134498_(); -+ this.f_9743_.m_9243_(); ++ this.player.getInventory().selected = p_9909_.getSlot(); ++ this.player.resetLastActionTime(); + } else { -+ f_9744_.warn( "{} tried to set an invalid carried item", (Object) this.f_9743_.m_7755_().getString() ); ++ LOGGER.warn( "{} tried to set an invalid carried item", (Object) this.player.getName().getString() ); + this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit + } + } + -+ public void m_7388_(ServerboundChatPacket p_9841_) { ++ public void handleChat(ServerboundChatPacket p_9841_) { + // CraftBukkit start - async chat + // SPIGOT-3638 -+ if (this.f_9745_.m_129918_()) { ++ if (this.server.isStopped()) { + return; + } + // CraftBukkit end -+ String s = org.apache.commons.lang3.StringUtils.normalizeSpace( p_9841_.m_133837_() ); ++ String s = org.apache.commons.lang3.StringUtils.normalizeSpace( p_9841_.getMessage() ); + + for (int i = 0; i < s.length(); ++i) { -+ if (!SharedConstants.m_136188_( s.charAt( i ) )) { -+ this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.illegal_characters" ) ); ++ if (!SharedConstants.isAllowedChatCharacter( s.charAt( i ) )) { ++ this.disconnect( new TranslatableComponent( "multiplayer.disconnect.illegal_characters" ) ); + return; + } + } + + if (s.startsWith( "/" )) { -+ PacketUtils.m_131359_( p_9841_, this, this.f_9743_.m_183503_() ); -+ this.m_143628_( TextFilter.FilteredText.m_143720_( s ) ); ++ PacketUtils.ensureRunningOnSameThread( p_9841_, this, this.player.getLevel() ); ++ this.handleChat( TextFilter.FilteredText.passThrough( s ) ); + } else { -+ this.m_143628_(TextFilter.FilteredText.m_143720_(s)); // CraftBukkit - filter NYI ++ this.handleChat(TextFilter.FilteredText.passThrough(s)); // CraftBukkit - filter NYI + } + + } + + // CraftBukkit start - add method //Magma - implement ArcLight version -+ private void m_143628_(TextFilter.FilteredText p_143629_) { -+ if (this.f_9743_.m_146910_() || this.f_9743_.m_9241_() == ChatVisiblity.HIDDEN) { -+ this.m_141995_(new ClientboundChatPacket((new TranslatableComponent("chat.cannotSend")).m_130940_(ChatFormatting.RED), ChatType.SYSTEM, Util.f_137441_)); ++ private void handleChat(TextFilter.FilteredText p_143629_) { ++ if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { ++ this.send(new ClientboundChatPacket((new TranslatableComponent("chat.cannotSend")).withStyle(ChatFormatting.RED), ChatType.SYSTEM, Util.NIL_UUID)); + } else { -+ this.f_9743_.m_9243_(); -+ String s = p_143629_.m_143719_(); ++ this.player.resetLastActionTime(); ++ String s = p_143629_.getRaw(); + boolean isSync = s.startsWith("/"); + if (isSync) { + try { + this.cserver.playerCommandState = true; -+ this.m_9957_(s); ++ this.handleCommand(s); + } finally { + this.cserver.playerCommandState = false; + } + } else if (s.isEmpty()) { -+ f_9744_.warn(this.f_9743_.m_6302_() + " tried to send an empty message"); ++ LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); + } else if (this.getCraftPlayer().isConversing()) { + String conversationInput = s; -+ this.f_9745_.processQueue.add(() -> this.getCraftPlayer().acceptConversationInput(conversationInput)); -+ } else if (this.f_9743_.m_9241_() == ChatVisiblity.SYSTEM) { -+ this.m_141995_(new ClientboundChatPacket((new TranslatableComponent("chat.cannotSend")).m_130940_(ChatFormatting.RED), ChatType.SYSTEM, Util.f_137441_)); ++ this.server.processQueue.add(() -> this.getCraftPlayer().acceptConversationInput(conversationInput)); ++ } else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) { ++ this.send(new ClientboundChatPacket((new TranslatableComponent("chat.cannotSend")).withStyle(ChatFormatting.RED), ChatType.SYSTEM, Util.NIL_UUID)); + } else { + this.chat(s, true); + } @@ -2485,19 +2485,19 @@ + } + } + if (counted) { -+ this.f_9750_ += 20; -+ if (this.f_9750_ > 200 && !this.f_9745_.m_6846_().m_11303_(this.f_9743_.m_36316_())) { ++ this.chatSpamTickCount += 20; ++ if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { + if (!isSync) { + class Disconnect2 extends org.bukkit.craftbukkit.v1_18_R2.util.Waitable { + + @Override + protected Object evaluate() { -+ m_9942_(new TranslatableComponent("disconnect.spam")); ++ disconnect(new TranslatableComponent("disconnect.spam")); + return null; + } + } + org.bukkit.craftbukkit.v1_18_R2.util.Waitable waitable2 = new Disconnect2(); -+ this.f_9745_.processQueue.add(waitable2); ++ this.server.processQueue.add(waitable2); + try { + waitable2.get(); + return; @@ -2508,21 +2508,21 @@ + throw new RuntimeException(e2); + } + } -+ this.m_9942_(new TranslatableComponent("disconnect.spam")); ++ this.disconnect(new TranslatableComponent("disconnect.spam")); + } + } + } + } + -+ private void m_9957_(String p_9958_) { ++ private void handleCommand(String p_9958_) { + co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper + // CraftBukkit start - whole method + if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot -+ f_9744_.info( this.f_9743_.m_6302_() + " issued server command: " + p_9958_ ); ++ LOGGER.info( this.player.getScoreboardName() + " issued server command: " + p_9958_ ); + + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer player = this.getCraftPlayer(); + -+ org.bukkit.event.player.PlayerCommandPreprocessEvent event = new org.bukkit.event.player.PlayerCommandPreprocessEvent( player, p_9958_, new org.bukkit.craftbukkit.v1_18_R2.util.LazyPlayerSet( f_9745_ ) ); ++ org.bukkit.event.player.PlayerCommandPreprocessEvent event = new org.bukkit.event.player.PlayerCommandPreprocessEvent( player, p_9958_, new org.bukkit.craftbukkit.v1_18_R2.util.LazyPlayerSet( server ) ); + this.cserver.getPluginManager().callEvent( event ); + + if (event.isCancelled()) { @@ -2545,30 +2545,30 @@ + // CraftBukkit end + } + -+ public void m_7953_(ServerboundSwingPacket p_9926_) { -+ PacketUtils.m_131359_( p_9926_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ this.f_9743_.m_9243_(); ++ public void handleAnimate(ServerboundSwingPacket p_9926_) { ++ PacketUtils.ensureRunningOnSameThread( p_9926_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit ++ this.player.resetLastActionTime(); + // CraftBukkit start - Raytrace to look for 'rogue armswings' -+ float f1 = this.f_9743_.m_146909_(); -+ float f2 = this.f_9743_.m_146908_(); -+ double d0 = this.f_9743_.m_20185_(); -+ double d1 = this.f_9743_.m_20186_() + (double) this.f_9743_.m_20192_(); -+ double d2 = this.f_9743_.m_20189_(); ++ float f1 = this.player.getXRot(); ++ float f2 = this.player.getYRot(); ++ double d0 = this.player.getX(); ++ double d1 = this.player.getY() + (double) this.player.getEyeHeight(); ++ double d2 = this.player.getZ(); + Vec3 vec3d = new Vec3(d0, d1, d2); + -+ float f3 = Mth.m_14089_(-f2 * 0.017453292F - 3.1415927F); -+ float f4 = Mth.m_14031_(-f2 * 0.017453292F - 3.1415927F); -+ float f5 = -Mth.m_14089_(-f1 * 0.017453292F); -+ float f6 = Mth.m_14031_(-f1 * 0.017453292F); ++ float f3 = Mth.cos(-f2 * 0.017453292F - 3.1415927F); ++ float f4 = Mth.sin(-f2 * 0.017453292F - 3.1415927F); ++ float f5 = -Mth.cos(-f1 * 0.017453292F); ++ float f6 = Mth.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; -+ double d3 = f_9743_.f_8941_.m_9290_()== GameType.CREATIVE ? 5.0D : 4.5D; -+ Vec3 vec3d1 = vec3d.m_82520_((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ net.minecraft.world.phys.HitResult movingobjectposition = this.f_9743_.f_19853_.m_45547_(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.OUTLINE, net.minecraft.world.level.ClipContext.Fluid.NONE, f_9743_)); ++ double d3 = player.gameMode.getGameModeForPlayer()== GameType.CREATIVE ? 5.0D : 4.5D; ++ Vec3 vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); ++ net.minecraft.world.phys.HitResult movingobjectposition = this.player.level.clip(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.OUTLINE, net.minecraft.world.level.ClipContext.Fluid.NONE, player)); + -+ if (movingobjectposition == null || movingobjectposition.m_6662_() != net.minecraft.world.phys.HitResult.Type.BLOCK) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.f_9743_, org.bukkit.event.block.Action.LEFT_CLICK_AIR, this.f_9743_.m_150109_().m_36056_(), InteractionHand.MAIN_HAND); ++ if (movingobjectposition == null || movingobjectposition.getType() != net.minecraft.world.phys.HitResult.Type.BLOCK) { ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); + } + + // Arm swing animation @@ -2577,17 +2577,17 @@ + + if (event.isCancelled()) return; + // CraftBukkit end -+ this.f_9743_.m_6674_( p_9926_.m_134674_() ); ++ this.player.swing( p_9926_.getHand() ); + } + -+ public void m_5681_(ServerboundPlayerCommandPacket p_9891_) { -+ PacketUtils.m_131359_( p_9891_, this, this.f_9743_.m_183503_() ); ++ public void handlePlayerCommand(ServerboundPlayerCommandPacket p_9891_) { ++ PacketUtils.ensureRunningOnSameThread( p_9891_, this, this.player.getLevel() ); + // CraftBukkit start -+ if (this.f_9743_.m_146910_()) return; -+ switch (p_9891_.m_134320_()) { ++ if (this.player.isRemoved()) return; ++ switch (p_9891_.getAction()) { + case PRESS_SHIFT_KEY: + case RELEASE_SHIFT_KEY: -+ org.bukkit.event.player.PlayerToggleSneakEvent event = new org.bukkit.event.player.PlayerToggleSneakEvent(this.getCraftPlayer(), p_9891_.m_134320_() == ServerboundPlayerCommandPacket.Action.PRESS_SHIFT_KEY); ++ org.bukkit.event.player.PlayerToggleSneakEvent event = new org.bukkit.event.player.PlayerToggleSneakEvent(this.getCraftPlayer(), p_9891_.getAction() == ServerboundPlayerCommandPacket.Action.PRESS_SHIFT_KEY); + this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; @@ -2595,7 +2595,7 @@ + break; + case START_SPRINTING: + case STOP_SPRINTING: -+ org.bukkit.event.player.PlayerToggleSprintEvent e2 = new org.bukkit.event.player.PlayerToggleSprintEvent(this.getCraftPlayer(), p_9891_.m_134320_() == ServerboundPlayerCommandPacket.Action.START_SPRINTING); ++ org.bukkit.event.player.PlayerToggleSprintEvent e2 = new org.bukkit.event.player.PlayerToggleSprintEvent(this.getCraftPlayer(), p_9891_.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING); + this.cserver.getPluginManager().callEvent(e2); + if (e2.isCancelled()) { + return; @@ -2603,49 +2603,49 @@ + break; + } + // CraftBukkit end -+ this.f_9743_.m_9243_(); -+ switch (p_9891_.m_134320_()) { ++ this.player.resetLastActionTime(); ++ switch (p_9891_.getAction()) { + case PRESS_SHIFT_KEY: -+ this.f_9743_.m_20260_( true ); ++ this.player.setShiftKeyDown( true ); + break; + case RELEASE_SHIFT_KEY: -+ this.f_9743_.m_20260_( false ); ++ this.player.setShiftKeyDown( false ); + break; + case START_SPRINTING: -+ this.f_9743_.m_6858_( true ); ++ this.player.setSprinting( true ); + break; + case STOP_SPRINTING: -+ this.f_9743_.m_6858_( false ); ++ this.player.setSprinting( false ); + break; + case STOP_SLEEPING: -+ if (this.f_9743_.m_5803_()) { -+ this.f_9743_.m_6145_( false, true ); -+ this.f_9766_ = this.f_9743_.m_20182_(); ++ if (this.player.isSleeping()) { ++ this.player.stopSleepInBed( false, true ); ++ this.awaitingPositionFromClient = this.player.position(); + } + break; + case START_RIDING_JUMP: -+ if (this.f_9743_.m_20202_() instanceof PlayerRideableJumping) { -+ PlayerRideableJumping playerrideablejumping1 = (PlayerRideableJumping) this.f_9743_.m_20202_(); -+ int i = p_9891_.m_134321_(); -+ if (playerrideablejumping1.m_7132_() && i > 0) { -+ playerrideablejumping1.m_7199_( i ); ++ if (this.player.getVehicle() instanceof PlayerRideableJumping) { ++ PlayerRideableJumping playerrideablejumping1 = (PlayerRideableJumping) this.player.getVehicle(); ++ int i = p_9891_.getData(); ++ if (playerrideablejumping1.canJump() && i > 0) { ++ playerrideablejumping1.handleStartJump( i ); + } + } + break; + case STOP_RIDING_JUMP: -+ if (this.f_9743_.m_20202_() instanceof PlayerRideableJumping) { -+ PlayerRideableJumping playerrideablejumping = (PlayerRideableJumping) this.f_9743_.m_20202_(); -+ playerrideablejumping.m_8012_(); ++ if (this.player.getVehicle() instanceof PlayerRideableJumping) { ++ PlayerRideableJumping playerrideablejumping = (PlayerRideableJumping) this.player.getVehicle(); ++ playerrideablejumping.handleStopJump(); + } + break; + case OPEN_INVENTORY: -+ if (this.f_9743_.m_20202_() instanceof AbstractHorse) { -+ ((AbstractHorse) this.f_9743_.m_20202_()).m_30620_( this.f_9743_ ); ++ if (this.player.getVehicle() instanceof AbstractHorse) { ++ ((AbstractHorse) this.player.getVehicle()).openInventory( this.player ); + } + break; + case START_FALL_FLYING: -+ if (!this.f_9743_.m_36319_()) { -+ this.f_9743_.m_36321_(); ++ if (!this.player.tryToStartFallFlying()) { ++ this.player.stopFallFlying(); + } + break; + default: @@ -2654,100 +2654,100 @@ + + } + -+ public void m_6946_(ServerboundInteractPacket p_9866_) { -+ PacketUtils.m_131359_( p_9866_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ ServerLevel serverlevel = this.f_9743_.m_183503_(); -+ final Entity entity = p_9866_.m_179603_( serverlevel ); ++ public void handleInteract(ServerboundInteractPacket p_9866_) { ++ PacketUtils.ensureRunningOnSameThread( p_9866_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit ++ ServerLevel serverlevel = this.player.getLevel(); ++ final Entity entity = p_9866_.getTarget( serverlevel ); + // Spigot Start -+ if ( entity == f_9743_ && !f_9743_.m_5833_() ) ++ if ( entity == player && !player.isSpectator() ) + { + disconnect( "Cannot interact with self!" ); + return; + } + // Spigot End -+ this.f_9743_.m_9243_(); -+ this.f_9743_.m_20260_( p_9866_.m_134061_() ); ++ this.player.resetLastActionTime(); ++ this.player.setShiftKeyDown( p_9866_.isUsingSecondaryAction() ); + if (entity != null) { -+ if (!serverlevel.m_6857_().m_61937_( entity.m_142538_() )) { ++ if (!serverlevel.getWorldBorder().isWithinBounds( entity.blockPosition() )) { + return; + } + + double d0 = 36.0D; -+ if (this.f_9743_.m_20280_( entity ) < 36.0D) { -+ p_9866_.m_179617_( new ServerboundInteractPacket.Handler() { ++ if (this.player.distanceToSqr( entity ) < 36.0D) { ++ p_9866_.dispatch( new ServerboundInteractPacket.Handler() { + private void performInteraction(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_, org.bukkit.event.player.PlayerInteractEntityEvent event) { // CraftBukkit -+ if(!ServerGamePacketListenerImpl.this.f_9743_.canInteractWith(entity, 1.5D)) return; //Forge: If the entity cannot be reached, do nothing. Original check was dist < 6, range is 4.5, so vanilla used padding=1.5 ++ if(!ServerGamePacketListenerImpl.this.player.canInteractWith(entity, 1.5D)) return; //Forge: If the entity cannot be reached, do nothing. Original check was dist < 6, range is 4.5, so vanilla used padding=1.5 + -+ ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_( p_143679_ ).m_41777_(); ++ ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand( p_143679_ ).copy(); + // CraftBukkit start -+ ItemStack itemInHand = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_); -+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.m_41720_() == Items.f_42655_ && entity instanceof net.minecraft.world.entity.Mob; -+ Item origItem = f_9743_.m_150109_().m_36056_() == null ? null : f_9743_.m_150109_().m_36056_().m_41720_(); ++ ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(p_143679_); ++ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof net.minecraft.world.entity.Mob; ++ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + + cserver.getPluginManager().callEvent(event); + + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859 -+ if ((entity instanceof net.minecraft.world.entity.animal.Bucketable && entity instanceof net.minecraft.world.entity.LivingEntity && origItem != null && origItem.m_5456_() == Items.f_42447_) && (event.isCancelled() || f_9743_.m_150109_().m_36056_() == null || f_9743_.m_150109_().m_36056_().m_41720_() != origItem)) { -+ m_141995_(new net.minecraft.network.protocol.game.ClientboundAddMobPacket((net.minecraft.world.entity.LivingEntity) entity)); -+ f_9743_.f_36096_.m_150429_(); ++ if ((entity instanceof net.minecraft.world.entity.animal.Bucketable && entity instanceof net.minecraft.world.entity.LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ send(new net.minecraft.network.protocol.game.ClientboundAddMobPacket((net.minecraft.world.entity.LivingEntity) entity)); ++ player.containerMenu.sendAllDataToRemote(); + } + -+ if (triggerLeashUpdate && (event.isCancelled() || f_9743_.m_150109_().m_36056_() == null || f_9743_.m_150109_().m_36056_().m_41720_() != origItem)) { ++ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { + // Refresh the current leash state -+ m_141995_(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(entity, ((net.minecraft.world.entity.Mob) entity).m_21524_())); ++ send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(entity, ((net.minecraft.world.entity.Mob) entity).getLeashHolder())); + } + -+ if (event.isCancelled() || f_9743_.m_150109_().m_36056_() == null || f_9743_.m_150109_().m_36056_().m_41720_() != origItem) { ++ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { + // Refresh the current entity metadata -+ m_141995_(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(entity.m_142049_(), entity.m_20088_(), true)); ++ send(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(entity.getId(), entity.getEntityData(), true)); + } + + if (event.isCancelled()) { + return; + } + // CraftBukkit end -+ InteractionResult interactionresult = p_143680_.m_143694_( ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_ ); ++ InteractionResult interactionresult = p_143680_.run( ServerGamePacketListenerImpl.this.player, entity, p_143679_ ); + + // CraftBukkit start -+ if (!itemInHand.m_41619_() && itemInHand.m_41613_() <= -1) { -+ f_9743_.f_36096_.m_150429_(); ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { ++ player.containerMenu.sendAllDataToRemote(); + } + // CraftBukkit end -+ if (interactionresult.m_19077_()) { -+ CriteriaTriggers.f_10565_.m_61494_( ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity ); -+ if (interactionresult.m_19080_()) { -+ ServerGamePacketListenerImpl.this.f_9743_.m_21011_( p_143679_, true ); ++ if (interactionresult.consumesAction()) { ++ CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger( ServerGamePacketListenerImpl.this.player, itemstack, entity ); ++ if (interactionresult.shouldSwing()) { ++ ServerGamePacketListenerImpl.this.player.swing( p_143679_, true ); + } + } + + } + -+ public void m_142299_(InteractionHand p_143677_) { -+ this.performInteraction( p_143677_, Player::m_36157_ , new org.bukkit.event.player.PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (p_143677_ == InteractionHand.OFF_HAND) ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND)); ++ public void onInteraction(InteractionHand p_143677_) { ++ this.performInteraction( p_143677_, Player::interactOn , new org.bukkit.event.player.PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (p_143677_ == InteractionHand.OFF_HAND) ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND)); + } + -+ public void m_142143_(InteractionHand p_143682_, Vec3 p_143683_) { ++ public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { + this.performInteraction(p_143682_, (p_143686_, p_143687_, p_143688_) -> { -+ InteractionResult onInteractEntityAtResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAt(f_9743_, entity, p_143683_, p_143682_); ++ InteractionResult onInteractEntityAtResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAt(player, entity, p_143683_, p_143682_); + if (onInteractEntityAtResult != null) return onInteractEntityAtResult; -+ return p_143687_.m_7111_(p_143686_, p_143683_, p_143688_); -+ }, new org.bukkit.event.player.PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(p_143683_.f_82479_, p_143683_.f_82480_, p_143683_.f_82481_), (p_143682_ == InteractionHand.OFF_HAND) ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND)); // CraftBukkit ++ return p_143687_.interactAt(p_143686_, p_143683_, p_143688_); ++ }, new org.bukkit.event.player.PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(p_143683_.x, p_143683_.y, p_143683_.z), (p_143682_ == InteractionHand.OFF_HAND) ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND)); // CraftBukkit + } + -+ public void m_141994_() { ++ public void onAttack() { + // CraftBukkit start -+ if (!(entity instanceof ItemEntity) && !(entity instanceof ExperienceOrb) && !(entity instanceof AbstractArrow) && (entity != ServerGamePacketListenerImpl.this.f_9743_ || f_9743_.m_5833_())) { -+ ItemStack itemInHand = ServerGamePacketListenerImpl.this.f_9743_.m_21205_(); -+ ServerGamePacketListenerImpl.this.f_9743_.m_5706_( entity ); ++ if (!(entity instanceof ItemEntity) && !(entity instanceof ExperienceOrb) && !(entity instanceof AbstractArrow) && (entity != ServerGamePacketListenerImpl.this.player || player.isSpectator())) { ++ ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getMainHandItem(); ++ ServerGamePacketListenerImpl.this.player.attack( entity ); + -+ if (!itemInHand.m_41619_() && itemInHand.m_41613_() <= -1) { -+ f_9743_.f_36096_.m_150429_(); ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { ++ player.containerMenu.sendAllDataToRemote(); + } + // CraftBukkit end + } else { -+ ServerGamePacketListenerImpl.this.m_9942_( new TranslatableComponent( "multiplayer.disconnect.invalid_entity_attacked" ) ); -+ ServerGamePacketListenerImpl.f_9744_.warn( "Player {} tried to attack an invalid entity", (Object) ServerGamePacketListenerImpl.this.f_9743_.m_7755_().getString() ); ++ ServerGamePacketListenerImpl.this.disconnect( new TranslatableComponent( "multiplayer.disconnect.invalid_entity_attacked" ) ); ++ ServerGamePacketListenerImpl.LOGGER.warn( "Player {} tried to attack an invalid entity", (Object) ServerGamePacketListenerImpl.this.player.getName().getString() ); + } + } + } ); @@ -2756,124 +2756,124 @@ + + } + -+ public void m_6272_(ServerboundClientCommandPacket p_9843_) { -+ PacketUtils.m_131359_( p_9843_, this, this.f_9743_.m_183503_() ); -+ this.f_9743_.m_9243_(); -+ ServerboundClientCommandPacket.Action serverboundclientcommandpacket$action = p_9843_.m_133850_(); ++ public void handleClientCommand(ServerboundClientCommandPacket p_9843_) { ++ PacketUtils.ensureRunningOnSameThread( p_9843_, this, this.player.getLevel() ); ++ this.player.resetLastActionTime(); ++ ServerboundClientCommandPacket.Action serverboundclientcommandpacket$action = p_9843_.getAction(); + switch (serverboundclientcommandpacket$action) { + case PERFORM_RESPAWN: -+ if (this.f_9743_.f_8944_) { -+ this.f_9743_.f_8944_ = false; -+ this.f_9743_ = this.f_9745_.m_6846_().m_11236_( this.f_9743_, true ); -+ CriteriaTriggers.f_10588_.m_19757_( this.f_9743_, Level.f_46430_, Level.f_46428_ ); ++ if (this.player.wonGame) { ++ this.player.wonGame = false; ++ this.player = this.server.getPlayerList().respawn( this.player, true ); ++ CriteriaTriggers.CHANGED_DIMENSION.trigger( this.player, Level.END, Level.OVERWORLD ); + } else { -+ if (this.f_9743_.m_21223_() > 0.0F) { ++ if (this.player.getHealth() > 0.0F) { + return; + } + -+ this.f_9743_ = this.f_9745_.m_6846_().m_11236_( this.f_9743_, false ); -+ if (this.f_9745_.m_7035_()) { -+ this.f_9743_.m_143403_( GameType.SPECTATOR ); -+ this.f_9743_.m_183503_().m_46469_().m_46170_( GameRules.f_46146_ ).m_46246_( false, this.f_9745_ ); ++ this.player = this.server.getPlayerList().respawn( this.player, false ); ++ if (this.server.isHardcore()) { ++ this.player.setGameMode( GameType.SPECTATOR ); ++ this.player.getLevel().getGameRules().getRule( GameRules.RULE_SPECTATORSGENERATECHUNKS ).set( false, this.server ); + } + } + break; + case REQUEST_STATS: -+ this.f_9743_.m_8951_().m_12819_( this.f_9743_ ); ++ this.player.getStats().sendStats( this.player ); + } + + } + -+ public void m_7951_(ServerboundContainerClosePacket p_9858_) { -+ PacketUtils.m_131359_( p_9858_, this, this.f_9743_.m_183503_() ); ++ public void handleContainerClose(ServerboundContainerClosePacket p_9858_) { ++ PacketUtils.ensureRunningOnSameThread( p_9858_, this, this.player.getLevel() ); + -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit ++ if (this.player.isImmobile()) return; // CraftBukkit + -+ this.f_9743_.m_9230_(); ++ this.player.doCloseContainer(); + } + -+ public void m_5914_(ServerboundContainerClickPacket p_9856_) { -+ PacketUtils.m_131359_( p_9856_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ this.f_9743_.m_9243_(); -+ if (this.f_9743_.f_36096_.f_38840_ == p_9856_.m_133959_() && this.f_9743_.f_36096_.m_6875_( this.f_9743_ )) { // CraftBukkit -+ boolean cancelled = this.f_9743_.m_5833_(); // CraftBukkit - see below if ++ public void handleContainerClick(ServerboundContainerClickPacket p_9856_) { ++ PacketUtils.ensureRunningOnSameThread( p_9856_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit ++ this.player.resetLastActionTime(); ++ if (this.player.containerMenu.containerId == p_9856_.getContainerId() && this.player.containerMenu.stillValid( this.player )) { // CraftBukkit ++ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + if (false/*this.player.isSpectator()*/) { // CraftBukkit -+ this.f_9743_.f_36096_.m_150429_(); ++ this.player.containerMenu.sendAllDataToRemote(); + } else { -+ int i = p_9856_.m_133962_(); -+ if (!this.f_9743_.f_36096_.m_207775_( i )) { -+ f_9744_.debug( "Player {} clicked invalid slot index: {}, available slots: {}", this.f_9743_.m_7755_(), i, this.f_9743_.f_36096_.f_38839_.size() ); ++ int i = p_9856_.getSlotNum(); ++ if (!this.player.containerMenu.isValidSlotIndex( i )) { ++ LOGGER.debug( "Player {} clicked invalid slot index: {}, available slots: {}", this.player.getName(), i, this.player.containerMenu.slots.size() ); + } else { -+ boolean flag = p_9856_.m_182741_() != this.f_9743_.f_36096_.m_182424_(); -+ this.f_9743_.f_36096_.m_150443_(); ++ boolean flag = p_9856_.getStateId() != this.player.containerMenu.getStateId(); ++ this.player.containerMenu.suppressRemoteUpdates(); +// this.player.containerMenu.clicked(i, p_9856_.getButtonNum(), p_9856_.getClickType(), this.player); + + // CraftBukkit start - Call InventoryClickEvent -+ if (p_9856_.m_133962_() < -1 && p_9856_.m_133962_() != -999) { ++ if (p_9856_.getSlotNum() < -1 && p_9856_.getSlotNum() != -999) { + return; + } + + // org.magmafoundation.magma.Magma start - capture container owner -+ org.magmafoundation.magma.helpers.InventoryViewHelper.captureContainerOwner(this.f_9743_); -+ org.bukkit.inventory.InventoryView inventory = this.f_9743_.f_36096_.getBukkitView(); ++ org.magmafoundation.magma.helpers.InventoryViewHelper.captureContainerOwner(this.player); ++ org.bukkit.inventory.InventoryView inventory = this.player.containerMenu.getBukkitView(); + org.magmafoundation.magma.helpers.InventoryViewHelper.resetContainerOwner(); + // org.magmafoundation.magma.Magma end -+ org.bukkit.event.inventory.InventoryType.SlotType type = inventory.getSlotType( p_9856_.m_133962_() ); ++ org.bukkit.event.inventory.InventoryType.SlotType type = inventory.getSlotType( p_9856_.getSlotNum() ); + + org.bukkit.event.inventory.InventoryClickEvent event; + org.bukkit.event.inventory.ClickType click = org.bukkit.event.inventory.ClickType.UNKNOWN; + org.bukkit.event.inventory.InventoryAction action = org.bukkit.event.inventory.InventoryAction.UNKNOWN; + -+ ItemStack itemstack = ItemStack.f_41583_; ++ ItemStack itemstack = ItemStack.EMPTY; + -+ switch (p_9856_.m_133966_()) { ++ switch (p_9856_.getClickType()) { + case PICKUP: -+ if (p_9856_.m_133963_() == 0) { ++ if (p_9856_.getButtonNum() == 0) { + click = org.bukkit.event.inventory.ClickType.LEFT; -+ } else if (p_9856_.m_133963_() == 1) { ++ } else if (p_9856_.getButtonNum() == 1) { + click = org.bukkit.event.inventory.ClickType.RIGHT; + } -+ if (p_9856_.m_133963_() == 0 || p_9856_.m_133963_() == 1) { ++ if (p_9856_.getButtonNum() == 0 || p_9856_.getButtonNum() == 1) { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; // Don't want to repeat ourselves -+ if (p_9856_.m_133962_() == -999) { -+ if (!f_9743_.f_36096_.m_142621_().m_41619_()) { -+ action = p_9856_.m_133963_() == 0 ? org.bukkit.event.inventory.InventoryAction.DROP_ALL_CURSOR : org.bukkit.event.inventory.InventoryAction.DROP_ONE_CURSOR; ++ if (p_9856_.getSlotNum() == -999) { ++ if (!player.containerMenu.getCarried().isEmpty()) { ++ action = p_9856_.getButtonNum() == 0 ? org.bukkit.event.inventory.InventoryAction.DROP_ALL_CURSOR : org.bukkit.event.inventory.InventoryAction.DROP_ONE_CURSOR; + } -+ } else if (p_9856_.m_133962_() < 0) { ++ } else if (p_9856_.getSlotNum() < 0) { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; + } else { -+ net.minecraft.world.inventory.Slot slot = this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ); ++ net.minecraft.world.inventory.Slot slot = this.player.containerMenu.getSlot( p_9856_.getSlotNum() ); + if (slot != null) { -+ ItemStack clickedItem = slot.m_7993_(); -+ ItemStack cursor = f_9743_.f_36096_.m_142621_(); -+ if (clickedItem.m_41619_()) { -+ if (!cursor.m_41619_()) { -+ action = p_9856_.m_133963_() == 0 ? org.bukkit.event.inventory.InventoryAction.PLACE_ALL : org.bukkit.event.inventory.InventoryAction.PLACE_ONE; ++ ItemStack clickedItem = slot.getItem(); ++ ItemStack cursor = player.containerMenu.getCarried(); ++ if (clickedItem.isEmpty()) { ++ if (!cursor.isEmpty()) { ++ action = p_9856_.getButtonNum() == 0 ? org.bukkit.event.inventory.InventoryAction.PLACE_ALL : org.bukkit.event.inventory.InventoryAction.PLACE_ONE; + } -+ } else if (slot.m_8010_( f_9743_ )) { -+ if (cursor.m_41619_()) { -+ action = p_9856_.m_133963_() == 0 ? org.bukkit.event.inventory.InventoryAction.PICKUP_ALL : org.bukkit.event.inventory.InventoryAction.PICKUP_HALF; -+ } else if (slot.m_5857_( cursor )) { -+ if (clickedItem.m_41656_( cursor ) && ItemStack.m_41658_( clickedItem, cursor )) { -+ int toPlace = p_9856_.m_133963_() == 0 ? cursor.m_41613_() : 1; -+ toPlace = Math.min( toPlace, clickedItem.m_41741_() - clickedItem.m_41613_() ); -+ toPlace = Math.min( toPlace, slot.f_40218_.m_6893_() - clickedItem.m_41613_() ); ++ } else if (slot.mayPickup( player )) { ++ if (cursor.isEmpty()) { ++ action = p_9856_.getButtonNum() == 0 ? org.bukkit.event.inventory.InventoryAction.PICKUP_ALL : org.bukkit.event.inventory.InventoryAction.PICKUP_HALF; ++ } else if (slot.mayPlace( cursor )) { ++ if (clickedItem.sameItem( cursor ) && ItemStack.tagMatches( clickedItem, cursor )) { ++ int toPlace = p_9856_.getButtonNum() == 0 ? cursor.getCount() : 1; ++ toPlace = Math.min( toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount() ); ++ toPlace = Math.min( toPlace, slot.container.getMaxStackSize() - clickedItem.getCount() ); + if (toPlace == 1) { + action = org.bukkit.event.inventory.InventoryAction.PLACE_ONE; -+ } else if (toPlace == cursor.m_41613_()) { ++ } else if (toPlace == cursor.getCount()) { + action = org.bukkit.event.inventory.InventoryAction.PLACE_ALL; + } else if (toPlace < 0) { + action = toPlace != -1 ? org.bukkit.event.inventory.InventoryAction.PICKUP_SOME : org.bukkit.event.inventory.InventoryAction.PICKUP_ONE; // this happens with oversized stacks + } else if (toPlace != 0) { + action = org.bukkit.event.inventory.InventoryAction.PLACE_SOME; + } -+ } else if (cursor.m_41613_() <= slot.m_6641_()) { ++ } else if (cursor.getCount() <= slot.getMaxStackSize()) { + action = org.bukkit.event.inventory.InventoryAction.SWAP_WITH_CURSOR; + } -+ } else if (cursor.m_41720_() == clickedItem.m_41720_() && ItemStack.m_41658_( cursor, clickedItem )) { -+ if (clickedItem.m_41613_() >= 0) { -+ if (clickedItem.m_41613_() + cursor.m_41613_() <= cursor.m_41741_()) { ++ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.tagMatches( cursor, clickedItem )) { ++ if (clickedItem.getCount() >= 0) { ++ if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { + // As of 1.5, this is result slots only + action = org.bukkit.event.inventory.InventoryAction.PICKUP_ALL; + } @@ -2886,17 +2886,17 @@ + break; + // TODO check on updates + case QUICK_MOVE: -+ if (p_9856_.m_133963_() == 0) { ++ if (p_9856_.getButtonNum() == 0) { + click = org.bukkit.event.inventory.ClickType.SHIFT_LEFT; -+ } else if (p_9856_.m_133963_() == 1) { ++ } else if (p_9856_.getButtonNum() == 1) { + click = org.bukkit.event.inventory.ClickType.SHIFT_RIGHT; + } -+ if (p_9856_.m_133963_() == 0 || p_9856_.m_133963_() == 1) { -+ if (p_9856_.m_133962_() < 0) { ++ if (p_9856_.getButtonNum() == 0 || p_9856_.getButtonNum() == 1) { ++ if (p_9856_.getSlotNum() < 0) { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; + } else { -+ net.minecraft.world.inventory.Slot slot = this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ); -+ if (slot != null && slot.m_8010_( this.f_9743_ ) && slot.m_6657_()) { ++ net.minecraft.world.inventory.Slot slot = this.player.containerMenu.getSlot( p_9856_.getSlotNum() ); ++ if (slot != null && slot.mayPickup( this.player ) && slot.hasItem()) { + action = org.bukkit.event.inventory.InventoryAction.MOVE_TO_OTHER_INVENTORY; + } else { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; @@ -2905,19 +2905,19 @@ + } + break; + case SWAP: -+ if ((p_9856_.m_133963_() >= 0 && p_9856_.m_133963_() < 9) || p_9856_.m_133963_() == 40) { -+ click = (p_9856_.m_133963_() == 40) ? org.bukkit.event.inventory.ClickType.SWAP_OFFHAND : org.bukkit.event.inventory.ClickType.NUMBER_KEY; -+ net.minecraft.world.inventory.Slot clickedSlot = this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ); -+ if (clickedSlot.m_8010_( f_9743_ )) { -+ ItemStack hotbar = this.f_9743_.m_150109_().m_8020_( p_9856_.m_133963_() ); -+ boolean canCleanSwap = hotbar.m_41619_() || (clickedSlot.f_40218_ == f_9743_.m_150109_() && clickedSlot.m_5857_( hotbar )); // the slot will accept the hotbar item -+ if (clickedSlot.m_6657_()) { ++ if ((p_9856_.getButtonNum() >= 0 && p_9856_.getButtonNum() < 9) || p_9856_.getButtonNum() == 40) { ++ click = (p_9856_.getButtonNum() == 40) ? org.bukkit.event.inventory.ClickType.SWAP_OFFHAND : org.bukkit.event.inventory.ClickType.NUMBER_KEY; ++ net.minecraft.world.inventory.Slot clickedSlot = this.player.containerMenu.getSlot( p_9856_.getSlotNum() ); ++ if (clickedSlot.mayPickup( player )) { ++ ItemStack hotbar = this.player.getInventory().getItem( p_9856_.getButtonNum() ); ++ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace( hotbar )); // the slot will accept the hotbar item ++ if (clickedSlot.hasItem()) { + if (canCleanSwap) { + action = org.bukkit.event.inventory.InventoryAction.HOTBAR_SWAP; + } else { + action = org.bukkit.event.inventory.InventoryAction.HOTBAR_MOVE_AND_READD; + } -+ } else if (!clickedSlot.m_6657_() && !hotbar.m_41619_() && clickedSlot.m_5857_( hotbar )) { ++ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.mayPlace( hotbar )) { + action = org.bukkit.event.inventory.InventoryAction.HOTBAR_SWAP; + } else { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; @@ -2928,13 +2928,13 @@ + } + break; + case CLONE: -+ if (p_9856_.m_133963_() == 2) { ++ if (p_9856_.getButtonNum() == 2) { + click = org.bukkit.event.inventory.ClickType.MIDDLE; -+ if (p_9856_.m_133962_() < 0) { ++ if (p_9856_.getSlotNum() < 0) { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; + } else { -+ net.minecraft.world.inventory.Slot slot = this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ); -+ if (slot != null && slot.m_6657_() && f_9743_.m_150110_().f_35937_ && f_9743_.f_36096_.m_142621_().m_41619_()) { ++ net.minecraft.world.inventory.Slot slot = this.player.containerMenu.getSlot( p_9856_.getSlotNum() ); ++ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) { + action = org.bukkit.event.inventory.InventoryAction.CLONE_STACK; + } else { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; @@ -2946,19 +2946,19 @@ + } + break; + case THROW: -+ if (p_9856_.m_133962_() >= 0) { -+ if (p_9856_.m_133963_() == 0) { ++ if (p_9856_.getSlotNum() >= 0) { ++ if (p_9856_.getButtonNum() == 0) { + click = org.bukkit.event.inventory.ClickType.DROP; -+ net.minecraft.world.inventory.Slot slot = this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ); -+ if (slot != null && slot.m_6657_() && slot.m_8010_( f_9743_ ) && !slot.m_7993_().m_41619_() && slot.m_7993_().m_41720_() != Item.m_41439_( Blocks.f_50016_ )) { ++ net.minecraft.world.inventory.Slot slot = this.player.containerMenu.getSlot( p_9856_.getSlotNum() ); ++ if (slot != null && slot.hasItem() && slot.mayPickup( player ) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock( Blocks.AIR )) { + action = org.bukkit.event.inventory.InventoryAction.DROP_ONE_SLOT; + } else { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; + } -+ } else if (p_9856_.m_133963_() == 1) { ++ } else if (p_9856_.getButtonNum() == 1) { + click = org.bukkit.event.inventory.ClickType.CONTROL_DROP; -+ net.minecraft.world.inventory.Slot slot = this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ); -+ if (slot != null && slot.m_6657_() && slot.m_8010_( f_9743_ ) && !slot.m_7993_().m_41619_() && slot.m_7993_().m_41720_() != Item.m_41439_( Blocks.f_50016_ )) { ++ net.minecraft.world.inventory.Slot slot = this.player.containerMenu.getSlot( p_9856_.getSlotNum() ); ++ if (slot != null && slot.hasItem() && slot.mayPickup( player ) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock( Blocks.AIR )) { + action = org.bukkit.event.inventory.InventoryAction.DROP_ALL_SLOT; + } else { + action = org.bukkit.event.inventory.InventoryAction.NOTHING; @@ -2967,23 +2967,23 @@ + } else { + // Sane default (because this happens when they are holding nothing. Don't ask why.) + click = org.bukkit.event.inventory.ClickType.LEFT; -+ if (p_9856_.m_133963_() == 1) { ++ if (p_9856_.getButtonNum() == 1) { + click = org.bukkit.event.inventory.ClickType.RIGHT; + } + action = org.bukkit.event.inventory.InventoryAction.NOTHING; + } + break; + case QUICK_CRAFT: -+ this.f_9743_.f_36096_.m_150399_( p_9856_.m_133962_(), p_9856_.m_133963_(), p_9856_.m_133966_(), this.f_9743_ ); ++ this.player.containerMenu.clicked( p_9856_.getSlotNum(), p_9856_.getButtonNum(), p_9856_.getClickType(), this.player ); + break; + case PICKUP_ALL: + click = org.bukkit.event.inventory.ClickType.DOUBLE_CLICK; + action = org.bukkit.event.inventory.InventoryAction.NOTHING; -+ if (p_9856_.m_133962_() >= 0 && !this.f_9743_.f_36096_.m_142621_().m_41619_()) { -+ ItemStack cursor = this.f_9743_.f_36096_.m_142621_(); ++ if (p_9856_.getSlotNum() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { ++ ItemStack cursor = this.player.containerMenu.getCarried(); + action = org.bukkit.event.inventory.InventoryAction.NOTHING; + // Quick check for if we have any of the item -+ if (inventory.getTopInventory().contains( org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.getMaterial( cursor.m_41720_() ) ) || inventory.getBottomInventory().contains( org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.getMaterial( cursor.m_41720_() ) )) { ++ if (inventory.getTopInventory().contains( org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.getMaterial( cursor.getItem() ) ) || inventory.getBottomInventory().contains( org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.getMaterial( cursor.getItem() ) )) { + action = org.bukkit.event.inventory.InventoryAction.COLLECT_TO_CURSOR; + } + } @@ -2991,43 +2991,43 @@ + default: + break; + } -+ if (p_9856_.m_133966_() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) { ++ if (p_9856_.getClickType() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) { + if (click == org.bukkit.event.inventory.ClickType.NUMBER_KEY) { -+ event = new org.bukkit.event.inventory.InventoryClickEvent( inventory, type, p_9856_.m_133962_(), click, action, p_9856_.m_133963_() ); ++ event = new org.bukkit.event.inventory.InventoryClickEvent( inventory, type, p_9856_.getSlotNum(), click, action, p_9856_.getButtonNum() ); + } else { -+ event = new org.bukkit.event.inventory.InventoryClickEvent( inventory, type, p_9856_.m_133962_(), click, action ); ++ event = new org.bukkit.event.inventory.InventoryClickEvent( inventory, type, p_9856_.getSlotNum(), click, action ); + } + org.bukkit.inventory.Inventory top = inventory.getTopInventory(); -+ if (p_9856_.m_133962_() == 0 && top instanceof org.bukkit.inventory.CraftingInventory) { ++ if (p_9856_.getSlotNum() == 0 && top instanceof org.bukkit.inventory.CraftingInventory) { + org.bukkit.inventory.Recipe recipe = ((org.bukkit.inventory.CraftingInventory) top).getRecipe(); + if (recipe != null) { + if (click == org.bukkit.event.inventory.ClickType.NUMBER_KEY) { -+ event = new org.bukkit.event.inventory.CraftItemEvent( recipe, inventory, type, p_9856_.m_133962_(), click, action, p_9856_.m_133963_() ); ++ event = new org.bukkit.event.inventory.CraftItemEvent( recipe, inventory, type, p_9856_.getSlotNum(), click, action, p_9856_.getButtonNum() ); + } else { -+ event = new org.bukkit.event.inventory.CraftItemEvent( recipe, inventory, type, p_9856_.m_133962_(), click, action ); ++ event = new org.bukkit.event.inventory.CraftItemEvent( recipe, inventory, type, p_9856_.getSlotNum(), click, action ); + } + } + } -+ if (p_9856_.m_133962_() == 2 && top instanceof org.bukkit.inventory.SmithingInventory) { ++ if (p_9856_.getSlotNum() == 2 && top instanceof org.bukkit.inventory.SmithingInventory) { + org.bukkit.inventory.ItemStack result = ((org.bukkit.inventory.SmithingInventory) top).getResult(); + if (result != null) { + if (click == org.bukkit.event.inventory.ClickType.NUMBER_KEY) { -+ event = new org.bukkit.event.inventory.SmithItemEvent( inventory, type, p_9856_.m_133962_(), click, action, p_9856_.m_133963_() ); ++ event = new org.bukkit.event.inventory.SmithItemEvent( inventory, type, p_9856_.getSlotNum(), click, action, p_9856_.getButtonNum() ); + } else { -+ event = new org.bukkit.event.inventory.SmithItemEvent( inventory, type, p_9856_.m_133962_(), click, action ); ++ event = new org.bukkit.event.inventory.SmithItemEvent( inventory, type, p_9856_.getSlotNum(), click, action ); + } + } + } + event.setCancelled( cancelled ); -+ AbstractContainerMenu oldContainer = this.f_9743_.f_36096_; // SPIGOT-1224 ++ AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 + cserver.getPluginManager().callEvent( event ); -+ if (this.f_9743_.f_36096_ != oldContainer) { ++ if (this.player.containerMenu != oldContainer) { + return; + } + switch (event.getResult()) { + case ALLOW: + case DEFAULT: -+ this.f_9743_.f_36096_.m_150399_( i, p_9856_.m_133963_(), p_9856_.m_133966_(), this.f_9743_ ); ++ this.player.containerMenu.clicked( i, p_9856_.getButtonNum(), p_9856_.getClickType(), this.player ); + break; + case DENY: + switch (action) { @@ -3038,7 +3038,7 @@ + case HOTBAR_SWAP: + case COLLECT_TO_CURSOR: + case UNKNOWN: -+ this.f_9743_.f_36096_.m_150429_(); ++ this.player.containerMenu.sendAllDataToRemote(); + break; + // Modified cursor and clicked + case PICKUP_SOME: @@ -3048,19 +3048,19 @@ + case PLACE_SOME: + case PLACE_ONE: + case SWAP_WITH_CURSOR: -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( -1, -1, this.f_9743_.f_36095_.m_182425_(), this.f_9743_.f_36096_.m_142621_() ) ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( this.f_9743_.f_36096_.f_38840_, this.f_9743_.f_36095_.m_182425_(), p_9856_.m_133962_(), this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ).m_7993_() ) ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( -1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried() ) ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), p_9856_.getSlotNum(), this.player.containerMenu.getSlot( p_9856_.getSlotNum() ).getItem() ) ); + break; + // Modified clicked only + case DROP_ALL_SLOT: + case DROP_ONE_SLOT: -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( this.f_9743_.f_36096_.f_38840_, this.f_9743_.f_36095_.m_182425_(), p_9856_.m_133962_(), this.f_9743_.f_36096_.m_38853_( p_9856_.m_133962_() ).m_7993_() ) ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), p_9856_.getSlotNum(), this.player.containerMenu.getSlot( p_9856_.getSlotNum() ).getItem() ) ); + break; + // Modified cursor only + case DROP_ALL_CURSOR: + case DROP_ONE_CURSOR: + case CLONE_STACK: -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( -1, -1, this.f_9743_.f_36095_.m_182425_(), this.f_9743_.f_36096_.m_142621_() ) ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( -1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried() ) ); + break; + // Nothing + case NOTHING: @@ -3070,21 +3070,21 @@ + if (event instanceof org.bukkit.event.inventory.CraftItemEvent || event instanceof org.bukkit.event.inventory.SmithItemEvent) { + // Need to update the inventory on crafting to + // correctly support custom recipes -+ f_9743_.f_36096_.m_150429_(); ++ player.containerMenu.sendAllDataToRemote(); + } + } + // CraftBukkit end + -+ for (Entry entry : Int2ObjectMaps.fastIterable( p_9856_.m_179582_() )) { -+ this.f_9743_.f_36096_.m_182414_( entry.getIntKey(), entry.getValue() ); ++ for (Entry entry : Int2ObjectMaps.fastIterable( p_9856_.getChangedSlots() )) { ++ this.player.containerMenu.setRemoteSlotNoCopy( entry.getIntKey(), entry.getValue() ); + } + -+ this.f_9743_.f_36096_.m_150422_( p_9856_.m_179581_() ); -+ this.f_9743_.f_36096_.m_150444_(); ++ this.player.containerMenu.setRemoteCarried( p_9856_.getCarriedItem() ); ++ this.player.containerMenu.resumeRemoteUpdates(); + if (flag) { -+ this.f_9743_.f_36096_.m_182423_(); ++ this.player.containerMenu.broadcastFullState(); + } else { -+ this.f_9743_.f_36096_.m_38946_(); ++ this.player.containerMenu.broadcastChanges(); + } + + } @@ -3092,60 +3092,60 @@ + } + } + -+ public void m_7191_(ServerboundPlaceRecipePacket p_9882_) { -+ PacketUtils.m_131359_( p_9882_, this, this.f_9743_.m_183503_() ); -+ this.f_9743_.m_9243_(); -+ if (!this.f_9743_.m_5833_() && this.f_9743_.f_36096_.f_38840_ == p_9882_.m_134249_() && this.f_9743_.f_36096_ instanceof RecipeBookMenu) { -+ this.f_9745_.m_129894_().m_44043_( p_9882_.m_134252_() ).ifPresent( (p_184200_) -> { -+ ((RecipeBookMenu) this.f_9743_.f_36096_).m_6951_( p_9882_.m_134253_(), p_184200_, this.f_9743_ ); ++ public void handlePlaceRecipe(ServerboundPlaceRecipePacket p_9882_) { ++ PacketUtils.ensureRunningOnSameThread( p_9882_, this, this.player.getLevel() ); ++ this.player.resetLastActionTime(); ++ if (!this.player.isSpectator() && this.player.containerMenu.containerId == p_9882_.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) { ++ this.server.getRecipeManager().byKey( p_9882_.getRecipe() ).ifPresent( (p_184200_) -> { ++ ((RecipeBookMenu) this.player.containerMenu).handlePlacement( p_9882_.isShiftDown(), p_184200_, this.player ); + } ); + } + } + -+ public void m_6557_(ServerboundContainerButtonClickPacket p_9854_) { -+ PacketUtils.m_131359_( p_9854_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ this.f_9743_.m_9243_(); -+ if (this.f_9743_.f_36096_.f_38840_ == p_9854_.m_133935_() && !this.f_9743_.m_5833_()) { -+ boolean flag = this.f_9743_.f_36096_.m_6366_( this.f_9743_, p_9854_.m_133938_() ); ++ public void handleContainerButtonClick(ServerboundContainerButtonClickPacket p_9854_) { ++ PacketUtils.ensureRunningOnSameThread( p_9854_, this, this.player.getLevel() ); ++ if (this.player.isImmobile()) return; // CraftBukkit ++ this.player.resetLastActionTime(); ++ if (this.player.containerMenu.containerId == p_9854_.getContainerId() && !this.player.isSpectator()) { ++ boolean flag = this.player.containerMenu.clickMenuButton( this.player, p_9854_.getButtonId() ); + if (flag) { -+ this.f_9743_.f_36096_.m_38946_(); ++ this.player.containerMenu.broadcastChanges(); + } + } + + } + -+ public void m_5964_(ServerboundSetCreativeModeSlotPacket p_9915_) { -+ PacketUtils.m_131359_( p_9915_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.f_8941_.m_9295_()) { -+ boolean flag = p_9915_.m_134561_() < 0; -+ ItemStack itemstack = p_9915_.m_134564_(); -+ CompoundTag compoundtag = BlockItem.m_186336_( itemstack ); -+ if (!itemstack.m_41619_() && compoundtag != null && compoundtag.m_128441_( "x" ) && compoundtag.m_128441_( "y" ) && compoundtag.m_128441_( "z" ) && this.f_9743_.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot -+ BlockPos blockpos = BlockEntity.m_187472_( compoundtag ); -+ BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_( blockpos ); ++ public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket p_9915_) { ++ PacketUtils.ensureRunningOnSameThread( p_9915_, this, this.player.getLevel() ); ++ if (this.player.gameMode.isCreative()) { ++ boolean flag = p_9915_.getSlotNum() < 0; ++ ItemStack itemstack = p_9915_.getItem(); ++ CompoundTag compoundtag = BlockItem.getBlockEntityData( itemstack ); ++ if (!itemstack.isEmpty() && compoundtag != null && compoundtag.contains( "x" ) && compoundtag.contains( "y" ) && compoundtag.contains( "z" ) && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot ++ BlockPos blockpos = BlockEntity.getPosFromTag( compoundtag ); ++ BlockEntity blockentity = this.player.level.getBlockEntity( blockpos ); + if (blockentity != null) { -+ blockentity.m_187476_( itemstack ); ++ blockentity.saveToItem( itemstack ); + } + } + -+ boolean flag1 = p_9915_.m_134561_() >= 1 && p_9915_.m_134561_() <= 45; -+ boolean flag2 = itemstack.m_41619_() || itemstack.m_41773_() >= 0 && itemstack.m_41613_() <= 64 && !itemstack.m_41619_(); -+ if (flag || (flag1 && !ItemStack.m_41728_( this.f_9743_.f_36095_.m_38853_( p_9915_.m_134561_() ).m_7993_(), p_9915_.m_134564_() ))) { // Insist on valid slot ++ boolean flag1 = p_9915_.getSlotNum() >= 1 && p_9915_.getSlotNum() <= 45; ++ boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); ++ if (flag || (flag1 && !ItemStack.matches( this.player.inventoryMenu.getSlot( p_9915_.getSlotNum() ).getItem(), p_9915_.getItem() ))) { // Insist on valid slot + // CraftBukkit start - Call click event -+ org.bukkit.inventory.InventoryView inventory = this.f_9743_.f_36095_.getBukkitView(); -+ org.bukkit.inventory.ItemStack item = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy( p_9915_.m_134564_() ); ++ org.bukkit.inventory.InventoryView inventory = this.player.inventoryMenu.getBukkitView(); ++ org.bukkit.inventory.ItemStack item = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy( p_9915_.getItem() ); + org.bukkit.event.inventory.InventoryType.SlotType type = org.bukkit.event.inventory.InventoryType.SlotType.QUICKBAR; + if (flag) { + type = org.bukkit.event.inventory.InventoryType.SlotType.OUTSIDE; -+ } else if (p_9915_.m_134561_() < 36) { -+ if (p_9915_.m_134561_() >= 5 && p_9915_.m_134561_() < 9) { ++ } else if (p_9915_.getSlotNum() < 36) { ++ if (p_9915_.getSlotNum() >= 5 && p_9915_.getSlotNum() < 9) { + type = org.bukkit.event.inventory.InventoryType.SlotType.ARMOR; + } else { + type = org.bukkit.event.inventory.InventoryType.SlotType.CONTAINER; + } + } -+ org.bukkit.event.inventory.InventoryCreativeEvent event = new org.bukkit.event.inventory.InventoryCreativeEvent( inventory, type, flag ? -999 : p_9915_.m_134561_(), item ); ++ org.bukkit.event.inventory.InventoryCreativeEvent event = new org.bukkit.event.inventory.InventoryCreativeEvent( inventory, type, flag ? -999 : p_9915_.getSlotNum(), item ); + cserver.getPluginManager().callEvent( event ); + itemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy( event.getCursor() ); + switch (event.getResult()) { @@ -3157,266 +3157,266 @@ + break; + case DENY: + // Reset the slot -+ if (p_9915_.m_134561_() >= 0) { -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( this.f_9743_.f_36095_.f_38840_, this.f_9743_.f_36095_.m_182425_(), p_9915_.m_134561_(), this.f_9743_.f_36095_.m_38853_( p_9915_.m_134561_() ).m_7993_() ) ); -+ this.f_9743_.f_8906_.m_141995_( new ClientboundContainerSetSlotPacket( -1, this.f_9743_.f_36095_.m_182425_(), -1, ItemStack.f_41583_ ) ); ++ if (p_9915_.getSlotNum() >= 0) { ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), p_9915_.getSlotNum(), this.player.inventoryMenu.getSlot( p_9915_.getSlotNum() ).getItem() ) ); ++ this.player.connection.send( new ClientboundContainerSetSlotPacket( -1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY ) ); + } + return; + } + } + // CraftBukkit end + if (flag1 && flag2) { -+ this.f_9743_.f_36095_.m_38853_( p_9915_.m_134561_() ).m_5852_( itemstack ); -+ this.f_9743_.f_36095_.m_38946_(); -+ } else if (flag && flag2 && this.f_9751_ < 200) { -+ this.f_9751_ += 20; -+ this.f_9743_.m_36176_( itemstack, true ); ++ this.player.inventoryMenu.getSlot( p_9915_.getSlotNum() ).set( itemstack ); ++ this.player.inventoryMenu.broadcastChanges(); ++ } else if (flag && flag2 && this.dropSpamTickCount < 200) { ++ this.dropSpamTickCount += 20; ++ this.player.drop( itemstack, true ); + } + } + + } + -+ public void m_5527_(ServerboundSignUpdatePacket p_9921_) { -+ List list = Stream.of( p_9921_.m_134663_() ).map( ChatFormatting::m_126649_ ).collect( Collectors.toList() ); -+ this.m_9815_( list, (p_184205_) -> { -+ this.m_9922_( p_9921_, p_184205_ ); ++ public void handleSignUpdate(ServerboundSignUpdatePacket p_9921_) { ++ List list = Stream.of( p_9921_.getLines() ).map( ChatFormatting::stripFormatting ).collect( Collectors.toList() ); ++ this.filterTextPacket( list, (p_184205_) -> { ++ this.updateSignText( p_9921_, p_184205_ ); + } ); + } + -+ private void m_9922_(ServerboundSignUpdatePacket p_9923_, List p_9924_) { -+ if (this.f_9743_.m_6107_()) return; // CraftBukkit -+ this.f_9743_.m_9243_(); -+ ServerLevel serverlevel = this.f_9743_.m_183503_(); -+ BlockPos blockpos = p_9923_.m_134660_(); -+ if (serverlevel.m_46805_( blockpos )) { -+ BlockState blockstate = serverlevel.m_8055_( blockpos ); -+ BlockEntity blockentity = serverlevel.m_7702_( blockpos ); ++ private void updateSignText(ServerboundSignUpdatePacket p_9923_, List p_9924_) { ++ if (this.player.isImmobile()) return; // CraftBukkit ++ this.player.resetLastActionTime(); ++ ServerLevel serverlevel = this.player.getLevel(); ++ BlockPos blockpos = p_9923_.getPos(); ++ if (serverlevel.hasChunkAt( blockpos )) { ++ BlockState blockstate = serverlevel.getBlockState( blockpos ); ++ BlockEntity blockentity = serverlevel.getBlockEntity( blockpos ); + if (!(blockentity instanceof SignBlockEntity)) { + return; + } + + SignBlockEntity signblockentity = (SignBlockEntity) blockentity; -+ if (!signblockentity.m_59751_() || !this.f_9743_.m_142081_().equals( signblockentity.m_155726_() )) { -+ f_9744_.warn( "Player {} just tried to change non-editable sign", (Object) this.f_9743_.m_7755_().getString() ); -+ this.m_141995_(blockentity.m_183216_()); // CraftBukkit ++ if (!signblockentity.isEditable() || !this.player.getUUID().equals( signblockentity.getPlayerWhoMayEdit() )) { ++ LOGGER.warn( "Player {} just tried to change non-editable sign", (Object) this.player.getName().getString() ); ++ this.send(blockentity.getUpdatePacket()); // CraftBukkit + return; + } + + // CraftBukkit start -+ org.bukkit.entity.Player player = this.f_9743_.getBukkitEntity(); -+ int x = p_9923_.m_134660_().m_123341_(); -+ int y = p_9923_.m_134660_().m_123342_(); -+ int z = p_9923_.m_134660_().m_123343_(); ++ org.bukkit.entity.Player player = this.player.getBukkitEntity(); ++ int x = p_9923_.getPos().getX(); ++ int y = p_9923_.getPos().getY(); ++ int z = p_9923_.getPos().getZ(); + String[] lines = new String[4]; + + for (int i = 0; i < p_9924_.size(); ++i) { + TextFilter.FilteredText textfilter$filteredtext = p_9924_.get( i ); -+ if (this.f_9743_.m_143387_()) { -+ lines[i] = ChatFormatting.m_126649_(new TextComponent(ChatFormatting.m_126649_(textfilter$filteredtext.m_143722_())).getString()); ++ if (this.player.isTextFilteringEnabled()) { ++ lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(textfilter$filteredtext.getFiltered())).getString()); + } else { -+ lines[i] = ChatFormatting.m_126649_(new TextComponent(ChatFormatting.m_126649_(textfilter$filteredtext.m_143719_())).getString()); ++ lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(textfilter$filteredtext.getRaw())).getString()); + } + } + -+ org.bukkit.event.block.SignChangeEvent event = new org.bukkit.event.block.SignChangeEvent((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.f_9743_.getBukkitEntity(), lines); ++ org.bukkit.event.block.SignChangeEvent event = new org.bukkit.event.block.SignChangeEvent((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); + this.cserver.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + Component[] components = org.bukkit.craftbukkit.v1_18_R2.block.CraftSign.sanitizeLines(event.getLines()); + for (int i = 0; i < components.length; i++) { -+ signblockentity.m_59732_(i, components[i]); ++ signblockentity.setMessage(i, components[i]); + } -+ signblockentity.f_59721_ = false; ++ signblockentity.isEditable = false; + } + // CraftBukkit end + -+ signblockentity.m_6596_(); -+ serverlevel.m_7260_( blockpos, blockstate, blockstate, 3 ); ++ signblockentity.setChanged(); ++ serverlevel.sendBlockUpdated( blockpos, blockstate, blockstate, 3 ); + } + + } + -+ public void m_5683_(ServerboundKeepAlivePacket p_9870_) { -+ PacketUtils.m_131359_(p_9870_, this, this.f_9743_.m_183503_()); // CraftBukkit -+ if (this.f_9748_ && p_9870_.m_134102_() == this.f_9749_) { -+ int i = (int) (Util.m_137550_() - this.f_9747_); -+ this.f_9743_.f_8943_ = (this.f_9743_.f_8943_ * 3 + i) / 4; -+ this.f_9748_ = false; -+ } else if (!this.m_9956_()) { -+ this.m_9942_( new TranslatableComponent( "disconnect.timeout" ) ); ++ public void handleKeepAlive(ServerboundKeepAlivePacket p_9870_) { ++ PacketUtils.ensureRunningOnSameThread(p_9870_, this, this.player.getLevel()); // CraftBukkit ++ if (this.keepAlivePending && p_9870_.getId() == this.keepAliveChallenge) { ++ int i = (int) (Util.getMillis() - this.keepAliveTime); ++ this.player.latency = (this.player.latency * 3 + i) / 4; ++ this.keepAlivePending = false; ++ } else if (!this.isSingleplayerOwner()) { ++ this.disconnect( new TranslatableComponent( "disconnect.timeout" ) ); + } + + } + -+ public void m_6828_(ServerboundPlayerAbilitiesPacket p_9887_) { -+ PacketUtils.m_131359_( p_9887_, this, this.f_9743_.m_183503_() ); ++ public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket p_9887_) { ++ PacketUtils.ensureRunningOnSameThread( p_9887_, this, this.player.getLevel() ); + // CraftBukkit start -+ if (this.f_9743_.m_150110_().f_35936_ && this.f_9743_.m_150110_().f_35935_ != p_9887_.m_134264_()) { -+ org.bukkit.event.player.PlayerToggleFlightEvent event = new org.bukkit.event.player.PlayerToggleFlightEvent(this.f_9743_.getBukkitEntity(), p_9887_.m_134264_()); ++ if (this.player.getAbilities().mayfly && this.player.getAbilities().flying != p_9887_.isFlying()) { ++ org.bukkit.event.player.PlayerToggleFlightEvent event = new org.bukkit.event.player.PlayerToggleFlightEvent(this.player.getBukkitEntity(), p_9887_.isFlying()); + this.cserver.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.f_9743_.m_150110_().f_35935_ = p_9887_.m_134264_(); // Actually set the player's flying status ++ this.player.getAbilities().flying = p_9887_.isFlying(); // Actually set the player's flying status + } else { -+ this.f_9743_.m_6885_(); // Tell the player their ability was reverted ++ this.player.onUpdateAbilities(); // Tell the player their ability was reverted + } + } + // CraftBukkit end + } + -+ public void m_5617_(ServerboundClientInformationPacket p_9845_) { -+ PacketUtils.m_131359_( p_9845_, this, this.f_9743_.m_183503_() ); -+ this.f_9743_.m_9156_( p_9845_ ); ++ public void handleClientInformation(ServerboundClientInformationPacket p_9845_) { ++ PacketUtils.ensureRunningOnSameThread( p_9845_, this, this.player.getLevel() ); ++ this.player.updateOptions( p_9845_ ); + } + + // CraftBukkit start + private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register"); + private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister"); -+ public void m_7423_(ServerboundCustomPayloadPacket p_9860_) { -+ PacketUtils.m_131359_( p_9860_, this, this.f_9743_.m_183503_() ); -+ io.netty.buffer.ByteBuf copy = p_9860_.m_179590_().copy(); ++ public void handleCustomPayload(ServerboundCustomPayloadPacket p_9860_) { ++ PacketUtils.ensureRunningOnSameThread( p_9860_, this, this.player.getLevel() ); ++ io.netty.buffer.ByteBuf copy = p_9860_.getData().copy(); + var buf = new byte[copy.readableBytes()]; + copy.readBytes(buf); -+ net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer().m_201446_(() -> { ++ net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer().executeIfPossible(() -> { + if (net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer().hasStopped() || processedDisconnect) + return; + -+ if (this.f_9742_.m_129536_()) { -+ if (p_9860_.f_133980_.equals(CUSTOM_REGISTER)) { ++ if (this.connection.isConnected()) { ++ if (p_9860_.identifier.equals(CUSTOM_REGISTER)) { + try { + String channels = new String(buf, java.nio.charset.StandardCharsets.UTF_8); + for (String channel : channels.split("\0")) { -+ if (!StringUtil.m_14408_(channel)) ++ if (!StringUtil.isNullOrEmpty(channel)) + this.getCraftPlayer().addChannel(channel); + } + } catch (Exception ex) { -+ f_9744_.error("Couldn't register custom payload", ex); ++ LOGGER.error("Couldn't register custom payload", ex); + this.disconnect("Invalid payload REGISTER!"); + } -+ } else if (p_9860_.f_133980_.equals(CUSTOM_UNREGISTER)) { ++ } else if (p_9860_.identifier.equals(CUSTOM_UNREGISTER)) { + try { + final String channels = new String(buf, java.nio.charset.StandardCharsets.UTF_8); + for (String channel : channels.split("\0")) { -+ if (!StringUtil.m_14408_(channel)) ++ if (!StringUtil.isNullOrEmpty(channel)) + this.getCraftPlayer().removeChannel(channel); + } + } catch (Exception ex) { -+ f_9744_.error("Couldn't unregister custom payload", ex); ++ LOGGER.error("Couldn't unregister custom payload", ex); + this.disconnect("Invalid payload UNREGISTER!"); + } + } else { + try { -+ this.cserver.getMessenger().dispatchIncomingMessage(this.f_9743_.getBukkitEntity(), p_9860_.f_133980_.toString(), buf); ++ this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), p_9860_.identifier.toString(), buf); + } catch (Exception ex) { -+ f_9744_.error("Couldn't dispatch custom payload", ex); ++ LOGGER.error("Couldn't dispatch custom payload", ex); + this.disconnect("Invalid custom payload!"); + } + } + } + }); -+ net.minecraftforge.network.NetworkHooks.onCustomPayload( p_9860_, this.f_9742_ ); ++ net.minecraftforge.network.NetworkHooks.onCustomPayload( p_9860_, this.connection ); + } + + public final boolean isDisconnected() { -+ return !this.f_9743_.joining && !this.f_9742_.m_129536_(); ++ return !this.player.joining && !this.connection.isConnected(); + } + // CraftBukkit end + -+ public void m_7477_(ServerboundChangeDifficultyPacket p_9839_) { -+ PacketUtils.m_131359_( p_9839_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_20310_( 2 ) || this.m_9956_()) { -+ this.f_9745_.m_129827_( p_9839_.m_133824_(), false ); ++ public void handleChangeDifficulty(ServerboundChangeDifficultyPacket p_9839_) { ++ PacketUtils.ensureRunningOnSameThread( p_9839_, this, this.player.getLevel() ); ++ if (this.player.hasPermissions( 2 ) || this.isSingleplayerOwner()) { ++ this.server.setDifficulty( p_9839_.getDifficulty(), false ); + } + } + -+ public void m_7728_(ServerboundLockDifficultyPacket p_9872_) { -+ PacketUtils.m_131359_( p_9872_, this, this.f_9743_.m_183503_() ); -+ if (this.f_9743_.m_20310_( 2 ) || this.m_9956_()) { -+ this.f_9745_.m_129958_( p_9872_.m_134115_() ); ++ public void handleLockDifficulty(ServerboundLockDifficultyPacket p_9872_) { ++ PacketUtils.ensureRunningOnSameThread( p_9872_, this, this.player.getLevel() ); ++ if (this.player.hasPermissions( 2 ) || this.isSingleplayerOwner()) { ++ this.server.setDifficultyLocked( p_9872_.isLocked() ); + } + } + -+ public ServerPlayer m_142253_() { -+ return this.f_9743_; ++ public ServerPlayer getPlayer() { ++ return this.player; + } + + // CraftBukkit start - add method //Magma - implement ArcLight version + public void chat(String s, boolean async) { -+ if (s.isEmpty() || this.f_9743_.m_9241_() == ChatVisiblity.HIDDEN) { ++ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { + return; + } + if (!async && s.startsWith("/")) { - this.m_9957_(s); + this.handleCommand(s); - } else { -- String s1 = p_143629_.m_143722_(); -- Component component = s1.isEmpty() ? null : new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s1); -- Component component1 = new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s); -- this.f_9745_.m_6846_().m_143991_(component1, (p_184197_) -> { -- return this.f_9743_.m_143421_(p_184197_) ? component : component1; -- }, ChatType.CHAT, this.f_9743_.m_142081_()); +- String s1 = p_143629_.getFiltered(); +- Component component = s1.isEmpty() ? null : new TranslatableComponent("chat.type.text", this.player.getDisplayName(), s1); +- Component component1 = new TranslatableComponent("chat.type.text", this.player.getDisplayName(), s); +- this.server.getPlayerList().broadcastMessage(component1, (p_184197_) -> { +- return this.player.shouldFilterMessageTo(p_184197_) ? component : component1; +- }, ChatType.CHAT, this.player.getUUID()); - } - -- this.f_9750_ += 20; -- if (this.f_9750_ > 200 && !this.f_9745_.m_6846_().m_11303_(this.f_9743_.m_36316_())) { -- this.m_9942_(new TranslatableComponent("disconnect.spam")); +- this.chatSpamTickCount += 20; +- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { +- this.disconnect(new TranslatableComponent("disconnect.spam")); - } - - } - } - -- private void m_9957_(String p_9958_) { -- this.f_9745_.m_129892_().m_82117_(this.f_9743_.m_20203_(), p_9958_); +- private void handleCommand(String p_9958_) { +- this.server.getCommands().performCommand(this.player.createCommandSourceStack(), p_9958_); - } - -- public void m_7953_(ServerboundSwingPacket p_9926_) { -- PacketUtils.m_131359_(p_9926_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9243_(); -- this.f_9743_.m_6674_(p_9926_.m_134674_()); +- public void handleAnimate(ServerboundSwingPacket p_9926_) { +- PacketUtils.ensureRunningOnSameThread(p_9926_, this, this.player.getLevel()); +- this.player.resetLastActionTime(); +- this.player.swing(p_9926_.getHand()); - } - -- public void m_5681_(ServerboundPlayerCommandPacket p_9891_) { -- PacketUtils.m_131359_(p_9891_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9243_(); -- switch(p_9891_.m_134320_()) { +- public void handlePlayerCommand(ServerboundPlayerCommandPacket p_9891_) { +- PacketUtils.ensureRunningOnSameThread(p_9891_, this, this.player.getLevel()); +- this.player.resetLastActionTime(); +- switch(p_9891_.getAction()) { - case PRESS_SHIFT_KEY: -- this.f_9743_.m_20260_(true); +- this.player.setShiftKeyDown(true); - break; - case RELEASE_SHIFT_KEY: -- this.f_9743_.m_20260_(false); +- this.player.setShiftKeyDown(false); - break; - case START_SPRINTING: -- this.f_9743_.m_6858_(true); +- this.player.setSprinting(true); - break; - case STOP_SPRINTING: -- this.f_9743_.m_6858_(false); +- this.player.setSprinting(false); - break; - case STOP_SLEEPING: -- if (this.f_9743_.m_5803_()) { -- this.f_9743_.m_6145_(false, true); -- this.f_9766_ = this.f_9743_.m_20182_(); +- if (this.player.isSleeping()) { +- this.player.stopSleepInBed(false, true); +- this.awaitingPositionFromClient = this.player.position(); - } - break; - case START_RIDING_JUMP: -- if (this.f_9743_.m_20202_() instanceof PlayerRideableJumping) { -- PlayerRideableJumping playerrideablejumping1 = (PlayerRideableJumping)this.f_9743_.m_20202_(); -- int i = p_9891_.m_134321_(); -- if (playerrideablejumping1.m_7132_() && i > 0) { -- playerrideablejumping1.m_7199_(i); +- if (this.player.getVehicle() instanceof PlayerRideableJumping) { +- PlayerRideableJumping playerrideablejumping1 = (PlayerRideableJumping)this.player.getVehicle(); +- int i = p_9891_.getData(); +- if (playerrideablejumping1.canJump() && i > 0) { +- playerrideablejumping1.handleStartJump(i); - } - } - break; - case STOP_RIDING_JUMP: -- if (this.f_9743_.m_20202_() instanceof PlayerRideableJumping) { -- PlayerRideableJumping playerrideablejumping = (PlayerRideableJumping)this.f_9743_.m_20202_(); -- playerrideablejumping.m_8012_(); +- if (this.player.getVehicle() instanceof PlayerRideableJumping) { +- PlayerRideableJumping playerrideablejumping = (PlayerRideableJumping)this.player.getVehicle(); +- playerrideablejumping.handleStopJump(); - } - break; - case OPEN_INVENTORY: -- if (this.f_9743_.m_20202_() instanceof AbstractHorse) { -- ((AbstractHorse)this.f_9743_.m_20202_()).m_30620_(this.f_9743_); +- if (this.player.getVehicle() instanceof AbstractHorse) { +- ((AbstractHorse)this.player.getVehicle()).openInventory(this.player); - } - break; - case START_FALL_FLYING: -- if (!this.f_9743_.m_36319_()) { -- this.f_9743_.m_36321_(); +- if (!this.player.tryToStartFallFlying()) { +- this.player.stopFallFlying(); - } - break; - default: @@ -3425,48 +3425,48 @@ - - } - -- public void m_6946_(ServerboundInteractPacket p_9866_) { -- PacketUtils.m_131359_(p_9866_, this, this.f_9743_.m_183503_()); -- ServerLevel serverlevel = this.f_9743_.m_183503_(); -- final Entity entity = p_9866_.m_179603_(serverlevel); -- this.f_9743_.m_9243_(); -- this.f_9743_.m_20260_(p_9866_.m_134061_()); +- public void handleInteract(ServerboundInteractPacket p_9866_) { +- PacketUtils.ensureRunningOnSameThread(p_9866_, this, this.player.getLevel()); +- ServerLevel serverlevel = this.player.getLevel(); +- final Entity entity = p_9866_.getTarget(serverlevel); +- this.player.resetLastActionTime(); +- this.player.setShiftKeyDown(p_9866_.isUsingSecondaryAction()); - if (entity != null) { -- if (!serverlevel.m_6857_().m_61937_(entity.m_142538_())) { +- if (!serverlevel.getWorldBorder().isWithinBounds(entity.blockPosition())) { - return; - } - - double d0 = 36.0D; -- if (this.f_9743_.m_20280_(entity) < 36.0D) { -- p_9866_.m_179617_(new ServerboundInteractPacket.Handler() { -- private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) { -- ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_).m_41777_(); -- InteractionResult interactionresult = p_143680_.m_143694_(ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_); -- if (interactionresult.m_19077_()) { -- CriteriaTriggers.f_10565_.m_61494_(ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity); -- if (interactionresult.m_19080_()) { -- ServerGamePacketListenerImpl.this.f_9743_.m_21011_(p_143679_, true); +- if (this.player.distanceToSqr(entity) < 36.0D) { +- p_9866_.dispatch(new ServerboundInteractPacket.Handler() { +- private void performInteraction(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) { +- ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(p_143679_).copy(); +- InteractionResult interactionresult = p_143680_.run(ServerGamePacketListenerImpl.this.player, entity, p_143679_); +- if (interactionresult.consumesAction()) { +- CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemstack, entity); +- if (interactionresult.shouldSwing()) { +- ServerGamePacketListenerImpl.this.player.swing(p_143679_, true); - } - } - - } - -- public void m_142299_(InteractionHand p_143677_) { -- this.m_143678_(p_143677_, Player::m_36157_); +- public void onInteraction(InteractionHand p_143677_) { +- this.performInteraction(p_143677_, Player::interactOn); - } - -- public void m_142143_(InteractionHand p_143682_, Vec3 p_143683_) { -- this.m_143678_(p_143682_, (p_143686_, p_143687_, p_143688_) -> { -- return p_143687_.m_7111_(p_143686_, p_143683_, p_143688_); +- public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { +- this.performInteraction(p_143682_, (p_143686_, p_143687_, p_143688_) -> { +- return p_143687_.interactAt(p_143686_, p_143683_, p_143688_); - }); - } - -- public void m_141994_() { -- if (!(entity instanceof ItemEntity) && !(entity instanceof ExperienceOrb) && !(entity instanceof AbstractArrow) && entity != ServerGamePacketListenerImpl.this.f_9743_) { -- ServerGamePacketListenerImpl.this.f_9743_.m_5706_(entity); +- public void onAttack() { +- if (!(entity instanceof ItemEntity) && !(entity instanceof ExperienceOrb) && !(entity instanceof AbstractArrow) && entity != ServerGamePacketListenerImpl.this.player) { +- ServerGamePacketListenerImpl.this.player.attack(entity); - } else { -- ServerGamePacketListenerImpl.this.m_9942_(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked")); -- ServerGamePacketListenerImpl.f_9744_.warn("Player {} tried to attack an invalid entity", (Object)ServerGamePacketListenerImpl.this.f_9743_.m_7755_().getString()); +- ServerGamePacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked")); +- ServerGamePacketListenerImpl.LOGGER.warn("Player {} tried to attack an invalid entity", (Object)ServerGamePacketListenerImpl.this.player.getName().getString()); - } - } - }); @@ -3475,64 +3475,64 @@ - - } - -- public void m_6272_(ServerboundClientCommandPacket p_9843_) { -- PacketUtils.m_131359_(p_9843_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9243_(); -- ServerboundClientCommandPacket.Action serverboundclientcommandpacket$action = p_9843_.m_133850_(); +- public void handleClientCommand(ServerboundClientCommandPacket p_9843_) { +- PacketUtils.ensureRunningOnSameThread(p_9843_, this, this.player.getLevel()); +- this.player.resetLastActionTime(); +- ServerboundClientCommandPacket.Action serverboundclientcommandpacket$action = p_9843_.getAction(); - switch(serverboundclientcommandpacket$action) { - case PERFORM_RESPAWN: -- if (this.f_9743_.f_8944_) { -- this.f_9743_.f_8944_ = false; -- this.f_9743_ = this.f_9745_.m_6846_().m_11236_(this.f_9743_, true); -- CriteriaTriggers.f_10588_.m_19757_(this.f_9743_, Level.f_46430_, Level.f_46428_); +- if (this.player.wonGame) { +- this.player.wonGame = false; +- this.player = this.server.getPlayerList().respawn(this.player, true); +- CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); - } else { -- if (this.f_9743_.m_21223_() > 0.0F) { +- if (this.player.getHealth() > 0.0F) { - return; - } - -- this.f_9743_ = this.f_9745_.m_6846_().m_11236_(this.f_9743_, false); -- if (this.f_9745_.m_7035_()) { -- this.f_9743_.m_143403_(GameType.SPECTATOR); -- this.f_9743_.m_183503_().m_46469_().m_46170_(GameRules.f_46146_).m_46246_(false, this.f_9745_); +- this.player = this.server.getPlayerList().respawn(this.player, false); +- if (this.server.isHardcore()) { +- this.player.setGameMode(GameType.SPECTATOR); +- this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS).set(false, this.server); - } - } - break; - case REQUEST_STATS: -- this.f_9743_.m_8951_().m_12819_(this.f_9743_); +- this.player.getStats().sendStats(this.player); - } - - } - -- public void m_7951_(ServerboundContainerClosePacket p_9858_) { -- PacketUtils.m_131359_(p_9858_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9230_(); +- public void handleContainerClose(ServerboundContainerClosePacket p_9858_) { +- PacketUtils.ensureRunningOnSameThread(p_9858_, this, this.player.getLevel()); +- this.player.doCloseContainer(); - } - -- public void m_5914_(ServerboundContainerClickPacket p_9856_) { -- PacketUtils.m_131359_(p_9856_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9243_(); -- if (this.f_9743_.f_36096_.f_38840_ == p_9856_.m_133959_()) { -- if (this.f_9743_.m_5833_()) { -- this.f_9743_.f_36096_.m_150429_(); +- public void handleContainerClick(ServerboundContainerClickPacket p_9856_) { +- PacketUtils.ensureRunningOnSameThread(p_9856_, this, this.player.getLevel()); +- this.player.resetLastActionTime(); +- if (this.player.containerMenu.containerId == p_9856_.getContainerId()) { +- if (this.player.isSpectator()) { +- this.player.containerMenu.sendAllDataToRemote(); - } else { -- int i = p_9856_.m_133962_(); -- if (!this.f_9743_.f_36096_.m_207775_(i)) { -- f_9744_.debug("Player {} clicked invalid slot index: {}, available slots: {}", this.f_9743_.m_7755_(), i, this.f_9743_.f_36096_.f_38839_.size()); +- int i = p_9856_.getSlotNum(); +- if (!this.player.containerMenu.isValidSlotIndex(i)) { +- LOGGER.debug("Player {} clicked invalid slot index: {}, available slots: {}", this.player.getName(), i, this.player.containerMenu.slots.size()); - } else { -- boolean flag = p_9856_.m_182741_() != this.f_9743_.f_36096_.m_182424_(); -- this.f_9743_.f_36096_.m_150443_(); -- this.f_9743_.f_36096_.m_150399_(i, p_9856_.m_133963_(), p_9856_.m_133966_(), this.f_9743_); +- boolean flag = p_9856_.getStateId() != this.player.containerMenu.getStateId(); +- this.player.containerMenu.suppressRemoteUpdates(); +- this.player.containerMenu.clicked(i, p_9856_.getButtonNum(), p_9856_.getClickType(), this.player); - -- for(Entry entry : Int2ObjectMaps.fastIterable(p_9856_.m_179582_())) { -- this.f_9743_.f_36096_.m_182414_(entry.getIntKey(), entry.getValue()); +- for(Entry entry : Int2ObjectMaps.fastIterable(p_9856_.getChangedSlots())) { +- this.player.containerMenu.setRemoteSlotNoCopy(entry.getIntKey(), entry.getValue()); - } - -- this.f_9743_.f_36096_.m_150422_(p_9856_.m_179581_()); -- this.f_9743_.f_36096_.m_150444_(); +- this.player.containerMenu.setRemoteCarried(p_9856_.getCarriedItem()); +- this.player.containerMenu.resumeRemoteUpdates(); - if (flag) { -- this.f_9743_.f_36096_.m_182423_(); +- this.player.containerMenu.broadcastFullState(); - } else { -- this.f_9743_.f_36096_.m_38946_(); +- this.player.containerMenu.broadcastChanges(); - } - - } @@ -3540,143 +3540,143 @@ - } - } - -- public void m_7191_(ServerboundPlaceRecipePacket p_9882_) { -- PacketUtils.m_131359_(p_9882_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9243_(); -- if (!this.f_9743_.m_5833_() && this.f_9743_.f_36096_.f_38840_ == p_9882_.m_134249_() && this.f_9743_.f_36096_ instanceof RecipeBookMenu) { -- this.f_9745_.m_129894_().m_44043_(p_9882_.m_134252_()).ifPresent((p_184200_) -> { -- ((RecipeBookMenu)this.f_9743_.f_36096_).m_6951_(p_9882_.m_134253_(), p_184200_, this.f_9743_); +- public void handlePlaceRecipe(ServerboundPlaceRecipePacket p_9882_) { +- PacketUtils.ensureRunningOnSameThread(p_9882_, this, this.player.getLevel()); +- this.player.resetLastActionTime(); +- if (!this.player.isSpectator() && this.player.containerMenu.containerId == p_9882_.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) { +- this.server.getRecipeManager().byKey(p_9882_.getRecipe()).ifPresent((p_184200_) -> { +- ((RecipeBookMenu)this.player.containerMenu).handlePlacement(p_9882_.isShiftDown(), p_184200_, this.player); - }); - } - } - -- public void m_6557_(ServerboundContainerButtonClickPacket p_9854_) { -- PacketUtils.m_131359_(p_9854_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9243_(); -- if (this.f_9743_.f_36096_.f_38840_ == p_9854_.m_133935_() && !this.f_9743_.m_5833_()) { -- boolean flag = this.f_9743_.f_36096_.m_6366_(this.f_9743_, p_9854_.m_133938_()); +- public void handleContainerButtonClick(ServerboundContainerButtonClickPacket p_9854_) { +- PacketUtils.ensureRunningOnSameThread(p_9854_, this, this.player.getLevel()); +- this.player.resetLastActionTime(); +- if (this.player.containerMenu.containerId == p_9854_.getContainerId() && !this.player.isSpectator()) { +- boolean flag = this.player.containerMenu.clickMenuButton(this.player, p_9854_.getButtonId()); - if (flag) { -- this.f_9743_.f_36096_.m_38946_(); +- this.player.containerMenu.broadcastChanges(); - } - } - - } - -- public void m_5964_(ServerboundSetCreativeModeSlotPacket p_9915_) { -- PacketUtils.m_131359_(p_9915_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.f_8941_.m_9295_()) { -- boolean flag = p_9915_.m_134561_() < 0; -- ItemStack itemstack = p_9915_.m_134564_(); -- CompoundTag compoundtag = BlockItem.m_186336_(itemstack); -- if (!itemstack.m_41619_() && compoundtag != null && compoundtag.m_128441_("x") && compoundtag.m_128441_("y") && compoundtag.m_128441_("z")) { -- BlockPos blockpos = BlockEntity.m_187472_(compoundtag); -- BlockEntity blockentity = this.f_9743_.f_19853_.m_7702_(blockpos); +- public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket p_9915_) { +- PacketUtils.ensureRunningOnSameThread(p_9915_, this, this.player.getLevel()); +- if (this.player.gameMode.isCreative()) { +- boolean flag = p_9915_.getSlotNum() < 0; +- ItemStack itemstack = p_9915_.getItem(); +- CompoundTag compoundtag = BlockItem.getBlockEntityData(itemstack); +- if (!itemstack.isEmpty() && compoundtag != null && compoundtag.contains("x") && compoundtag.contains("y") && compoundtag.contains("z")) { +- BlockPos blockpos = BlockEntity.getPosFromTag(compoundtag); +- BlockEntity blockentity = this.player.level.getBlockEntity(blockpos); - if (blockentity != null) { -- blockentity.m_187476_(itemstack); +- blockentity.saveToItem(itemstack); - } - } - -- boolean flag1 = p_9915_.m_134561_() >= 1 && p_9915_.m_134561_() <= 45; -- boolean flag2 = itemstack.m_41619_() || itemstack.m_41773_() >= 0 && itemstack.m_41613_() <= 64 && !itemstack.m_41619_(); +- boolean flag1 = p_9915_.getSlotNum() >= 1 && p_9915_.getSlotNum() <= 45; +- boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); - if (flag1 && flag2) { -- this.f_9743_.f_36095_.m_38853_(p_9915_.m_134561_()).m_5852_(itemstack); -- this.f_9743_.f_36095_.m_38946_(); -- } else if (flag && flag2 && this.f_9751_ < 200) { -- this.f_9751_ += 20; -- this.f_9743_.m_36176_(itemstack, true); +- this.player.inventoryMenu.getSlot(p_9915_.getSlotNum()).set(itemstack); +- this.player.inventoryMenu.broadcastChanges(); +- } else if (flag && flag2 && this.dropSpamTickCount < 200) { +- this.dropSpamTickCount += 20; +- this.player.drop(itemstack, true); - } - } - - } - -- public void m_5527_(ServerboundSignUpdatePacket p_9921_) { -- List list = Stream.of(p_9921_.m_134663_()).map(ChatFormatting::m_126649_).collect(Collectors.toList()); -- this.m_9815_(list, (p_184205_) -> { -- this.m_9922_(p_9921_, p_184205_); +- public void handleSignUpdate(ServerboundSignUpdatePacket p_9921_) { +- List list = Stream.of(p_9921_.getLines()).map(ChatFormatting::stripFormatting).collect(Collectors.toList()); +- this.filterTextPacket(list, (p_184205_) -> { +- this.updateSignText(p_9921_, p_184205_); - }); - } - -- private void m_9922_(ServerboundSignUpdatePacket p_9923_, List p_9924_) { -- this.f_9743_.m_9243_(); -- ServerLevel serverlevel = this.f_9743_.m_183503_(); -- BlockPos blockpos = p_9923_.m_134660_(); -- if (serverlevel.m_46805_(blockpos)) { -- BlockState blockstate = serverlevel.m_8055_(blockpos); -- BlockEntity blockentity = serverlevel.m_7702_(blockpos); +- private void updateSignText(ServerboundSignUpdatePacket p_9923_, List p_9924_) { +- this.player.resetLastActionTime(); +- ServerLevel serverlevel = this.player.getLevel(); +- BlockPos blockpos = p_9923_.getPos(); +- if (serverlevel.hasChunkAt(blockpos)) { +- BlockState blockstate = serverlevel.getBlockState(blockpos); +- BlockEntity blockentity = serverlevel.getBlockEntity(blockpos); - if (!(blockentity instanceof SignBlockEntity)) { - return; - } - - SignBlockEntity signblockentity = (SignBlockEntity)blockentity; -- if (!signblockentity.m_59751_() || !this.f_9743_.m_142081_().equals(signblockentity.m_155726_())) { -- f_9744_.warn("Player {} just tried to change non-editable sign", (Object)this.f_9743_.m_7755_().getString()); +- if (!signblockentity.isEditable() || !this.player.getUUID().equals(signblockentity.getPlayerWhoMayEdit())) { +- LOGGER.warn("Player {} just tried to change non-editable sign", (Object)this.player.getName().getString()); - return; - } - - for(int i = 0; i < p_9924_.size(); ++i) { - TextFilter.FilteredText textfilter$filteredtext = p_9924_.get(i); -- if (this.f_9743_.m_143387_()) { -- signblockentity.m_59732_(i, new TextComponent(textfilter$filteredtext.m_143722_())); +- if (this.player.isTextFilteringEnabled()) { +- signblockentity.setMessage(i, new TextComponent(textfilter$filteredtext.getFiltered())); - } else { -- signblockentity.m_155702_(i, new TextComponent(textfilter$filteredtext.m_143719_()), new TextComponent(textfilter$filteredtext.m_143722_())); +- signblockentity.setMessage(i, new TextComponent(textfilter$filteredtext.getRaw()), new TextComponent(textfilter$filteredtext.getFiltered())); - } - } - -- signblockentity.m_6596_(); -- serverlevel.m_7260_(blockpos, blockstate, blockstate, 3); +- signblockentity.setChanged(); +- serverlevel.sendBlockUpdated(blockpos, blockstate, blockstate, 3); - } - - } - -- public void m_5683_(ServerboundKeepAlivePacket p_9870_) { -- if (this.f_9748_ && p_9870_.m_134102_() == this.f_9749_) { -- int i = (int)(Util.m_137550_() - this.f_9747_); -- this.f_9743_.f_8943_ = (this.f_9743_.f_8943_ * 3 + i) / 4; -- this.f_9748_ = false; -- } else if (!this.m_9956_()) { -- this.m_9942_(new TranslatableComponent("disconnect.timeout")); +- public void handleKeepAlive(ServerboundKeepAlivePacket p_9870_) { +- if (this.keepAlivePending && p_9870_.getId() == this.keepAliveChallenge) { +- int i = (int)(Util.getMillis() - this.keepAliveTime); +- this.player.latency = (this.player.latency * 3 + i) / 4; +- this.keepAlivePending = false; +- } else if (!this.isSingleplayerOwner()) { +- this.disconnect(new TranslatableComponent("disconnect.timeout")); - } - - } - -- public void m_6828_(ServerboundPlayerAbilitiesPacket p_9887_) { -- PacketUtils.m_131359_(p_9887_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_150110_().f_35935_ = p_9887_.m_134264_() && this.f_9743_.m_150110_().f_35936_; +- public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket p_9887_) { +- PacketUtils.ensureRunningOnSameThread(p_9887_, this, this.player.getLevel()); +- this.player.getAbilities().flying = p_9887_.isFlying() && this.player.getAbilities().mayfly; - } - -- public void m_5617_(ServerboundClientInformationPacket p_9845_) { -- PacketUtils.m_131359_(p_9845_, this, this.f_9743_.m_183503_()); -- this.f_9743_.m_9156_(p_9845_); +- public void handleClientInformation(ServerboundClientInformationPacket p_9845_) { +- PacketUtils.ensureRunningOnSameThread(p_9845_, this, this.player.getLevel()); +- this.player.updateOptions(p_9845_); - } - -- public void m_7423_(ServerboundCustomPayloadPacket p_9860_) { +- public void handleCustomPayload(ServerboundCustomPayloadPacket p_9860_) { - } - -- public void m_7477_(ServerboundChangeDifficultyPacket p_9839_) { -- PacketUtils.m_131359_(p_9839_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_20310_(2) || this.m_9956_()) { -- this.f_9745_.m_129827_(p_9839_.m_133824_(), false); +- public void handleChangeDifficulty(ServerboundChangeDifficultyPacket p_9839_) { +- PacketUtils.ensureRunningOnSameThread(p_9839_, this, this.player.getLevel()); +- if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) { +- this.server.setDifficulty(p_9839_.getDifficulty(), false); - } - } - -- public void m_7728_(ServerboundLockDifficultyPacket p_9872_) { -- PacketUtils.m_131359_(p_9872_, this, this.f_9743_.m_183503_()); -- if (this.f_9743_.m_20310_(2) || this.m_9956_()) { -- this.f_9745_.m_129958_(p_9872_.m_134115_()); +- public void handleLockDifficulty(ServerboundLockDifficultyPacket p_9872_) { +- PacketUtils.ensureRunningOnSameThread(p_9872_, this, this.player.getLevel()); +- if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) { +- this.server.setDifficultyLocked(p_9872_.isLocked()); - } - } - -- public ServerPlayer m_142253_() { -- return this.f_9743_; +- public ServerPlayer getPlayer() { +- return this.player; - } - - @FunctionalInterface - interface EntityInteraction { -- InteractionResult m_143694_(ServerPlayer p_143695_, Entity p_143696_, InteractionHand p_143697_); +- InteractionResult run(ServerPlayer p_143695_, Entity p_143696_, InteractionHand p_143697_); - } -+ } else if (this.f_9743_.m_9241_() != ChatVisiblity.SYSTEM) { ++ } else if (this.player.getChatVisibility() != ChatVisiblity.SYSTEM) { + org.bukkit.entity.Player thisPlayer = this.getCraftPlayer(); -+ org.bukkit.event.player.AsyncPlayerChatEvent event = new org.bukkit.event.player.AsyncPlayerChatEvent(async, thisPlayer, s, new org.bukkit.craftbukkit.v1_18_R2.util.LazyPlayerSet(this.f_9745_)); ++ org.bukkit.event.player.AsyncPlayerChatEvent event = new org.bukkit.event.player.AsyncPlayerChatEvent(async, thisPlayer, s, new org.bukkit.craftbukkit.v1_18_R2.util.LazyPlayerSet(this.server)); + this.cserver.getPluginManager().callEvent(event); + if (org.bukkit.event.player.PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { + org.bukkit.event.player.PlayerChatEvent queueEvent = new org.bukkit.event.player.PlayerChatEvent(thisPlayer, event.getMessage(), event.getFormat(), event.getRecipients()); @@ -3697,12 +3697,12 @@ + if (component == null) return null; + org.bukkit.Bukkit.getConsoleSender().sendMessage(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(component)); + if (((org.bukkit.craftbukkit.v1_18_R2.util.LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { -+ for (ServerPlayer player : f_9745_.m_6846_().f_11196_) { -+ player.m_6352_(component, thisPlayer.getUniqueId()); ++ for (ServerPlayer player : server.getPlayerList().players) { ++ player.sendMessage(component, thisPlayer.getUniqueId()); + } + } else { + for (org.bukkit.entity.Player player2 : queueEvent.getRecipients()) { -+ ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) player2).getHandle().m_6352_(component, thisPlayer.getUniqueId()); ++ ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) player2).getHandle().sendMessage(component, thisPlayer.getUniqueId()); + } + } + return null; @@ -3710,7 +3710,7 @@ + } + org.bukkit.craftbukkit.v1_18_R2.util.Waitable waitable = new SyncChat(); + if (async) { -+ this.f_9745_.processQueue.add(waitable); ++ this.server.processQueue.add(waitable); + } else { + waitable.run(); + } @@ -3740,12 +3740,12 @@ + if (component == null) return null; + org.bukkit.Bukkit.getConsoleSender().sendMessage(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(component)); + if (((org.bukkit.craftbukkit.v1_18_R2.util.LazyPlayerSet) event.getRecipients()).isLazy()) { -+ for (ServerPlayer recipient : f_9745_.m_6846_().f_11196_) { -+ recipient.m_6352_(component, thisPlayer.getUniqueId()); ++ for (ServerPlayer recipient : server.getPlayerList().players) { ++ recipient.sendMessage(component, thisPlayer.getUniqueId()); + } + } else { + for (org.bukkit.entity.Player recipient2 : event.getRecipients()) { -+ ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) recipient2).getHandle().m_6352_(component, thisPlayer.getUniqueId()); ++ ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) recipient2).getHandle().sendMessage(component, thisPlayer.getUniqueId()); + } + } + return null; @@ -3753,7 +3753,7 @@ + } + org.bukkit.craftbukkit.v1_18_R2.util.Waitable waitable = new ForgeChat(); + if (async) { -+ this.f_9745_.processQueue.add(waitable); ++ this.server.processQueue.add(waitable); + } else { + waitable.run(); + } @@ -3761,12 +3761,12 @@ + } + + public void teleport(org.bukkit.Location dest) { -+ this.f_9743_.m_143425_(((org.bukkit.craftbukkit.v1_18_R2.CraftWorld)dest.getWorld()).getHandle()); ++ this.player.setLevel(((org.bukkit.craftbukkit.v1_18_R2.CraftWorld)dest.getWorld()).getHandle()); + internalTeleport( dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet(), true ); + } + + @FunctionalInterface + interface EntityInteraction { -+ InteractionResult m_143694_(ServerPlayer p_143695_, Entity p_143696_, InteractionHand p_143697_); ++ InteractionResult run(ServerPlayer p_143695_, Entity p_143696_, InteractionHand p_143697_); + } } diff --git a/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index cf110140..be6949a1 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -16,27 +_,98 @@ - private final MinecraftServer f_9965_; - private final Connection f_9966_; + private final MinecraftServer server; + private final Connection connection; + // Spigot start + private static final com.google.gson.Gson gson = new com.google.gson.Gson(); @@ -15,27 +15,27 @@ + // CraftBukkit end + public ServerHandshakePacketListenerImpl(MinecraftServer p_9969_, Connection p_9970_) { - this.f_9965_ = p_9969_; - this.f_9966_ = p_9970_; + this.server = p_9969_; + this.connection = p_9970_; } - public void m_7322_(ClientIntentionPacket p_9975_) { -+ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9975_, this.f_9966_)) return; - switch(p_9975_.m_134735_()) { + public void handleIntention(ClientIntentionPacket p_9975_) { ++ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9975_, this.connection)) return; + switch(p_9975_.getIntention()) { case LOGIN: - this.f_9966_.m_129498_(ConnectionProtocol.LOGIN); + this.connection.setProtocol(ConnectionProtocol.LOGIN); + + // CraftBukkit start - Connection throttle + try { + long currentTime = System.currentTimeMillis(); -+ long connectionThrottle = this.f_9965_.server.getConnectionThrottle(); -+ java.net.InetAddress address = ((java.net.InetSocketAddress) this.f_9966_.m_129523_()).getAddress(); ++ long connectionThrottle = this.server.server.getConnectionThrottle(); ++ java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); + synchronized (throttleTracker) { + if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { + throttleTracker.put(address, currentTime); + TranslatableComponent chatmessage = new TranslatableComponent("Connection throttled! Please wait before reconnecting."); -+ this.f_9966_.m_129512_(new ClientboundLoginDisconnectPacket(chatmessage)); -+ this.f_9966_.m_129507_(chatmessage); ++ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); ++ this.connection.disconnect(chatmessage); + return; + } + throttleTracker.put(address, currentTime); @@ -57,47 +57,47 @@ + } + // CraftBukkit end + - if (p_9975_.m_134738_() != SharedConstants.m_183709_().getProtocolVersion()) { + if (p_9975_.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) { Component component; - if (p_9975_.m_134738_() < 754) { -- component = new TranslatableComponent("multiplayer.disconnect.outdated_client", SharedConstants.m_183709_().getName()); -+ component = new TranslatableComponent(java.text.MessageFormat.format(org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.m_183709_().getName())); // Spigot + if (p_9975_.getProtocolVersion() < 754) { +- component = new TranslatableComponent("multiplayer.disconnect.outdated_client", SharedConstants.getCurrentVersion().getName()); ++ component = new TranslatableComponent(java.text.MessageFormat.format(org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName())); // Spigot } else { -- component = new TranslatableComponent("multiplayer.disconnect.incompatible", SharedConstants.m_183709_().getName()); -+ component = new TranslatableComponent(java.text.MessageFormat.format(org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.m_183709_().getName())); // Spigot +- component = new TranslatableComponent("multiplayer.disconnect.incompatible", SharedConstants.getCurrentVersion().getName()); ++ component = new TranslatableComponent(java.text.MessageFormat.format(org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName())); // Spigot } - this.f_9966_.m_129512_(new ClientboundLoginDisconnectPacket(component)); - this.f_9966_.m_129507_(component); + this.connection.send(new ClientboundLoginDisconnectPacket(component)); + this.connection.disconnect(component); } else { - this.f_9966_.m_129505_(new ServerLoginPacketListenerImpl(this.f_9965_, this.f_9966_)); + this.connection.setListener(new ServerLoginPacketListenerImpl(this.server, this.connection)); + // Spigot Start -+ String[] split = p_9975_.f_134721_.split("\00"); -+ p_9975_.f_134721_ = split[0]; ++ String[] split = p_9975_.hostName.split("\00"); ++ p_9975_.hostName = split[0]; + if (org.spigotmc.SpigotConfig.bungee) { + if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) { -+ f_9966_.f_129469_ = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) f_9966_.m_129523_()).getPort()); -+ f_9966_.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] ); ++ connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort()); ++ connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] ); + } else + { + TranslatableComponent chatmessage = new TranslatableComponent("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!"); -+ this.f_9966_.m_129512_(new ClientboundLoginDisconnectPacket(chatmessage)); -+ this.f_9966_.m_129507_(chatmessage); ++ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); ++ this.connection.disconnect(chatmessage); + return; + } + if ( split.length == 4 ) + { -+ f_9966_.spoofedProfile = gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class); ++ connection.spoofedProfile = gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class); + } + } else if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) { + TranslatableComponent chatmessage = new TranslatableComponent("Unknown data in login hostname, did you forget to enable BungeeCord in spigot.yml?"); -+ this.f_9966_.m_129512_(new ClientboundLoginDisconnectPacket(chatmessage)); -+ this.f_9966_.m_129507_(chatmessage); ++ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); ++ this.connection.disconnect(chatmessage); + return; + } + + // Spigot End -+ ((ServerLoginPacketListenerImpl) this.f_9966_.m_129538_()).hostname = p_9975_.f_134721_ + ":" + p_9975_.f_134722_; // CraftBukkit - set hostname ++ ((ServerLoginPacketListenerImpl) this.connection.getPacketListener()).hostname = p_9975_.hostName + ":" + p_9975_.port; // CraftBukkit - set hostname } break; case STATUS: diff --git a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 444163ec..e5ce707f 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -51,6 +_,8 @@ - private final String f_10022_ = ""; + private final String serverId = ""; @Nullable - private ServerPlayer f_10024_; + private ServerPlayer delayedAcceptPlayer; + public String hostname = ""; // CraftBukkit - add field + private int velocityLoginMessageId = -1; // Paper - Velocity suppor public ServerLoginPacketListenerImpl(MinecraftServer p_10027_, Connection p_10028_) { - this.f_10018_ = p_10027_; + this.server = p_10027_; @@ -59,7 +_,13 @@ } - public void m_10050_() { -- if (this.f_10019_ == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { -+ if (this.f_10019_ == State.NEGOTIATING) { + public void tick() { +- if (this.state == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { ++ if (this.state == State.NEGOTIATING) { + // We force the state into "NEGOTIATING" which is otherwise unused. Once we're completed we move the negotiation onto "READY_TO_ACCEPT" + // Might want to promote player object creation to here as well.. -+ boolean negotiationComplete = net.minecraftforge.network.NetworkHooks.tickNegotiation(this, this.f_10013_, this.f_10024_); ++ boolean negotiationComplete = net.minecraftforge.network.NetworkHooks.tickNegotiation(this, this.connection, this.delayedAcceptPlayer); + if (negotiationComplete) -+ this.f_10019_ = State.READY_TO_ACCEPT; -+ } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { - this.m_10055_(); - } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.DELAY_ACCEPT) { - ServerPlayer serverplayer = this.f_10018_.m_6846_().m_11259_(this.f_10021_.getId()); ++ this.state = State.READY_TO_ACCEPT; ++ } else if (this.state == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { + this.handleAcceptedLogin(); + } else if (this.state == ServerLoginPacketListenerImpl.State.DELAY_ACCEPT) { + ServerPlayer serverplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId()); @@ -76,6 +_,20 @@ } @@ -33,17 +33,17 @@ + public void disconnect(String s) { + try { + Component ichatbasecomponent = new net.minecraft.network.chat.TextComponent(s); -+ ServerLoginPacketListenerImpl.f_10015_.info("Disconnecting {}: {}", this.m_10056_(), s); -+ this.f_10013_.m_129512_(new ClientboundLoginDisconnectPacket(ichatbasecomponent)); -+ this.f_10013_.m_129507_(ichatbasecomponent); ++ ServerLoginPacketListenerImpl.LOGGER.info("Disconnecting {}: {}", this.getUserName(), s); ++ this.connection.send(new ClientboundLoginDisconnectPacket(ichatbasecomponent)); ++ this.connection.disconnect(ichatbasecomponent); + } catch (Exception exception) { -+ ServerLoginPacketListenerImpl.f_10015_.error("Error whilst disconnecting player", exception); ++ ServerLoginPacketListenerImpl.LOGGER.error("Error whilst disconnecting player", exception); + } + } + // CraftBukkit end + - public Connection m_6198_() { - return this.f_10013_; + public Connection getConnection() { + return this.connection; } @@ -91,15 +_,57 @@ @@ -54,7 +54,7 @@ + private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool( + r -> { + Thread ret = new Thread(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER, r, "User Authenticator #" + threadId.incrementAndGet()); -+ ret.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(f_10015_)); ++ ret.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); + return ret; + } + ); @@ -63,76 +63,74 @@ + // Spigot start + public void initUUID() { + UUID uuid; -+ if (f_10013_.spoofedUUID != null) { -+ uuid = f_10013_.spoofedUUID; ++ if (connection.spoofedUUID != null) { ++ uuid = connection.spoofedUUID; + } else { -+ uuid = Player.m_36283_(this.f_10021_.getName()); ++ uuid = Player.createPlayerUUID(this.gameProfile.getName()); + } + -+ this.f_10021_ = new GameProfile(uuid, this.f_10021_.getName()); ++ this.gameProfile = new GameProfile(uuid, this.gameProfile.getName()); + -+ if (f_10013_.spoofedProfile != null) { -+ for (com.mojang.authlib.properties.Property property : f_10013_.spoofedProfile) { ++ if (connection.spoofedProfile != null) { ++ for (com.mojang.authlib.properties.Property property : connection.spoofedProfile) { + if (!ServerHandshakePacketListenerImpl.PROP_PATTERN.matcher(property.getName()).matches()) continue; -+ this.f_10021_.getProperties().put(property.getName(), property); ++ this.gameProfile.getProperties().put(property.getName(), property); + } + } + } + // Spigot end + - public void m_10055_() { -- if (!this.f_10021_.isComplete()) { -- this.f_10021_ = this.m_10038_(this.f_10021_); + public void handleAcceptedLogin() { + // Spigot start - Moved to initUUID + /* -+ if (!this.gameProfile.isComplete()) { -+ this.gameProfile = this.createFakeProfile(this.gameProfile); + if (!this.gameProfile.isComplete()) { + this.gameProfile = this.createFakeProfile(this.gameProfile); } + */ + // Spigot end -- Component component = this.f_10018_.m_6846_().m_6418_(this.f_10013_.m_129523_(), this.f_10021_); +- Component component = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile); - if (component != null) { -- this.m_10053_(component); +- this.disconnect(component); + // CraftBukkit start - fire PlayerLoginEvent + // Magma - don't. Just move out the player creation, and call the playerJoinEvent after Forge -+ ServerPlayer s = this.f_10018_.m_6846_().m_11300_(this.f_10021_); ++ ServerPlayer s = this.server.getPlayerList().getPlayerForLogin(this.gameProfile); + if (s == null) { + // CraftBukkit end } else { + s.resetBukkitEntity(); //Magma - fixes an issue where the CraftPlayer got initialized before actually getting valid data + // Magma start - fixes mixin problems -+ this.f_10018_.m_6846_().preparePlayerLogin(this, hostname, s); -+ this.f_10018_.m_6846_().m_6418_(this.f_10013_.m_129523_(), this.f_10021_); ++ this.server.getPlayerList().preparePlayerLogin(this, hostname, s); ++ this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile); + // Magma end - this.f_10019_ = ServerLoginPacketListenerImpl.State.ACCEPTED; - if (this.f_10018_.m_6328_() >= 0 && !this.f_10013_.m_129531_()) { - this.f_10013_.m_129514_(new ClientboundLoginCompressionPacket(this.f_10018_.m_6328_()), (p_10041_) -> { + this.state = ServerLoginPacketListenerImpl.State.ACCEPTED; + if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { + this.connection.send(new ClientboundLoginCompressionPacket(this.server.getCompressionThreshold()), (p_10041_) -> { @@ -107,11 +_,11 @@ }); } -+ ServerPlayer serverplayer = this.f_10018_.m_6846_().m_11259_(this.f_10021_.getId()); - this.f_10013_.m_129512_(new ClientboundGameProfilePacket(this.f_10021_)); -- ServerPlayer serverplayer = this.f_10018_.m_6846_().m_11259_(this.f_10021_.getId()); ++ ServerPlayer serverplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId()); + this.connection.send(new ClientboundGameProfilePacket(this.gameProfile)); +- ServerPlayer serverplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId()); try { -- ServerPlayer serverplayer1 = this.f_10018_.m_6846_().m_11300_(this.f_10021_); -+ ServerPlayer serverplayer1 = this.f_10018_.m_6846_().getPlayerForLogin(this.f_10021_, s); // CraftBukkit - add player reference +- ServerPlayer serverplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile); ++ ServerPlayer serverplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference if (serverplayer != null) { - this.f_10019_ = ServerLoginPacketListenerImpl.State.DELAY_ACCEPT; - this.f_10024_ = serverplayer1; + this.state = ServerLoginPacketListenerImpl.State.DELAY_ACCEPT; + this.delayedAcceptPlayer = serverplayer1; @@ -148,7 +_,31 @@ - this.f_10019_ = ServerLoginPacketListenerImpl.State.KEY; - this.f_10013_.m_129512_(new ClientboundHelloPacket("", this.f_10018_.m_129790_().getPublic().getEncoded(), this.f_10017_)); + this.state = ServerLoginPacketListenerImpl.State.KEY; + this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.nonce)); } else { -- this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; +- this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; + // this.state = ServerLoginPacketListenerImpl.State.NEGOTIATING; + // Paper start - Velocity support + if (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport) { + this.velocityLoginMessageId = java.util.concurrent.ThreadLocalRandom.current().nextInt(); + net.minecraft.network.protocol.login.ClientboundCustomQueryPacket packet1 = new net.minecraft.network.protocol.login.ClientboundCustomQueryPacket(this.velocityLoginMessageId, com.destroystokyo.paper.youcandfindpaper.proxy.VelocityProxy.PLAYER_INFO_CHANNEL, new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.EMPTY_BUFFER)); -+ this.f_10013_.m_129512_(packet1); ++ this.connection.send(packet1); + return; + } + // Paper end @@ -146,7 +144,7 @@ + new LoginHandler().fireEvents(); + } catch (Exception ex) { + disconnect("Failed to verify username!"); -+ f_10018_.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + f_10021_.getName(), ex); ++ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameProfile.getName(), ex); + } + } + }); @@ -159,59 +157,55 @@ throw new IllegalStateException("Protocol error", cryptexception); } -- Thread thread = new Thread("User Authenticator #" + f_10014_.incrementAndGet()) { +- Thread thread = new Thread("User Authenticator #" + UNIQUE_THREAD_ID.incrementAndGet()) { + // Paper start - Cache authenticator threads + authenticatorPool.execute(new Runnable() { public void run() { - GameProfile gameprofile = ServerLoginPacketListenerImpl.this.f_10021_; + GameProfile gameprofile = ServerLoginPacketListenerImpl.this.gameProfile; try { -- ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.f_10018_.m_129925_().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.m_10064_()); -+ ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.f_10018_.m_129925_().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.getAddress()); - if (ServerLoginPacketListenerImpl.this.f_10021_ != null) { -- ServerLoginPacketListenerImpl.f_10015_.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.f_10021_.getName(), ServerLoginPacketListenerImpl.this.f_10021_.getId()); -- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; + ServerLoginPacketListenerImpl.this.gameProfile = ServerLoginPacketListenerImpl.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.getAddress()); + if (ServerLoginPacketListenerImpl.this.gameProfile != null) { +- ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.gameProfile.getName(), ServerLoginPacketListenerImpl.this.gameProfile.getId()); +- ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; + // CraftBukkit start - fire PlayerPreLoginEvent -+ if (!f_10013_.m_129536_()) { ++ if (!connection.isConnected()) { + return; + } + + new LoginHandler().fireEvents(); - } else if (ServerLoginPacketListenerImpl.this.f_10018_.m_129792_()) { - ServerLoginPacketListenerImpl.f_10015_.warn("Failed to verify username but will let them in anyway!"); - ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.m_10038_(gameprofile); -- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; -+ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; + } else if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { + ServerLoginPacketListenerImpl.LOGGER.warn("Failed to verify username but will let them in anyway!"); + ServerLoginPacketListenerImpl.this.gameProfile = ServerLoginPacketListenerImpl.this.createFakeProfile(gameprofile); +- ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; ++ ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.NEGOTIATING; } else { - ServerLoginPacketListenerImpl.this.m_10053_(new TranslatableComponent("multiplayer.disconnect.unverified_username")); - ServerLoginPacketListenerImpl.f_10015_.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); -@@ -200,26 +_,112 @@ - if (ServerLoginPacketListenerImpl.this.f_10018_.m_129792_()) { - ServerLoginPacketListenerImpl.f_10015_.warn("Authentication servers are down but will let them in anyway!"); - ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.m_10038_(gameprofile); -- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; -+ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; + ServerLoginPacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.unverified_username")); + ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); +@@ -200,11 +_,16 @@ + if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { + ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); + ServerLoginPacketListenerImpl.this.gameProfile = ServerLoginPacketListenerImpl.this.createFakeProfile(gameprofile); +- ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; ++ ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.NEGOTIATING; } else { - ServerLoginPacketListenerImpl.this.m_10053_(new TranslatableComponent("multiplayer.disconnect.authservers_down")); - ServerLoginPacketListenerImpl.f_10015_.error("Couldn't verify username because servers are unavailable"); + ServerLoginPacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.authservers_down")); + ServerLoginPacketListenerImpl.LOGGER.error("Couldn't verify username because servers are unavailable"); } + // CraftBukkit start - catch all exceptions + } catch (Exception exception) { + disconnect("Failed to verify username!"); -+ f_10018_.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameprofile.getName(), exception); ++ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameprofile.getName(), exception); + // CraftBukkit end } } - - @Nullable -- private InetAddress m_10064_() { -+ private InetAddress getAddress() { - SocketAddress socketaddress = ServerLoginPacketListenerImpl.this.f_10013_.m_129523_(); - return ServerLoginPacketListenerImpl.this.f_10018_.m_129798_() && socketaddress instanceof InetSocketAddress ? ((InetSocketAddress)socketaddress).getAddress() : null; +@@ -214,12 +_,93 @@ + SocketAddress socketaddress = ServerLoginPacketListenerImpl.this.connection.getRemoteAddress(); + return ServerLoginPacketListenerImpl.this.server.getPreventProxyConnections() && socketaddress instanceof InetSocketAddress ? ((InetSocketAddress)socketaddress).getAddress() : null; } - }; -- thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(f_10015_)); +- thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); - thread.start(); - } + }); @@ -227,10 +221,10 @@ + return; + } + // Paper end -+ String playerName = f_10021_.getName(); -+ java.net.InetAddress address = ((java.net.InetSocketAddress) f_10013_.m_129523_()).getAddress(); -+ java.util.UUID uniqueId = f_10021_.getId(); -+ final org.bukkit.craftbukkit.v1_18_R2.CraftServer server = ServerLoginPacketListenerImpl.this.f_10018_.server; ++ String playerName = gameProfile.getName(); ++ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress(); ++ java.util.UUID uniqueId = gameProfile.getId(); ++ final org.bukkit.craftbukkit.v1_18_R2.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; + + org.bukkit.event.player.AsyncPlayerPreLoginEvent asyncEvent = new org.bukkit.event.player.AsyncPlayerPreLoginEvent(playerName, address, uniqueId); + server.getPluginManager().callEvent(asyncEvent); @@ -247,7 +241,7 @@ + return event.getResult(); + }}; + -+ ServerLoginPacketListenerImpl.this.f_10018_.processQueue.add(waitable); ++ ServerLoginPacketListenerImpl.this.server.processQueue.add(waitable); + if (waitable.get() != org.bukkit.event.player.PlayerPreLoginEvent.Result.ALLOWED) { + disconnect(event.getKickMessage()); + return; @@ -259,16 +253,16 @@ + } + } + // CraftBukkit end -+ ServerLoginPacketListenerImpl.f_10015_.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.f_10021_.getName(), ServerLoginPacketListenerImpl.this.f_10021_.getId()); -+ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; ++ ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.gameProfile.getName(), ServerLoginPacketListenerImpl.this.gameProfile.getId()); ++ ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.NEGOTIATING; + } + } + // Spigot end - public void m_7223_(ServerboundCustomQueryPacket p_10045_) { + public void handleCustomQueryPacket(ServerboundCustomQueryPacket p_10045_) { + // Paper start - Velocity support -+ if (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport && p_10045_.m_179824_() == this.velocityLoginMessageId) { -+ net.minecraft.network.FriendlyByteBuf buf = p_10045_.m_179825_(); ++ if (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport && p_10045_.getTransactionId() == this.velocityLoginMessageId) { ++ net.minecraft.network.FriendlyByteBuf buf = p_10045_.getData(); + if (buf == null) { + this.disconnect("This server requires you to connect with Velocity."); + return; @@ -279,14 +273,14 @@ + return; + } + -+ java.net.SocketAddress listening = this.f_10013_.m_129523_(); ++ java.net.SocketAddress listening = this.connection.getRemoteAddress(); + int port = 0; + if (listening instanceof java.net.InetSocketAddress) { + port = ((java.net.InetSocketAddress) listening).getPort(); + } -+ this.f_10013_.f_129469_ = new java.net.InetSocketAddress(com.destroystokyo.paper.youcandfindpaper.proxy.VelocityProxy.readAddress(buf), port); ++ this.connection.address = new java.net.InetSocketAddress(com.destroystokyo.paper.youcandfindpaper.proxy.VelocityProxy.readAddress(buf), port); + -+ this.f_10021_ = com.destroystokyo.paper.youcandfindpaper.proxy.VelocityProxy.createProfile(buf); ++ this.gameProfile = com.destroystokyo.paper.youcandfindpaper.proxy.VelocityProxy.createProfile(buf); + + // Proceed with login + authenticatorPool.execute(() -> { @@ -294,13 +288,13 @@ + new LoginHandler().fireEvents(); + } catch (Exception ex) { + disconnect("Failed to verify username!"); -+ f_10018_.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + f_10021_.getName(), ex); ++ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameProfile.getName(), ex); + } + }); + return; + } + // Paper end -+ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_10045_, this.f_10013_)) - this.m_10053_(new TranslatableComponent("multiplayer.disconnect.unexpected_query_response")); ++ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_10045_, this.connection)) + this.disconnect(new TranslatableComponent("multiplayer.disconnect.unexpected_query_response")); } diff --git a/patches/minecraft/net/minecraft/server/network/ServerStatusPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerStatusPacketListenerImpl.java.patch index db9b4e15..0750d234 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerStatusPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerStatusPacketListenerImpl.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerStatusPacketListenerImpl.java @@ -33,7 +_,44 @@ - this.f_10083_.m_129507_(f_10081_); + this.connection.disconnect(DISCONNECT_REASON); } else { - this.f_10084_ = true; -- this.f_10083_.m_129512_(new ClientboundStatusResponsePacket(this.f_10082_.m_129928_())); + this.hasRequestedStatus = true; +- this.connection.send(new ClientboundStatusResponsePacket(this.server.getStatus())); +// this.connection.send(new ClientboundStatusResponsePacket(this.server.getStatus())); + // CraftBukkit start -+ org.magmafoundation.magma.craftbukkit.ServerListPingEventImpl event = new org.magmafoundation.magma.craftbukkit.ServerListPingEventImpl(f_10083_, f_10082_); -+ this.f_10082_.server.getPluginManager().callEvent(event); ++ org.magmafoundation.magma.craftbukkit.ServerListPingEventImpl event = new org.magmafoundation.magma.craftbukkit.ServerListPingEventImpl(connection, server); ++ this.server.server.getPluginManager().callEvent(event); + + java.util.List profiles = new java.util.ArrayList(event.getPlayers().length); + for (Object player : event.getPlayers()) { + if (player != null) { + net.minecraft.server.level.ServerPlayer entityPlayer = ((net.minecraft.server.level.ServerPlayer) player); -+ if (entityPlayer.m_184128_()) { -+ profiles.add(entityPlayer.m_36316_()); ++ if (entityPlayer.allowsListing()) { ++ profiles.add(entityPlayer.getGameProfile()); + } else { -+ profiles.add(MinecraftServer.f_195496_); ++ profiles.add(MinecraftServer.ANONYMOUS_PLAYER_PROFILE); + } + } + } + + net.minecraft.network.protocol.status.ServerStatus.Players playerSample = new net.minecraft.network.protocol.status.ServerStatus.Players(event.getMaxPlayers(), profiles.size()); -+ if (!this.f_10082_.m_183306_()) { ++ if (!this.server.hidesOnlinePlayers()) { + // Spigot Start + if ( !profiles.isEmpty() ) + { @@ -31,17 +31,17 @@ + profiles = profiles.subList( 0, Math.min( profiles.size(), org.spigotmc.SpigotConfig.playerSample ) ); // Cap the sample to n (or less) displayed players, ie: Vanilla behaviour + } + // Spigot End -+ playerSample.m_134924_(profiles.toArray(new com.mojang.authlib.GameProfile[profiles.size()])); ++ playerSample.setSample(profiles.toArray(new com.mojang.authlib.GameProfile[profiles.size()])); + } + + net.minecraft.network.protocol.status.ServerStatus ping = new net.minecraft.network.protocol.status.ServerStatus(); -+ ping.m_134906_(event.icon.value); -+ ping.m_134908_(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(event.getMotd(), true)[0]); -+ ping.m_134910_(playerSample); -+ int version = net.minecraft.SharedConstants.m_183709_().getProtocolVersion(); -+ ping.m_134912_(new net.minecraft.network.protocol.status.ServerStatus.Version(f_10082_.m_130001_() + " " + f_10082_.m_7630_(), version)); -+ ping.setForgeData(this.f_10082_.m_129928_().getForgeData()); -+ this.f_10083_.m_129512_(new ClientboundStatusResponsePacket(ping)); ++ ping.setFavicon(event.icon.value); ++ ping.setDescription(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(event.getMotd(), true)[0]); ++ ping.setPlayers(playerSample); ++ int version = net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion(); ++ ping.setVersion(new net.minecraft.network.protocol.status.ServerStatus.Version(server.getServerModName() + " " + server.getServerVersion(), version)); ++ ping.setForgeData(this.server.getStatus().getForgeData()); ++ this.connection.send(new ClientboundStatusResponsePacket(ping)); + // CraftBukkit end } } diff --git a/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch index 7748e215..32ac4b4f 100644 --- a/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/packs/AbstractPackResources.java +++ b/net/minecraft/server/packs/AbstractPackResources.java @@ -119,4 +_,10 @@ - public String m_8017_() { - return this.f_10203_.getName(); + public String getName() { + return this.file.getName(); } + + @Override + public String toString() + { -+ return String.format(java.util.Locale.ROOT, "%s: %s", getClass().getName(), f_10203_.getPath()); ++ return String.format(java.util.Locale.ROOT, "%s: %s", getClass().getName(), file.getPath()); + } } diff --git a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch index 16a76607..df457c82 100644 --- a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch @@ -6,6 +6,6 @@ -public interface PackResources extends AutoCloseable { +public interface PackResources extends AutoCloseable, net.minecraftforge.common.extensions.IForgePackResources { - String f_143748_ = ".mcmeta"; - String f_143749_ = "pack.mcmeta"; + String METADATA_EXTENSION = ".mcmeta"; + String PACK_META = "pack.mcmeta"; diff --git a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch index 97758a31..92ced7ea 100644 --- a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch @@ -4,20 +4,20 @@ try { URL url = VanillaPackResources.class.getResource(s); -- return m_10335_(s, url) ? url.openStream() : null; -+ return m_10335_(s, url) ? getExtraInputStream(p_10359_, s) : null; +- return isResourceUrlValid(s, url) ? url.openStream() : null; ++ return isResourceUrlValid(s, url) ? getExtraInputStream(p_10359_, s) : null; } catch (IOException ioexception) { return VanillaPackResources.class.getResourceAsStream(s); } @@ -219,7 +_,7 @@ @Nullable - protected InputStream m_5539_(String p_10334_) { + protected InputStream getResourceAsStream(String p_10334_) { - return VanillaPackResources.class.getResourceAsStream("/" + p_10334_); + return getExtraInputStream(PackType.SERVER_DATA, "/" + p_10334_); } - public boolean m_7211_(PackType p_10355_, ResourceLocation p_10356_) { + public boolean hasResource(PackType p_10355_, ResourceLocation p_10356_) { @@ -292,6 +_,20 @@ } @@ -29,7 +29,7 @@ + //So find that extra jar using the .mcassetsroot marker. + private InputStream getExtraInputStream(PackType type, String resource) { + try { -+ Path rootDir = f_182296_.get(type); ++ Path rootDir = ROOT_DIR_BY_TYPE.get(type); + if (rootDir != null) + return Files.newInputStream(rootDir.resolve(resource)); + return VanillaPackResources.class.getResourceAsStream(resource); @@ -38,4 +38,4 @@ + } } - public Resource m_142591_(final ResourceLocation p_143764_) throws IOException { + public Resource getResource(final ResourceLocation p_143764_) throws IOException { diff --git a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch index ef0387fe..4e40e69c 100644 --- a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java +++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java @@ -6,17 +_,29 @@ - public static final PackMetadataSectionSerializer f_10366_ = new PackMetadataSectionSerializer(); - private final Component f_10367_; - private final int f_10368_; + public static final PackMetadataSectionSerializer SERIALIZER = new PackMetadataSectionSerializer(); + private final Component description; + private final int packFormat; + private final java.util.Map packTypeVersions; public PackMetadataSection(Component p_10371_, int p_10372_) { - this.f_10367_ = p_10371_; - this.f_10368_ = p_10372_; + this.description = p_10371_; + this.packFormat = p_10372_; + this.packTypeVersions = java.util.Map.of(); + } + public PackMetadataSection(Component p_10371_, int p_10372_, java.util.Map packTypeVersions) { -+ this.f_10367_ = p_10371_; -+ this.f_10368_ = p_10372_; ++ this.description = p_10371_; ++ this.packFormat = p_10372_; + this.packTypeVersions = packTypeVersions; } - public Component m_10373_() { - return this.f_10367_; + public Component getDescription() { + return this.description; } + /** @deprecated Forge: Use {@link #getPackFormat(net.minecraft.server.packs.PackType)} instead.*/ + @Deprecated - public int m_10374_() { - return this.f_10368_; + public int getPackFormat() { + return this.packFormat; + } + public int getPackFormat(net.minecraft.server.packs.PackType packType) { -+ return packTypeVersions.getOrDefault(packType, this.f_10368_); ++ return packTypeVersions.getOrDefault(packType, this.packFormat); } } diff --git a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch index c7c1e72d..8be04a1c 100644 --- a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch @@ -3,7 +3,7 @@ @@ -13,7 +_,7 @@ throw new JsonParseException("Invalid/missing description!"); } else { - int i = GsonHelper.m_13927_(p_10380_, "pack_format"); + int i = GsonHelper.getAsInt(p_10380_, "pack_format"); - return new PackMetadataSection(component, i); + return new PackMetadataSection(component, i, net.minecraftforge.common.ForgeHooks.readTypedPackFormats(p_10380_)); } diff --git a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch index 557098e2..297f7a79 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/packs/repository/Pack.java +++ b/net/minecraft/server/packs/repository/Pack.java @@ -27,6 +_,7 @@ - private final Pack.Position f_10406_; - private final boolean f_10407_; - private final boolean f_10408_; + private final Pack.Position defaultPosition; + private final boolean required; + private final boolean fixedPosition; + private final boolean hidden; // Forge: Allow packs to be hidden from the UI entirely - private final PackSource f_10409_; + private final PackSource packSource; @Nullable @@ -39,7 +_,7 @@ try { - PackMetadataSection packmetadatasection = packresources.m_5550_(PackMetadataSection.f_10366_); + PackMetadataSection packmetadatasection = packresources.getMetadataSection(PackMetadataSection.SERIALIZER); if (packmetadatasection != null) { -- pack = p_10434_.m_143873_(p_10431_, new TextComponent(packresources.m_8017_()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_); -+ pack = p_10434_.create(p_10431_, new TextComponent(packresources.m_8017_()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_, packresources.isHidden()); +- pack = p_10434_.create(p_10431_, new TextComponent(packresources.getName()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_); ++ pack = p_10434_.create(p_10431_, new TextComponent(packresources.getName()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_, packresources.isHidden()); break label54; } @@ -27,29 +27,29 @@ + } + + public Pack(String p_10420_, boolean p_10421_, Supplier p_10422_, Component p_10423_, Component p_10424_, PackCompatibility p_10425_, Pack.Position p_10426_, boolean p_10427_, PackSource p_10428_, boolean hidden) { - this.f_10401_ = p_10420_; - this.f_10402_ = p_10422_; - this.f_10403_ = p_10423_; + this.id = p_10420_; + this.supplier = p_10422_; + this.title = p_10423_; @@ -84,10 +_,16 @@ - this.f_10406_ = p_10426_; - this.f_10408_ = p_10427_; - this.f_10409_ = p_10428_; + this.defaultPosition = p_10426_; + this.fixedPosition = p_10427_; + this.packSource = p_10428_; + this.hidden = hidden; } + @Deprecated public Pack(String p_143865_, Component p_143866_, boolean p_143867_, Supplier p_143868_, PackMetadataSection p_143869_, PackType p_143870_, Pack.Position p_143871_, PackSource p_143872_) { -- this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_); -+ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_, false); +- this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.getDescription(), PackCompatibility.forMetadata(p_143869_, p_143870_), p_143871_, false, p_143872_); ++ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.getDescription(), PackCompatibility.forMetadata(p_143869_, p_143870_), p_143871_, false, p_143872_, false); + } + + public Pack(String p_143865_, Component p_143866_, boolean p_143867_, Supplier p_143868_, PackMetadataSection p_143869_, PackType p_143870_, Pack.Position p_143871_, PackSource p_143872_, boolean hidden) { -+ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_, hidden); ++ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.getDescription(), PackCompatibility.forMetadata(p_143869_, p_143870_), p_143871_, false, p_143872_, hidden); } - public Component m_10429_() { + public Component getTitle() { @@ -132,6 +_,8 @@ - return this.f_10409_; + return this.packSource; } + public boolean isHidden() { return hidden; } @@ -62,10 +62,10 @@ @FunctionalInterface public interface PackConstructor { - @Nullable -- Pack m_143873_(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_); +- Pack create(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_); + @Deprecated + @Nullable -+ default Pack m_143873_(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_) ++ default Pack create(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_) + { + return create(p_143874_, p_143875_, p_143876_, p_143877_, p_143878_, p_143879_, p_143880_, false); + } diff --git a/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch index cbb3caf9..4bf9f4c5 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch @@ -3,9 +3,9 @@ @@ -34,7 +_,7 @@ } - public static PackCompatibility m_143885_(PackMetadataSection p_143886_, PackType p_143887_) { -- return m_143882_(p_143886_.m_10374_(), p_143887_); -+ return m_143882_(p_143886_.getPackFormat(p_143887_), p_143887_); + public static PackCompatibility forMetadata(PackMetadataSection p_143886_, PackType p_143887_) { +- return forFormat(p_143886_.getPackFormat(), p_143887_); ++ return forFormat(p_143886_.getPackFormat(p_143887_), p_143887_); } - public Component m_10492_() { + public Component getDescription() { 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 b244e129..0d674855 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -3,9 +3,9 @@ @@ -24,13 +_,14 @@ public PackRepository(Pack.PackConstructor p_10502_, RepositorySource... p_10503_) { - this.f_10500_ = p_10502_; -- this.f_10497_ = ImmutableSet.copyOf(p_10503_); -+ this.f_10497_ = new java.util.HashSet<>(java.util.Arrays.asList(p_10503_)); + this.constructor = p_10502_; +- this.sources = ImmutableSet.copyOf(p_10503_); ++ this.sources = new java.util.HashSet<>(java.util.Arrays.asList(p_10503_)); } public PackRepository(PackType p_143890_, RepositorySource... p_143891_) { @@ -14,18 +14,18 @@ + this((p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143899_, p_143900_, hidden) -> { + return new Pack(p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143890_, p_143899_, p_143900_, hidden); }, p_143891_); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(p_143890_, f_10497_::add)); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(p_143890_, sources::add)); } - public void m_10506_() { + public void reload() { @@ -91,6 +_,10 @@ @Nullable - public Pack m_10507_(String p_10508_) { - return this.f_10498_.get(p_10508_); + public Pack getPack(String p_10508_) { + return this.available.get(p_10508_); + } + + public synchronized void addPackFinder(RepositorySource packFinder) { -+ this.f_10497_.add(packFinder); ++ this.sources.add(packFinder); } public void close() { diff --git a/patches/minecraft/net/minecraft/server/packs/resources/ReloadableResourceManager.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/ReloadableResourceManager.java.patch index 33e6f234..489a4f23 100644 --- a/patches/minecraft/net/minecraft/server/packs/resources/ReloadableResourceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/resources/ReloadableResourceManager.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/packs/resources/ReloadableResourceManager.java +++ b/net/minecraft/server/packs/resources/ReloadableResourceManager.java @@ -68,4 +_,10 @@ - public Stream m_7536_() { - return this.f_203815_.m_7536_(); + public Stream listPacks() { + return this.resources.listPacks(); } + + public void registerReloadListenerIfNotPresent(PreparableReloadListener listener) { -+ if (!this.f_203816_.contains(listener)) { -+ this.m_7217_(listener); ++ if (!this.listeners.contains(listener)) { ++ this.registerReloadListener(listener); + } + } } 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 80b3ab51..ab8b9a08 100644 --- a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -6,6 +6,6 @@ } + + protected ResourceLocation getPreparedPath(ResourceLocation rl) { -+ return new ResourceLocation(rl.m_135827_(), this.f_10765_ + "/" + rl.m_135815_() + ".json"); ++ return new ResourceLocation(rl.getNamespace(), this.directory + "/" + rl.getPath() + ".json"); + } } diff --git a/patches/minecraft/net/minecraft/server/players/BanListEntry.java.patch b/patches/minecraft/net/minecraft/server/players/BanListEntry.java.patch index 5f1e26a4..e0d8ec28 100644 --- a/patches/minecraft/net/minecraft/server/players/BanListEntry.java.patch +++ b/patches/minecraft/net/minecraft/server/players/BanListEntry.java.patch @@ -10,15 +10,15 @@ Date date; try { @@ -77,4 +_,20 @@ - p_10959_.addProperty("expires", this.f_10946_ == null ? "forever" : f_10943_.format(this.f_10946_)); - p_10959_.addProperty("reason", this.f_10947_); + p_10959_.addProperty("expires", this.expires == null ? "forever" : DATE_FORMAT.format(this.expires)); + p_10959_.addProperty("reason", this.reason); } + + // CraftBukkit start + private static T checkExpiry(T object, JsonObject jsonobject) { + Date expires = null; + try { -+ expires = jsonobject.has("expires") ? f_10943_.parse(jsonobject.get("expires").getAsString()) : null; ++ expires = jsonobject.has("expires") ? DATE_FORMAT.parse(jsonobject.get("expires").getAsString()) : null; + } catch (ParseException ex) { + // Guess we don't have a date + } diff --git a/patches/minecraft/net/minecraft/server/players/GameProfileCache.java.patch b/patches/minecraft/net/minecraft/server/players/GameProfileCache.java.patch index 9d06626e..ebe6ee56 100644 --- a/patches/minecraft/net/minecraft/server/players/GameProfileCache.java.patch +++ b/patches/minecraft/net/minecraft/server/players/GameProfileCache.java.patch @@ -3,27 +3,27 @@ @@ -115,7 +_,7 @@ Date date = calendar.getTime(); GameProfileCache.GameProfileInfo gameprofilecache$gameprofileinfo = new GameProfileCache.GameProfileInfo(p_10992_, date); - this.m_10979_(gameprofilecache$gameprofileinfo); -- this.m_11006_(); -+ if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.m_11006_(); // Spigot - skip saving if disabled + this.safeAdd(gameprofilecache$gameprofileinfo); +- this.save(); ++ if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(); // Spigot - skip saving if disabled } - private long m_11008_() { + private long getNextOperation() { @@ -138,14 +_,14 @@ - gameprofilecache$gameprofileinfo.m_11029_(this.m_11008_()); - optional = Optional.of(gameprofilecache$gameprofileinfo.m_11028_()); + gameprofilecache$gameprofileinfo.setLastAccess(this.getNextOperation()); + optional = Optional.of(gameprofilecache$gameprofileinfo.getProfile()); } else { -- optional = m_10993_(this.f_10968_, s); -+ optional = m_10993_(this.f_10968_, s); // Spigot - use correct case for offline players +- optional = lookupGameProfile(this.profileRepository, s); ++ optional = lookupGameProfile(this.profileRepository, s); // Spigot - use correct case for offline players if (optional.isPresent()) { - this.m_10991_(optional.get()); + this.add(optional.get()); flag = false; } } - if (flag) { + if (flag && !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { // Spigot - skip saving if disabled - this.m_11006_(); + this.save(); } @@ -240,6 +_,11 @@ @@ -32,18 +32,18 @@ } catch (FileNotFoundException filenotfoundexception) { + // Spigot Start + } catch (com.google.gson.JsonSyntaxException | NullPointerException ex) { -+ GameProfileCache.f_10964_.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." ); -+ this.f_10970_.delete(); ++ GameProfileCache.LOGGER.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." ); ++ this.file.delete(); + // Spigot End } catch (JsonParseException | IOException ioexception) { - f_10964_.warn("Failed to load profile cache {}", this.f_10970_, ioexception); + LOGGER.warn("Failed to load profile cache {}", this.file, ioexception); } @@ -250,7 +_,7 @@ - public void m_11006_() { + public void save() { JsonArray jsonarray = new JsonArray(); - DateFormat dateformat = m_11009_(); -- this.m_10977_(1000).forEach((p_143962_) -> { -+ this.m_10977_(org.spigotmc.SpigotConfig.userCacheCap).forEach((p_143962_) -> { // Spigot - jsonarray.add(m_10981_(p_143962_, dateformat)); + DateFormat dateformat = createDateFormat(); +- this.getTopMRUProfiles(1000).forEach((p_143962_) -> { ++ this.getTopMRUProfiles(org.spigotmc.SpigotConfig.userCacheCap).forEach((p_143962_) -> { // Spigot + jsonarray.add(writeGameProfile(p_143962_, dateformat)); }); - String s = this.f_10969_.toJson((JsonElement)jsonarray); + String s = this.gson.toJson((JsonElement)jsonarray); diff --git a/patches/minecraft/net/minecraft/server/players/OldUsersConverter.java.patch b/patches/minecraft/net/minecraft/server/players/OldUsersConverter.java.patch index ef599ae2..f11451e7 100644 --- a/patches/minecraft/net/minecraft/server/players/OldUsersConverter.java.patch +++ b/patches/minecraft/net/minecraft/server/players/OldUsersConverter.java.patch @@ -4,73 +4,73 @@ }).toArray((p_11070_) -> { return new String[p_11070_]; }); -- if (p_11087_.m_129797_()) { -+ if (p_11087_.m_129797_() || org.spigotmc.SpigotConfig.bungee || (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport && com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocityOnlineMode)) { // Spigot: bungee = online mode, for now. - p_11087_.m_129926_().findProfilesByNames(astring, Agent.MINECRAFT, p_11089_); +- if (p_11087_.usesAuthentication()) { ++ if (p_11087_.usesAuthentication() || org.spigotmc.SpigotConfig.bungee || (com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocitySupport && com.destroystokyo.paper.youcandfindpaper.PaperConfig.velocityOnlineMode)) { // Spigot: bungee = online mode, for now. + p_11087_.getProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, p_11089_); } else { for(String s : astring) { @@ -73,7 +_,7 @@ try { - userbanlist.m_11399_(); + userbanlist.load(); } catch (IOException ioexception1) { -- f_11066_.warn("Could not load existing file {}", userbanlist.m_11385_().getName(), ioexception1); -+ f_11066_.warn("Could not load existing file {}", userbanlist.m_11385_().getName()); // CraftBukkit - don't print stacktrace +- LOGGER.warn("Could not load existing file {}", userbanlist.getFile().getName(), ioexception1); ++ LOGGER.warn("Could not load existing file {}", userbanlist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -126,7 +_,7 @@ try { - ipbanlist.m_11399_(); + ipbanlist.load(); } catch (IOException ioexception1) { -- f_11066_.warn("Could not load existing file {}", ipbanlist.m_11385_().getName(), ioexception1); -+ f_11066_.warn("Could not load existing file {}", ipbanlist.m_11385_().getName()); // CraftBukkit - don't print stacktrace +- LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName(), ioexception1); ++ LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -162,7 +_,7 @@ try { - serveroplist.m_11399_(); + serveroplist.load(); } catch (IOException ioexception1) { -- f_11066_.warn("Could not load existing file {}", serveroplist.m_11385_().getName(), ioexception1); -+ f_11066_.warn("Could not load existing file {}", serveroplist.m_11385_().getName()); // CraftBukkit - don't print stacktrace +- LOGGER.warn("Could not load existing file {}", serveroplist.getFile().getName(), ioexception1); ++ LOGGER.warn("Could not load existing file {}", serveroplist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -204,7 +_,7 @@ try { - userwhitelist.m_11399_(); + userwhitelist.load(); } catch (IOException ioexception1) { -- f_11066_.warn("Could not load existing file {}", userwhitelist.m_11385_().getName(), ioexception1); -+ f_11066_.warn("Could not load existing file {}", userwhitelist.m_11385_().getName()); // CraftBukkit - don't print stacktrace +- LOGGER.warn("Could not load existing file {}", userwhitelist.getFile().getName(), ioexception1); ++ LOGGER.warn("Could not load existing file {}", userwhitelist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -315,6 +_,28 @@ - private void m_11167_(File p_11168_, String p_11169_, String p_11170_) { + private void movePlayerFile(File p_11168_, String p_11169_, String p_11170_) { File file5 = new File(file1, p_11169_ + ".dat"); File file6 = new File(p_11168_, p_11170_ + ".dat"); + + // CraftBukkit start - Use old file name to seed lastKnownName + net.minecraft.nbt.CompoundTag root = null; + try { -+ root = net.minecraft.nbt.NbtIo.m_128939_(new java.io.FileInputStream(file5)); ++ root = net.minecraft.nbt.NbtIo.readCompressed(new java.io.FileInputStream(file5)); + } catch (Exception exception) { + exception.printStackTrace(); + } + if (root != null) { -+ if (!root.m_128441_("bukkit")) { -+ root.m_128365_("bukkit", new net.minecraft.nbt.CompoundTag()); ++ if (!root.contains("bukkit")) { ++ root.put("bukkit", new net.minecraft.nbt.CompoundTag()); + } -+ net.minecraft.nbt.CompoundTag data = root.m_128469_("bukkit"); -+ data.m_128359_("lastKnownName", p_11169_); ++ net.minecraft.nbt.CompoundTag data = root.getCompound("bukkit"); ++ data.putString("lastKnownName", p_11169_); + try { -+ net.minecraft.nbt.NbtIo.m_128947_(root, new java.io.FileOutputStream(file2)); ++ net.minecraft.nbt.NbtIo.writeCompressed(root, new java.io.FileOutputStream(file2)); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + // CraftBukkit end + - OldUsersConverter.m_11093_(p_11168_); + OldUsersConverter.ensureDirectoryExists(p_11168_); if (!file5.renameTo(file6)) { throw new OldUsersConverter.ConversionError("Could not convert file for " + p_11169_); diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index ad7c9ca3..745a2172 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -101,14 +_,16 @@ - private static final int f_143987_ = 600; - private static final SimpleDateFormat f_11194_ = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); - private final MinecraftServer f_11195_; -- public final List f_11196_ = Lists.newArrayList(); -+ public final List f_11196_ = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - java.util.ArrayList -> java.util.concurrent.CopyOnWriteArrayList: java.util.Iterator safety - private final Map f_11197_ = Maps.newHashMap(); - private final UserBanList f_11198_ = new UserBanList(f_11189_); - private final IpBanList f_11199_ = new IpBanList(f_11190_); - private final ServerOpList f_11200_ = new ServerOpList(f_11191_); - private final UserWhiteList f_11201_ = new UserWhiteList(f_11192_); -- private final Map f_11202_ = Maps.newHashMap(); -- private final Map f_11203_ = Maps.newHashMap(); + private static final int SEND_PLAYER_INFO_INTERVAL = 600; + private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); + private final MinecraftServer server; +- public final List players = Lists.newArrayList(); ++ public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - java.util.ArrayList -> java.util.concurrent.CopyOnWriteArrayList: java.util.Iterator safety + private final Map playersByUUID = Maps.newHashMap(); + private final UserBanList bans = new UserBanList(USERBANLIST_FILE); + private final IpBanList ipBans = new IpBanList(IPBANLIST_FILE); + private final ServerOpList ops = new ServerOpList(OPLIST_FILE); + private final UserWhiteList whitelist = new UserWhiteList(WHITELIST_FILE); +- private final Map stats = Maps.newHashMap(); +- private final Map advancements = Maps.newHashMap(); + // CraftBukkit start + // private final Map stats = Maps.newHashMap(); -+ private final Map f_11203_ = Maps.newHashMap(); //Magma - use this ++ private final Map advancements = Maps.newHashMap(); //Magma - use this + // CraftBukkit end - public final PlayerDataStorage f_11204_; - private boolean f_11205_; - private final RegistryAccess.Frozen f_11206_; + public final PlayerDataStorage playerIo; + private boolean doWhiteList; + private final RegistryAccess.Frozen registryHolder; @@ -118,8 +_,19 @@ - private boolean f_11209_; - private static final boolean f_143988_ = false; - private int f_11210_; -+ private final List playersView = java.util.Collections.unmodifiableList(f_11196_); + private boolean allowCheatsForAllPlayers; + private static final boolean ALLOW_LOGOUTIVATOR = false; + private int sendAllPlayerInfoIn; ++ private final List playersView = java.util.Collections.unmodifiableList(players); + + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.CraftServer cserver; @@ -37,27 +37,27 @@ + // CraftBukkit end + + org.magmafoundation.magma.forge.ForgeInject.init(); //MAGMA - Forge Inject - Initialize - this.f_11195_ = p_203842_; - this.f_11206_ = p_203843_; - this.f_11193_ = p_203845_; + this.server = p_203842_; + this.registryHolder = p_203843_; + this.maxPlayers = p_203845_; @@ -133,6 +_,12 @@ String s = optional.map(GameProfile::getName).orElse(gameprofile.getName()); - gameprofilecache.m_10991_(gameprofile); - CompoundTag compoundtag = this.m_11224_(p_11263_); + gameprofilecache.add(gameprofile); + CompoundTag compoundtag = this.load(p_11263_); + // CraftBukkit start - Better rename detection -+ if (compoundtag != null && compoundtag.m_128441_("bukkit")) { -+ CompoundTag bukkit = compoundtag.m_128469_("bukkit"); -+ s = bukkit.m_128425_("lastKnownName", 8) ? bukkit.m_128461_("lastKnownName") : s; ++ if (compoundtag != null && compoundtag.contains("bukkit")) { ++ CompoundTag bukkit = compoundtag.getCompound("bukkit"); ++ s = bukkit.contains("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s; + } + // CraftBukkit end - ResourceKey resourcekey = compoundtag != null ? DimensionType.m_63911_(new Dynamic<>(NbtOps.f_128958_, compoundtag.m_128423_("Dimension"))).resultOrPartial(f_11188_::error).orElse(Level.f_46428_) : Level.f_46428_; - ServerLevel serverlevel = this.f_11195_.m_129880_(resourcekey); + ResourceKey resourcekey = compoundtag != null ? DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, compoundtag.get("Dimension"))).resultOrPartial(LOGGER::error).orElse(Level.OVERWORLD) : Level.OVERWORLD; + ServerLevel serverlevel = this.server.getLevel(resourcekey); ServerLevel serverlevel1; @@ -149,18 +_,36 @@ - s1 = p_11262_.m_129523_().toString(); + s1 = p_11262_.getRemoteAddress().toString(); } -- f_11188_.info("{}[{}] logged in with entity id {} at ({}, {}, {})", p_11263_.m_7755_().getString(), s1, p_11263_.m_142049_(), p_11263_.m_20185_(), p_11263_.m_20186_(), p_11263_.m_20189_()); +- LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", p_11263_.getName().getString(), s1, p_11263_.getId(), p_11263_.getX(), p_11263_.getY(), p_11263_.getZ()); + // Spigot start - spawn location event + org.bukkit.entity.Player spawnPlayer = p_11263_.getBukkitEntity(); + org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(spawnPlayer, spawnPlayer.getLocation()); @@ -67,56 +67,56 @@ + serverlevel = ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) loc.getWorld()).getHandle(); + + p_11263_.spawnIn(serverlevel); -+ p_11263_.f_8941_.m_9260_((ServerLevel) p_11263_.f_19853_); -+ p_11263_.m_19890_(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); ++ p_11263_.gameMode.setLevel((ServerLevel) p_11263_.level); ++ p_11263_.absMoveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + // Spigot end + + // CraftBukkit - Moved message to after join + // LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", p_11263_.getName().getString(), s1, p_11263_.getId(), p_11263_.getX(), p_11263_.getY(), p_11263_.getZ()); - LevelData leveldata = serverlevel1.m_6106_(); - p_11263_.m_143427_(compoundtag); - ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.f_11195_, p_11262_, p_11263_); + LevelData leveldata = serverlevel1.getLevelData(); + p_11263_.loadGameTypes(compoundtag); + ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.server, p_11262_, p_11263_); + net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(p_11262_, "PLAY_TO_CLIENT"); - GameRules gamerules = serverlevel1.m_46469_(); - boolean flag = gamerules.m_46207_(GameRules.f_46156_); - boolean flag1 = gamerules.m_46207_(GameRules.f_46145_); -- servergamepacketlistenerimpl.m_141995_(new ClientboundLoginPacket(p_11263_.m_142049_(), leveldata.m_5466_(), p_11263_.f_8941_.m_9290_(), p_11263_.f_8941_.m_9293_(), this.f_11195_.m_129784_(), this.f_11206_, serverlevel1.m_204156_(), serverlevel1.m_46472_(), BiomeManager.m_47877_(serverlevel1.m_7328_()), this.m_11310_(), this.f_11207_, this.f_184208_, flag1, !flag, serverlevel1.m_46659_(), serverlevel1.m_8584_())); + GameRules gamerules = serverlevel1.getGameRules(); + boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); + boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); +- servergamepacketlistenerimpl.send(new ClientboundLoginPacket(p_11263_.getId(), leveldata.isHardcore(), p_11263_.gameMode.getGameModeForPlayer(), p_11263_.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, serverlevel1.dimensionTypeRegistration(), serverlevel1.dimension(), BiomeManager.obfuscateSeed(serverlevel1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, serverlevel1.isDebug(), serverlevel1.isFlat())); + // Spigot - view distance -+ servergamepacketlistenerimpl.m_141995_(new ClientboundLoginPacket(p_11263_.m_142049_(), leveldata.m_5466_(), p_11263_.f_8941_.m_9290_(), p_11263_.f_8941_.m_9293_(), this.f_11195_.m_129784_(), this.f_11206_, serverlevel1.m_204156_(), serverlevel1.m_46472_(), BiomeManager.m_47877_(serverlevel1.m_7328_()), this.m_11310_(), serverlevel1.spigotConfig.viewDistance, serverlevel1.spigotConfig.simulationDistance, flag1, !flag, serverlevel1.m_46659_(), serverlevel1.m_8584_())); ++ servergamepacketlistenerimpl.send(new ClientboundLoginPacket(p_11263_.getId(), leveldata.isHardcore(), p_11263_.gameMode.getGameModeForPlayer(), p_11263_.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, serverlevel1.dimensionTypeRegistration(), serverlevel1.dimension(), BiomeManager.obfuscateSeed(serverlevel1.getSeed()), this.getMaxPlayers(), serverlevel1.spigotConfig.viewDistance, serverlevel1.spigotConfig.simulationDistance, flag1, !flag, serverlevel1.isDebug(), serverlevel1.isFlat())); + p_11263_.getBukkitEntity().sendSupportedChannels(); // CraftBukkit - servergamepacketlistenerimpl.m_141995_(new ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.f_132012_, (new FriendlyByteBuf(Unpooled.buffer())).m_130070_(this.m_7873_().m_130001_()))); - servergamepacketlistenerimpl.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); - servergamepacketlistenerimpl.m_141995_(new ClientboundPlayerAbilitiesPacket(p_11263_.m_150110_())); - servergamepacketlistenerimpl.m_141995_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_)); + servergamepacketlistenerimpl.send(new ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.BRAND, (new FriendlyByteBuf(Unpooled.buffer())).writeUtf(this.getServer().getServerModName()))); + servergamepacketlistenerimpl.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); + servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); + servergamepacketlistenerimpl.send(new ClientboundSetCarriedItemPacket(p_11263_.getInventory().selected)); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_)); - servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_())); - servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_203950_(this.f_11206_))); - this.m_11289_(p_11263_); + servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getRecipes())); + servergamepacketlistenerimpl.send(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registryHolder))); + this.sendPlayerPermissionLevel(p_11263_); @@ -175,18 +_,66 @@ - mutablecomponent = new TranslatableComponent("multiplayer.player.joined.renamed", p_11263_.m_5446_(), s); + mutablecomponent = new TranslatableComponent("multiplayer.player.joined.renamed", p_11263_.getDisplayName(), s); } -- this.m_11264_(mutablecomponent.m_130940_(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.f_137441_); +- this.broadcastMessage(mutablecomponent.withStyle(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.NIL_UUID); + // CraftBukkit start -+ mutablecomponent.m_130940_(ChatFormatting.YELLOW); ++ mutablecomponent.withStyle(ChatFormatting.YELLOW); + String joinMessage = org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(mutablecomponent); + - servergamepacketlistenerimpl.m_9774_(p_11263_.m_20185_(), p_11263_.m_20186_(), p_11263_.m_20189_(), p_11263_.m_146908_(), p_11263_.m_146909_()); -- this.f_11196_.add(p_11263_); + servergamepacketlistenerimpl.teleport(p_11263_.getX(), p_11263_.getY(), p_11263_.getZ(), p_11263_.getYRot(), p_11263_.getXRot()); +- this.players.add(p_11263_); + this.addPlayer(p_11263_); -+ this.playersByName.put(p_11263_.m_6302_().toLowerCase(java.util.Locale.ROOT), p_11263_); // Spigot - this.f_11197_.put(p_11263_.m_142081_(), p_11263_); -- this.m_11268_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, p_11263_)); ++ this.playersByName.put(p_11263_.getScoreboardName().toLowerCase(java.util.Locale.ROOT), p_11263_); // Spigot + this.playersByUUID.put(p_11263_.getUUID(), p_11263_); +- this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, p_11263_)); + + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer bukkitPlayer = p_11263_.getBukkitEntity(); + // Ensure that player inventory is populated with its viewer -+ p_11263_.f_36096_.transferTo(p_11263_.f_36096_, bukkitPlayer); ++ p_11263_.containerMenu.transferTo(p_11263_.containerMenu, bukkitPlayer); + + org.bukkit.event.player.PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(bukkitPlayer, joinMessage); + cserver.getPluginManager().callEvent(playerJoinEvent); + -+ if (!p_11263_.f_8906_.f_9742_.m_129536_()) { ++ if (!p_11263_.connection.connection.isConnected()) { + return; + } + @@ -124,7 +124,7 @@ + + if (joinMessage != null && joinMessage.length() > 0) { + for (Component line : org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(joinMessage)) { -+ f_11195_.m_6846_().m_11268_(new net.minecraft.network.protocol.game.ClientboundChatPacket(line, ChatType.SYSTEM, Util.f_137441_)); ++ server.getPlayerList().broadcastAll(new net.minecraft.network.protocol.game.ClientboundChatPacket(line, ChatType.SYSTEM, Util.NIL_UUID)); + } + } + // CraftBukkit end @@ -132,51 +132,51 @@ + // CraftBukkit start - sendAll above replaced with this loop + ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, p_11263_); - for(int i = 0; i < this.f_11196_.size(); ++i) { -- p_11263_.f_8906_.m_141995_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, this.f_11196_.get(i))); + for(int i = 0; i < this.players.size(); ++i) { +- p_11263_.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, this.players.get(i))); - } - -- serverlevel1.m_8834_(p_11263_); -- this.f_11195_.m_129901_().m_136293_(p_11263_); -+ ServerPlayer entityplayer1 = (ServerPlayer) this.f_11196_.get(i); +- serverlevel1.addNewPlayer(p_11263_); +- this.server.getCustomBossEvents().onPlayerConnect(p_11263_); ++ ServerPlayer entityplayer1 = (ServerPlayer) this.players.get(i); + + if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) { -+ entityplayer1.f_8906_.m_141995_(packet); ++ entityplayer1.connection.send(packet); + } + + if (!bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) { + continue; + } + -+ p_11263_.f_8906_.m_141995_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[]{entityplayer1})); ++ p_11263_.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[]{entityplayer1})); + } + p_11263_.sentListPacket = true; + // CraftBukkit end + + -+ p_11263_.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(p_11263_.m_142049_(), p_11263_.m_20088_(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn ++ p_11263_.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(p_11263_.getId(), p_11263_.getEntityData(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn + + // CraftBukkit start - Only add if the player wasn't moved in the event -+ if (p_11263_.f_19853_ == serverlevel1 && !serverlevel1.m_6907_().contains(p_11263_)) { -+ serverlevel1.m_8834_(p_11263_); -+ this.f_11195_.m_129901_().m_136293_(p_11263_); ++ if (p_11263_.level == serverlevel1 && !serverlevel1.players().contains(p_11263_)) { ++ serverlevel1.addNewPlayer(p_11263_); ++ this.server.getCustomBossEvents().onPlayerConnect(p_11263_); + } -+ serverlevel1 = p_11263_.m_183503_(); // CraftBukkit - Update in case join event changed it ++ serverlevel1 = p_11263_.getLevel(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end + - this.m_11229_(p_11263_, serverlevel1); - if (!this.f_11195_.m_129795_().isEmpty()) { - p_11263_.m_143408_(this.f_11195_.m_129795_(), this.f_11195_.m_129796_(), this.f_11195_.m_142205_(), this.f_11195_.m_141958_()); + this.sendLevelInfo(p_11263_, serverlevel1); + if (!this.server.getResourcePack().isEmpty()) { + p_11263_.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.isResourcePackRequired(), this.server.getResourcePackPrompt()); @@ -198,8 +_,11 @@ - if (compoundtag != null && compoundtag.m_128425_("RootVehicle", 10)) { - CompoundTag compoundtag1 = compoundtag.m_128469_("RootVehicle"); -- Entity entity1 = EntityType.m_20645_(compoundtag1.m_128469_("Entity"), serverlevel1, (p_11223_) -> { -- return !serverlevel1.m_8847_(p_11223_) ? null : p_11223_; + if (compoundtag != null && compoundtag.contains("RootVehicle", 10)) { + CompoundTag compoundtag1 = compoundtag.getCompound("RootVehicle"); +- Entity entity1 = EntityType.loadEntityRecursive(compoundtag1.getCompound("Entity"), serverlevel1, (p_11223_) -> { +- return !serverlevel1.addWithUUID(p_11223_) ? null : p_11223_; + // CraftBukkit start + ServerLevel finalServerLevel = serverlevel1; -+ Entity entity1 = EntityType.m_20645_(compoundtag1.m_128469_("Entity"), finalServerLevel, (entity) -> { -+ return !finalServerLevel.m_8847_(entity) ? null : entity; ++ Entity entity1 = EntityType.loadEntityRecursive(compoundtag1.getCompound("Entity"), finalServerLevel, (entity) -> { ++ return !finalServerLevel.addWithUUID(entity) ? null : entity; + // CraftBukkit end }); if (entity1 != null) { @@ -184,64 +184,64 @@ @@ -232,6 +_,9 @@ } - p_11263_.m_143429_(); + p_11263_.initInventoryMenu(); + net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn( p_11263_ ); + // CraftBukkit - Moved from above, added world -+ f_11188_.info("{}[{}] logged in with entity id {} at ({}, {}, {})", p_11263_.m_7755_().getString(), s1, p_11263_.m_142049_(), p_11263_.m_20185_(), p_11263_.m_20186_(), p_11263_.m_20189_()); ++ LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", p_11263_.getName().getString(), s1, p_11263_.getId(), p_11263_.getX(), p_11263_.getY(), p_11263_.getZ()); } - public void m_11273_(ServerScoreboard p_11274_, ServerPlayer p_11275_) { + public void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { @@ -255,25 +_,26 @@ } - public void m_184209_(ServerLevel p_184210_) { -+ if (f_11204_ != null) return; // CraftBukkit - p_184210_.m_6857_().m_61929_(new BorderChangeListener() { - public void m_6312_(WorldBorder p_11321_, double p_11322_) { -- PlayerList.this.m_11268_(new ClientboundSetBorderSizePacket(p_11321_)); + public void addWorldborderListener(ServerLevel p_184210_) { ++ if (playerIo != null) return; // CraftBukkit + p_184210_.getWorldBorder().addListener(new BorderChangeListener() { + public void onBorderSizeSet(WorldBorder p_11321_, double p_11322_) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(p_11321_)); + PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(p_11321_), p_11321_.world); // CraftBukkit } - public void m_6689_(WorldBorder p_11328_, double p_11329_, double p_11330_, long p_11331_) { -- PlayerList.this.m_11268_(new ClientboundSetBorderLerpSizePacket(p_11328_)); + public void onBorderSizeLerping(WorldBorder p_11328_, double p_11329_, double p_11330_, long p_11331_) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(p_11328_)); + PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(p_11328_), p_11328_.world); // CraftBukkit } - public void m_7721_(WorldBorder p_11324_, double p_11325_, double p_11326_) { -- PlayerList.this.m_11268_(new ClientboundSetBorderCenterPacket(p_11324_)); + public void onBorderCenterSet(WorldBorder p_11324_, double p_11325_, double p_11326_) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderCenterPacket(p_11324_)); + PlayerList.this.broadcastAll(new ClientboundSetBorderCenterPacket(p_11324_), p_11324_.world); // CraftBukkit } - public void m_5904_(WorldBorder p_11333_, int p_11334_) { -- PlayerList.this.m_11268_(new ClientboundSetBorderWarningDelayPacket(p_11333_)); + public void onBorderSetWarningTime(WorldBorder p_11333_, int p_11334_) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDelayPacket(p_11333_)); + PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDelayPacket(p_11333_), p_11333_.world); // CraftBukkit } - public void m_5903_(WorldBorder p_11339_, int p_11340_) { -- PlayerList.this.m_11268_(new ClientboundSetBorderWarningDistancePacket(p_11339_)); + public void onBorderSetWarningBlocks(WorldBorder p_11339_, int p_11340_) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDistancePacket(p_11339_)); + PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDistancePacket(p_11339_), p_11339_.world); // CraftBukkit } - public void m_6315_(WorldBorder p_11336_, double p_11337_) { + public void onBorderSetDamagePerBlock(WorldBorder p_11336_, double p_11337_) { @@ -292,6 +_,7 @@ compoundtag1 = compoundtag; - p_11225_.m_20258_(compoundtag); - f_11188_.debug("loading single player"); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_11225_, this.f_11204_, p_11225_.m_142081_().toString()); + p_11225_.load(compoundtag); + LOGGER.debug("loading single player"); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_11225_, this.playerIo, p_11225_.getUUID().toString()); } else { - compoundtag1 = this.f_11204_.m_78435_(p_11225_); + compoundtag1 = this.playerIo.load(p_11225_); } @@ -300,8 +_,10 @@ } - protected void m_6765_(ServerPlayer p_11277_) { + protected void save(ServerPlayer p_11277_) { + if (!p_11277_.getBukkitEntity().isPersistent()) return; // CraftBukkit -+ if (p_11277_.f_8906_ == null) return; - this.f_11204_.m_78433_(p_11277_); -- ServerStatsCounter serverstatscounter = this.f_11202_.get(p_11277_.m_142081_()); -+ ServerStatsCounter serverstatscounter = p_11277_.m_8951_(); // CraftBukkit ++ if (p_11277_.connection == null) return; + this.playerIo.save(p_11277_); +- ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); ++ ServerStatsCounter serverstatscounter = p_11277_.getStats(); // CraftBukkit if (serverstatscounter != null) { - serverstatscounter.m_12818_(); + serverstatscounter.save(); } @@ -313,9 +_,37 @@ @@ -250,66 +250,66 @@ + //Magma start - move to original method + @Nullable + public String removeAndReturn(ServerPlayer thePlayer) { -+ m_11286_(thePlayer); ++ remove(thePlayer); + String tmp = remove_quitMsg; + remove_quitMsg = null; //reset + return tmp; + } + + public @Nullable String remove_quitMsg = null; //Magma - public void m_11286_(ServerPlayer p_11287_) { + public void remove(ServerPlayer p_11287_) { + if (remove_quitMsg != null) + remove_quitMsg = null; //reset + + net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedOut(p_11287_); - ServerLevel serverlevel = p_11287_.m_183503_(); - p_11287_.m_36220_(Stats.f_12989_); + ServerLevel serverlevel = p_11287_.getLevel(); + p_11287_.awardStat(Stats.LEAVE_GAME); + + // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it + // See SPIGOT-5799, SPIGOT-6145 -+ if (p_11287_.f_36096_ != p_11287_.f_36095_) { -+ p_11287_.m_6915_(); ++ if (p_11287_.containerMenu != p_11287_.inventoryMenu) { ++ p_11287_.closeContainer(); + } + -+ org.bukkit.event.player.PlayerQuitEvent playerQuitEvent = new org.bukkit.event.player.PlayerQuitEvent(p_11287_.getBukkitEntity(), p_11287_.kickLeaveMessage != null ? p_11287_.kickLeaveMessage : "\u00A7e" + p_11287_.m_6302_() + " left the game"); ++ org.bukkit.event.player.PlayerQuitEvent playerQuitEvent = new org.bukkit.event.player.PlayerQuitEvent(p_11287_.getBukkitEntity(), p_11287_.kickLeaveMessage != null ? p_11287_.kickLeaveMessage : "\u00A7e" + p_11287_.getScoreboardName() + " left the game"); + cserver.getPluginManager().callEvent(playerQuitEvent); + p_11287_.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); + -+ p_11287_.m_9240_(); // SPIGOT-924 ++ p_11287_.doTick(); // SPIGOT-924 + // CraftBukkit end + - this.m_6765_(p_11287_); - if (p_11287_.m_20159_()) { - Entity entity = p_11287_.m_20201_(); + this.save(p_11287_); + if (p_11287_.isPassenger()) { + Entity entity = p_11287_.getRootVehicle(); @@ -332,43 +_,102 @@ - serverlevel.m_143261_(p_11287_, Entity.RemovalReason.UNLOADED_WITH_PLAYER); - p_11287_.m_8960_().m_135978_(); - this.f_11196_.remove(p_11287_); -+ this.playersByName.remove(p_11287_.m_6302_().toLowerCase(java.util.Locale.ROOT)); // Spigot - this.f_11195_.m_129901_().m_136305_(p_11287_); - UUID uuid = p_11287_.m_142081_(); - ServerPlayer serverplayer = this.f_11197_.get(uuid); + serverlevel.removePlayerImmediately(p_11287_, Entity.RemovalReason.UNLOADED_WITH_PLAYER); + p_11287_.getAdvancements().stopListening(); + this.players.remove(p_11287_); ++ this.playersByName.remove(p_11287_.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot + this.server.getCustomBossEvents().onPlayerDisconnect(p_11287_); + UUID uuid = p_11287_.getUUID(); + ServerPlayer serverplayer = this.playersByUUID.get(uuid); if (serverplayer == p_11287_) { - this.f_11197_.remove(uuid); -- this.f_11202_.remove(uuid); -- this.f_11203_.remove(uuid); + this.playersByUUID.remove(uuid); +- this.stats.remove(uuid); +- this.advancements.remove(uuid); - } - -- this.m_11268_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, p_11287_)); +- this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, p_11287_)); - } + // CraftBukkit start + // this.stats.remove(uuid); -+ this.f_11203_.remove(uuid); //Magma ++ this.advancements.remove(uuid); //Magma + // CraftBukkit end + } + + // CraftBukkit start + ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, p_11287_); -+ for (int i = 0; i < f_11196_.size(); i++) { -+ ServerPlayer entityplayer2 = (ServerPlayer) this.f_11196_.get(i); ++ for (int i = 0; i < players.size(); i++) { ++ ServerPlayer entityplayer2 = (ServerPlayer) this.players.get(i); + + if (entityplayer2.getBukkitEntity().canSee(p_11287_.getBukkitEntity())) { -+ entityplayer2.f_8906_.m_141995_(packet); ++ entityplayer2.connection.send(packet); + } else { + entityplayer2.getBukkitEntity().onEntityRemove(p_11287_); + } @@ -337,52 +337,52 @@ @Nullable + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return ServerPlayer - public Component m_6418_(SocketAddress p_11257_, GameProfile p_11258_) { -- if (this.f_11198_.m_11406_(p_11258_)) { + public Component canPlayerLogin(SocketAddress p_11257_, GameProfile p_11258_) { +- if (this.bans.isBanned(p_11258_)) { + MutableComponent chatmessage = null; + // Instead of kicking then returning, we need to store the kick reason + // in the event, check with plugins to see if it's ok, and THEN kick + // depending on the outcome. + + org.bukkit.entity.Player player = entity.getBukkitEntity(); -+ org.bukkit.event.player.PlayerLoginEvent event = new org.bukkit.event.player.PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) p_11257_).getAddress(), ((java.net.InetSocketAddress) serverLoginPacketListener.f_10013_.getRawAddress()).getAddress()); -+ -+ if (m_11295_().m_11406_(p_11258_) && !m_11295_().m_11388_(p_11258_).m_7524_()) { - UserBanListEntry userbanlistentry = this.f_11198_.m_11388_(p_11258_); -- MutableComponent mutablecomponent1 = new TranslatableComponent("multiplayer.disconnect.banned.reason", userbanlistentry.m_10962_()); -+ chatmessage = new TranslatableComponent("multiplayer.disconnect.banned.reason", userbanlistentry.m_10962_()); - if (userbanlistentry.m_10961_() != null) { -- mutablecomponent1.m_7220_(new TranslatableComponent("multiplayer.disconnect.banned.expiration", f_11194_.format(userbanlistentry.m_10961_()))); -+ chatmessage.m_7220_(new TranslatableComponent("multiplayer.disconnect.banned.expiration", f_11194_.format(userbanlistentry.m_10961_()))); ++ org.bukkit.event.player.PlayerLoginEvent event = new org.bukkit.event.player.PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) p_11257_).getAddress(), ((java.net.InetSocketAddress) serverLoginPacketListener.connection.getRawAddress()).getAddress()); ++ ++ if (getBans().isBanned(p_11258_) && !getBans().get(p_11258_).hasExpired()) { + UserBanListEntry userbanlistentry = this.bans.get(p_11258_); +- MutableComponent mutablecomponent1 = new TranslatableComponent("multiplayer.disconnect.banned.reason", userbanlistentry.getReason()); ++ chatmessage = new TranslatableComponent("multiplayer.disconnect.banned.reason", userbanlistentry.getReason()); + if (userbanlistentry.getExpires() != null) { +- mutablecomponent1.append(new TranslatableComponent("multiplayer.disconnect.banned.expiration", BAN_DATE_FORMAT.format(userbanlistentry.getExpires()))); ++ chatmessage.append(new TranslatableComponent("multiplayer.disconnect.banned.expiration", BAN_DATE_FORMAT.format(userbanlistentry.getExpires()))); } - return mutablecomponent1; + // return mutablecomponent1; + event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_BANNED, org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(chatmessage)); - } else if (!this.m_5764_(p_11258_)) { + } else if (!this.isWhiteListed(p_11258_)) { - return new TranslatableComponent("multiplayer.disconnect.not_whitelisted"); -- } else if (this.f_11199_.m_11041_(p_11257_)) { +- } else if (this.ipBans.isBanned(p_11257_)) { + chatmessage = new TranslatableComponent("multiplayer.disconnect.not_whitelisted"); + event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot -+ } else if (m_11299_().m_11041_(p_11257_) && !m_11299_().m_11043_(p_11257_).m_7524_()) { - IpBanListEntry ipbanlistentry = this.f_11199_.m_11043_(p_11257_); -- MutableComponent mutablecomponent = new TranslatableComponent("multiplayer.disconnect.banned_ip.reason", ipbanlistentry.m_10962_()); -+ chatmessage = new TranslatableComponent("multiplayer.disconnect.banned_ip.reason", ipbanlistentry.m_10962_()); - if (ipbanlistentry.m_10961_() != null) { -- mutablecomponent.m_7220_(new TranslatableComponent("multiplayer.disconnect.banned_ip.expiration", f_11194_.format(ipbanlistentry.m_10961_()))); -+ chatmessage.m_7220_(new TranslatableComponent("multiplayer.disconnect.banned_ip.expiration", f_11194_.format(ipbanlistentry.m_10961_()))); ++ } else if (getIpBans().isBanned(p_11257_) && !getIpBans().get(p_11257_).hasExpired()) { + IpBanListEntry ipbanlistentry = this.ipBans.get(p_11257_); +- MutableComponent mutablecomponent = new TranslatableComponent("multiplayer.disconnect.banned_ip.reason", ipbanlistentry.getReason()); ++ chatmessage = new TranslatableComponent("multiplayer.disconnect.banned_ip.reason", ipbanlistentry.getReason()); + if (ipbanlistentry.getExpires() != null) { +- mutablecomponent.append(new TranslatableComponent("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ipbanlistentry.getExpires()))); ++ chatmessage.append(new TranslatableComponent("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ipbanlistentry.getExpires()))); } - return mutablecomponent; + // return mutablecomponent; + event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_BANNED, org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(chatmessage)); } else { -- return this.f_11196_.size() >= this.f_11193_ && !this.m_5765_(p_11258_) ? new TranslatableComponent("multiplayer.disconnect.server_full") : null; +- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(p_11258_) ? new TranslatableComponent("multiplayer.disconnect.server_full") : null; - } - } - + // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(p_11258_) ? new TranslatableComponent("multiplayer.disconnect.server_full") : null; -+ if (this.f_11196_.size() >= this.f_11193_ && !this.m_5765_(p_11258_)) { ++ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(p_11258_)) { + event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot + } + } @@ -400,37 +400,37 @@ + } + + //Magma start - revert to original - public ServerPlayer m_11300_(GameProfile p_11301_) { - UUID uuid = Player.m_36198_(p_11301_); + public ServerPlayer getPlayerForLogin(GameProfile p_11301_) { + UUID uuid = Player.createPlayerUUID(p_11301_); List list = Lists.newArrayList(); @@ -385,81 +_,283 @@ list.add(serverplayer2); } - for(ServerPlayer serverplayer1 : list) { -- serverplayer1.f_8906_.m_9942_(new TranslatableComponent("multiplayer.disconnect.duplicate_login")); +- serverplayer1.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login")); + for (ServerPlayer serverPlayer : list) { -+ m_6765_(serverPlayer); // CraftBukkit - Force the player's inventory to be saved -+ serverPlayer.f_8906_.m_9942_(new TranslatableComponent("multiplayer.disconnect.duplicate_login", new Object[0])); ++ save(serverPlayer); // CraftBukkit - Force the player's inventory to be saved ++ serverPlayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login", new Object[0])); } - return new ServerPlayer(this.f_11195_, this.f_11195_.m_129783_(), p_11301_); + return new ServerPlayer(this.server, this.server.overworld(), p_11301_); } - + //Magma end + + //Magma - implementation based on Arclight but modified for our own needs + public ServerPlayer respawn(ServerPlayer playerIn, ServerLevel worldIn, boolean conqueredEnd, org.bukkit.Location location, boolean avoidSuffocation) { -+ playerIn.m_8127_(); ++ playerIn.stopRiding(); + this.removePlayer(playerIn); -+ this.playersByName.remove(playerIn.m_6302_().toLowerCase(java.util.Locale.ROOT)); // Spigot -+ playerIn.m_183503_().m_143261_(playerIn, Entity.RemovalReason.DISCARDED); ++ this.playersByName.remove(playerIn.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot ++ playerIn.getLevel().removePlayerImmediately(playerIn, Entity.RemovalReason.DISCARDED); + playerIn.revive(); -+ BlockPos pos = playerIn.m_8961_(); -+ float f = playerIn.m_8962_(); -+ boolean flag2 = playerIn.m_8964_(); ++ BlockPos pos = playerIn.getRespawnPosition(); ++ float f = playerIn.getRespawnAngle(); ++ boolean flag2 = playerIn.isRespawnForced(); + org.bukkit.World fromWorld = playerIn.getBukkitEntity().getWorld(); -+ playerIn.f_8944_ = false; ++ playerIn.wonGame = false; + /* + playerIn.copyFrom(playerIn, flag); + playerIn.setEntityId(playerIn.getEntityId()); @@ -442,44 +442,44 @@ + boolean flag3 = false; + if (location == null) { + boolean isBedSpawn = false; -+ ServerLevel spawnWorld = this.f_11195_.m_129880_(playerIn.m_8963_()); ++ ServerLevel spawnWorld = this.server.getLevel(playerIn.getRespawnDimension()); + if (spawnWorld != null) { + Optional optional; + if (pos != null) { -+ optional = Player.m_36130_(spawnWorld, pos, f, flag2, conqueredEnd); ++ optional = Player.findRespawnPositionAndUseSpawnBlock(spawnWorld, pos, f, flag2, conqueredEnd); + } else { + optional = Optional.empty(); + } + if (optional.isPresent()) { -+ BlockState iblockdata = spawnWorld.m_8055_(pos); -+ boolean flag4 = iblockdata.m_60713_(Blocks.f_50724_); ++ BlockState iblockdata = spawnWorld.getBlockState(pos); ++ boolean flag4 = iblockdata.is(Blocks.RESPAWN_ANCHOR); + Vec3 vec3d = optional.get(); + float f2; -+ if (!iblockdata.m_204336_(BlockTags.f_13038_) && !flag4) { ++ if (!iblockdata.is(BlockTags.BEDS) && !flag4) { + f2 = f; + } else { -+ Vec3 vec3d2 = Vec3.m_82539_(pos).m_82546_(vec3d).m_82541_(); -+ f2 = (float) Mth.m_14175_(Mth.m_14136_(vec3d2.f_82481_, vec3d2.f_82479_) * 57.2957763671875 - 90.0); ++ Vec3 vec3d2 = Vec3.atBottomCenterOf(pos).subtract(vec3d).normalize(); ++ f2 = (float) Mth.wrapDegrees(Mth.atan2(vec3d2.z, vec3d2.x) * 57.2957763671875 - 90.0); + } + // playerIn.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, f2, 0.0f); -+ playerIn.m_9158_(spawnWorld.m_46472_(), pos, f2, flag2, false); ++ playerIn.setRespawnPosition(spawnWorld.dimension(), pos, f2, flag2, false); + flag3 = (!conqueredEnd && flag4); + isBedSpawn = true; -+ location = new org.bukkit.Location(spawnWorld.getWorld(), vec3d.f_82479_, vec3d.f_82480_, vec3d.f_82481_); ++ location = new org.bukkit.Location(spawnWorld.getWorld(), vec3d.x, vec3d.y, vec3d.z); + } else if (pos != null) { -+ playerIn.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132153_, 0.0f)); -+ playerIn.m_9158_(Level.f_46428_, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed ++ playerIn.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0f)); ++ playerIn.setRespawnPosition(Level.OVERWORLD, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed + } + } + if (location == null) { -+ spawnWorld = this.f_11195_.m_129880_(Level.f_46428_); ++ spawnWorld = this.server.getLevel(Level.OVERWORLD); + pos = playerIn.getSpawnPoint(spawnWorld); -+ location = new org.bukkit.Location(spawnWorld.getWorld(), pos.m_123341_() + 0.5f, pos.m_123342_() + 0.1f, pos.m_123343_() + 0.5f); ++ location = new org.bukkit.Location(spawnWorld.getWorld(), pos.getX() + 0.5f, pos.getY() + 0.1f, pos.getZ() + 0.5f); + } + org.bukkit.entity.Player respawnPlayer = playerIn.getBukkitEntity(); + org.bukkit.event.player.PlayerRespawnEvent respawnEvent = new org.bukkit.event.player.PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag3, flag3); + this.cserver.getPluginManager().callEvent(respawnEvent); -+ if (playerIn.f_8906_.isDisconnected()) { ++ if (playerIn.connection.isDisconnected()) { + return playerIn; + } + location = respawnEvent.getRespawnLocation(); @@ -490,114 +490,114 @@ + location.setWorld(worldIn.getWorld()); + } + ServerLevel serverWorld = ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) location.getWorld()).getHandle(); -+ playerIn.m_19890_(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); -+ playerIn.f_8906_.m_9953_(); -+ while (avoidSuffocation && !serverWorld.m_45786_(playerIn) && playerIn.m_20186_() < 256.0) { -+ playerIn.m_6034_(playerIn.m_20185_(), playerIn.m_20186_() + 1.0, playerIn.m_20189_()); ++ playerIn.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); ++ playerIn.connection.resetPosition(); ++ while (avoidSuffocation && !serverWorld.noCollision(playerIn) && playerIn.getY() < 256.0) { ++ playerIn.setPos(playerIn.getX(), playerIn.getY() + 1.0, playerIn.getZ()); + } -+ LevelData worlddata = serverWorld.m_6106_(); -+ playerIn.f_8906_.m_141995_(new ClientboundRespawnPacket(serverWorld.m_204156_(), serverWorld.m_46472_(), BiomeManager.m_47877_(serverWorld.m_7328_()), playerIn.f_8941_.m_9290_(), playerIn.f_8941_.m_9293_(), serverWorld.m_46659_(), serverWorld.m_8584_(), conqueredEnd)); -+ playerIn.f_8906_.m_141995_(new ClientboundSetChunkCacheRadiusPacket(serverWorld.spigotConfig.viewDistance)); -+ playerIn.f_8906_.m_141995_(new ClientboundSetSimulationDistancePacket(serverWorld.spigotConfig.simulationDistance)); -+ playerIn.m_143425_(serverWorld); ++ LevelData worlddata = serverWorld.getLevelData(); ++ playerIn.connection.send(new ClientboundRespawnPacket(serverWorld.dimensionTypeRegistration(), serverWorld.dimension(), BiomeManager.obfuscateSeed(serverWorld.getSeed()), playerIn.gameMode.getGameModeForPlayer(), playerIn.gameMode.getPreviousGameModeForPlayer(), serverWorld.isDebug(), serverWorld.isFlat(), conqueredEnd)); ++ playerIn.connection.send(new ClientboundSetChunkCacheRadiusPacket(serverWorld.spigotConfig.viewDistance)); ++ playerIn.connection.send(new ClientboundSetSimulationDistancePacket(serverWorld.spigotConfig.simulationDistance)); ++ playerIn.setLevel(serverWorld); + playerIn.spawnIn(serverWorld); -+ playerIn.m_146912_(); -+ playerIn.f_8906_.teleport(new org.bukkit.Location(serverWorld.getWorld(), playerIn.m_20185_(), playerIn.m_20186_(), playerIn.m_20189_(), playerIn.m_146908_(), playerIn.m_146909_())); -+ playerIn.m_20260_(false); -+ playerIn.f_8906_.m_141995_(new ClientboundSetDefaultSpawnPositionPacket(serverWorld.m_8900_(), serverWorld.m_8901_())); -+ playerIn.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(worlddata.m_5472_(), worlddata.m_5474_())); -+ playerIn.f_8906_.m_141995_(new ClientboundSetExperiencePacket(playerIn.f_36080_, playerIn.f_36079_, playerIn.f_36078_)); -+ this.m_11229_(playerIn, serverWorld); -+ this.m_11289_(playerIn); -+ if (!playerIn.f_8906_.isDisconnected()) { -+ serverWorld.m_8622_(playerIn); ++ playerIn.unsetRemoved(); ++ playerIn.connection.teleport(new org.bukkit.Location(serverWorld.getWorld(), playerIn.getX(), playerIn.getY(), playerIn.getZ(), playerIn.getYRot(), playerIn.getXRot())); ++ playerIn.setShiftKeyDown(false); ++ playerIn.connection.send(new ClientboundSetDefaultSpawnPositionPacket(serverWorld.getSharedSpawnPos(), serverWorld.getSharedSpawnAngle())); ++ playerIn.connection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); ++ playerIn.connection.send(new ClientboundSetExperiencePacket(playerIn.experienceProgress, playerIn.totalExperience, playerIn.experienceLevel)); ++ this.sendLevelInfo(playerIn, serverWorld); ++ this.sendPlayerPermissionLevel(playerIn); ++ if (!playerIn.connection.isDisconnected()) { ++ serverWorld.addDuringCommandTeleport(playerIn); + this.addPlayer(playerIn); -+ this.playersByName.put(playerIn.m_6302_().toLowerCase(java.util.Locale.ROOT), playerIn); // Spigot -+ this.f_11197_.put(playerIn.m_142081_(), playerIn); ++ this.playersByName.put(playerIn.getScoreboardName().toLowerCase(java.util.Locale.ROOT), playerIn); // Spigot ++ this.playersByUUID.put(playerIn.getUUID(), playerIn); + } -+ playerIn.m_21153_(playerIn.m_21223_()); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(playerIn, ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) fromWorld).getHandle().m_46472_(), serverWorld.m_46472_()); ++ playerIn.setHealth(playerIn.getHealth()); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(playerIn, ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) fromWorld).getHandle().dimension(), serverWorld.dimension()); + if (flag3) { -+ playerIn.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, pos.m_123341_(), pos.m_123342_(), pos.m_123343_(), 1.0f, 1.0f)); ++ playerIn.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f)); + } -+ this.m_11292_(playerIn); -+ playerIn.m_6885_(); -+ for (MobEffectInstance effect : playerIn.m_21220_()) { -+ playerIn.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(playerIn.m_142049_(), effect)); ++ this.sendAllPlayerInfo(playerIn); ++ playerIn.onUpdateAbilities(); ++ for (MobEffectInstance effect : playerIn.getActiveEffects()) { ++ playerIn.connection.send(new ClientboundUpdateMobEffectPacket(playerIn.getId(), effect)); + } -+ playerIn.m_9209_(((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) fromWorld).getHandle()); ++ playerIn.triggerDimensionChangeTriggers(((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) fromWorld).getHandle()); + if (fromWorld != location.getWorld()) { + org.bukkit.event.player.PlayerChangedWorldEvent event = new org.bukkit.event.player.PlayerChangedWorldEvent(playerIn.getBukkitEntity(), fromWorld); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + } -+ if (playerIn.f_8906_.isDisconnected()) { -+ this.m_6765_(playerIn); ++ if (playerIn.connection.isDisconnected()) { ++ this.save(playerIn); + } + return playerIn; + } + + private @Nullable org.bukkit.Location respawn_location; - public ServerPlayer m_11236_(ServerPlayer p_11237_, boolean p_11238_) { -- this.f_11196_.remove(p_11237_); + public ServerPlayer respawn(ServerPlayer p_11237_, boolean p_11238_) { +- this.players.remove(p_11237_); + respawn_location = null; -+ p_11237_.m_8127_(); ++ p_11237_.stopRiding(); + this.removePlayer(p_11237_); -+ this.playersByName.remove(p_11237_.m_6302_().toLowerCase(java.util.Locale.ROOT)); // Spigot - p_11237_.m_183503_().m_143261_(p_11237_, Entity.RemovalReason.DISCARDED); -- BlockPos blockpos = p_11237_.m_8961_(); -+ BlockPos pos = p_11237_.m_8961_(); - float f = p_11237_.m_8962_(); -- boolean flag = p_11237_.m_8964_(); -- ServerLevel serverlevel = this.f_11195_.m_129880_(p_11237_.m_8963_()); ++ this.playersByName.remove(p_11237_.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot + p_11237_.getLevel().removePlayerImmediately(p_11237_, Entity.RemovalReason.DISCARDED); +- BlockPos blockpos = p_11237_.getRespawnPosition(); ++ BlockPos pos = p_11237_.getRespawnPosition(); + float f = p_11237_.getRespawnAngle(); +- boolean flag = p_11237_.isRespawnForced(); +- ServerLevel serverlevel = this.server.getLevel(p_11237_.getRespawnDimension()); - Optional optional; - if (serverlevel != null && blockpos != null) { -- optional = Player.m_36130_(serverlevel, blockpos, f, flag, p_11238_); -+ boolean flag2 = p_11237_.m_8964_(); +- optional = Player.findRespawnPositionAndUseSpawnBlock(serverlevel, blockpos, f, flag, p_11238_); ++ boolean flag2 = p_11237_.isRespawnForced(); + + org.bukkit.World fromWorld = p_11237_.getBukkitEntity().getWorld(); -+ p_11237_.f_8944_ = false; ++ p_11237_.wonGame = false; + + boolean flag3 = false; -+ ServerLevel spawnWorld = this.f_11195_.m_129880_(p_11237_.m_8963_()); ++ ServerLevel spawnWorld = this.server.getLevel(p_11237_.getRespawnDimension()); + if (respawn_location == null) { + boolean isBedSpawn = false; + if (spawnWorld != null) { + Optional optional; + if (pos != null) { -+ optional = Player.m_36130_(spawnWorld, pos, f, flag2, p_11238_); ++ optional = Player.findRespawnPositionAndUseSpawnBlock(spawnWorld, pos, f, flag2, p_11238_); + } else { + optional = Optional.empty(); + } + if (optional.isPresent()) { -+ BlockState iblockdata = spawnWorld.m_8055_(pos); -+ boolean flag4 = iblockdata.m_60713_(Blocks.f_50724_); ++ BlockState iblockdata = spawnWorld.getBlockState(pos); ++ boolean flag4 = iblockdata.is(Blocks.RESPAWN_ANCHOR); + Vec3 vec3d = optional.get(); + float f2; -+ if (!iblockdata.m_204336_(BlockTags.f_13038_) && !flag4) { ++ if (!iblockdata.is(BlockTags.BEDS) && !flag4) { + f2 = f; + } else { -+ Vec3 vec3d2 = Vec3.m_82539_(pos).m_82546_(vec3d).m_82541_(); -+ f2 = (float) Mth.m_14175_(Mth.m_14136_(vec3d2.f_82481_, vec3d2.f_82479_) * 57.2957763671875 - 90.0); ++ Vec3 vec3d2 = Vec3.atBottomCenterOf(pos).subtract(vec3d).normalize(); ++ f2 = (float) Mth.wrapDegrees(Mth.atan2(vec3d2.z, vec3d2.x) * 57.2957763671875 - 90.0); + } + // playerIn.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, f2, 0.0f); -+ p_11237_.m_9158_(spawnWorld.m_46472_(), pos, f2, flag2, false); ++ p_11237_.setRespawnPosition(spawnWorld.dimension(), pos, f2, flag2, false); + flag3 = (!flag2 && flag4); + isBedSpawn = true; -+ respawn_location = new org.bukkit.Location(spawnWorld.getWorld(), vec3d.f_82479_, vec3d.f_82480_, vec3d.f_82481_); ++ respawn_location = new org.bukkit.Location(spawnWorld.getWorld(), vec3d.x, vec3d.y, vec3d.z); + } else if (pos != null) { -+ p_11237_.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132153_, 0.0f)); -+ p_11237_.m_9158_(Level.f_46428_, null, 0f, false, false); ++ p_11237_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0f)); ++ p_11237_.setRespawnPosition(Level.OVERWORLD, null, 0f, false, false); + } + } + if (respawn_location == null) { -+ spawnWorld = this.f_11195_.m_129880_(Level.f_46428_); ++ spawnWorld = this.server.getLevel(Level.OVERWORLD); + pos = p_11237_.getSpawnPoint(spawnWorld); -+ respawn_location = new org.bukkit.Location(spawnWorld.getWorld(), pos.m_123341_() + 0.5f, pos.m_123342_() + 0.1f, pos.m_123343_() + 0.5f); ++ respawn_location = new org.bukkit.Location(spawnWorld.getWorld(), pos.getX() + 0.5f, pos.getY() + 0.1f, pos.getZ() + 0.5f); + } + org.bukkit.entity.Player respawnPlayer = p_11237_.getBukkitEntity(); + org.bukkit.event.player.PlayerRespawnEvent respawnEvent = new org.bukkit.event.player.PlayerRespawnEvent(respawnPlayer, respawn_location, isBedSpawn && !flag3, flag3); + this.cserver.getPluginManager().callEvent(respawnEvent); -+ if (p_11237_.f_8906_.isDisconnected()) { ++ if (p_11237_.connection.isDisconnected()) { + return p_11237_; + } + respawn_location = respawnEvent.getRespawnLocation(); @@ -608,141 +608,141 @@ - optional = Optional.empty(); - } - -- ServerLevel serverlevel1 = serverlevel != null && optional.isPresent() ? serverlevel : this.f_11195_.m_129783_(); -- ServerPlayer serverplayer = new ServerPlayer(this.f_11195_, serverlevel1, p_11237_.m_36316_()); -- serverplayer.f_8906_ = p_11237_.f_8906_; -- serverplayer.m_9015_(p_11237_, p_11238_); -- serverplayer.m_20234_(p_11237_.m_142049_()); -- serverplayer.m_36163_(p_11237_.m_5737_()); +- ServerLevel serverlevel1 = serverlevel != null && optional.isPresent() ? serverlevel : this.server.overworld(); +- ServerPlayer serverplayer = new ServerPlayer(this.server, serverlevel1, p_11237_.getGameProfile()); +- serverplayer.connection = p_11237_.connection; +- serverplayer.restoreFrom(p_11237_, p_11238_); +- serverplayer.setId(p_11237_.getId()); +- serverplayer.setMainArm(p_11237_.getMainArm()); - -- for(String s : p_11237_.m_19880_()) { -- serverplayer.m_20049_(s); +- for(String s : p_11237_.getTags()) { +- serverplayer.addTag(s); - } - - boolean flag2 = false; - if (optional.isPresent()) { -- BlockState blockstate = serverlevel1.m_8055_(blockpos); -- boolean flag1 = blockstate.m_60713_(Blocks.f_50724_); +- BlockState blockstate = serverlevel1.getBlockState(blockpos); +- boolean flag1 = blockstate.is(Blocks.RESPAWN_ANCHOR); - Vec3 vec3 = optional.get(); - float f1; -- if (!blockstate.m_204336_(BlockTags.f_13038_) && !flag1) { +- if (!blockstate.is(BlockTags.BEDS) && !flag1) { - f1 = f; - } else { -- Vec3 vec31 = Vec3.m_82539_(blockpos).m_82546_(vec3).m_82541_(); -- f1 = (float)Mth.m_14175_(Mth.m_14136_(vec31.f_82481_, vec31.f_82479_) * (double)(180F / (float)Math.PI) - 90.0D); +- Vec3 vec31 = Vec3.atBottomCenterOf(blockpos).subtract(vec3).normalize(); +- f1 = (float)Mth.wrapDegrees(Mth.atan2(vec31.z, vec31.x) * (double)(180F / (float)Math.PI) - 90.0D); - } - -- serverplayer.m_7678_(vec3.f_82479_, vec3.f_82480_, vec3.f_82481_, f1, 0.0F); -- serverplayer.m_9158_(serverlevel1.m_46472_(), blockpos, f, flag, false); +- serverplayer.moveTo(vec3.x, vec3.y, vec3.z, f1, 0.0F); +- serverplayer.setRespawnPosition(serverlevel1.dimension(), blockpos, f, flag, false); - flag2 = !p_11238_ && flag1; - } else if (blockpos != null) { -- serverplayer.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132153_, 0.0F)); +- serverplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); - } - -- while(!serverlevel1.m_45786_(serverplayer) && serverplayer.m_20186_() < (double)serverlevel1.m_151558_()) { -- serverplayer.m_6034_(serverplayer.m_20185_(), serverplayer.m_20186_() + 1.0D, serverplayer.m_20189_()); +- while(!serverlevel1.noCollision(serverplayer) && serverplayer.getY() < (double)serverlevel1.getMaxBuildHeight()) { +- serverplayer.setPos(serverplayer.getX(), serverplayer.getY() + 1.0D, serverplayer.getZ()); - } - -- LevelData leveldata = serverplayer.f_19853_.m_6106_(); -- serverplayer.f_8906_.m_141995_(new ClientboundRespawnPacket(serverplayer.f_19853_.m_204156_(), serverplayer.f_19853_.m_46472_(), BiomeManager.m_47877_(serverplayer.m_183503_().m_7328_()), serverplayer.f_8941_.m_9290_(), serverplayer.f_8941_.m_9293_(), serverplayer.m_183503_().m_46659_(), serverplayer.m_183503_().m_8584_(), p_11238_)); -- serverplayer.f_8906_.m_9774_(serverplayer.m_20185_(), serverplayer.m_20186_(), serverplayer.m_20189_(), serverplayer.m_146908_(), serverplayer.m_146909_()); -- serverplayer.f_8906_.m_141995_(new ClientboundSetDefaultSpawnPositionPacket(serverlevel1.m_8900_(), serverlevel1.m_8901_())); -- serverplayer.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); -- serverplayer.f_8906_.m_141995_(new ClientboundSetExperiencePacket(serverplayer.f_36080_, serverplayer.f_36079_, serverplayer.f_36078_)); -- this.m_11229_(serverplayer, serverlevel1); -- this.m_11289_(serverplayer); -- serverlevel1.m_8845_(serverplayer); -- this.f_11196_.add(serverplayer); -- this.f_11197_.put(serverplayer.m_142081_(), serverplayer); -- serverplayer.m_143429_(); -- serverplayer.m_21153_(serverplayer.m_21223_()); +- LevelData leveldata = serverplayer.level.getLevelData(); +- serverplayer.connection.send(new ClientboundRespawnPacket(serverplayer.level.dimensionTypeRegistration(), serverplayer.level.dimension(), BiomeManager.obfuscateSeed(serverplayer.getLevel().getSeed()), serverplayer.gameMode.getGameModeForPlayer(), serverplayer.gameMode.getPreviousGameModeForPlayer(), serverplayer.getLevel().isDebug(), serverplayer.getLevel().isFlat(), p_11238_)); +- serverplayer.connection.teleport(serverplayer.getX(), serverplayer.getY(), serverplayer.getZ(), serverplayer.getYRot(), serverplayer.getXRot()); +- serverplayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(serverlevel1.getSharedSpawnPos(), serverlevel1.getSharedSpawnAngle())); +- serverplayer.connection.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); +- serverplayer.connection.send(new ClientboundSetExperiencePacket(serverplayer.experienceProgress, serverplayer.totalExperience, serverplayer.experienceLevel)); +- this.sendLevelInfo(serverplayer, serverlevel1); +- this.sendPlayerPermissionLevel(serverplayer); +- serverlevel1.addRespawnedPlayer(serverplayer); +- this.players.add(serverplayer); +- this.playersByUUID.put(serverplayer.getUUID(), serverplayer); +- serverplayer.initInventoryMenu(); +- serverplayer.setHealth(serverplayer.getHealth()); + respawn_location.setWorld(spawnWorld.getWorld()); + } + + ServerLevel serverWorld = ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) respawn_location.getWorld()).getHandle(); + -+ ServerPlayer serverplayerentity = new ServerPlayer(this.f_11195_, serverWorld, p_11237_.m_36316_()); ++ ServerPlayer serverplayerentity = new ServerPlayer(this.server, serverWorld, p_11237_.getGameProfile()); + + // Forward to new player instance + serverplayerentity.getBukkitEntity().restore(p_11237_.getBukkitEntity()); + serverplayerentity.setBukkitEntity(p_11237_.getBukkitEntity()); + if ((Object) p_11237_ instanceof net.minecraft.world.entity.Mob mob) { -+ mob.m_21455_(true, false); ++ mob.dropLeash(true, false); + } -+ p_11237_.f_8906_.f_9743_ = serverplayerentity; ++ p_11237_.connection.player = serverplayerentity; + -+ serverplayerentity.f_8906_ = p_11237_.f_8906_; -+ serverplayerentity.m_143429_(); //Magma - fix inventory not displaying items while they are there ++ serverplayerentity.connection = p_11237_.connection; ++ serverplayerentity.initInventoryMenu(); //Magma - fix inventory not displaying items while they are there + + if (!p_11238_) { // keep inventory here since inventory dropped at ServerPlayer#die -+ serverplayerentity.m_150109_().m_36006_(p_11237_.m_150109_()); ++ serverplayerentity.getInventory().replaceWith(p_11237_.getInventory()); + } //Magma - move up before restoreFrom + -+ serverplayerentity.m_9015_(p_11237_, p_11238_); -+ serverplayerentity.m_9158_(p_11237_.m_8963_(), p_11237_.m_8961_(), p_11237_.m_8962_(), p_11237_.m_8964_(), false); -+ serverplayerentity.m_20234_(p_11237_.m_142049_()); -+ serverplayerentity.m_36163_(p_11237_.m_5737_()); ++ serverplayerentity.restoreFrom(p_11237_, p_11238_); ++ serverplayerentity.setRespawnPosition(p_11237_.getRespawnDimension(), p_11237_.getRespawnPosition(), p_11237_.getRespawnAngle(), p_11237_.isRespawnForced(), false); ++ serverplayerentity.setId(p_11237_.getId()); ++ serverplayerentity.setMainArm(p_11237_.getMainArm()); + -+ for (String s : p_11237_.m_19880_()) { -+ serverplayerentity.m_20049_(s); ++ for (String s : p_11237_.getTags()) { ++ serverplayerentity.addTag(s); + } + -+ serverplayerentity.m_19890_(respawn_location.getX(), respawn_location.getY(), respawn_location.getZ(), respawn_location.getYaw(), respawn_location.getPitch()); -+ serverplayerentity.f_8906_.m_9953_(); ++ serverplayerentity.absMoveTo(respawn_location.getX(), respawn_location.getY(), respawn_location.getZ(), respawn_location.getYaw(), respawn_location.getPitch()); ++ serverplayerentity.connection.resetPosition(); + -+ while (!serverWorld.m_45786_(serverplayerentity) && serverplayerentity.m_20186_() < serverWorld.m_151558_()) { -+ serverplayerentity.m_6034_(serverplayerentity.m_20185_(), serverplayerentity.m_20186_() + 1.0D, serverplayerentity.m_20189_()); ++ while (!serverWorld.noCollision(serverplayerentity) && serverplayerentity.getY() < serverWorld.getMaxBuildHeight()) { ++ serverplayerentity.setPos(serverplayerentity.getX(), serverplayerentity.getY() + 1.0D, serverplayerentity.getZ()); + } + + // CraftBukkit start -+ LevelData leveldata = serverWorld.m_6106_(); -+ serverplayerentity.f_8906_.m_141995_(new ClientboundRespawnPacket(serverWorld.m_204156_(), serverWorld.m_46472_(), BiomeManager.m_47877_(serverWorld.m_7328_()), serverplayerentity.f_8941_.m_9290_(), serverplayerentity.f_8941_.m_9293_(), serverWorld.m_46659_(), serverWorld.m_8584_(), p_11238_)); -+ serverplayerentity.f_8906_.m_141995_(new ClientboundSetChunkCacheRadiusPacket(serverWorld.spigotConfig.viewDistance)); // Spigot -+ serverplayerentity.f_8906_.m_141995_(new ClientboundSetSimulationDistancePacket(serverWorld.spigotConfig.simulationDistance)); // Spigot ++ LevelData leveldata = serverWorld.getLevelData(); ++ serverplayerentity.connection.send(new ClientboundRespawnPacket(serverWorld.dimensionTypeRegistration(), serverWorld.dimension(), BiomeManager.obfuscateSeed(serverWorld.getSeed()), serverplayerentity.gameMode.getGameModeForPlayer(), serverplayerentity.gameMode.getPreviousGameModeForPlayer(), serverWorld.isDebug(), serverWorld.isFlat(), p_11238_)); ++ serverplayerentity.connection.send(new ClientboundSetChunkCacheRadiusPacket(serverWorld.spigotConfig.viewDistance)); // Spigot ++ serverplayerentity.connection.send(new ClientboundSetSimulationDistancePacket(serverWorld.spigotConfig.simulationDistance)); // Spigot + serverplayerentity.spawnIn(serverWorld); -+ serverplayerentity.m_146912_(); -+ serverplayerentity.f_8906_.teleport(new org.bukkit.Location(serverWorld.getWorld(), serverplayerentity.m_20185_(), serverplayerentity.m_20186_(), serverplayerentity.m_20189_(), serverplayerentity.m_146908_(), serverplayerentity.m_146909_())); -+ serverplayerentity.m_20260_(false); -+ serverplayerentity.f_8906_.m_141995_(new ClientboundSetDefaultSpawnPositionPacket(serverWorld.m_8900_(), serverWorld.m_8901_())); -+ serverplayerentity.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); -+ serverplayerentity.f_8906_.m_141995_(new ClientboundSetExperiencePacket(serverplayerentity.f_36080_, serverplayerentity.f_36079_, serverplayerentity.f_36078_)); -+ this.m_11229_(serverplayerentity, serverWorld); -+ this.m_11289_(serverplayerentity); -+ if (!p_11237_.f_8906_.isDisconnected()) { -+ serverWorld.m_8845_(serverplayerentity); ++ serverplayerentity.unsetRemoved(); ++ serverplayerentity.connection.teleport(new org.bukkit.Location(serverWorld.getWorld(), serverplayerentity.getX(), serverplayerentity.getY(), serverplayerentity.getZ(), serverplayerentity.getYRot(), serverplayerentity.getXRot())); ++ serverplayerentity.setShiftKeyDown(false); ++ serverplayerentity.connection.send(new ClientboundSetDefaultSpawnPositionPacket(serverWorld.getSharedSpawnPos(), serverWorld.getSharedSpawnAngle())); ++ serverplayerentity.connection.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); ++ serverplayerentity.connection.send(new ClientboundSetExperiencePacket(serverplayerentity.experienceProgress, serverplayerentity.totalExperience, serverplayerentity.experienceLevel)); ++ this.sendLevelInfo(serverplayerentity, serverWorld); ++ this.sendPlayerPermissionLevel(serverplayerentity); ++ if (!p_11237_.connection.isDisconnected()) { ++ serverWorld.addRespawnedPlayer(serverplayerentity); + this.addPlayer(serverplayerentity); -+ this.playersByName.put(serverplayerentity.m_6302_().toLowerCase(java.util.Locale.ROOT), serverplayerentity); // Spigot -+ this.f_11197_.put(serverplayerentity.m_142081_(), serverplayerentity); ++ this.playersByName.put(serverplayerentity.getScoreboardName().toLowerCase(java.util.Locale.ROOT), serverplayerentity); // Spigot ++ this.playersByUUID.put(serverplayerentity.getUUID(), serverplayerentity); + } -+ serverplayerentity.m_21153_(serverplayerentity.m_21223_()); ++ serverplayerentity.setHealth(serverplayerentity.getHealth()); + net.minecraftforge.event.ForgeEventFactory.firePlayerRespawnEvent(serverplayerentity, p_11238_); if (flag2) { -- serverplayer.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F)); +- serverplayer.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 1.0F, 1.0F)); - } - - return serverplayer; -+ serverplayerentity.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)pos.m_123341_(), (double)pos.m_123342_(), (double)pos.m_123343_(), 1.0F, 1.0F)); ++ serverplayerentity.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), 1.0F, 1.0F)); + } + + // Added from changeDimension -+ m_11292_(serverplayerentity); // Update health, etc... -+ p_11237_.m_6885_(); -+ for (MobEffectInstance mobEffect : p_11237_.m_21220_()) { -+ p_11237_.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(p_11237_.m_142049_(), mobEffect)); ++ sendAllPlayerInfo(serverplayerentity); // Update health, etc... ++ p_11237_.onUpdateAbilities(); ++ for (MobEffectInstance mobEffect : p_11237_.getActiveEffects()) { ++ p_11237_.connection.send(new ClientboundUpdateMobEffectPacket(p_11237_.getId(), mobEffect)); + } + + // Fire advancement trigger -+ p_11237_.m_9209_(((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) fromWorld).getHandle()); ++ p_11237_.triggerDimensionChangeTriggers(((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) fromWorld).getHandle()); + + // Don't fire on respawn + if (fromWorld != respawn_location.getWorld()) { + org.bukkit.event.player.PlayerChangedWorldEvent event = new org.bukkit.event.player.PlayerChangedWorldEvent(p_11237_.getBukkitEntity(), fromWorld); -+ f_11195_.server.getPluginManager().callEvent(event); ++ server.server.getPluginManager().callEvent(event); + } + + // Save player file again if they were disconnected -+ if (p_11237_.f_8906_.isDisconnected()) { -+ this.m_6765_(p_11237_); ++ if (p_11237_.connection.isDisconnected()) { ++ this.save(p_11237_); + } + // CraftBukkit end + @@ -750,17 +750,17 @@ } + //Magma end - public void m_11289_(ServerPlayer p_11290_) { - GameProfile gameprofile = p_11290_.m_36316_(); + public void sendPlayerPermissionLevel(ServerPlayer p_11290_) { + GameProfile gameprofile = p_11290_.getGameProfile(); @@ -469,7 +_,17 @@ - public void m_11288_() { - if (++this.f_11210_ > 600) { -- this.m_11268_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.f_11196_)); + public void tick() { + if (++this.sendAllPlayerInfoIn > 600) { +- this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.players)); + // CraftBukkit start -+ for (int i = 0; i < this.f_11196_.size(); ++i) { -+ final ServerPlayer target = (ServerPlayer) this.f_11196_.get(i); -+ target.f_8906_.m_141995_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.f_11196_.stream().filter(new com.google.common.base.Predicate() { ++ for (int i = 0; i < this.players.size(); ++i) { ++ final ServerPlayer target = (ServerPlayer) this.players.get(i); ++ target.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.players.stream().filter(new com.google.common.base.Predicate() { + @Override + public boolean apply(ServerPlayer input) { + return target.getBukkitEntity().canSee(input.getBukkitEntity()); @@ -768,7 +768,7 @@ + }).collect(java.util.stream.Collectors.toList()))); + } + // CraftBukkit end - this.f_11210_ = 0; + this.sendAllPlayerInfoIn = 0; } @@ -482,6 +_,24 @@ @@ -777,55 +777,55 @@ + // CraftBukkit start - add a world/entity limited version + public void broadcastAll(Packet packet, Player entityhuman) { -+ for (int i = 0; i < this.f_11196_.size(); ++i) { -+ ServerPlayer entityplayer = this.f_11196_.get(i); ++ for (int i = 0; i < this.players.size(); ++i) { ++ ServerPlayer entityplayer = this.players.get(i); + if (entityhuman != null && !entityplayer.getBukkitEntity().canSee(entityhuman.getBukkitEntity())) { + continue; + } -+ ((ServerPlayer) this.f_11196_.get(i)).f_8906_.m_141995_(packet); ++ ((ServerPlayer) this.players.get(i)).connection.send(packet); + } + } + + public void broadcastAll(Packet packet, Level world) { -+ for (int i = 0; i < world.m_6907_().size(); ++i) { -+ ((ServerPlayer) world.m_6907_().get(i)).f_8906_.m_141995_(packet); ++ for (int i = 0; i < world.players().size(); ++i) { ++ ((ServerPlayer) world.players().get(i)).connection.send(packet); + } + } + // CraftBukkit end + - public void m_11270_(Packet p_11271_, ResourceKey p_11272_) { - for(ServerPlayer serverplayer : this.f_11196_) { - if (serverplayer.f_19853_.m_46472_() == p_11272_) { + public void broadcastAll(Packet p_11271_, ResourceKey p_11272_) { + for(ServerPlayer serverplayer : this.players) { + if (serverplayer.level.dimension() == p_11272_) { @@ -538,6 +_,7 @@ } - public void m_5749_(GameProfile p_11254_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11254_, this.f_11195_.m_7022_(), this)) return; - this.f_11200_.m_11381_(new ServerOpListEntry(p_11254_, this.f_11195_.m_7022_(), this.f_11200_.m_11351_(p_11254_))); - ServerPlayer serverplayer = this.m_11259_(p_11254_.getId()); + public void op(GameProfile p_11254_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11254_, this.server.getOperatorUserPermissionLevel(), this)) return; + 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) { @@ -547,6 +_,7 @@ } - public void m_5750_(GameProfile p_11281_) { + public void deop(GameProfile p_11281_) { + if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11281_, 0, this)) return; - this.f_11200_.m_11393_(p_11281_); - ServerPlayer serverplayer = this.m_11259_(p_11281_.getId()); + this.ops.remove(p_11281_); + ServerPlayer serverplayer = this.getPlayer(p_11281_.getId()); if (serverplayer != null) { @@ -569,6 +_,7 @@ - p_11227_.f_8906_.m_141995_(new ClientboundEntityEventPacket(p_11227_, b0)); + p_11227_.connection.send(new ClientboundEntityEventPacket(p_11227_, b0)); } + p_11227_.getBukkitEntity().recalculatePermissions(); // CraftBukkit - this.f_11195_.m_129892_().m_82095_(p_11227_); + this.server.getCommands().sendCommands(p_11227_); } @@ -582,18 +_,19 @@ @Nullable - public ServerPlayer m_11255_(String p_11256_) { -- for(ServerPlayer serverplayer : this.f_11196_) { -- if (serverplayer.m_36316_().getName().equalsIgnoreCase(p_11256_)) { + public ServerPlayer getPlayerByName(String p_11256_) { +- for(ServerPlayer serverplayer : this.players) { +- if (serverplayer.getGameProfile().getName().equalsIgnoreCase(p_11256_)) { - return serverplayer; - } - } @@ -834,9 +834,9 @@ + return this.playersByName.get(p_11256_.toLowerCase(java.util.Locale.ROOT)); // Spigot } - public void m_11241_(@Nullable Player p_11242_, double p_11243_, double p_11244_, double p_11245_, double p_11246_, ResourceKey p_11247_, Packet p_11248_) { - for(int i = 0; i < this.f_11196_.size(); ++i) { - ServerPlayer serverplayer = this.f_11196_.get(i); + public void broadcast(@Nullable Player p_11242_, double p_11243_, double p_11244_, double p_11245_, double p_11246_, ResourceKey p_11247_, Packet p_11248_) { + for(int i = 0; i < this.players.size(); ++i) { + ServerPlayer serverplayer = this.players.get(i); + + // CraftBukkit start - Test if player receiving packet can see the source of the packet + if (p_11242_ != null && !serverplayer.getBukkitEntity().canSee(p_11242_.getBukkitEntity())) { @@ -844,16 +844,16 @@ + } + // CraftBukkit end + - if (serverplayer != p_11242_ && serverplayer.f_19853_.m_46472_() == p_11247_) { - double d0 = p_11243_ - serverplayer.m_20185_(); - double d1 = p_11244_ - serverplayer.m_20186_(); + if (serverplayer != p_11242_ && serverplayer.level.dimension() == p_11247_) { + double d0 = p_11243_ - serverplayer.getX(); + double d1 = p_11244_ - serverplayer.getY(); @@ -607,9 +_,11 @@ } - public void m_11302_() { + public void saveAll() { + co.aikar.timings.MinecraftTimings.savePlayers.startTiming(); // Paper - for(int i = 0; i < this.f_11196_.size(); ++i) { - this.m_6765_(this.f_11196_.get(i)); + for(int i = 0; i < this.players.size(); ++i) { + this.save(this.players.get(i)); } + co.aikar.timings.MinecraftTimings.savePlayers.stopTiming(); // Paper @@ -862,51 +862,51 @@ @@ -633,22 +_,33 @@ } - public void m_11229_(ServerPlayer p_11230_, ServerLevel p_11231_) { -- WorldBorder worldborder = this.f_11195_.m_129783_().m_6857_(); -+ WorldBorder worldborder = p_11230_.f_19853_.m_6857_(); // CraftBukkit - p_11230_.f_8906_.m_141995_(new ClientboundInitializeBorderPacket(worldborder)); - p_11230_.f_8906_.m_141995_(new ClientboundSetTimePacket(p_11231_.m_46467_(), p_11231_.m_46468_(), p_11231_.m_46469_().m_46207_(GameRules.f_46140_))); - p_11230_.f_8906_.m_141995_(new ClientboundSetDefaultSpawnPositionPacket(p_11231_.m_8900_(), p_11231_.m_8901_())); - if (p_11231_.m_46471_()) { -- p_11230_.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132154_, 0.0F)); -- p_11230_.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132160_, p_11231_.m_46722_(1.0F))); -- p_11230_.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, p_11231_.m_46661_(1.0F))); + public void sendLevelInfo(ServerPlayer p_11230_, ServerLevel p_11231_) { +- WorldBorder worldborder = this.server.overworld().getWorldBorder(); ++ WorldBorder worldborder = p_11230_.level.getWorldBorder(); // CraftBukkit + p_11230_.connection.send(new ClientboundInitializeBorderPacket(worldborder)); + p_11230_.connection.send(new ClientboundSetTimePacket(p_11231_.getGameTime(), p_11231_.getDayTime(), p_11231_.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + p_11230_.connection.send(new ClientboundSetDefaultSpawnPositionPacket(p_11231_.getSharedSpawnPos(), p_11231_.getSharedSpawnAngle())); + if (p_11231_.isRaining()) { +- p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); +- p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, p_11231_.getRainLevel(1.0F))); +- p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, p_11231_.getThunderLevel(1.0F))); + // CraftBukkit start - handle player weather + // p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); + // p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, p_11231_.getRainLevel(1.0F))); + // p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, p_11231_.getThunderLevel(1.0F))); + p_11230_.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); -+ p_11230_.updateWeather(-p_11231_.f_46438_, p_11231_.f_46438_, -p_11231_.f_46440_, p_11231_.f_46440_); ++ p_11230_.updateWeather(-p_11231_.rainLevel, p_11231_.rainLevel, -p_11231_.thunderLevel, p_11231_.thunderLevel); + // CraftBukkit end } } - public void m_11292_(ServerPlayer p_11293_) { - p_11293_.f_36095_.m_150429_(); -- p_11293_.m_9233_(); + public void sendAllPlayerInfo(ServerPlayer p_11293_) { + p_11293_.inventoryMenu.sendAllDataToRemote(); +- p_11293_.resetSentInfo(); + // p_11293_.resetSentInfo(); + p_11293_.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange - p_11293_.f_8906_.m_141995_(new ClientboundSetCarriedItemPacket(p_11293_.m_150109_().f_35977_)); + p_11293_.connection.send(new ClientboundSetCarriedItemPacket(p_11293_.getInventory().selected)); + // CraftBukkit start - from GameRules -+ int i = p_11293_.f_19853_.m_46469_().m_46207_(GameRules.f_46145_) ? 22 : 23; -+ p_11293_.f_8906_.m_141995_(new ClientboundEntityEventPacket(p_11293_, (byte) i)); -+ float immediateRespawn = p_11293_.f_19853_.m_46469_().m_46207_(GameRules.f_46156_) ? 1.0F: 0.0F; -+ p_11293_.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132164_, immediateRespawn)); ++ int i = p_11293_.level.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; ++ p_11293_.connection.send(new ClientboundEntityEventPacket(p_11293_, (byte) i)); ++ float immediateRespawn = p_11293_.level.getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; ++ p_11293_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, immediateRespawn)); + // CraftBukkit end } - public int m_11309_() { + public int getPlayerCount() { @@ -701,11 +_,20 @@ } - public void m_11313_() { -- for(int i = 0; i < this.f_11196_.size(); ++i) { -- (this.f_11196_.get(i)).f_8906_.m_9942_(new TranslatableComponent("multiplayer.disconnect.server_shutdown")); + public void removeAll() { +- for(int i = 0; i < this.players.size(); ++i) { +- (this.players.get(i)).connection.disconnect(new TranslatableComponent("multiplayer.disconnect.server_shutdown")); + // CraftBukkit start - disconnect safely -+ for (ServerPlayer player : this.f_11196_) { -+ player.f_8906_.disconnect(this.f_11195_.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message ++ for (ServerPlayer player : this.players) { ++ player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message } + // CraftBukkit end + } @@ -914,69 +914,69 @@ + // CraftBukkit start + public void broadcastMessage(Component[] iChatBaseComponents) { + for (Component component : iChatBaseComponents) { -+ m_11264_(component, ChatType.SYSTEM, Util.f_137441_); ++ broadcastMessage(component, ChatType.SYSTEM, Util.NIL_UUID); + } } + // CraftBukkit end - public void m_11264_(Component p_11265_, ChatType p_11266_, UUID p_11267_) { - this.f_11195_.m_6352_(p_11265_, p_11267_); + public void broadcastMessage(Component p_11265_, ChatType p_11266_, UUID p_11267_) { + this.server.sendMessage(p_11265_, p_11267_); @@ -728,22 +_,35 @@ } + // CraftBukkit start + //Magma start - introduce original function but redirect to bukkit - public ServerStatsCounter m_11239_(Player p_11240_) { -- UUID uuid = p_11240_.m_142081_(); -- ServerStatsCounter serverstatscounter = this.f_11202_.get(uuid); -+ return p_11240_ instanceof ServerPlayer serverPlayer ? getPlayerStats(serverPlayer) : getPlayerStats(p_11240_.m_142081_(), p_11240_.m_7755_().getString()); + public ServerStatsCounter getPlayerStats(Player p_11240_) { +- UUID uuid = p_11240_.getUUID(); +- ServerStatsCounter serverstatscounter = this.stats.get(uuid); ++ return p_11240_ instanceof ServerPlayer serverPlayer ? getPlayerStats(serverPlayer) : getPlayerStats(p_11240_.getUUID(), p_11240_.getName().getString()); + } + //Magma end + + public ServerStatsCounter getPlayerStats(ServerPlayer p_11240_) { -+ ServerStatsCounter serverstatisticmanager = p_11240_.m_8951_(); -+ return serverstatisticmanager == null ? getPlayerStats(p_11240_.m_142081_(), p_11240_.m_5446_().getString()) : serverstatisticmanager; ++ ServerStatsCounter serverstatisticmanager = p_11240_.getStats(); ++ return serverstatisticmanager == null ? getPlayerStats(p_11240_.getUUID(), p_11240_.getDisplayName().getString()) : serverstatisticmanager; + } + + public ServerStatsCounter getPlayerStats(UUID uuid, String displayName) { -+ ServerPlayer player = m_11259_(uuid); -+ ServerStatsCounter serverstatscounter = player == null ? null : (ServerStatsCounter) player.m_8951_(); ++ ServerPlayer player = getPlayer(uuid); ++ ServerStatsCounter serverstatscounter = player == null ? null : (ServerStatsCounter) player.getStats(); + // CraftBukkit end + if (serverstatscounter == null) { - File file1 = this.f_11195_.m_129843_(LevelResource.f_78175_).toFile(); + File file1 = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); File file2 = new File(file1, uuid + ".json"); if (!file2.exists()) { -- File file3 = new File(file1, p_11240_.m_7755_().getString() + ".json"); +- File file3 = new File(file1, p_11240_.getName().getString() + ".json"); - Path path = file3.toPath(); -- if (FileUtil.m_133728_(path) && FileUtil.m_133734_(path) && path.startsWith(file1.getPath()) && file3.isFile()) { +- if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file1.getPath()) && file3.isFile()) { + File file3 = new File(file1, displayName + ".json"); // CraftBukkit + if(file3.exists() && file3.isFile()) { file3.renameTo(file2); } } - serverstatscounter = new ServerStatsCounter(this.f_11195_, file2); -- this.f_11202_.put(uuid, serverstatscounter); + serverstatscounter = new ServerStatsCounter(this.server, file2); +- this.stats.put(uuid, serverstatscounter); + // this.stats.put(uuid, serverstatscounter); // CraftBukkit } return serverstatscounter; @@ -759,6 +_,8 @@ - this.f_11203_.put(uuid, playeradvancements); + this.advancements.put(uuid, playeradvancements); } + // Forge: don't overwrite active player with a fake one. + if (!(p_11297_ instanceof net.minecraftforge.common.util.FakePlayer)) - playeradvancements.m_135979_(p_11297_); + playeradvancements.setPlayer(p_11297_); return playeradvancements; } @@ -788,7 +_,7 @@ } - public List m_11314_() { -- return this.f_11196_; + public List getPlayers() { +- return this.players; + return this.playersView; //Unmodifiable view, we don't want people removing things without us knowing. } @@ -984,31 +984,31 @@ @@ -801,10 +_,14 @@ } - public void m_11315_() { -- for(PlayerAdvancements playeradvancements : this.f_11203_.values()) { -- playeradvancements.m_135981_(this.f_11195_.m_129889_()); + public void reloadResources() { +- for(PlayerAdvancements playeradvancements : this.advancements.values()) { +- playeradvancements.reload(this.server.getAdvancements()); + // CraftBukkit start -+ for (ServerPlayer player : f_11196_) { -+ player.m_8960_().m_135981_(this.f_11195_.m_129889_()); -+ player.m_8960_().m_135992_(player); // CraftBukkit - trigger immediate flush of advancements ++ for (ServerPlayer player : players) { ++ player.getAdvancements().reload(this.server.getAdvancements()); ++ player.getAdvancements().flushDirty(player); // CraftBukkit - trigger immediate flush of advancements } + // CraftBukkit end + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, null)); - this.m_11268_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_203950_(this.f_11206_))); - ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_()); + this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registryHolder))); + ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getRecipes()); @@ -818,4 +_,13 @@ - public boolean m_11316_() { - return this.f_11209_; + public boolean isAllowCheatsForAllPlayers() { + return this.allowCheatsForAllPlayers; } + + public boolean addPlayer(ServerPlayer player) { -+ return f_11196_.add(player); ++ return players.add(player); + } + + public boolean removePlayer(ServerPlayer player) { -+ return this.f_11196_.remove(player); ++ return this.players.remove(player); + } + } diff --git a/patches/minecraft/net/minecraft/server/players/SleepStatus.java.patch b/patches/minecraft/net/minecraft/server/players/SleepStatus.java.patch index 45b5456a..27288aa5 100644 --- a/patches/minecraft/net/minecraft/server/players/SleepStatus.java.patch +++ b/patches/minecraft/net/minecraft/server/players/SleepStatus.java.patch @@ -3,39 +3,39 @@ @@ -14,8 +_,11 @@ } - public boolean m_144004_(int p_144005_, List p_144006_) { -- int i = (int)p_144006_.stream().filter(Player::m_36317_).count(); -- return i >= this.m_144010_(p_144005_); + public boolean areEnoughDeepSleeping(int p_144005_, List p_144006_) { +- int i = (int)p_144006_.stream().filter(Player::isSleepingLongEnough).count(); +- return i >= this.sleepersNeeded(p_144005_); + // CraftBukkit start -+ int j = (int) p_144006_.stream().filter((eh) -> eh.m_36317_() || eh.fauxSleeping).count(); -+ boolean anyDeepSleep = p_144006_.stream().anyMatch(Player::m_36317_); -+ return anyDeepSleep && j >= this.m_144010_(p_144005_); ++ int j = (int) p_144006_.stream().filter((eh) -> eh.isSleepingLongEnough() || eh.fauxSleeping).count(); ++ boolean anyDeepSleep = p_144006_.stream().anyMatch(Player::isSleepingLongEnough); ++ return anyDeepSleep && j >= this.sleepersNeeded(p_144005_); + // CraftBukkit end } - public int m_144010_(int p_144011_) { + public int sleepersNeeded(int p_144011_) { @@ -35,16 +_,22 @@ - int j = this.f_143999_; - this.f_143998_ = 0; - this.f_143999_ = 0; + int j = this.sleepingPlayers; + this.activePlayers = 0; + this.sleepingPlayers = 0; + boolean anySleep = false; // CraftBukkit for(ServerPlayer serverplayer : p_144008_) { - if (!serverplayer.m_5833_()) { - ++this.f_143998_; -- if (serverplayer.m_5803_()) { -+ if (serverplayer.m_5803_() || serverplayer.fauxSleeping) { // CraftBukkit - ++this.f_143999_; + if (!serverplayer.isSpectator()) { + ++this.activePlayers; +- if (serverplayer.isSleeping()) { ++ if (serverplayer.isSleeping() || serverplayer.fauxSleeping) { // CraftBukkit + ++this.sleepingPlayers; } + // CraftBukkit start -+ if (serverplayer.m_5803_()) { ++ if (serverplayer.isSleeping()) { + anySleep = true; + } + // CraftBukkit end } } -- return (j > 0 || this.f_143999_ > 0) && (i != this.f_143998_ || j != this.f_143999_); -+ return anySleep && (j > 0 || this.f_143999_ > 0) && (i != this.f_143998_ || j != this.f_143999_); // CraftBukkit +- return (j > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || j != this.sleepingPlayers); ++ return anySleep && (j > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || j != this.sleepingPlayers); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/server/players/StoredUserList.java.patch b/patches/minecraft/net/minecraft/server/players/StoredUserList.java.patch index 4fed2fb8..17148a91 100644 --- a/patches/minecraft/net/minecraft/server/players/StoredUserList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/StoredUserList.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/server/players/StoredUserList.java +++ b/net/minecraft/server/players/StoredUserList.java @@ -72,6 +_,12 @@ - return this.f_11377_.keySet().toArray(new String[0]); + return this.map.keySet().toArray(new String[0]); } + // CraftBukkit start + public Collection getValues() { -+ return this.f_11377_.values(); ++ return this.map.values(); + } + // CraftBukkit end + - public boolean m_11390_() { - return this.f_11377_.size() < 1; + public boolean isEmpty() { + return this.map.size() < 1; } @@ -147,6 +_,14 @@ - this.f_11377_.put(this.m_5981_(storeduserentry.m_11373_()), (V)storeduserentry); + this.map.put(this.getKeyForUser(storeduserentry.getUser()), (V)storeduserentry); } } + // Spigot Start + } catch ( com.google.gson.JsonParseException | NullPointerException ex ) + { -+ org.bukkit.Bukkit.getLogger().log( java.util.logging.Level.WARNING, "Unable to read file " + this.f_11376_ + ", backing it up to {0}.backup and creating new copy.", ex ); -+ File backup = new File( this.f_11376_ + ".backup" ); -+ this.f_11376_.renameTo( backup ); -+ this.f_11376_.delete(); ++ org.bukkit.Bukkit.getLogger().log( java.util.logging.Level.WARNING, "Unable to read file " + this.file + ", backing it up to {0}.backup and creating new copy.", ex ); ++ File backup = new File( this.file + ".backup" ); ++ this.file.renameTo( backup ); ++ this.file.delete(); + // Spigot End } catch (Throwable throwable1) { if (bufferedreader != null) { diff --git a/patches/minecraft/net/minecraft/server/players/UserBanListEntry.java.patch b/patches/minecraft/net/minecraft/server/players/UserBanListEntry.java.patch index aaadc08a..7576c6e9 100644 --- a/patches/minecraft/net/minecraft/server/players/UserBanListEntry.java.patch +++ b/patches/minecraft/net/minecraft/server/players/UserBanListEntry.java.patch @@ -3,7 +3,7 @@ @@ -36,19 +_,30 @@ } - private static GameProfile m_11445_(JsonObject p_11446_) { + private static GameProfile createGameProfile(JsonObject p_11446_) { - if (p_11446_.has("uuid") && p_11446_.has("name")) { + // Spigot start + // this whole method has to be reworked to account for the fact Bukkit only accepts UUID bans and gives no way for usernames to be stored! diff --git a/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch index a86c8f9f..6af37295 100644 --- a/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch +++ b/patches/minecraft/net/minecraft/server/rcon/RconConsoleSource.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/rcon/RconConsoleSource.java +++ b/net/minecraft/server/rcon/RconConsoleSource.java @@ -34,8 +_,19 @@ - return new CommandSourceStack(this, Vec3.m_82528_(serverlevel.m_8900_()), Vec2.f_82462_, serverlevel, 4, "Rcon", f_11500_, this.f_11502_, (Entity)null); + return new CommandSourceStack(this, Vec3.atLowerCornerOf(serverlevel.getSharedSpawnPos()), Vec2.ZERO, serverlevel, 4, "Rcon", RCON_COMPONENT, this.server, (Entity)null); } + // CraftBukkit start - Send a String + public void sendMessage(String message) { -+ this.f_11501_.append(message); ++ this.buffer.append(message); + } + + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return f_11502_.remoteConsole; ++ return server.remoteConsole; + } + // CraftBukkit end + - public void m_6352_(Component p_11509_, UUID p_11510_) { -- this.f_11501_.append(p_11509_.getString()); -+ this.f_11501_.append(p_11509_.getString()).append("\n"); // FIX MC-7569 - RCON has no newlines in multiline output + public void sendMessage(Component p_11509_, UUID p_11510_) { +- this.buffer.append(p_11509_.getString()); ++ this.buffer.append(p_11509_.getString()).append("\n"); // FIX MC-7569 - RCON has no newlines in multiline output } - public boolean m_6999_() { + public boolean acceptsSuccess() { diff --git a/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch b/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch index 59706377..303bc440 100644 --- a/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch +++ b/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch @@ -3,7 +3,7 @@ @@ -125,13 +_,14 @@ } - private void m_11594_(int p_11595_, String p_11596_) throws IOException { + private void sendCmdResponse(int p_11595_, String p_11596_) throws IOException { - int i = p_11596_.length(); - + byte[] whole = p_11596_.getBytes(StandardCharsets.UTF_8); @@ -11,10 +11,10 @@ + int start = 0; do { int j = 4096 <= i ? 4096 : i; -- this.m_11590_(p_11595_, 0, p_11596_.substring(0, j)); +- this.send(p_11595_, 0, p_11596_.substring(0, j)); - p_11596_ = p_11596_.substring(j); - i = p_11596_.length(); -+ this.m_11590_(p_11595_, 0, new String(java.util.Arrays.copyOfRange(whole, start, j+start), StandardCharsets.UTF_8)); ++ this.send(p_11595_, 0, new String(java.util.Arrays.copyOfRange(whole, start, j+start), StandardCharsets.UTF_8)); + i -= j; + start += j; } while(0 != i); diff --git a/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch b/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch index 24a088a8..452fb1e7 100644 --- a/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch +++ b/patches/minecraft/net/minecraft/sounds/SoundEvent.java.patch @@ -6,6 +6,6 @@ -public class SoundEvent { +public class SoundEvent extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final Codec f_11655_ = ResourceLocation.f_135803_.xmap(SoundEvent::new, (p_11662_) -> { - return p_11662_.f_11656_; + public static final Codec CODEC = ResourceLocation.CODEC.xmap(SoundEvent::new, (p_11662_) -> { + return p_11662_.location; }); diff --git a/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch b/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch index 726486d8..eb583309 100644 --- a/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch +++ b/patches/minecraft/net/minecraft/sounds/SoundEvents.java.patch @@ -6,5 +6,5 @@ +@net.minecraftforge.registries.ObjectHolder("minecraft") public class SoundEvents { - public static final SoundEvent f_11689_ = m_12656_("ambient.cave"); - public static final SoundEvent f_11742_ = m_12656_("ambient.basalt_deltas.additions"); + public static final SoundEvent AMBIENT_CAVE = register("ambient.cave"); + public static final SoundEvent AMBIENT_BASALT_DELTAS_ADDITIONS = register("ambient.basalt_deltas.additions"); diff --git a/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch b/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch index 76a1edbe..688520eb 100644 --- a/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch +++ b/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch @@ -4,19 +4,19 @@ import net.minecraft.world.inventory.RecipeBookType; public final class RecipeBookSettings { -- private static final Map> f_12725_ = ImmutableMap.of(RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, Pair.of("isFurnaceGuiOpen", "isFurnaceFilteringCraftable"), RecipeBookType.BLAST_FURNACE, Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable")); -+ private static final Map> f_12725_ = new java.util.HashMap<>(ImmutableMap.of(RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, Pair.of("isFurnaceGuiOpen", "isFurnaceFilteringCraftable"), RecipeBookType.BLAST_FURNACE, Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable"))); - private final Map f_12726_; +- private static final Map> TAG_FIELDS = ImmutableMap.of(RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, Pair.of("isFurnaceGuiOpen", "isFurnaceFilteringCraftable"), RecipeBookType.BLAST_FURNACE, Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable")); ++ private static final Map> TAG_FIELDS = new java.util.HashMap<>(ImmutableMap.of(RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, Pair.of("isFurnaceGuiOpen", "isFurnaceFilteringCraftable"), RecipeBookType.BLAST_FURNACE, Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable"))); + private final Map states; private RecipeBookSettings(Map p_12730_) { @@ -115,6 +_,10 @@ - return this.f_12726_.hashCode(); + return this.states.hashCode(); } + //FORGE -- called automaticlly on Enum creation - useed for serialization + public static void addTagsForType(RecipeBookType type, String openTag, String filteringTag) { -+ f_12725_.put(type, Pair.of(openTag, filteringTag)); ++ TAG_FIELDS.put(type, Pair.of(openTag, filteringTag)); + } static final class TypeSettings { - boolean f_12766_; - boolean f_12767_; + boolean open; + boolean filtering; diff --git a/patches/minecraft/net/minecraft/stats/ServerRecipeBook.java.patch b/patches/minecraft/net/minecraft/stats/ServerRecipeBook.java.patch index 33887e56..ea72e5fe 100644 --- a/patches/minecraft/net/minecraft/stats/ServerRecipeBook.java.patch +++ b/patches/minecraft/net/minecraft/stats/ServerRecipeBook.java.patch @@ -3,17 +3,17 @@ @@ -29,7 +_,7 @@ for(Recipe recipe : p_12792_) { - ResourceLocation resourcelocation = recipe.m_6423_(); -- if (!this.f_12680_.contains(resourcelocation) && !recipe.m_5598_()) { -+ if (!this.f_12680_.contains(resourcelocation) && !recipe.m_5598_() && org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handlePlayerRecipeListUpdateEvent(p_12793_, resourcelocation)) { // CraftBukkit - this.m_12702_(resourcelocation); - this.m_12719_(resourcelocation); + ResourceLocation resourcelocation = recipe.getId(); +- if (!this.known.contains(resourcelocation) && !recipe.isSpecial()) { ++ if (!this.known.contains(resourcelocation) && !recipe.isSpecial() && org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handlePlayerRecipeListUpdateEvent(p_12793_, resourcelocation)) { // CraftBukkit + this.add(resourcelocation); + this.addHighlight(resourcelocation); list.add(resourcelocation); @@ -60,6 +_,7 @@ } - private void m_12801_(ClientboundRecipePacket.State p_12802_, ServerPlayer p_12803_, List p_12804_) { -+ if (p_12803_.f_8906_ == null) return; // SPIGOT-4478 during PlayerLoginEvent - p_12803_.f_8906_.m_141995_(new ClientboundRecipePacket(p_12802_, p_12804_, Collections.emptyList(), this.m_12684_())); + private void sendRecipes(ClientboundRecipePacket.State p_12802_, ServerPlayer p_12803_, List p_12804_) { ++ if (p_12803_.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent + p_12803_.connection.send(new ClientboundRecipePacket(p_12802_, p_12804_, Collections.emptyList(), this.getBookSettings())); } diff --git a/patches/minecraft/net/minecraft/stats/ServerStatsCounter.java.patch b/patches/minecraft/net/minecraft/stats/ServerStatsCounter.java.patch index e0cb89b1..c172c088 100644 --- a/patches/minecraft/net/minecraft/stats/ServerStatsCounter.java.patch +++ b/patches/minecraft/net/minecraft/stats/ServerStatsCounter.java.patch @@ -2,31 +2,31 @@ +++ b/net/minecraft/stats/ServerStatsCounter.java @@ -43,6 +_,13 @@ public ServerStatsCounter(MinecraftServer p_12816_, File p_12817_) { - this.f_12810_ = p_12816_; - this.f_12811_ = p_12817_; + this.server = p_12816_; + this.file = p_12817_; + // Spigot start + for ( Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet() ) + { -+ Stat wrapper = Stats.f_12988_.m_12902_( entry.getKey() ); -+ this.f_13013_.put( wrapper, entry.getValue().intValue() ); ++ Stat wrapper = Stats.CUSTOM.get( entry.getKey() ); ++ this.stats.put( wrapper, entry.getValue().intValue() ); + } + // Spigot end if (p_12817_.isFile()) { try { - this.m_12832_(p_12816_.m_129933_(), FileUtils.readFileToString(p_12817_)); + this.parseLocal(p_12816_.getFixerUpper(), FileUtils.readFileToString(p_12817_)); @@ -56,6 +_,7 @@ } - public void m_12818_() { + public void save() { + if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot try { - FileUtils.writeStringToFile(this.f_12811_, this.m_12845_()); + FileUtils.writeStringToFile(this.file, this.toJson()); } catch (IOException ioexception) { @@ -65,6 +_,7 @@ } - public void m_6085_(Player p_12827_, Stat p_12828_, int p_12829_) { + public void setValue(Player p_12827_, Stat p_12828_, int p_12829_) { + if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot - super.m_6085_(p_12827_, p_12828_, p_12829_); - this.f_12812_.add(p_12828_); + super.setValue(p_12827_, p_12828_, p_12829_); + this.dirty.add(p_12828_); } diff --git a/patches/minecraft/net/minecraft/stats/StatType.java.patch b/patches/minecraft/net/minecraft/stats/StatType.java.patch index 03f6652d..4cbb31ce 100644 --- a/patches/minecraft/net/minecraft/stats/StatType.java.patch +++ b/patches/minecraft/net/minecraft/stats/StatType.java.patch @@ -6,6 +6,6 @@ -public class StatType implements Iterable> { +public class StatType extends net.minecraftforge.registries.ForgeRegistryEntry> implements Iterable> { - private final Registry f_12888_; - private final Map> f_12889_ = new IdentityHashMap<>(); + private final Registry registry; + private final Map> map = new IdentityHashMap<>(); @Nullable diff --git a/patches/minecraft/net/minecraft/stats/StatsCounter.java.patch b/patches/minecraft/net/minecraft/stats/StatsCounter.java.patch index ad18ab69..52ef8508 100644 --- a/patches/minecraft/net/minecraft/stats/StatsCounter.java.patch +++ b/patches/minecraft/net/minecraft/stats/StatsCounter.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/stats/StatsCounter.java @@ -14,6 +_,14 @@ - public void m_13023_(Player p_13024_, Stat p_13025_, int p_13026_) { - int i = (int)Math.min((long)this.m_13015_(p_13025_) + (long)p_13026_, 2147483647L); + public void increment(Player p_13024_, Stat p_13025_, int p_13026_) { + int i = (int)Math.min((long)this.getValue(p_13025_) + (long)p_13026_, 2147483647L); + + // CraftBukkit start - fire Statistic events -+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleStatisticsIncrease(p_13024_, p_13025_, this.m_13015_(p_13025_), i); ++ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleStatisticsIncrease(p_13024_, p_13025_, this.getValue(p_13025_), i); + if (cancellable != null && cancellable.isCancelled()) { + return; + } + // CraftBukkit end + - this.m_6085_(p_13024_, p_13025_, i); + this.setValue(p_13024_, p_13025_, i); } diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index e03c797a..65e08f51 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java @@ -145,4 +_,8 @@ - private static TagKey m_203846_(String p_203847_) { - return TagKey.m_203882_(Registry.f_122901_, new ResourceLocation(p_203847_)); + private static TagKey create(String p_203847_) { + return TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(p_203847_)); } + + public static TagKey create(ResourceLocation name) { -+ return TagKey.m_203882_(Registry.f_122901_, name); ++ return TagKey.create(Registry.BLOCK_REGISTRY, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch index c6601f56..2cdeff69 100644 --- a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/tags/FluidTags.java +++ b/net/minecraft/tags/FluidTags.java @@ -14,4 +_,8 @@ - private static TagKey m_203850_(String p_203851_) { - return TagKey.m_203882_(Registry.f_122899_, new ResourceLocation(p_203851_)); + private static TagKey create(String p_203851_) { + return TagKey.create(Registry.FLUID_REGISTRY, new ResourceLocation(p_203851_)); } + + public static TagKey create(ResourceLocation name) { -+ return TagKey.m_203882_(Registry.f_122899_, name); ++ return TagKey.create(Registry.FLUID_REGISTRY, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index bce41f12..df539a4d 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java @@ -83,4 +_,8 @@ - private static TagKey m_203854_(String p_203855_) { - return TagKey.m_203882_(Registry.f_122904_, new ResourceLocation(p_203855_)); + private static TagKey bind(String p_203855_) { + return TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(p_203855_)); } + + public static TagKey create(final ResourceLocation name) { -+ return TagKey.m_203882_(Registry.f_122904_, name); ++ return TagKey.create(Registry.ITEM_REGISTRY, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/Tag.java.patch b/patches/minecraft/net/minecraft/tags/Tag.java.patch index 616c8621..61b11ba2 100644 --- a/patches/minecraft/net/minecraft/tags/Tag.java.patch +++ b/patches/minecraft/net/minecraft/tags/Tag.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/tags/Tag.java +++ b/net/minecraft/tags/Tag.java @@ -31,8 +_,16 @@ - return (Tag)f_203856_; + return (Tag)EMPTY; } - public static class Builder { @@ -13,13 +13,13 @@ + this.removeEntries.add(proxy); + return this; + } - private final List f_13302_ = new ArrayList<>(); + private final List entries = new ArrayList<>(); + private boolean replace = false; - public static Tag.Builder m_13304_() { + public static Tag.Builder tag() { return new Tag.Builder(); @@ -63,6 +_,15 @@ - return this.m_13307_(new Tag.OptionalTagEntry(p_144383_), p_144384_); + return this.add(new Tag.OptionalTagEntry(p_144383_), p_144384_); } + public Tag.Builder replace(boolean value) { @@ -31,19 +31,19 @@ + return replace(true); + } + - public Either, Tag> m_144371_(Function> p_144372_, Function p_144373_) { + public Either, Tag> build(Function> p_144372_, Function p_144373_) { ImmutableSet.Builder builder = ImmutableSet.builder(); List list = new ArrayList<>(); @@ -104,6 +_,7 @@ - this.f_13302_.clear(); + this.entries.clear(); } -+ net.minecraftforge.common.ForgeHooks.deserializeTagAdditions(list, p_13313_, f_13302_); ++ net.minecraftforge.common.ForgeHooks.deserializeTagAdditions(list, p_13313_, entries); list.forEach((p_13319_) -> { - this.f_13302_.add(new Tag.BuilderEntry(p_13319_, p_13314_)); + this.entries.add(new Tag.BuilderEntry(p_13319_, p_13314_)); }); @@ -139,8 +_,9 @@ - tag$builderentry.f_13338_().m_6383_(jsonarray); + tag$builderentry.entry().serializeTo(jsonarray); } - jsonobject.addProperty("replace", false); @@ -55,18 +55,18 @@ } @@ -179,6 +_,7 @@ public String toString() { - return this.f_13349_.toString(); + return this.id.toString(); } -+ @Override public boolean equals(Object o) { return o == this || (o instanceof Tag.ElementEntry && java.util.Objects.equals(this.f_13349_, ((Tag.ElementEntry) o).f_13349_)); } ++ @Override public boolean equals(Object o) { return o == this || (o instanceof Tag.ElementEntry && java.util.Objects.equals(this.id, ((Tag.ElementEntry) o).id)); } } public interface Entry { @@ -287,6 +_,8 @@ public String toString() { - return "#" + this.f_13383_; + return "#" + this.id; } -+ @Override public boolean equals(Object o) { return o == this || (o instanceof Tag.TagEntry && java.util.Objects.equals(this.f_13383_, ((Tag.TagEntry) o).f_13383_)); } -+ public ResourceLocation getId() { return f_13383_; } ++ @Override public boolean equals(Object o) { return o == this || (o instanceof Tag.TagEntry && java.util.Objects.equals(this.id, ((Tag.TagEntry) o).id)); } ++ public ResourceLocation getId() { return id; } - public boolean m_142746_(Predicate p_144404_, Predicate p_144405_) { - return p_144405_.test(this.f_13383_); + public boolean verifyIfPresent(Predicate p_144404_, Predicate p_144405_) { + return p_144405_.test(this.id); diff --git a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch index 6509e763..7341805f 100644 --- a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/tags/TagLoader.java @@ -156,7 +_,7 @@ p_203899_.keySet().forEach((p_144522_) -> { - m_144523_(p_203899_, multimap, set, p_144522_, (p_144537_, p_144538_) -> { - p_144538_.m_144371_(function, function1).ifLeft((p_144543_) -> { -- f_13445_.error("Couldn't load tag {} as it is missing following references: {}", p_144537_, p_144543_.stream().map(Objects::toString).collect(Collectors.joining(", "))); -+ f_13445_.error("Couldn't load tag {} as it is missing following references: {}", p_144537_, p_144543_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t"))); + visitDependenciesAndElement(p_203899_, multimap, set, p_144522_, (p_144537_, p_144538_) -> { + p_144538_.build(function, function1).ifLeft((p_144543_) -> { +- LOGGER.error("Couldn't load tag {} as it is missing following references: {}", p_144537_, p_144543_.stream().map(Objects::toString).collect(Collectors.joining(", "))); ++ LOGGER.error("Couldn't load tag {} as it is missing following references: {}", p_144537_, p_144543_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t"))); }).ifRight((p_144532_) -> { map.put(p_144537_, p_144532_); }); diff --git a/patches/minecraft/net/minecraft/tags/TagManager.java.patch b/patches/minecraft/net/minecraft/tags/TagManager.java.patch index 97e57d98..645d9236 100644 --- a/patches/minecraft/net/minecraft/tags/TagManager.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagManager.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/tags/TagManager.java @@ -29,7 +_,8 @@ - public static String m_203918_(ResourceKey> p_203919_) { - String s = f_203902_.get(p_203919_); -- return s != null ? s : "tags/" + p_203919_.m_135782_().m_135815_(); -+ ResourceLocation registryName = p_203919_.m_135782_(); -+ return s != null ? s : "tags/" + (registryName.m_135827_().equals("minecraft") ? "" : registryName.m_135827_() + "/") + registryName.m_135815_(); + public static String getTagDir(ResourceKey> p_203919_) { + String s = CUSTOM_REGISTRY_DIRECTORIES.get(p_203919_); +- return s != null ? s : "tags/" + p_203919_.location().getPath(); ++ ResourceLocation registryName = p_203919_.location(); ++ return s != null ? s : "tags/" + (registryName.getNamespace().equals("minecraft") ? "" : registryName.getNamespace() + "/") + registryName.getPath(); } - public CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_13482_, ResourceManager p_13483_, ProfilerFiller p_13484_, ProfilerFiller p_13485_, Executor p_13486_, Executor p_13487_) { + public CompletableFuture reload(PreparableReloadListener.PreparationBarrier p_13482_, ResourceManager p_13483_, ProfilerFiller p_13484_, ProfilerFiller p_13485_, Executor p_13486_, Executor p_13487_) { diff --git a/patches/minecraft/net/minecraft/util/datafix/DataFixers.java.patch b/patches/minecraft/net/minecraft/util/datafix/DataFixers.java.patch index 6e6abefc..b4fa5cfd 100644 --- a/patches/minecraft/net/minecraft/util/datafix/DataFixers.java.patch +++ b/patches/minecraft/net/minecraft/util/datafix/DataFixers.java.patch @@ -4,61 +4,61 @@ import net.minecraft.util.datafix.schemas.V99; public class DataFixers { -- private static final BiFunction f_14508_ = Schema::new; -- private static final BiFunction f_14509_ = NamespacedSchema::new; -- private static final DataFixer f_14510_ = m_14529_(); +- private static final BiFunction SAME = Schema::new; +- private static final BiFunction SAME_NAMESPACED = NamespacedSchema::new; +- private static final DataFixer DATA_FIXER = createFixerUpper(); - -- private static DataFixer m_14529_() { -- DataFixerBuilder datafixerbuilder = new DataFixerBuilder(SharedConstants.m_183709_().getWorldVersion()); -- m_14513_(datafixerbuilder); -- return datafixerbuilder.build(Util.m_183988_()); +- private static DataFixer createFixerUpper() { +- DataFixerBuilder datafixerbuilder = new DataFixerBuilder(SharedConstants.getCurrentVersion().getWorldVersion()); +- addFixers(datafixerbuilder); +- return datafixerbuilder.build(Util.bootstrapExecutor()); - } - -- public static DataFixer m_14512_() { -- return f_14510_; +- public static DataFixer getDataFixer() { +- return DATA_FIXER; - } - -- private static void m_14513_(DataFixerBuilder p_14514_) { +- private static void addFixers(DataFixerBuilder p_14514_) { - Schema schema = p_14514_.addSchema(99, V99::new); - Schema schema1 = p_14514_.addSchema(100, V100::new); - p_14514_.addFixer(new EntityEquipmentToArmorAndHandFix(schema1, true)); -- Schema schema2 = p_14514_.addSchema(101, f_14508_); +- Schema schema2 = p_14514_.addSchema(101, SAME); - p_14514_.addFixer(new BlockEntitySignTextStrictJsonFix(schema2, false)); - Schema schema3 = p_14514_.addSchema(102, V102::new); - p_14514_.addFixer(new ItemIdFix(schema3, true)); - p_14514_.addFixer(new ItemPotionFix(schema3, false)); -- Schema schema4 = p_14514_.addSchema(105, f_14508_); +- Schema schema4 = p_14514_.addSchema(105, SAME); - p_14514_.addFixer(new ItemSpawnEggFix(schema4, true)); - Schema schema5 = p_14514_.addSchema(106, V106::new); - p_14514_.addFixer(new MobSpawnerEntityIdentifiersFix(schema5, true)); - Schema schema6 = p_14514_.addSchema(107, V107::new); - p_14514_.addFixer(new EntityMinecartIdentifiersFix(schema6, true)); -- Schema schema7 = p_14514_.addSchema(108, f_14508_); +- Schema schema7 = p_14514_.addSchema(108, SAME); - p_14514_.addFixer(new EntityStringUuidFix(schema7, true)); -- Schema schema8 = p_14514_.addSchema(109, f_14508_); +- Schema schema8 = p_14514_.addSchema(109, SAME); - p_14514_.addFixer(new EntityHealthFix(schema8, true)); -- Schema schema9 = p_14514_.addSchema(110, f_14508_); +- Schema schema9 = p_14514_.addSchema(110, SAME); - p_14514_.addFixer(new EntityHorseSaddleFix(schema9, true)); -- Schema schema10 = p_14514_.addSchema(111, f_14508_); +- Schema schema10 = p_14514_.addSchema(111, SAME); - p_14514_.addFixer(new EntityPaintingItemFrameDirectionFix(schema10, true)); -- Schema schema11 = p_14514_.addSchema(113, f_14508_); +- Schema schema11 = p_14514_.addSchema(113, SAME); - p_14514_.addFixer(new EntityRedundantChanceTagsFix(schema11, true)); - Schema schema12 = p_14514_.addSchema(135, V135::new); - p_14514_.addFixer(new EntityRidingToPassengersFix(schema12, true)); - Schema schema13 = p_14514_.addSchema(143, V143::new); - p_14514_.addFixer(new EntityTippedArrowFix(schema13, true)); -- Schema schema14 = p_14514_.addSchema(147, f_14508_); +- Schema schema14 = p_14514_.addSchema(147, SAME); - p_14514_.addFixer(new EntityArmorStandSilentFix(schema14, true)); -- Schema schema15 = p_14514_.addSchema(165, f_14508_); +- Schema schema15 = p_14514_.addSchema(165, SAME); - p_14514_.addFixer(new ItemWrittenBookPagesStrictJsonFix(schema15, true)); - Schema schema16 = p_14514_.addSchema(501, V501::new); -- p_14514_.addFixer(new AddNewChoices(schema16, "Add 1.10 entities fix", References.f_16786_)); -- Schema schema17 = p_14514_.addSchema(502, f_14508_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema17, "cooked_fished item renamer", (p_14533_) -> { -- return Objects.equals(NamespacedSchema.m_17311_(p_14533_), "minecraft:cooked_fished") ? "minecraft:cooked_fish" : p_14533_; +- p_14514_.addFixer(new AddNewChoices(schema16, "Add 1.10 entities fix", References.ENTITY)); +- Schema schema17 = p_14514_.addSchema(502, SAME); +- p_14514_.addFixer(ItemRenameFix.create(schema17, "cooked_fished item renamer", (p_14533_) -> { +- return Objects.equals(NamespacedSchema.ensureNamespaced(p_14533_), "minecraft:cooked_fished") ? "minecraft:cooked_fish" : p_14533_; - })); - p_14514_.addFixer(new EntityZombieVillagerTypeFix(schema17, false)); -- Schema schema18 = p_14514_.addSchema(505, f_14508_); +- Schema schema18 = p_14514_.addSchema(505, SAME); - p_14514_.addFixer(new OptionsForceVBOFix(schema18, false)); - Schema schema19 = p_14514_.addSchema(700, V700::new); - p_14514_.addFixer(new EntityElderGuardianSplitFix(schema19, true)); @@ -72,34 +72,34 @@ - p_14514_.addFixer(new BlockEntityIdFix(schema23, true)); - Schema schema24 = p_14514_.addSchema(705, V705::new); - p_14514_.addFixer(new EntityIdFix(schema24, true)); -- Schema schema25 = p_14514_.addSchema(804, f_14509_); +- Schema schema25 = p_14514_.addSchema(804, SAME_NAMESPACED); - p_14514_.addFixer(new ItemBannerColorFix(schema25, true)); -- Schema schema26 = p_14514_.addSchema(806, f_14509_); +- Schema schema26 = p_14514_.addSchema(806, SAME_NAMESPACED); - p_14514_.addFixer(new ItemWaterPotionFix(schema26, false)); - Schema schema27 = p_14514_.addSchema(808, V808::new); -- p_14514_.addFixer(new AddNewChoices(schema27, "added shulker box", References.f_16781_)); -- Schema schema28 = p_14514_.addSchema(808, 1, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema27, "added shulker box", References.BLOCK_ENTITY)); +- Schema schema28 = p_14514_.addSchema(808, 1, SAME_NAMESPACED); - p_14514_.addFixer(new EntityShulkerColorFix(schema28, false)); -- Schema schema29 = p_14514_.addSchema(813, f_14509_); +- Schema schema29 = p_14514_.addSchema(813, SAME_NAMESPACED); - p_14514_.addFixer(new ItemShulkerBoxColorFix(schema29, false)); - p_14514_.addFixer(new BlockEntityShulkerBoxColorFix(schema29, false)); -- Schema schema30 = p_14514_.addSchema(816, f_14509_); +- Schema schema30 = p_14514_.addSchema(816, SAME_NAMESPACED); - p_14514_.addFixer(new OptionsLowerCaseLanguageFix(schema30, false)); -- Schema schema31 = p_14514_.addSchema(820, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema31, "totem item renamer", m_14517_("minecraft:totem", "minecraft:totem_of_undying"))); +- Schema schema31 = p_14514_.addSchema(820, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema31, "totem item renamer", createRenamer("minecraft:totem", "minecraft:totem_of_undying"))); - Schema schema32 = p_14514_.addSchema(1022, V1022::new); -- p_14514_.addFixer(new WriteAndReadFix(schema32, "added shoulder entities to players", References.f_16772_)); +- p_14514_.addFixer(new WriteAndReadFix(schema32, "added shoulder entities to players", References.PLAYER)); - Schema schema33 = p_14514_.addSchema(1125, V1125::new); - p_14514_.addFixer(new ChunkBedBlockEntityInjecterFix(schema33, true)); - p_14514_.addFixer(new BedItemColorFix(schema33, false)); -- Schema schema34 = p_14514_.addSchema(1344, f_14509_); +- Schema schema34 = p_14514_.addSchema(1344, SAME_NAMESPACED); - p_14514_.addFixer(new OptionsKeyLwjgl3Fix(schema34, false)); -- Schema schema35 = p_14514_.addSchema(1446, f_14509_); +- Schema schema35 = p_14514_.addSchema(1446, SAME_NAMESPACED); - p_14514_.addFixer(new OptionsKeyTranslationFix(schema35, false)); -- Schema schema36 = p_14514_.addSchema(1450, f_14509_); +- Schema schema36 = p_14514_.addSchema(1450, SAME_NAMESPACED); - p_14514_.addFixer(new BlockStateStructureTemplateFix(schema36, false)); - Schema schema37 = p_14514_.addSchema(1451, V1451::new); -- p_14514_.addFixer(new AddNewChoices(schema37, "AddTrappedChestFix", References.f_16781_)); +- p_14514_.addFixer(new AddNewChoices(schema37, "AddTrappedChestFix", References.BLOCK_ENTITY)); - Schema schema38 = p_14514_.addSchema(1451, 1, V1451_1::new); - p_14514_.addFixer(new ChunkPalettedStorageFix(schema38, true)); - Schema schema39 = p_14514_.addSchema(1451, 2, V1451_2::new); @@ -111,22 +111,22 @@ - p_14514_.addFixer(new BlockNameFlatteningFix(schema41, true)); - p_14514_.addFixer(new ItemStackTheFlatteningFix(schema41, false)); - Schema schema42 = p_14514_.addSchema(1451, 5, V1451_5::new); -- p_14514_.addFixer(new AddNewChoices(schema42, "RemoveNoteBlockFlowerPotFix", References.f_16781_)); +- p_14514_.addFixer(new AddNewChoices(schema42, "RemoveNoteBlockFlowerPotFix", References.BLOCK_ENTITY)); - p_14514_.addFixer(new ItemStackSpawnEggFix(schema42, false)); - p_14514_.addFixer(new EntityWolfColorFix(schema42, false)); - p_14514_.addFixer(new BlockEntityBannerColorFix(schema42, false)); - p_14514_.addFixer(new LevelFlatGeneratorInfoFix(schema42, false)); - Schema schema43 = p_14514_.addSchema(1451, 6, V1451_6::new); - p_14514_.addFixer(new StatsCounterFix(schema43, true)); -- p_14514_.addFixer(new WriteAndReadFix(schema43, "Rewrite objectives", References.f_16791_)); +- p_14514_.addFixer(new WriteAndReadFix(schema43, "Rewrite objectives", References.OBJECTIVE)); - p_14514_.addFixer(new BlockEntityJukeboxFix(schema43, false)); - Schema schema44 = p_14514_.addSchema(1451, 7, V1451_7::new); - p_14514_.addFixer(new SavedDataVillageCropFix(schema44, true)); -- Schema schema45 = p_14514_.addSchema(1451, 7, f_14509_); +- Schema schema45 = p_14514_.addSchema(1451, 7, SAME_NAMESPACED); - p_14514_.addFixer(new VillagerTradeFix(schema45, false)); -- Schema schema46 = p_14514_.addSchema(1456, f_14509_); +- Schema schema46 = p_14514_.addSchema(1456, SAME_NAMESPACED); - p_14514_.addFixer(new EntityItemFrameDirectionFix(schema46, false)); -- Schema schema47 = p_14514_.addSchema(1458, f_14509_); +- Schema schema47 = p_14514_.addSchema(1458, SAME_NAMESPACED); - p_14514_.addFixer(new EntityCustomNameToComponentFix(schema47, false)); - p_14514_.addFixer(new ItemCustomNameToComponentFix(schema47, false)); - p_14514_.addFixer(new BlockEntityCustomNameToComponentFix(schema47, false)); @@ -135,351 +135,351 @@ - Schema schema49 = p_14514_.addSchema(1466, V1466::new); - p_14514_.addFixer(new ChunkToProtochunkFix(schema49, true)); - Schema schema50 = p_14514_.addSchema(1470, V1470::new); -- p_14514_.addFixer(new AddNewChoices(schema50, "Add 1.13 entities fix", References.f_16786_)); -- Schema schema51 = p_14514_.addSchema(1474, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema50, "Add 1.13 entities fix", References.ENTITY)); +- Schema schema51 = p_14514_.addSchema(1474, SAME_NAMESPACED); - p_14514_.addFixer(new ColorlessShulkerEntityFix(schema51, false)); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema51, "Colorless shulker block fixer", (p_14531_) -> { -- return Objects.equals(NamespacedSchema.m_17311_(p_14531_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14531_; +- p_14514_.addFixer(BlockRenameFix.create(schema51, "Colorless shulker block fixer", (p_14531_) -> { +- return Objects.equals(NamespacedSchema.ensureNamespaced(p_14531_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14531_; - })); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema51, "Colorless shulker item fixer", (p_14516_) -> { -- return Objects.equals(NamespacedSchema.m_17311_(p_14516_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14516_; +- p_14514_.addFixer(ItemRenameFix.create(schema51, "Colorless shulker item fixer", (p_14516_) -> { +- return Objects.equals(NamespacedSchema.ensureNamespaced(p_14516_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14516_; - })); -- Schema schema52 = p_14514_.addSchema(1475, f_14509_); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema52, "Flowing fixer", m_14524_(ImmutableMap.of("minecraft:flowing_water", "minecraft:water", "minecraft:flowing_lava", "minecraft:lava")))); -- Schema schema53 = p_14514_.addSchema(1480, f_14509_); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema53, "Rename coral blocks", m_14524_(RenamedCoralFix.f_16850_))); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema53, "Rename coral items", m_14524_(RenamedCoralFix.f_16850_))); +- Schema schema52 = p_14514_.addSchema(1475, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFix.create(schema52, "Flowing fixer", createRenamer(ImmutableMap.of("minecraft:flowing_water", "minecraft:water", "minecraft:flowing_lava", "minecraft:lava")))); +- Schema schema53 = p_14514_.addSchema(1480, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFix.create(schema53, "Rename coral blocks", createRenamer(RenamedCoralFix.RENAMED_IDS))); +- p_14514_.addFixer(ItemRenameFix.create(schema53, "Rename coral items", createRenamer(RenamedCoralFix.RENAMED_IDS))); - Schema schema54 = p_14514_.addSchema(1481, V1481::new); -- p_14514_.addFixer(new AddNewChoices(schema54, "Add conduit", References.f_16781_)); +- p_14514_.addFixer(new AddNewChoices(schema54, "Add conduit", References.BLOCK_ENTITY)); - Schema schema55 = p_14514_.addSchema(1483, V1483::new); - p_14514_.addFixer(new EntityPufferfishRenameFix(schema55, true)); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema55, "Rename pufferfish egg item", m_14524_(EntityPufferfishRenameFix.f_15584_))); -- Schema schema56 = p_14514_.addSchema(1484, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema56, "Rename seagrass items", m_14524_(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema56, "Rename seagrass blocks", m_14524_(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); +- p_14514_.addFixer(ItemRenameFix.create(schema55, "Rename pufferfish egg item", createRenamer(EntityPufferfishRenameFix.RENAMED_IDS))); +- Schema schema56 = p_14514_.addSchema(1484, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema56, "Rename seagrass items", createRenamer(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); +- p_14514_.addFixer(BlockRenameFix.create(schema56, "Rename seagrass blocks", createRenamer(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); - p_14514_.addFixer(new HeightmapRenamingFix(schema56, false)); - Schema schema57 = p_14514_.addSchema(1486, V1486::new); - p_14514_.addFixer(new EntityCodSalmonFix(schema57, true)); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema57, "Rename cod/salmon egg items", m_14524_(EntityCodSalmonFix.f_15390_))); -- Schema schema58 = p_14514_.addSchema(1487, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema58, "Rename prismarine_brick(s)_* blocks", m_14524_(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema58, "Rename prismarine_brick(s)_* items", m_14524_(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); -- Schema schema59 = p_14514_.addSchema(1488, f_14509_); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema59, "Rename kelp/kelptop", m_14524_(ImmutableMap.of("minecraft:kelp_top", "minecraft:kelp", "minecraft:kelp", "minecraft:kelp_plant")))); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema59, "Rename kelptop", m_14517_("minecraft:kelp_top", "minecraft:kelp"))); -- p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block block entity custom name fix", References.f_16781_, "minecraft:command_block") { -- protected Typed m_7504_(Typed p_14541_) { -- return p_14541_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::m_15407_); +- p_14514_.addFixer(ItemRenameFix.create(schema57, "Rename cod/salmon egg items", createRenamer(EntityCodSalmonFix.RENAMED_EGG_IDS))); +- Schema schema58 = p_14514_.addSchema(1487, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema58, "Rename prismarine_brick(s)_* blocks", createRenamer(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); +- p_14514_.addFixer(BlockRenameFix.create(schema58, "Rename prismarine_brick(s)_* items", createRenamer(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); +- Schema schema59 = p_14514_.addSchema(1488, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFix.create(schema59, "Rename kelp/kelptop", createRenamer(ImmutableMap.of("minecraft:kelp_top", "minecraft:kelp", "minecraft:kelp", "minecraft:kelp_plant")))); +- p_14514_.addFixer(ItemRenameFix.create(schema59, "Rename kelptop", createRenamer("minecraft:kelp_top", "minecraft:kelp"))); +- p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block block entity custom name fix", References.BLOCK_ENTITY, "minecraft:command_block") { +- protected Typed fix(Typed p_14541_) { +- return p_14541_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::fixTagCustomName); - } - }); -- p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block minecart custom name fix", References.f_16786_, "minecraft:commandblock_minecart") { -- protected Typed m_7504_(Typed p_14549_) { -- return p_14549_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::m_15407_); +- p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block minecart custom name fix", References.ENTITY, "minecraft:commandblock_minecart") { +- protected Typed fix(Typed p_14549_) { +- return p_14549_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::fixTagCustomName); - } - }); - p_14514_.addFixer(new IglooMetadataRemovalFix(schema59, false)); -- Schema schema60 = p_14514_.addSchema(1490, f_14509_); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema60, "Rename melon_block", m_14517_("minecraft:melon_block", "minecraft:melon"))); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema60, "Rename melon_block/melon/speckled_melon", m_14524_(ImmutableMap.of("minecraft:melon_block", "minecraft:melon", "minecraft:melon", "minecraft:melon_slice", "minecraft:speckled_melon", "minecraft:glistering_melon_slice")))); -- Schema schema61 = p_14514_.addSchema(1492, f_14509_); +- Schema schema60 = p_14514_.addSchema(1490, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFix.create(schema60, "Rename melon_block", createRenamer("minecraft:melon_block", "minecraft:melon"))); +- p_14514_.addFixer(ItemRenameFix.create(schema60, "Rename melon_block/melon/speckled_melon", createRenamer(ImmutableMap.of("minecraft:melon_block", "minecraft:melon", "minecraft:melon", "minecraft:melon_slice", "minecraft:speckled_melon", "minecraft:glistering_melon_slice")))); +- Schema schema61 = p_14514_.addSchema(1492, SAME_NAMESPACED); - p_14514_.addFixer(new ChunkStructuresTemplateRenameFix(schema61, false)); -- Schema schema62 = p_14514_.addSchema(1494, f_14509_); +- Schema schema62 = p_14514_.addSchema(1494, SAME_NAMESPACED); - p_14514_.addFixer(new ItemStackEnchantmentNamesFix(schema62, false)); -- Schema schema63 = p_14514_.addSchema(1496, f_14509_); +- Schema schema63 = p_14514_.addSchema(1496, SAME_NAMESPACED); - p_14514_.addFixer(new LeavesFix(schema63, false)); -- Schema schema64 = p_14514_.addSchema(1500, f_14509_); +- Schema schema64 = p_14514_.addSchema(1500, SAME_NAMESPACED); - p_14514_.addFixer(new BlockEntityKeepPacked(schema64, false)); -- Schema schema65 = p_14514_.addSchema(1501, f_14509_); +- Schema schema65 = p_14514_.addSchema(1501, SAME_NAMESPACED); - p_14514_.addFixer(new AdvancementsFix(schema65, false)); -- Schema schema66 = p_14514_.addSchema(1502, f_14509_); +- Schema schema66 = p_14514_.addSchema(1502, SAME_NAMESPACED); - p_14514_.addFixer(new RecipesFix(schema66, false)); -- Schema schema67 = p_14514_.addSchema(1506, f_14509_); +- Schema schema67 = p_14514_.addSchema(1506, SAME_NAMESPACED); - p_14514_.addFixer(new LevelDataGeneratorOptionsFix(schema67, false)); - Schema schema68 = p_14514_.addSchema(1510, V1510::new); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema68, "Block renamening fix", m_14524_(EntityTheRenameningFix.f_15702_))); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema68, "Item renamening fix", m_14524_(EntityTheRenameningFix.f_15703_))); +- p_14514_.addFixer(BlockRenameFix.create(schema68, "Block renamening fix", createRenamer(EntityTheRenameningFix.RENAMED_BLOCKS))); +- p_14514_.addFixer(ItemRenameFix.create(schema68, "Item renamening fix", createRenamer(EntityTheRenameningFix.RENAMED_ITEMS))); - p_14514_.addFixer(new RecipesRenameningFix(schema68, false)); - p_14514_.addFixer(new EntityTheRenameningFix(schema68, true)); - p_14514_.addFixer(new StatsRenameFix(schema68, "SwimStatsRenameFix", ImmutableMap.of("minecraft:swim_one_cm", "minecraft:walk_on_water_one_cm", "minecraft:dive_one_cm", "minecraft:walk_under_water_one_cm"))); -- Schema schema69 = p_14514_.addSchema(1514, f_14509_); +- Schema schema69 = p_14514_.addSchema(1514, SAME_NAMESPACED); - p_14514_.addFixer(new ObjectiveDisplayNameFix(schema69, false)); - p_14514_.addFixer(new TeamDisplayNameFix(schema69, false)); - p_14514_.addFixer(new ObjectiveRenderTypeFix(schema69, false)); -- Schema schema70 = p_14514_.addSchema(1515, f_14509_); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema70, "Rename coral fan blocks", m_14524_(RenamedCoralFansFix.f_16848_))); -- Schema schema71 = p_14514_.addSchema(1624, f_14509_); +- Schema schema70 = p_14514_.addSchema(1515, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFix.create(schema70, "Rename coral fan blocks", createRenamer(RenamedCoralFansFix.RENAMED_IDS))); +- Schema schema71 = p_14514_.addSchema(1624, SAME_NAMESPACED); - p_14514_.addFixer(new TrappedChestBlockEntityFix(schema71, false)); - Schema schema72 = p_14514_.addSchema(1800, V1800::new); -- p_14514_.addFixer(new AddNewChoices(schema72, "Added 1.14 mobs fix", References.f_16786_)); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema72, "Rename dye items", m_14524_(DyeItemRenameFix.f_15321_))); +- p_14514_.addFixer(new AddNewChoices(schema72, "Added 1.14 mobs fix", References.ENTITY)); +- p_14514_.addFixer(ItemRenameFix.create(schema72, "Rename dye items", createRenamer(DyeItemRenameFix.RENAMED_IDS))); - Schema schema73 = p_14514_.addSchema(1801, V1801::new); -- p_14514_.addFixer(new AddNewChoices(schema73, "Added Illager Beast", References.f_16786_)); -- Schema schema74 = p_14514_.addSchema(1802, f_14509_); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema74, "Rename sign blocks & stone slabs", m_14524_(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign", "minecraft:wall_sign", "minecraft:oak_wall_sign")))); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema74, "Rename sign item & stone slabs", m_14524_(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign")))); -- Schema schema75 = p_14514_.addSchema(1803, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema73, "Added Illager Beast", References.ENTITY)); +- Schema schema74 = p_14514_.addSchema(1802, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFix.create(schema74, "Rename sign blocks & stone slabs", createRenamer(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign", "minecraft:wall_sign", "minecraft:oak_wall_sign")))); +- p_14514_.addFixer(ItemRenameFix.create(schema74, "Rename sign item & stone slabs", createRenamer(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign")))); +- Schema schema75 = p_14514_.addSchema(1803, SAME_NAMESPACED); - p_14514_.addFixer(new ItemLoreFix(schema75, false)); - Schema schema76 = p_14514_.addSchema(1904, V1904::new); -- p_14514_.addFixer(new AddNewChoices(schema76, "Added Cats", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema76, "Added Cats", References.ENTITY)); - p_14514_.addFixer(new EntityCatSplitFix(schema76, false)); -- Schema schema77 = p_14514_.addSchema(1905, f_14509_); +- Schema schema77 = p_14514_.addSchema(1905, SAME_NAMESPACED); - p_14514_.addFixer(new ChunkStatusFix(schema77, false)); - Schema schema78 = p_14514_.addSchema(1906, V1906::new); -- p_14514_.addFixer(new AddNewChoices(schema78, "Add POI Blocks", References.f_16781_)); +- p_14514_.addFixer(new AddNewChoices(schema78, "Add POI Blocks", References.BLOCK_ENTITY)); - Schema schema79 = p_14514_.addSchema(1909, V1909::new); -- p_14514_.addFixer(new AddNewChoices(schema79, "Add jigsaw", References.f_16781_)); -- Schema schema80 = p_14514_.addSchema(1911, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema79, "Add jigsaw", References.BLOCK_ENTITY)); +- Schema schema80 = p_14514_.addSchema(1911, SAME_NAMESPACED); - p_14514_.addFixer(new ChunkStatusFix2(schema80, false)); -- Schema schema81 = p_14514_.addSchema(1914, f_14509_); +- Schema schema81 = p_14514_.addSchema(1914, SAME_NAMESPACED); - p_14514_.addFixer(new WeaponSmithChestLootTableFix(schema81, false)); -- Schema schema82 = p_14514_.addSchema(1917, f_14509_); +- Schema schema82 = p_14514_.addSchema(1917, SAME_NAMESPACED); - p_14514_.addFixer(new CatTypeFix(schema82, false)); -- Schema schema83 = p_14514_.addSchema(1918, f_14509_); +- Schema schema83 = p_14514_.addSchema(1918, SAME_NAMESPACED); - p_14514_.addFixer(new VillagerDataFix(schema83, "minecraft:villager")); - p_14514_.addFixer(new VillagerDataFix(schema83, "minecraft:zombie_villager")); - Schema schema84 = p_14514_.addSchema(1920, V1920::new); - p_14514_.addFixer(new NewVillageFix(schema84, false)); -- p_14514_.addFixer(new AddNewChoices(schema84, "Add campfire", References.f_16781_)); -- Schema schema85 = p_14514_.addSchema(1925, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema84, "Add campfire", References.BLOCK_ENTITY)); +- Schema schema85 = p_14514_.addSchema(1925, SAME_NAMESPACED); - p_14514_.addFixer(new MapIdFix(schema85, false)); - Schema schema86 = p_14514_.addSchema(1928, V1928::new); - p_14514_.addFixer(new EntityRavagerRenameFix(schema86, true)); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema86, "Rename ravager egg item", m_14524_(EntityRavagerRenameFix.f_15591_))); +- p_14514_.addFixer(ItemRenameFix.create(schema86, "Rename ravager egg item", createRenamer(EntityRavagerRenameFix.RENAMED_IDS))); - Schema schema87 = p_14514_.addSchema(1929, V1929::new); -- p_14514_.addFixer(new AddNewChoices(schema87, "Add Wandering Trader and Trader Llama", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema87, "Add Wandering Trader and Trader Llama", References.ENTITY)); - Schema schema88 = p_14514_.addSchema(1931, V1931::new); -- p_14514_.addFixer(new AddNewChoices(schema88, "Added Fox", References.f_16786_)); -- Schema schema89 = p_14514_.addSchema(1936, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema88, "Added Fox", References.ENTITY)); +- Schema schema89 = p_14514_.addSchema(1936, SAME_NAMESPACED); - p_14514_.addFixer(new OptionsAddTextBackgroundFix(schema89, false)); -- Schema schema90 = p_14514_.addSchema(1946, f_14509_); +- Schema schema90 = p_14514_.addSchema(1946, SAME_NAMESPACED); - p_14514_.addFixer(new ReorganizePoi(schema90, false)); -- Schema schema91 = p_14514_.addSchema(1948, f_14509_); +- Schema schema91 = p_14514_.addSchema(1948, SAME_NAMESPACED); - p_14514_.addFixer(new OminousBannerRenameFix(schema91, false)); -- Schema schema92 = p_14514_.addSchema(1953, f_14509_); +- Schema schema92 = p_14514_.addSchema(1953, SAME_NAMESPACED); - p_14514_.addFixer(new OminousBannerBlockEntityRenameFix(schema92, false)); -- Schema schema93 = p_14514_.addSchema(1955, f_14509_); +- Schema schema93 = p_14514_.addSchema(1955, SAME_NAMESPACED); - p_14514_.addFixer(new VillagerRebuildLevelAndXpFix(schema93, false)); - p_14514_.addFixer(new ZombieVillagerRebuildXpFix(schema93, false)); -- Schema schema94 = p_14514_.addSchema(1961, f_14509_); +- Schema schema94 = p_14514_.addSchema(1961, SAME_NAMESPACED); - p_14514_.addFixer(new ChunkLightRemoveFix(schema94, false)); -- Schema schema95 = p_14514_.addSchema(1963, f_14509_); +- Schema schema95 = p_14514_.addSchema(1963, SAME_NAMESPACED); - p_14514_.addFixer(new RemoveGolemGossipFix(schema95, false)); - Schema schema96 = p_14514_.addSchema(2100, V2100::new); -- p_14514_.addFixer(new AddNewChoices(schema96, "Added Bee and Bee Stinger", References.f_16786_)); -- p_14514_.addFixer(new AddNewChoices(schema96, "Add beehive", References.f_16781_)); -- p_14514_.addFixer(new RecipesRenameFix(schema96, false, "Rename sugar recipe", m_14517_("minecraft:sugar", "sugar_from_sugar_cane"))); -- p_14514_.addFixer(new AdvancementsRenameFix(schema96, false, "Rename sugar recipe advancement", m_14517_("minecraft:recipes/misc/sugar", "minecraft:recipes/misc/sugar_from_sugar_cane"))); -- Schema schema97 = p_14514_.addSchema(2202, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema96, "Added Bee and Bee Stinger", References.ENTITY)); +- p_14514_.addFixer(new AddNewChoices(schema96, "Add beehive", References.BLOCK_ENTITY)); +- p_14514_.addFixer(new RecipesRenameFix(schema96, false, "Rename sugar recipe", createRenamer("minecraft:sugar", "sugar_from_sugar_cane"))); +- p_14514_.addFixer(new AdvancementsRenameFix(schema96, false, "Rename sugar recipe advancement", createRenamer("minecraft:recipes/misc/sugar", "minecraft:recipes/misc/sugar_from_sugar_cane"))); +- Schema schema97 = p_14514_.addSchema(2202, SAME_NAMESPACED); - p_14514_.addFixer(new ChunkBiomeFix(schema97, false)); -- Schema schema98 = p_14514_.addSchema(2209, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema98, "Rename bee_hive item to beehive", m_14517_("minecraft:bee_hive", "minecraft:beehive"))); +- Schema schema98 = p_14514_.addSchema(2209, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema98, "Rename bee_hive item to beehive", createRenamer("minecraft:bee_hive", "minecraft:beehive"))); - p_14514_.addFixer(new BeehivePoiRenameFix(schema98)); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema98, "Rename bee_hive block to beehive", m_14517_("minecraft:bee_hive", "minecraft:beehive"))); -- Schema schema99 = p_14514_.addSchema(2211, f_14509_); +- p_14514_.addFixer(BlockRenameFix.create(schema98, "Rename bee_hive block to beehive", createRenamer("minecraft:bee_hive", "minecraft:beehive"))); +- Schema schema99 = p_14514_.addSchema(2211, SAME_NAMESPACED); - p_14514_.addFixer(new StructureReferenceCountFix(schema99, false)); -- Schema schema100 = p_14514_.addSchema(2218, f_14509_); +- Schema schema100 = p_14514_.addSchema(2218, SAME_NAMESPACED); - p_14514_.addFixer(new ForcePoiRebuild(schema100, false)); - Schema schema101 = p_14514_.addSchema(2501, V2501::new); - p_14514_.addFixer(new FurnaceRecipeFix(schema101, true)); - Schema schema102 = p_14514_.addSchema(2502, V2502::new); -- p_14514_.addFixer(new AddNewChoices(schema102, "Added Hoglin", References.f_16786_)); -- Schema schema103 = p_14514_.addSchema(2503, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema102, "Added Hoglin", References.ENTITY)); +- Schema schema103 = p_14514_.addSchema(2503, SAME_NAMESPACED); - p_14514_.addFixer(new WallPropertyFix(schema103, false)); -- p_14514_.addFixer(new AdvancementsRenameFix(schema103, false, "Composter category change", m_14517_("minecraft:recipes/misc/composter", "minecraft:recipes/decorations/composter"))); +- p_14514_.addFixer(new AdvancementsRenameFix(schema103, false, "Composter category change", createRenamer("minecraft:recipes/misc/composter", "minecraft:recipes/decorations/composter"))); - Schema schema104 = p_14514_.addSchema(2505, V2505::new); -- p_14514_.addFixer(new AddNewChoices(schema104, "Added Piglin", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema104, "Added Piglin", References.ENTITY)); - p_14514_.addFixer(new MemoryExpiryDataFix(schema104, "minecraft:villager")); -- Schema schema105 = p_14514_.addSchema(2508, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema105, "Renamed fungi items to fungus", m_14524_(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema105, "Renamed fungi blocks to fungus", m_14524_(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); +- Schema schema105 = p_14514_.addSchema(2508, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema105, "Renamed fungi items to fungus", createRenamer(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); +- p_14514_.addFixer(BlockRenameFix.create(schema105, "Renamed fungi blocks to fungus", createRenamer(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); - Schema schema106 = p_14514_.addSchema(2509, V2509::new); - p_14514_.addFixer(new EntityZombifiedPiglinRenameFix(schema106)); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema106, "Rename zombie pigman egg item", m_14524_(EntityZombifiedPiglinRenameFix.f_15814_))); -- Schema schema107 = p_14514_.addSchema(2511, f_14509_); +- p_14514_.addFixer(ItemRenameFix.create(schema106, "Rename zombie pigman egg item", createRenamer(EntityZombifiedPiglinRenameFix.RENAMED_IDS))); +- Schema schema107 = p_14514_.addSchema(2511, SAME_NAMESPACED); - p_14514_.addFixer(new EntityProjectileOwnerFix(schema107)); -- Schema schema108 = p_14514_.addSchema(2514, f_14509_); +- Schema schema108 = p_14514_.addSchema(2514, SAME_NAMESPACED); - p_14514_.addFixer(new EntityUUIDFix(schema108)); - p_14514_.addFixer(new BlockEntityUUIDFix(schema108)); - p_14514_.addFixer(new PlayerUUIDFix(schema108)); - p_14514_.addFixer(new LevelUUIDFix(schema108)); - p_14514_.addFixer(new SavedDataUUIDFix(schema108)); - p_14514_.addFixer(new ItemStackUUIDFix(schema108)); -- Schema schema109 = p_14514_.addSchema(2516, f_14509_); +- Schema schema109 = p_14514_.addSchema(2516, SAME_NAMESPACED); - p_14514_.addFixer(new GossipUUIDFix(schema109, "minecraft:villager")); - p_14514_.addFixer(new GossipUUIDFix(schema109, "minecraft:zombie_villager")); -- Schema schema110 = p_14514_.addSchema(2518, f_14509_); +- Schema schema110 = p_14514_.addSchema(2518, SAME_NAMESPACED); - p_14514_.addFixer(new JigsawPropertiesFix(schema110, false)); - p_14514_.addFixer(new JigsawRotationFix(schema110, false)); - Schema schema111 = p_14514_.addSchema(2519, V2519::new); -- p_14514_.addFixer(new AddNewChoices(schema111, "Added Strider", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema111, "Added Strider", References.ENTITY)); - Schema schema112 = p_14514_.addSchema(2522, V2522::new); -- p_14514_.addFixer(new AddNewChoices(schema112, "Added Zoglin", References.f_16786_)); -- Schema schema113 = p_14514_.addSchema(2523, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema112, "Added Zoglin", References.ENTITY)); +- Schema schema113 = p_14514_.addSchema(2523, SAME_NAMESPACED); - p_14514_.addFixer(new AttributesRename(schema113)); -- Schema schema114 = p_14514_.addSchema(2527, f_14509_); +- Schema schema114 = p_14514_.addSchema(2527, SAME_NAMESPACED); - p_14514_.addFixer(new BitStorageAlignFix(schema114)); -- Schema schema115 = p_14514_.addSchema(2528, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema115, "Rename soul fire torch and soul fire lantern", m_14524_(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema115, "Rename soul fire torch and soul fire lantern", m_14524_(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_wall_torch", "minecraft:soul_wall_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); -- Schema schema116 = p_14514_.addSchema(2529, f_14509_); +- Schema schema115 = p_14514_.addSchema(2528, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema115, "Rename soul fire torch and soul fire lantern", createRenamer(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); +- p_14514_.addFixer(BlockRenameFix.create(schema115, "Rename soul fire torch and soul fire lantern", createRenamer(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_wall_torch", "minecraft:soul_wall_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); +- Schema schema116 = p_14514_.addSchema(2529, SAME_NAMESPACED); - p_14514_.addFixer(new StriderGravityFix(schema116, false)); -- Schema schema117 = p_14514_.addSchema(2531, f_14509_); +- Schema schema117 = p_14514_.addSchema(2531, SAME_NAMESPACED); - p_14514_.addFixer(new RedstoneWireConnectionsFix(schema117)); -- Schema schema118 = p_14514_.addSchema(2533, f_14509_); +- Schema schema118 = p_14514_.addSchema(2533, SAME_NAMESPACED); - p_14514_.addFixer(new VillagerFollowRangeFix(schema118)); -- Schema schema119 = p_14514_.addSchema(2535, f_14509_); +- Schema schema119 = p_14514_.addSchema(2535, SAME_NAMESPACED); - p_14514_.addFixer(new EntityShulkerRotationFix(schema119)); -- Schema schema120 = p_14514_.addSchema(2550, f_14509_); +- Schema schema120 = p_14514_.addSchema(2550, SAME_NAMESPACED); - p_14514_.addFixer(new WorldGenSettingsFix(schema120)); - Schema schema121 = p_14514_.addSchema(2551, V2551::new); -- p_14514_.addFixer(new WriteAndReadFix(schema121, "add types to WorldGenData", References.f_16795_)); -- Schema schema122 = p_14514_.addSchema(2552, f_14509_); +- p_14514_.addFixer(new WriteAndReadFix(schema121, "add types to WorldGenData", References.WORLD_GEN_SETTINGS)); +- Schema schema122 = p_14514_.addSchema(2552, SAME_NAMESPACED); - p_14514_.addFixer(new RenameBiomesFix(schema122, false, "Nether biome rename", ImmutableMap.of("minecraft:nether", "minecraft:nether_wastes"))); -- Schema schema123 = p_14514_.addSchema(2553, f_14509_); +- Schema schema123 = p_14514_.addSchema(2553, SAME_NAMESPACED); - p_14514_.addFixer(new BiomeFix(schema123, false)); -- Schema schema124 = p_14514_.addSchema(2558, f_14509_); +- Schema schema124 = p_14514_.addSchema(2558, SAME_NAMESPACED); - p_14514_.addFixer(new MissingDimensionFix(schema124, false)); - p_14514_.addFixer(new OptionsRenameFieldFix(schema124, false, "Rename swapHands setting", "key_key.swapHands", "key_key.swapOffhand")); - Schema schema125 = p_14514_.addSchema(2568, V2568::new); -- p_14514_.addFixer(new AddNewChoices(schema125, "Added Piglin Brute", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema125, "Added Piglin Brute", References.ENTITY)); - Schema schema126 = p_14514_.addSchema(2571, V2571::new); -- p_14514_.addFixer(new AddNewChoices(schema126, "Added Goat", References.f_16786_)); -- Schema schema127 = p_14514_.addSchema(2679, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema126, "Added Goat", References.ENTITY)); +- Schema schema127 = p_14514_.addSchema(2679, SAME_NAMESPACED); - p_14514_.addFixer(new CauldronRenameFix(schema127, false)); -- Schema schema128 = p_14514_.addSchema(2680, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema128, "Renamed grass path item to dirt path", m_14517_("minecraft:grass_path", "minecraft:dirt_path"))); -- p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema128, "Renamed grass path block to dirt path", m_14517_("minecraft:grass_path", "minecraft:dirt_path"))); +- Schema schema128 = p_14514_.addSchema(2680, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema128, "Renamed grass path item to dirt path", createRenamer("minecraft:grass_path", "minecraft:dirt_path"))); +- p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema128, "Renamed grass path block to dirt path", createRenamer("minecraft:grass_path", "minecraft:dirt_path"))); - Schema schema129 = p_14514_.addSchema(2684, V2684::new); -- p_14514_.addFixer(new AddNewChoices(schema129, "Added Sculk Sensor", References.f_16781_)); +- p_14514_.addFixer(new AddNewChoices(schema129, "Added Sculk Sensor", References.BLOCK_ENTITY)); - Schema schema130 = p_14514_.addSchema(2686, V2686::new); -- p_14514_.addFixer(new AddNewChoices(schema130, "Added Axolotl", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema130, "Added Axolotl", References.ENTITY)); - Schema schema131 = p_14514_.addSchema(2688, V2688::new); -- p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Squid", References.f_16786_)); -- p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Item Frame", References.f_16786_)); -- Schema schema132 = p_14514_.addSchema(2690, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Squid", References.ENTITY)); +- p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Item Frame", References.ENTITY)); +- Schema schema132 = p_14514_.addSchema(2690, SAME_NAMESPACED); - ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema132, "Renamed copper block items to new oxidized terms", m_14524_(immutablemap))); -- p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema132, "Renamed copper blocks to new oxidized terms", m_14524_(immutablemap))); -- Schema schema133 = p_14514_.addSchema(2691, f_14509_); +- p_14514_.addFixer(ItemRenameFix.create(schema132, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); +- p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); +- Schema schema133 = p_14514_.addSchema(2691, SAME_NAMESPACED); - ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema133, "Rename copper item suffixes", m_14524_(immutablemap1))); -- p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema133, "Rename copper blocks suffixes", m_14524_(immutablemap1))); -- Schema schema134 = p_14514_.addSchema(2693, f_14509_); -- p_14514_.addFixer(new AddFlagIfNotPresentFix(schema134, References.f_16795_, "has_increased_height_already", false)); -- Schema schema135 = p_14514_.addSchema(2696, f_14509_); +- p_14514_.addFixer(ItemRenameFix.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1))); +- p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1))); +- Schema schema134 = p_14514_.addSchema(2693, SAME_NAMESPACED); +- p_14514_.addFixer(new AddFlagIfNotPresentFix(schema134, References.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); +- Schema schema135 = p_14514_.addSchema(2696, SAME_NAMESPACED); - ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema135, "Renamed grimstone block items to deepslate", m_14524_(immutablemap2))); -- p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema135, "Renamed grimstone blocks to deepslate", m_14524_(immutablemap2))); -- Schema schema136 = p_14514_.addSchema(2700, f_14509_); -- p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema136, "Renamed cave vines blocks", m_14524_(ImmutableMap.of("minecraft:cave_vines_head", "minecraft:cave_vines", "minecraft:cave_vines_body", "minecraft:cave_vines_plant")))); -- Schema schema137 = p_14514_.addSchema(2701, f_14509_); +- p_14514_.addFixer(ItemRenameFix.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); +- p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); +- Schema schema136 = p_14514_.addSchema(2700, SAME_NAMESPACED); +- p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema136, "Renamed cave vines blocks", createRenamer(ImmutableMap.of("minecraft:cave_vines_head", "minecraft:cave_vines", "minecraft:cave_vines_body", "minecraft:cave_vines_plant")))); +- Schema schema137 = p_14514_.addSchema(2701, SAME_NAMESPACED); - p_14514_.addFixer(new SavedDataFeaturePoolElementFix(schema137)); -- Schema schema138 = p_14514_.addSchema(2702, f_14509_); +- Schema schema138 = p_14514_.addSchema(2702, SAME_NAMESPACED); - p_14514_.addFixer(new AbstractArrowPickupFix(schema138)); - Schema schema139 = p_14514_.addSchema(2704, V2704::new); -- p_14514_.addFixer(new AddNewChoices(schema139, "Added Goat", References.f_16786_)); +- p_14514_.addFixer(new AddNewChoices(schema139, "Added Goat", References.ENTITY)); - Schema schema140 = p_14514_.addSchema(2707, V2707::new); -- p_14514_.addFixer(new AddNewChoices(schema140, "Added Marker", References.f_16786_)); -- p_14514_.addFixer(new AddFlagIfNotPresentFix(schema140, References.f_16795_, "has_increased_height_already", true)); -- Schema schema141 = p_14514_.addSchema(2710, f_14509_); +- p_14514_.addFixer(new AddNewChoices(schema140, "Added Marker", References.ENTITY)); +- p_14514_.addFixer(new AddFlagIfNotPresentFix(schema140, References.WORLD_GEN_SETTINGS, "has_increased_height_already", true)); +- Schema schema141 = p_14514_.addSchema(2710, SAME_NAMESPACED); - p_14514_.addFixer(new StatsRenameFix(schema141, "Renamed play_one_minute stat to play_time", ImmutableMap.of("minecraft:play_one_minute", "minecraft:play_time"))); -- Schema schema142 = p_14514_.addSchema(2717, f_14509_); -- p_14514_.addFixer(ItemRenameFix.m_16003_(schema142, "Rename azalea_leaves_flowers", m_14524_(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); -- p_14514_.addFixer(BlockRenameFix.m_14914_(schema142, "Rename azalea_leaves_flowers items", m_14524_(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); -- Schema schema143 = p_14514_.addSchema(2825, f_14509_); -- p_14514_.addFixer(new AddFlagIfNotPresentFix(schema143, References.f_16795_, "has_increased_height_already", false)); +- Schema schema142 = p_14514_.addSchema(2717, SAME_NAMESPACED); +- p_14514_.addFixer(ItemRenameFix.create(schema142, "Rename azalea_leaves_flowers", createRenamer(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); +- p_14514_.addFixer(BlockRenameFix.create(schema142, "Rename azalea_leaves_flowers items", createRenamer(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); +- Schema schema143 = p_14514_.addSchema(2825, SAME_NAMESPACED); +- p_14514_.addFixer(new AddFlagIfNotPresentFix(schema143, References.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); - Schema schema144 = p_14514_.addSchema(2831, V2831::new); - p_14514_.addFixer(new SpawnerDataFix(schema144)); - Schema schema145 = p_14514_.addSchema(2832, V2832::new); - p_14514_.addFixer(new WorldGenSettingsHeightAndBiomeFix(schema145)); - p_14514_.addFixer(new ChunkHeightAndBiomeFix(schema145)); -- Schema schema146 = p_14514_.addSchema(2833, f_14509_); +- Schema schema146 = p_14514_.addSchema(2833, SAME_NAMESPACED); - p_14514_.addFixer(new WorldGenSettingsDisallowOldCustomWorldsFix(schema146)); -- Schema schema147 = p_14514_.addSchema(2838, f_14509_); -- p_14514_.addFixer(new RenameBiomesFix(schema147, false, "Caves and Cliffs biome renames", CavesAndCliffsRenames.f_184821_)); -- Schema schema148 = p_14514_.addSchema(2841, f_14509_); +- Schema schema147 = p_14514_.addSchema(2838, SAME_NAMESPACED); +- p_14514_.addFixer(new RenameBiomesFix(schema147, false, "Caves and Cliffs biome renames", CavesAndCliffsRenames.RENAMES)); +- Schema schema148 = p_14514_.addSchema(2841, SAME_NAMESPACED); - p_14514_.addFixer(new ChunkProtoTickListFix(schema148)); - Schema schema149 = p_14514_.addSchema(2842, V2842::new); - p_14514_.addFixer(new ChunkRenamesFix(schema149)); -- Schema schema150 = p_14514_.addSchema(2843, f_14509_); +- Schema schema150 = p_14514_.addSchema(2843, SAME_NAMESPACED); - p_14514_.addFixer(new OverreachingTickFix(schema150)); - p_14514_.addFixer(new RenameBiomesFix(schema150, false, "Remove Deep Warm Ocean", Map.of("minecraft:deep_warm_ocean", "minecraft:warm_ocean"))); -- Schema schema151 = p_14514_.addSchema(2846, f_14509_); -- p_14514_.addFixer(new AdvancementsRenameFix(schema151, false, "Rename some C&C part 2 advancements", m_14524_(ImmutableMap.of("minecraft:husbandry/play_jukebox_in_meadows", "minecraft:adventure/play_jukebox_in_meadows", "minecraft:adventure/caves_and_cliff", "minecraft:adventure/fall_from_world_height", "minecraft:adventure/ride_strider_in_overworld_lava", "minecraft:nether/ride_strider_in_overworld_lava")))); -- Schema schema152 = p_14514_.addSchema(2852, f_14509_); +- Schema schema151 = p_14514_.addSchema(2846, SAME_NAMESPACED); +- p_14514_.addFixer(new AdvancementsRenameFix(schema151, false, "Rename some C&C part 2 advancements", createRenamer(ImmutableMap.of("minecraft:husbandry/play_jukebox_in_meadows", "minecraft:adventure/play_jukebox_in_meadows", "minecraft:adventure/caves_and_cliff", "minecraft:adventure/fall_from_world_height", "minecraft:adventure/ride_strider_in_overworld_lava", "minecraft:nether/ride_strider_in_overworld_lava")))); +- Schema schema152 = p_14514_.addSchema(2852, SAME_NAMESPACED); - p_14514_.addFixer(new WorldGenSettingsDisallowOldCustomWorldsFix(schema152)); -- Schema schema153 = p_14514_.addSchema(2967, f_14509_); +- Schema schema153 = p_14514_.addSchema(2967, SAME_NAMESPACED); - p_14514_.addFixer(new StructureSettingsFlattenFix(schema153)); -- Schema schema154 = p_14514_.addSchema(2970, f_14509_); +- Schema schema154 = p_14514_.addSchema(2970, SAME_NAMESPACED); - p_14514_.addFixer(new StructuresBecomeConfiguredFix(schema154)); - } - -- private static UnaryOperator m_14524_(Map p_14525_) { +- private static UnaryOperator createRenamer(Map p_14525_) { - return (p_14528_) -> { - return p_14525_.getOrDefault(p_14528_, p_14528_); - }; - } - -- private static UnaryOperator m_14517_(String p_14518_, String p_14519_) { +- private static UnaryOperator createRenamer(String p_14518_, String p_14519_) { - return (p_14523_) -> { - return Objects.equals(p_14523_, p_14518_) ? p_14519_ : p_14523_; - }; - } -+ private static final BiFunction f_14508_ = Schema::new; -+ private static final BiFunction f_14509_ = NamespacedSchema::new; -+ private static final DataFixer f_14510_ = m_14529_(); ++ private static final BiFunction SAME = Schema::new; ++ private static final BiFunction SAME_NAMESPACED = NamespacedSchema::new; ++ private static final DataFixer DATA_FIXER = createFixerUpper(); + -+ private static DataFixer m_14529_() { -+ DataFixerBuilder datafixerbuilder = new DataFixerBuilder(SharedConstants.m_183709_().getWorldVersion()); -+ m_14513_(datafixerbuilder); -+ return datafixerbuilder.build(Util.m_183988_()); ++ private static DataFixer createFixerUpper() { ++ DataFixerBuilder datafixerbuilder = new DataFixerBuilder(SharedConstants.getCurrentVersion().getWorldVersion()); ++ addFixers(datafixerbuilder); ++ return datafixerbuilder.build(Util.bootstrapExecutor()); + } + -+ public static DataFixer m_14512_() { -+ return f_14510_; ++ public static DataFixer getDataFixer() { ++ return DATA_FIXER; + } + -+ private static void m_14513_(DataFixerBuilder p_14514_) { ++ private static void addFixers(DataFixerBuilder p_14514_) { + Schema schema = p_14514_.addSchema(99, V99::new); + Schema schema1 = p_14514_.addSchema(100, V100::new); + p_14514_.addFixer(new EntityEquipmentToArmorAndHandFix(schema1, true)); -+ Schema schema2 = p_14514_.addSchema(101, f_14508_); ++ Schema schema2 = p_14514_.addSchema(101, SAME); + p_14514_.addFixer(new BlockEntitySignTextStrictJsonFix(schema2, false)); + Schema schema3 = p_14514_.addSchema(102, V102::new); + p_14514_.addFixer(new ItemIdFix(schema3, true)); + p_14514_.addFixer(new ItemPotionFix(schema3, false)); -+ Schema schema4 = p_14514_.addSchema(105, f_14508_); ++ Schema schema4 = p_14514_.addSchema(105, SAME); + p_14514_.addFixer(new ItemSpawnEggFix(schema4, true)); + Schema schema5 = p_14514_.addSchema(106, V106::new); + p_14514_.addFixer(new MobSpawnerEntityIdentifiersFix(schema5, true)); + Schema schema6 = p_14514_.addSchema(107, V107::new); + p_14514_.addFixer(new EntityMinecartIdentifiersFix(schema6, true)); -+ Schema schema7 = p_14514_.addSchema(108, f_14508_); ++ Schema schema7 = p_14514_.addSchema(108, SAME); + p_14514_.addFixer(new EntityStringUuidFix(schema7, true)); -+ Schema schema8 = p_14514_.addSchema(109, f_14508_); ++ Schema schema8 = p_14514_.addSchema(109, SAME); + p_14514_.addFixer(new EntityHealthFix(schema8, true)); -+ Schema schema9 = p_14514_.addSchema(110, f_14508_); ++ Schema schema9 = p_14514_.addSchema(110, SAME); + p_14514_.addFixer(new EntityHorseSaddleFix(schema9, true)); -+ Schema schema10 = p_14514_.addSchema(111, f_14508_); ++ Schema schema10 = p_14514_.addSchema(111, SAME); + p_14514_.addFixer(new EntityPaintingItemFrameDirectionFix(schema10, true)); -+ Schema schema11 = p_14514_.addSchema(113, f_14508_); ++ Schema schema11 = p_14514_.addSchema(113, SAME); + p_14514_.addFixer(new EntityRedundantChanceTagsFix(schema11, true)); + Schema schema12 = p_14514_.addSchema(135, V135::new); + p_14514_.addFixer(new EntityRidingToPassengersFix(schema12, true)); + Schema schema13 = p_14514_.addSchema(143, V143::new); + p_14514_.addFixer(new EntityTippedArrowFix(schema13, true)); -+ Schema schema14 = p_14514_.addSchema(147, f_14508_); ++ Schema schema14 = p_14514_.addSchema(147, SAME); + p_14514_.addFixer(new EntityArmorStandSilentFix(schema14, true)); -+ Schema schema15 = p_14514_.addSchema(165, f_14508_); ++ Schema schema15 = p_14514_.addSchema(165, SAME); + p_14514_.addFixer(new ItemWrittenBookPagesStrictJsonFix(schema15, true)); + Schema schema16 = p_14514_.addSchema(501, V501::new); -+ p_14514_.addFixer(new AddNewChoices(schema16, "Add 1.10 entities fix", References.f_16786_)); -+ Schema schema17 = p_14514_.addSchema(502, f_14508_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema17, "cooked_fished item renamer", (p_14533_) -> { -+ return Objects.equals(NamespacedSchema.m_17311_(p_14533_), "minecraft:cooked_fished") ? "minecraft:cooked_fish" : p_14533_; ++ p_14514_.addFixer(new AddNewChoices(schema16, "Add 1.10 entities fix", References.ENTITY)); ++ Schema schema17 = p_14514_.addSchema(502, SAME); ++ p_14514_.addFixer(ItemRenameFix.create(schema17, "cooked_fished item renamer", (p_14533_) -> { ++ return Objects.equals(NamespacedSchema.ensureNamespaced(p_14533_), "minecraft:cooked_fished") ? "minecraft:cooked_fish" : p_14533_; + })); + p_14514_.addFixer(new EntityZombieVillagerTypeFix(schema17, false)); -+ Schema schema18 = p_14514_.addSchema(505, f_14508_); ++ Schema schema18 = p_14514_.addSchema(505, SAME); + p_14514_.addFixer(new OptionsForceVBOFix(schema18, false)); + Schema schema19 = p_14514_.addSchema(700, V700::new); + p_14514_.addFixer(new EntityElderGuardianSplitFix(schema19, true)); @@ -493,34 +493,34 @@ + p_14514_.addFixer(new BlockEntityIdFix(schema23, true)); + Schema schema24 = p_14514_.addSchema(705, V705::new); + p_14514_.addFixer(new EntityIdFix(schema24, true)); -+ Schema schema25 = p_14514_.addSchema(804, f_14509_); ++ Schema schema25 = p_14514_.addSchema(804, SAME_NAMESPACED); + p_14514_.addFixer(new ItemBannerColorFix(schema25, true)); -+ Schema schema26 = p_14514_.addSchema(806, f_14509_); ++ Schema schema26 = p_14514_.addSchema(806, SAME_NAMESPACED); + p_14514_.addFixer(new ItemWaterPotionFix(schema26, false)); + Schema schema27 = p_14514_.addSchema(808, V808::new); -+ p_14514_.addFixer(new AddNewChoices(schema27, "added shulker box", References.f_16781_)); -+ Schema schema28 = p_14514_.addSchema(808, 1, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema27, "added shulker box", References.BLOCK_ENTITY)); ++ Schema schema28 = p_14514_.addSchema(808, 1, SAME_NAMESPACED); + p_14514_.addFixer(new EntityShulkerColorFix(schema28, false)); -+ Schema schema29 = p_14514_.addSchema(813, f_14509_); ++ Schema schema29 = p_14514_.addSchema(813, SAME_NAMESPACED); + p_14514_.addFixer(new ItemShulkerBoxColorFix(schema29, false)); + p_14514_.addFixer(new BlockEntityShulkerBoxColorFix(schema29, false)); -+ Schema schema30 = p_14514_.addSchema(816, f_14509_); ++ Schema schema30 = p_14514_.addSchema(816, SAME_NAMESPACED); + p_14514_.addFixer(new OptionsLowerCaseLanguageFix(schema30, false)); -+ Schema schema31 = p_14514_.addSchema(820, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema31, "totem item renamer", m_14517_("minecraft:totem", "minecraft:totem_of_undying"))); ++ Schema schema31 = p_14514_.addSchema(820, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema31, "totem item renamer", createRenamer("minecraft:totem", "minecraft:totem_of_undying"))); + Schema schema32 = p_14514_.addSchema(1022, V1022::new); -+ p_14514_.addFixer(new WriteAndReadFix(schema32, "added shoulder entities to players", References.f_16772_)); ++ p_14514_.addFixer(new WriteAndReadFix(schema32, "added shoulder entities to players", References.PLAYER)); + Schema schema33 = p_14514_.addSchema(1125, V1125::new); + p_14514_.addFixer(new ChunkBedBlockEntityInjecterFix(schema33, true)); + p_14514_.addFixer(new BedItemColorFix(schema33, false)); -+ Schema schema34 = p_14514_.addSchema(1344, f_14509_); ++ Schema schema34 = p_14514_.addSchema(1344, SAME_NAMESPACED); + p_14514_.addFixer(new OptionsKeyLwjgl3Fix(schema34, false)); -+ Schema schema35 = p_14514_.addSchema(1446, f_14509_); ++ Schema schema35 = p_14514_.addSchema(1446, SAME_NAMESPACED); + p_14514_.addFixer(new OptionsKeyTranslationFix(schema35, false)); -+ Schema schema36 = p_14514_.addSchema(1450, f_14509_); ++ Schema schema36 = p_14514_.addSchema(1450, SAME_NAMESPACED); + p_14514_.addFixer(new BlockStateStructureTemplateFix(schema36, false)); + Schema schema37 = p_14514_.addSchema(1451, V1451::new); -+ p_14514_.addFixer(new AddNewChoices(schema37, "AddTrappedChestFix", References.f_16781_)); ++ p_14514_.addFixer(new AddNewChoices(schema37, "AddTrappedChestFix", References.BLOCK_ENTITY)); + Schema schema38 = p_14514_.addSchema(1451, 1, V1451_1::new); + p_14514_.addFixer(new ChunkPalettedStorageFix(schema38, true)); + Schema schema39 = p_14514_.addSchema(1451, 2, V1451_2::new); @@ -532,27 +532,27 @@ + p_14514_.addFixer(new BlockNameFlatteningFix(schema41, true)); + p_14514_.addFixer(new ItemStackTheFlatteningFix(schema41, false)); + Schema schema42 = p_14514_.addSchema(1451, 5, V1451_5::new); -+ p_14514_.addFixer(new AddNewChoices(schema42, "RemoveNoteBlockFlowerPotFix", References.f_16781_)); ++ p_14514_.addFixer(new AddNewChoices(schema42, "RemoveNoteBlockFlowerPotFix", References.BLOCK_ENTITY)); + p_14514_.addFixer(new ItemStackSpawnEggFix(schema42, false)); + p_14514_.addFixer(new EntityWolfColorFix(schema42, false)); + p_14514_.addFixer(new BlockEntityBannerColorFix(schema42, false)); + p_14514_.addFixer(new LevelFlatGeneratorInfoFix(schema42, false)); + Schema schema43 = p_14514_.addSchema(1451, 6, V1451_6::new); + p_14514_.addFixer(new StatsCounterFix(schema43, true)); -+ p_14514_.addFixer(new WriteAndReadFix(schema43, "Rewrite objectives", References.f_16791_)); ++ p_14514_.addFixer(new WriteAndReadFix(schema43, "Rewrite objectives", References.OBJECTIVE)); + p_14514_.addFixer(new BlockEntityJukeboxFix(schema43, false)); + Schema schema44 = p_14514_.addSchema(1451, 7, V1451_7::new); + p_14514_.addFixer(new SavedDataVillageCropFix(schema44, true)); -+ Schema schema45 = p_14514_.addSchema(1451, 7, f_14509_); ++ Schema schema45 = p_14514_.addSchema(1451, 7, SAME_NAMESPACED); + p_14514_.addFixer(new VillagerTradeFix(schema45, false)); -+ Schema schema46 = p_14514_.addSchema(1456, f_14509_); ++ Schema schema46 = p_14514_.addSchema(1456, SAME_NAMESPACED); + p_14514_.addFixer(new EntityItemFrameDirectionFix(schema46, false)); -+ Schema schema47 = p_14514_.addSchema(1458, f_14509_); ++ Schema schema47 = p_14514_.addSchema(1458, SAME_NAMESPACED); + // CraftBukkit start + p_14514_.addFixer(new com.mojang.datafixers.DataFix(schema47, false) { + @Override + protected com.mojang.datafixers.TypeRewriteRule makeRule() { -+ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(References.f_16772_), (typed) -> typed.update(DSL.remainderFinder(), (dynamic) -> EntityCustomNameToComponentFix.m_15407_(dynamic))); ++ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(References.PLAYER), (typed) -> typed.update(DSL.remainderFinder(), (dynamic) -> EntityCustomNameToComponentFix.fixTagCustomName(dynamic))); + } + }); + // CraftBukkit end @@ -564,292 +564,292 @@ + Schema schema49 = p_14514_.addSchema(1466, V1466::new); + p_14514_.addFixer(new ChunkToProtochunkFix(schema49, true)); + Schema schema50 = p_14514_.addSchema(1470, V1470::new); -+ p_14514_.addFixer(new AddNewChoices(schema50, "Add 1.13 entities fix", References.f_16786_)); -+ Schema schema51 = p_14514_.addSchema(1474, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema50, "Add 1.13 entities fix", References.ENTITY)); ++ Schema schema51 = p_14514_.addSchema(1474, SAME_NAMESPACED); + p_14514_.addFixer(new ColorlessShulkerEntityFix(schema51, false)); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema51, "Colorless shulker block fixer", (p_14531_) -> { -+ return Objects.equals(NamespacedSchema.m_17311_(p_14531_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14531_; ++ p_14514_.addFixer(BlockRenameFix.create(schema51, "Colorless shulker block fixer", (p_14531_) -> { ++ return Objects.equals(NamespacedSchema.ensureNamespaced(p_14531_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14531_; + })); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema51, "Colorless shulker item fixer", (p_14516_) -> { -+ return Objects.equals(NamespacedSchema.m_17311_(p_14516_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14516_; ++ p_14514_.addFixer(ItemRenameFix.create(schema51, "Colorless shulker item fixer", (p_14516_) -> { ++ return Objects.equals(NamespacedSchema.ensureNamespaced(p_14516_), "minecraft:purple_shulker_box") ? "minecraft:shulker_box" : p_14516_; + })); -+ Schema schema52 = p_14514_.addSchema(1475, f_14509_); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema52, "Flowing fixer", m_14524_(ImmutableMap.of("minecraft:flowing_water", "minecraft:water", "minecraft:flowing_lava", "minecraft:lava")))); -+ Schema schema53 = p_14514_.addSchema(1480, f_14509_); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema53, "Rename coral blocks", m_14524_(RenamedCoralFix.f_16850_))); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema53, "Rename coral items", m_14524_(RenamedCoralFix.f_16850_))); ++ Schema schema52 = p_14514_.addSchema(1475, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFix.create(schema52, "Flowing fixer", createRenamer(ImmutableMap.of("minecraft:flowing_water", "minecraft:water", "minecraft:flowing_lava", "minecraft:lava")))); ++ Schema schema53 = p_14514_.addSchema(1480, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFix.create(schema53, "Rename coral blocks", createRenamer(RenamedCoralFix.RENAMED_IDS))); ++ p_14514_.addFixer(ItemRenameFix.create(schema53, "Rename coral items", createRenamer(RenamedCoralFix.RENAMED_IDS))); + Schema schema54 = p_14514_.addSchema(1481, V1481::new); -+ p_14514_.addFixer(new AddNewChoices(schema54, "Add conduit", References.f_16781_)); ++ p_14514_.addFixer(new AddNewChoices(schema54, "Add conduit", References.BLOCK_ENTITY)); + Schema schema55 = p_14514_.addSchema(1483, V1483::new); + p_14514_.addFixer(new EntityPufferfishRenameFix(schema55, true)); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema55, "Rename pufferfish egg item", m_14524_(EntityPufferfishRenameFix.f_15584_))); -+ Schema schema56 = p_14514_.addSchema(1484, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema56, "Rename seagrass items", m_14524_(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema56, "Rename seagrass blocks", m_14524_(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); ++ p_14514_.addFixer(ItemRenameFix.create(schema55, "Rename pufferfish egg item", createRenamer(EntityPufferfishRenameFix.RENAMED_IDS))); ++ Schema schema56 = p_14514_.addSchema(1484, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema56, "Rename seagrass items", createRenamer(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); ++ p_14514_.addFixer(BlockRenameFix.create(schema56, "Rename seagrass blocks", createRenamer(ImmutableMap.of("minecraft:sea_grass", "minecraft:seagrass", "minecraft:tall_sea_grass", "minecraft:tall_seagrass")))); + p_14514_.addFixer(new HeightmapRenamingFix(schema56, false)); + Schema schema57 = p_14514_.addSchema(1486, V1486::new); + p_14514_.addFixer(new EntityCodSalmonFix(schema57, true)); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema57, "Rename cod/salmon egg items", m_14524_(EntityCodSalmonFix.f_15390_))); -+ Schema schema58 = p_14514_.addSchema(1487, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema58, "Rename prismarine_brick(s)_* blocks", m_14524_(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema58, "Rename prismarine_brick(s)_* items", m_14524_(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); -+ Schema schema59 = p_14514_.addSchema(1488, f_14509_); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema59, "Rename kelp/kelptop", m_14524_(ImmutableMap.of("minecraft:kelp_top", "minecraft:kelp", "minecraft:kelp", "minecraft:kelp_plant")))); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema59, "Rename kelptop", m_14517_("minecraft:kelp_top", "minecraft:kelp"))); -+ p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block block entity custom name fix", References.f_16781_, "minecraft:command_block") { -+ protected Typed m_7504_(Typed p_14549_) { -+ return p_14549_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::m_15407_); ++ p_14514_.addFixer(ItemRenameFix.create(schema57, "Rename cod/salmon egg items", createRenamer(EntityCodSalmonFix.RENAMED_EGG_IDS))); ++ Schema schema58 = p_14514_.addSchema(1487, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema58, "Rename prismarine_brick(s)_* blocks", createRenamer(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); ++ p_14514_.addFixer(BlockRenameFix.create(schema58, "Rename prismarine_brick(s)_* items", createRenamer(ImmutableMap.of("minecraft:prismarine_bricks_slab", "minecraft:prismarine_brick_slab", "minecraft:prismarine_bricks_stairs", "minecraft:prismarine_brick_stairs")))); ++ Schema schema59 = p_14514_.addSchema(1488, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFix.create(schema59, "Rename kelp/kelptop", createRenamer(ImmutableMap.of("minecraft:kelp_top", "minecraft:kelp", "minecraft:kelp", "minecraft:kelp_plant")))); ++ p_14514_.addFixer(ItemRenameFix.create(schema59, "Rename kelptop", createRenamer("minecraft:kelp_top", "minecraft:kelp"))); ++ p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block block entity custom name fix", References.BLOCK_ENTITY, "minecraft:command_block") { ++ protected Typed fix(Typed p_14549_) { ++ return p_14549_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::fixTagCustomName); + } + }); -+ p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block minecart custom name fix", References.f_16786_, "minecraft:commandblock_minecart") { -+ protected Typed m_7504_(Typed p_14549_) { -+ return p_14549_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::m_15407_); ++ p_14514_.addFixer(new NamedEntityFix(schema59, false, "Command block minecart custom name fix", References.ENTITY, "minecraft:commandblock_minecart") { ++ protected Typed fix(Typed p_14549_) { ++ return p_14549_.update(DSL.remainderFinder(), EntityCustomNameToComponentFix::fixTagCustomName); + } + }); + p_14514_.addFixer(new IglooMetadataRemovalFix(schema59, false)); -+ Schema schema60 = p_14514_.addSchema(1490, f_14509_); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema60, "Rename melon_block", m_14517_("minecraft:melon_block", "minecraft:melon"))); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema60, "Rename melon_block/melon/speckled_melon", m_14524_(ImmutableMap.of("minecraft:melon_block", "minecraft:melon", "minecraft:melon", "minecraft:melon_slice", "minecraft:speckled_melon", "minecraft:glistering_melon_slice")))); -+ Schema schema61 = p_14514_.addSchema(1492, f_14509_); ++ Schema schema60 = p_14514_.addSchema(1490, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFix.create(schema60, "Rename melon_block", createRenamer("minecraft:melon_block", "minecraft:melon"))); ++ p_14514_.addFixer(ItemRenameFix.create(schema60, "Rename melon_block/melon/speckled_melon", createRenamer(ImmutableMap.of("minecraft:melon_block", "minecraft:melon", "minecraft:melon", "minecraft:melon_slice", "minecraft:speckled_melon", "minecraft:glistering_melon_slice")))); ++ Schema schema61 = p_14514_.addSchema(1492, SAME_NAMESPACED); + p_14514_.addFixer(new ChunkStructuresTemplateRenameFix(schema61, false)); -+ Schema schema62 = p_14514_.addSchema(1494, f_14509_); ++ Schema schema62 = p_14514_.addSchema(1494, SAME_NAMESPACED); + p_14514_.addFixer(new ItemStackEnchantmentNamesFix(schema62, false)); -+ Schema schema63 = p_14514_.addSchema(1496, f_14509_); ++ Schema schema63 = p_14514_.addSchema(1496, SAME_NAMESPACED); + p_14514_.addFixer(new LeavesFix(schema63, false)); -+ Schema schema64 = p_14514_.addSchema(1500, f_14509_); ++ Schema schema64 = p_14514_.addSchema(1500, SAME_NAMESPACED); + p_14514_.addFixer(new BlockEntityKeepPacked(schema64, false)); -+ Schema schema65 = p_14514_.addSchema(1501, f_14509_); ++ Schema schema65 = p_14514_.addSchema(1501, SAME_NAMESPACED); + p_14514_.addFixer(new AdvancementsFix(schema65, false)); -+ Schema schema66 = p_14514_.addSchema(1502, f_14509_); ++ Schema schema66 = p_14514_.addSchema(1502, SAME_NAMESPACED); + p_14514_.addFixer(new RecipesFix(schema66, false)); -+ Schema schema67 = p_14514_.addSchema(1506, f_14509_); ++ Schema schema67 = p_14514_.addSchema(1506, SAME_NAMESPACED); + p_14514_.addFixer(new LevelDataGeneratorOptionsFix(schema67, false)); + Schema schema68 = p_14514_.addSchema(1510, V1510::new); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema68, "Block renamening fix", m_14524_(EntityTheRenameningFix.f_15702_))); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema68, "Item renamening fix", m_14524_(EntityTheRenameningFix.f_15703_))); ++ p_14514_.addFixer(BlockRenameFix.create(schema68, "Block renamening fix", createRenamer(EntityTheRenameningFix.RENAMED_BLOCKS))); ++ p_14514_.addFixer(ItemRenameFix.create(schema68, "Item renamening fix", createRenamer(EntityTheRenameningFix.RENAMED_ITEMS))); + p_14514_.addFixer(new RecipesRenameningFix(schema68, false)); + p_14514_.addFixer(new EntityTheRenameningFix(schema68, true)); + p_14514_.addFixer(new StatsRenameFix(schema68, "SwimStatsRenameFix", ImmutableMap.of("minecraft:swim_one_cm", "minecraft:walk_on_water_one_cm", "minecraft:dive_one_cm", "minecraft:walk_under_water_one_cm"))); -+ Schema schema69 = p_14514_.addSchema(1514, f_14509_); ++ Schema schema69 = p_14514_.addSchema(1514, SAME_NAMESPACED); + p_14514_.addFixer(new ObjectiveDisplayNameFix(schema69, false)); + p_14514_.addFixer(new TeamDisplayNameFix(schema69, false)); + p_14514_.addFixer(new ObjectiveRenderTypeFix(schema69, false)); -+ Schema schema70 = p_14514_.addSchema(1515, f_14509_); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema70, "Rename coral fan blocks", m_14524_(RenamedCoralFansFix.f_16848_))); -+ Schema schema71 = p_14514_.addSchema(1624, f_14509_); ++ Schema schema70 = p_14514_.addSchema(1515, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFix.create(schema70, "Rename coral fan blocks", createRenamer(RenamedCoralFansFix.RENAMED_IDS))); ++ Schema schema71 = p_14514_.addSchema(1624, SAME_NAMESPACED); + p_14514_.addFixer(new TrappedChestBlockEntityFix(schema71, false)); + Schema schema72 = p_14514_.addSchema(1800, V1800::new); -+ p_14514_.addFixer(new AddNewChoices(schema72, "Added 1.14 mobs fix", References.f_16786_)); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema72, "Rename dye items", m_14524_(DyeItemRenameFix.f_15321_))); ++ p_14514_.addFixer(new AddNewChoices(schema72, "Added 1.14 mobs fix", References.ENTITY)); ++ p_14514_.addFixer(ItemRenameFix.create(schema72, "Rename dye items", createRenamer(DyeItemRenameFix.RENAMED_IDS))); + Schema schema73 = p_14514_.addSchema(1801, V1801::new); -+ p_14514_.addFixer(new AddNewChoices(schema73, "Added Illager Beast", References.f_16786_)); -+ Schema schema74 = p_14514_.addSchema(1802, f_14509_); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema74, "Rename sign blocks & stone slabs", m_14524_(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign", "minecraft:wall_sign", "minecraft:oak_wall_sign")))); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema74, "Rename sign item & stone slabs", m_14524_(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign")))); -+ Schema schema75 = p_14514_.addSchema(1803, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema73, "Added Illager Beast", References.ENTITY)); ++ Schema schema74 = p_14514_.addSchema(1802, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFix.create(schema74, "Rename sign blocks & stone slabs", createRenamer(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign", "minecraft:wall_sign", "minecraft:oak_wall_sign")))); ++ p_14514_.addFixer(ItemRenameFix.create(schema74, "Rename sign item & stone slabs", createRenamer(ImmutableMap.of("minecraft:stone_slab", "minecraft:smooth_stone_slab", "minecraft:sign", "minecraft:oak_sign")))); ++ Schema schema75 = p_14514_.addSchema(1803, SAME_NAMESPACED); + p_14514_.addFixer(new ItemLoreFix(schema75, false)); + Schema schema76 = p_14514_.addSchema(1904, V1904::new); -+ p_14514_.addFixer(new AddNewChoices(schema76, "Added Cats", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema76, "Added Cats", References.ENTITY)); + p_14514_.addFixer(new EntityCatSplitFix(schema76, false)); -+ Schema schema77 = p_14514_.addSchema(1905, f_14509_); ++ Schema schema77 = p_14514_.addSchema(1905, SAME_NAMESPACED); + p_14514_.addFixer(new ChunkStatusFix(schema77, false)); + Schema schema78 = p_14514_.addSchema(1906, V1906::new); -+ p_14514_.addFixer(new AddNewChoices(schema78, "Add POI Blocks", References.f_16781_)); ++ p_14514_.addFixer(new AddNewChoices(schema78, "Add POI Blocks", References.BLOCK_ENTITY)); + Schema schema79 = p_14514_.addSchema(1909, V1909::new); -+ p_14514_.addFixer(new AddNewChoices(schema79, "Add jigsaw", References.f_16781_)); -+ Schema schema80 = p_14514_.addSchema(1911, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema79, "Add jigsaw", References.BLOCK_ENTITY)); ++ Schema schema80 = p_14514_.addSchema(1911, SAME_NAMESPACED); + p_14514_.addFixer(new ChunkStatusFix2(schema80, false)); -+ Schema schema81 = p_14514_.addSchema(1914, f_14509_); ++ Schema schema81 = p_14514_.addSchema(1914, SAME_NAMESPACED); + p_14514_.addFixer(new WeaponSmithChestLootTableFix(schema81, false)); -+ Schema schema82 = p_14514_.addSchema(1917, f_14509_); ++ Schema schema82 = p_14514_.addSchema(1917, SAME_NAMESPACED); + p_14514_.addFixer(new CatTypeFix(schema82, false)); -+ Schema schema83 = p_14514_.addSchema(1918, f_14509_); ++ Schema schema83 = p_14514_.addSchema(1918, SAME_NAMESPACED); + p_14514_.addFixer(new VillagerDataFix(schema83, "minecraft:villager")); + p_14514_.addFixer(new VillagerDataFix(schema83, "minecraft:zombie_villager")); + Schema schema84 = p_14514_.addSchema(1920, V1920::new); + p_14514_.addFixer(new NewVillageFix(schema84, false)); -+ p_14514_.addFixer(new AddNewChoices(schema84, "Add campfire", References.f_16781_)); -+ Schema schema85 = p_14514_.addSchema(1925, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema84, "Add campfire", References.BLOCK_ENTITY)); ++ Schema schema85 = p_14514_.addSchema(1925, SAME_NAMESPACED); + p_14514_.addFixer(new MapIdFix(schema85, false)); + Schema schema86 = p_14514_.addSchema(1928, V1928::new); + p_14514_.addFixer(new EntityRavagerRenameFix(schema86, true)); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema86, "Rename ravager egg item", m_14524_(EntityRavagerRenameFix.f_15591_))); ++ p_14514_.addFixer(ItemRenameFix.create(schema86, "Rename ravager egg item", createRenamer(EntityRavagerRenameFix.RENAMED_IDS))); + Schema schema87 = p_14514_.addSchema(1929, V1929::new); -+ p_14514_.addFixer(new AddNewChoices(schema87, "Add Wandering Trader and Trader Llama", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema87, "Add Wandering Trader and Trader Llama", References.ENTITY)); + Schema schema88 = p_14514_.addSchema(1931, V1931::new); -+ p_14514_.addFixer(new AddNewChoices(schema88, "Added Fox", References.f_16786_)); -+ Schema schema89 = p_14514_.addSchema(1936, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema88, "Added Fox", References.ENTITY)); ++ Schema schema89 = p_14514_.addSchema(1936, SAME_NAMESPACED); + p_14514_.addFixer(new OptionsAddTextBackgroundFix(schema89, false)); -+ Schema schema90 = p_14514_.addSchema(1946, f_14509_); ++ Schema schema90 = p_14514_.addSchema(1946, SAME_NAMESPACED); + p_14514_.addFixer(new ReorganizePoi(schema90, false)); -+ Schema schema91 = p_14514_.addSchema(1948, f_14509_); ++ Schema schema91 = p_14514_.addSchema(1948, SAME_NAMESPACED); + p_14514_.addFixer(new OminousBannerRenameFix(schema91, false)); -+ Schema schema92 = p_14514_.addSchema(1953, f_14509_); ++ Schema schema92 = p_14514_.addSchema(1953, SAME_NAMESPACED); + p_14514_.addFixer(new OminousBannerBlockEntityRenameFix(schema92, false)); -+ Schema schema93 = p_14514_.addSchema(1955, f_14509_); ++ Schema schema93 = p_14514_.addSchema(1955, SAME_NAMESPACED); + p_14514_.addFixer(new VillagerRebuildLevelAndXpFix(schema93, false)); + p_14514_.addFixer(new ZombieVillagerRebuildXpFix(schema93, false)); -+ Schema schema94 = p_14514_.addSchema(1961, f_14509_); ++ Schema schema94 = p_14514_.addSchema(1961, SAME_NAMESPACED); + p_14514_.addFixer(new ChunkLightRemoveFix(schema94, false)); -+ Schema schema95 = p_14514_.addSchema(1963, f_14509_); ++ Schema schema95 = p_14514_.addSchema(1963, SAME_NAMESPACED); + p_14514_.addFixer(new RemoveGolemGossipFix(schema95, false)); + Schema schema96 = p_14514_.addSchema(2100, V2100::new); -+ p_14514_.addFixer(new AddNewChoices(schema96, "Added Bee and Bee Stinger", References.f_16786_)); -+ p_14514_.addFixer(new AddNewChoices(schema96, "Add beehive", References.f_16781_)); -+ p_14514_.addFixer(new RecipesRenameFix(schema96, false, "Rename sugar recipe", m_14517_("minecraft:sugar", "sugar_from_sugar_cane"))); -+ p_14514_.addFixer(new AdvancementsRenameFix(schema96, false, "Rename sugar recipe advancement", m_14517_("minecraft:recipes/misc/sugar", "minecraft:recipes/misc/sugar_from_sugar_cane"))); -+ Schema schema97 = p_14514_.addSchema(2202, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema96, "Added Bee and Bee Stinger", References.ENTITY)); ++ p_14514_.addFixer(new AddNewChoices(schema96, "Add beehive", References.BLOCK_ENTITY)); ++ p_14514_.addFixer(new RecipesRenameFix(schema96, false, "Rename sugar recipe", createRenamer("minecraft:sugar", "sugar_from_sugar_cane"))); ++ p_14514_.addFixer(new AdvancementsRenameFix(schema96, false, "Rename sugar recipe advancement", createRenamer("minecraft:recipes/misc/sugar", "minecraft:recipes/misc/sugar_from_sugar_cane"))); ++ Schema schema97 = p_14514_.addSchema(2202, SAME_NAMESPACED); + p_14514_.addFixer(new ChunkBiomeFix(schema97, false)); -+ Schema schema98 = p_14514_.addSchema(2209, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema98, "Rename bee_hive item to beehive", m_14517_("minecraft:bee_hive", "minecraft:beehive"))); ++ Schema schema98 = p_14514_.addSchema(2209, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema98, "Rename bee_hive item to beehive", createRenamer("minecraft:bee_hive", "minecraft:beehive"))); + p_14514_.addFixer(new BeehivePoiRenameFix(schema98)); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema98, "Rename bee_hive block to beehive", m_14517_("minecraft:bee_hive", "minecraft:beehive"))); -+ Schema schema99 = p_14514_.addSchema(2211, f_14509_); ++ p_14514_.addFixer(BlockRenameFix.create(schema98, "Rename bee_hive block to beehive", createRenamer("minecraft:bee_hive", "minecraft:beehive"))); ++ Schema schema99 = p_14514_.addSchema(2211, SAME_NAMESPACED); + p_14514_.addFixer(new StructureReferenceCountFix(schema99, false)); -+ Schema schema100 = p_14514_.addSchema(2218, f_14509_); ++ Schema schema100 = p_14514_.addSchema(2218, SAME_NAMESPACED); + p_14514_.addFixer(new ForcePoiRebuild(schema100, false)); + Schema schema101 = p_14514_.addSchema(2501, V2501::new); + p_14514_.addFixer(new FurnaceRecipeFix(schema101, true)); + Schema schema102 = p_14514_.addSchema(2502, V2502::new); -+ p_14514_.addFixer(new AddNewChoices(schema102, "Added Hoglin", References.f_16786_)); -+ Schema schema103 = p_14514_.addSchema(2503, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema102, "Added Hoglin", References.ENTITY)); ++ Schema schema103 = p_14514_.addSchema(2503, SAME_NAMESPACED); + p_14514_.addFixer(new WallPropertyFix(schema103, false)); -+ p_14514_.addFixer(new AdvancementsRenameFix(schema103, false, "Composter category change", m_14517_("minecraft:recipes/misc/composter", "minecraft:recipes/decorations/composter"))); ++ p_14514_.addFixer(new AdvancementsRenameFix(schema103, false, "Composter category change", createRenamer("minecraft:recipes/misc/composter", "minecraft:recipes/decorations/composter"))); + Schema schema104 = p_14514_.addSchema(2505, V2505::new); -+ p_14514_.addFixer(new AddNewChoices(schema104, "Added Piglin", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema104, "Added Piglin", References.ENTITY)); + p_14514_.addFixer(new MemoryExpiryDataFix(schema104, "minecraft:villager")); -+ Schema schema105 = p_14514_.addSchema(2508, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema105, "Renamed fungi items to fungus", m_14524_(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema105, "Renamed fungi blocks to fungus", m_14524_(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); ++ Schema schema105 = p_14514_.addSchema(2508, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema105, "Renamed fungi items to fungus", createRenamer(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); ++ p_14514_.addFixer(BlockRenameFix.create(schema105, "Renamed fungi blocks to fungus", createRenamer(ImmutableMap.of("minecraft:warped_fungi", "minecraft:warped_fungus", "minecraft:crimson_fungi", "minecraft:crimson_fungus")))); + Schema schema106 = p_14514_.addSchema(2509, V2509::new); + p_14514_.addFixer(new EntityZombifiedPiglinRenameFix(schema106)); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema106, "Rename zombie pigman egg item", m_14524_(EntityZombifiedPiglinRenameFix.f_15814_))); -+ Schema schema107 = p_14514_.addSchema(2511, f_14509_); ++ p_14514_.addFixer(ItemRenameFix.create(schema106, "Rename zombie pigman egg item", createRenamer(EntityZombifiedPiglinRenameFix.RENAMED_IDS))); ++ Schema schema107 = p_14514_.addSchema(2511, SAME_NAMESPACED); + p_14514_.addFixer(new EntityProjectileOwnerFix(schema107)); -+ Schema schema108 = p_14514_.addSchema(2514, f_14509_); ++ Schema schema108 = p_14514_.addSchema(2514, SAME_NAMESPACED); + p_14514_.addFixer(new EntityUUIDFix(schema108)); + p_14514_.addFixer(new BlockEntityUUIDFix(schema108)); + p_14514_.addFixer(new PlayerUUIDFix(schema108)); + p_14514_.addFixer(new LevelUUIDFix(schema108)); + p_14514_.addFixer(new SavedDataUUIDFix(schema108)); + p_14514_.addFixer(new ItemStackUUIDFix(schema108)); -+ Schema schema109 = p_14514_.addSchema(2516, f_14509_); ++ Schema schema109 = p_14514_.addSchema(2516, SAME_NAMESPACED); + p_14514_.addFixer(new GossipUUIDFix(schema109, "minecraft:villager")); + p_14514_.addFixer(new GossipUUIDFix(schema109, "minecraft:zombie_villager")); -+ Schema schema110 = p_14514_.addSchema(2518, f_14509_); ++ Schema schema110 = p_14514_.addSchema(2518, SAME_NAMESPACED); + p_14514_.addFixer(new JigsawPropertiesFix(schema110, false)); + p_14514_.addFixer(new JigsawRotationFix(schema110, false)); + Schema schema111 = p_14514_.addSchema(2519, V2519::new); -+ p_14514_.addFixer(new AddNewChoices(schema111, "Added Strider", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema111, "Added Strider", References.ENTITY)); + Schema schema112 = p_14514_.addSchema(2522, V2522::new); -+ p_14514_.addFixer(new AddNewChoices(schema112, "Added Zoglin", References.f_16786_)); -+ Schema schema113 = p_14514_.addSchema(2523, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema112, "Added Zoglin", References.ENTITY)); ++ Schema schema113 = p_14514_.addSchema(2523, SAME_NAMESPACED); + p_14514_.addFixer(new AttributesRename(schema113)); -+ Schema schema114 = p_14514_.addSchema(2527, f_14509_); ++ Schema schema114 = p_14514_.addSchema(2527, SAME_NAMESPACED); + p_14514_.addFixer(new BitStorageAlignFix(schema114)); -+ Schema schema115 = p_14514_.addSchema(2528, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema115, "Rename soul fire torch and soul fire lantern", m_14524_(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema115, "Rename soul fire torch and soul fire lantern", m_14524_(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_wall_torch", "minecraft:soul_wall_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); -+ Schema schema116 = p_14514_.addSchema(2529, f_14509_); ++ Schema schema115 = p_14514_.addSchema(2528, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema115, "Rename soul fire torch and soul fire lantern", createRenamer(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); ++ p_14514_.addFixer(BlockRenameFix.create(schema115, "Rename soul fire torch and soul fire lantern", createRenamer(ImmutableMap.of("minecraft:soul_fire_torch", "minecraft:soul_torch", "minecraft:soul_fire_wall_torch", "minecraft:soul_wall_torch", "minecraft:soul_fire_lantern", "minecraft:soul_lantern")))); ++ Schema schema116 = p_14514_.addSchema(2529, SAME_NAMESPACED); + p_14514_.addFixer(new StriderGravityFix(schema116, false)); -+ Schema schema117 = p_14514_.addSchema(2531, f_14509_); ++ Schema schema117 = p_14514_.addSchema(2531, SAME_NAMESPACED); + p_14514_.addFixer(new RedstoneWireConnectionsFix(schema117)); -+ Schema schema118 = p_14514_.addSchema(2533, f_14509_); ++ Schema schema118 = p_14514_.addSchema(2533, SAME_NAMESPACED); + p_14514_.addFixer(new VillagerFollowRangeFix(schema118)); -+ Schema schema119 = p_14514_.addSchema(2535, f_14509_); ++ Schema schema119 = p_14514_.addSchema(2535, SAME_NAMESPACED); + p_14514_.addFixer(new EntityShulkerRotationFix(schema119)); -+ Schema schema120 = p_14514_.addSchema(2550, f_14509_); ++ Schema schema120 = p_14514_.addSchema(2550, SAME_NAMESPACED); + p_14514_.addFixer(new WorldGenSettingsFix(schema120)); + Schema schema121 = p_14514_.addSchema(2551, V2551::new); -+ p_14514_.addFixer(new WriteAndReadFix(schema121, "add types to WorldGenData", References.f_16795_)); -+ Schema schema122 = p_14514_.addSchema(2552, f_14509_); ++ p_14514_.addFixer(new WriteAndReadFix(schema121, "add types to WorldGenData", References.WORLD_GEN_SETTINGS)); ++ Schema schema122 = p_14514_.addSchema(2552, SAME_NAMESPACED); + p_14514_.addFixer(new RenameBiomesFix(schema122, false, "Nether biome rename", ImmutableMap.of("minecraft:nether", "minecraft:nether_wastes"))); -+ Schema schema123 = p_14514_.addSchema(2553, f_14509_); ++ Schema schema123 = p_14514_.addSchema(2553, SAME_NAMESPACED); + p_14514_.addFixer(new BiomeFix(schema123, false)); -+ Schema schema124 = p_14514_.addSchema(2558, f_14509_); ++ Schema schema124 = p_14514_.addSchema(2558, SAME_NAMESPACED); + p_14514_.addFixer(new MissingDimensionFix(schema124, false)); + p_14514_.addFixer(new OptionsRenameFieldFix(schema124, false, "Rename swapHands setting", "key_key.swapHands", "key_key.swapOffhand")); + Schema schema125 = p_14514_.addSchema(2568, V2568::new); -+ p_14514_.addFixer(new AddNewChoices(schema125, "Added Piglin Brute", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema125, "Added Piglin Brute", References.ENTITY)); + Schema schema126 = p_14514_.addSchema(2571, V2571::new); -+ p_14514_.addFixer(new AddNewChoices(schema126, "Added Goat", References.f_16786_)); -+ Schema schema127 = p_14514_.addSchema(2679, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema126, "Added Goat", References.ENTITY)); ++ Schema schema127 = p_14514_.addSchema(2679, SAME_NAMESPACED); + p_14514_.addFixer(new CauldronRenameFix(schema127, false)); -+ Schema schema128 = p_14514_.addSchema(2680, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema128, "Renamed grass path item to dirt path", m_14517_("minecraft:grass_path", "minecraft:dirt_path"))); -+ p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema128, "Renamed grass path block to dirt path", m_14517_("minecraft:grass_path", "minecraft:dirt_path"))); ++ Schema schema128 = p_14514_.addSchema(2680, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema128, "Renamed grass path item to dirt path", createRenamer("minecraft:grass_path", "minecraft:dirt_path"))); ++ p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema128, "Renamed grass path block to dirt path", createRenamer("minecraft:grass_path", "minecraft:dirt_path"))); + Schema schema129 = p_14514_.addSchema(2684, V2684::new); -+ p_14514_.addFixer(new AddNewChoices(schema129, "Added Sculk Sensor", References.f_16781_)); ++ p_14514_.addFixer(new AddNewChoices(schema129, "Added Sculk Sensor", References.BLOCK_ENTITY)); + Schema schema130 = p_14514_.addSchema(2686, V2686::new); -+ p_14514_.addFixer(new AddNewChoices(schema130, "Added Axolotl", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema130, "Added Axolotl", References.ENTITY)); + Schema schema131 = p_14514_.addSchema(2688, V2688::new); -+ p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Squid", References.f_16786_)); -+ p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Item Frame", References.f_16786_)); -+ Schema schema132 = p_14514_.addSchema(2690, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Squid", References.ENTITY)); ++ p_14514_.addFixer(new AddNewChoices(schema131, "Added Glow Item Frame", References.ENTITY)); ++ Schema schema132 = p_14514_.addSchema(2690, SAME_NAMESPACED); + ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema132, "Renamed copper block items to new oxidized terms", m_14524_(immutablemap))); -+ p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema132, "Renamed copper blocks to new oxidized terms", m_14524_(immutablemap))); -+ Schema schema133 = p_14514_.addSchema(2691, f_14509_); ++ p_14514_.addFixer(ItemRenameFix.create(schema132, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); ++ p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); ++ Schema schema133 = p_14514_.addSchema(2691, SAME_NAMESPACED); + ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema133, "Rename copper item suffixes", m_14524_(immutablemap1))); -+ p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema133, "Rename copper blocks suffixes", m_14524_(immutablemap1))); -+ Schema schema134 = p_14514_.addSchema(2693, f_14509_); -+ p_14514_.addFixer(new AddFlagIfNotPresentFix(schema134, References.f_16795_, "has_increased_height_already", false)); -+ Schema schema135 = p_14514_.addSchema(2696, f_14509_); ++ p_14514_.addFixer(ItemRenameFix.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1))); ++ p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1))); ++ Schema schema134 = p_14514_.addSchema(2693, SAME_NAMESPACED); ++ p_14514_.addFixer(new AddFlagIfNotPresentFix(schema134, References.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); ++ Schema schema135 = p_14514_.addSchema(2696, SAME_NAMESPACED); + ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema135, "Renamed grimstone block items to deepslate", m_14524_(immutablemap2))); -+ p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema135, "Renamed grimstone blocks to deepslate", m_14524_(immutablemap2))); -+ Schema schema136 = p_14514_.addSchema(2700, f_14509_); -+ p_14514_.addFixer(BlockRenameFixWithJigsaw.m_145163_(schema136, "Renamed cave vines blocks", m_14524_(ImmutableMap.of("minecraft:cave_vines_head", "minecraft:cave_vines", "minecraft:cave_vines_body", "minecraft:cave_vines_plant")))); -+ Schema schema137 = p_14514_.addSchema(2701, f_14509_); ++ p_14514_.addFixer(ItemRenameFix.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); ++ p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); ++ Schema schema136 = p_14514_.addSchema(2700, SAME_NAMESPACED); ++ p_14514_.addFixer(BlockRenameFixWithJigsaw.create(schema136, "Renamed cave vines blocks", createRenamer(ImmutableMap.of("minecraft:cave_vines_head", "minecraft:cave_vines", "minecraft:cave_vines_body", "minecraft:cave_vines_plant")))); ++ Schema schema137 = p_14514_.addSchema(2701, SAME_NAMESPACED); + p_14514_.addFixer(new SavedDataFeaturePoolElementFix(schema137)); -+ Schema schema138 = p_14514_.addSchema(2702, f_14509_); ++ Schema schema138 = p_14514_.addSchema(2702, SAME_NAMESPACED); + p_14514_.addFixer(new AbstractArrowPickupFix(schema138)); + Schema schema139 = p_14514_.addSchema(2704, V2704::new); -+ p_14514_.addFixer(new AddNewChoices(schema139, "Added Goat", References.f_16786_)); ++ p_14514_.addFixer(new AddNewChoices(schema139, "Added Goat", References.ENTITY)); + Schema schema140 = p_14514_.addSchema(2707, V2707::new); -+ p_14514_.addFixer(new AddNewChoices(schema140, "Added Marker", References.f_16786_)); -+ p_14514_.addFixer(new AddFlagIfNotPresentFix(schema140, References.f_16795_, "has_increased_height_already", true)); -+ Schema schema141 = p_14514_.addSchema(2710, f_14509_); ++ p_14514_.addFixer(new AddNewChoices(schema140, "Added Marker", References.ENTITY)); ++ p_14514_.addFixer(new AddFlagIfNotPresentFix(schema140, References.WORLD_GEN_SETTINGS, "has_increased_height_already", true)); ++ Schema schema141 = p_14514_.addSchema(2710, SAME_NAMESPACED); + p_14514_.addFixer(new StatsRenameFix(schema141, "Renamed play_one_minute stat to play_time", ImmutableMap.of("minecraft:play_one_minute", "minecraft:play_time"))); -+ Schema schema142 = p_14514_.addSchema(2717, f_14509_); -+ p_14514_.addFixer(ItemRenameFix.m_16003_(schema142, "Rename azalea_leaves_flowers", m_14524_(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); -+ p_14514_.addFixer(BlockRenameFix.m_14914_(schema142, "Rename azalea_leaves_flowers items", m_14524_(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); -+ Schema schema143 = p_14514_.addSchema(2825, f_14509_); -+ p_14514_.addFixer(new AddFlagIfNotPresentFix(schema143, References.f_16795_, "has_increased_height_already", false)); ++ Schema schema142 = p_14514_.addSchema(2717, SAME_NAMESPACED); ++ p_14514_.addFixer(ItemRenameFix.create(schema142, "Rename azalea_leaves_flowers", createRenamer(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); ++ p_14514_.addFixer(BlockRenameFix.create(schema142, "Rename azalea_leaves_flowers items", createRenamer(ImmutableMap.of("minecraft:azalea_leaves_flowers", "minecraft:flowering_azalea_leaves")))); ++ Schema schema143 = p_14514_.addSchema(2825, SAME_NAMESPACED); ++ p_14514_.addFixer(new AddFlagIfNotPresentFix(schema143, References.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); + Schema schema144 = p_14514_.addSchema(2831, V2831::new); + p_14514_.addFixer(new SpawnerDataFix(schema144)); + Schema schema145 = p_14514_.addSchema(2832, V2832::new); + p_14514_.addFixer(new WorldGenSettingsHeightAndBiomeFix(schema145)); + p_14514_.addFixer(new ChunkHeightAndBiomeFix(schema145)); -+ Schema schema146 = p_14514_.addSchema(2833, f_14509_); ++ Schema schema146 = p_14514_.addSchema(2833, SAME_NAMESPACED); + p_14514_.addFixer(new WorldGenSettingsDisallowOldCustomWorldsFix(schema146)); -+ Schema schema147 = p_14514_.addSchema(2838, f_14509_); -+ p_14514_.addFixer(new RenameBiomesFix(schema147, false, "Caves and Cliffs biome renames", CavesAndCliffsRenames.f_184821_)); -+ Schema schema148 = p_14514_.addSchema(2841, f_14509_); ++ Schema schema147 = p_14514_.addSchema(2838, SAME_NAMESPACED); ++ p_14514_.addFixer(new RenameBiomesFix(schema147, false, "Caves and Cliffs biome renames", CavesAndCliffsRenames.RENAMES)); ++ Schema schema148 = p_14514_.addSchema(2841, SAME_NAMESPACED); + p_14514_.addFixer(new ChunkProtoTickListFix(schema148)); + Schema schema149 = p_14514_.addSchema(2842, V2842::new); + p_14514_.addFixer(new ChunkRenamesFix(schema149)); -+ Schema schema150 = p_14514_.addSchema(2843, f_14509_); ++ Schema schema150 = p_14514_.addSchema(2843, SAME_NAMESPACED); + p_14514_.addFixer(new OverreachingTickFix(schema150)); + p_14514_.addFixer(new RenameBiomesFix(schema150, false, "Remove Deep Warm Ocean", Map.of("minecraft:deep_warm_ocean", "minecraft:warm_ocean"))); -+ Schema schema151 = p_14514_.addSchema(2846, f_14509_); -+ p_14514_.addFixer(new AdvancementsRenameFix(schema151, false, "Rename some C&C part 2 advancements", m_14524_(ImmutableMap.of("minecraft:husbandry/play_jukebox_in_meadows", "minecraft:adventure/play_jukebox_in_meadows", "minecraft:adventure/caves_and_cliff", "minecraft:adventure/fall_from_world_height", "minecraft:adventure/ride_strider_in_overworld_lava", "minecraft:nether/ride_strider_in_overworld_lava")))); -+ Schema schema152 = p_14514_.addSchema(2852, f_14509_); ++ Schema schema151 = p_14514_.addSchema(2846, SAME_NAMESPACED); ++ p_14514_.addFixer(new AdvancementsRenameFix(schema151, false, "Rename some C&C part 2 advancements", createRenamer(ImmutableMap.of("minecraft:husbandry/play_jukebox_in_meadows", "minecraft:adventure/play_jukebox_in_meadows", "minecraft:adventure/caves_and_cliff", "minecraft:adventure/fall_from_world_height", "minecraft:adventure/ride_strider_in_overworld_lava", "minecraft:nether/ride_strider_in_overworld_lava")))); ++ Schema schema152 = p_14514_.addSchema(2852, SAME_NAMESPACED); + p_14514_.addFixer(new WorldGenSettingsDisallowOldCustomWorldsFix(schema152)); -+ Schema schema153 = p_14514_.addSchema(2967, f_14509_); ++ Schema schema153 = p_14514_.addSchema(2967, SAME_NAMESPACED); + p_14514_.addFixer(new StructureSettingsFlattenFix(schema153)); -+ Schema schema154 = p_14514_.addSchema(2970, f_14509_); ++ Schema schema154 = p_14514_.addSchema(2970, SAME_NAMESPACED); + p_14514_.addFixer(new StructuresBecomeConfiguredFix(schema154)); + } + -+ private static UnaryOperator m_14524_(Map p_14525_) { ++ private static UnaryOperator createRenamer(Map p_14525_) { + return (p_14528_) -> { + return p_14525_.getOrDefault(p_14528_, p_14528_); + }; + } + -+ private static UnaryOperator m_14517_(String p_14518_, String p_14519_) { ++ private static UnaryOperator createRenamer(String p_14518_, String p_14519_) { + return (p_14523_) -> { + return Objects.equals(p_14523_, p_14518_) ? p_14519_ : p_14523_; + }; diff --git a/patches/minecraft/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch b/patches/minecraft/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch index 30fea335..3e8dacbd 100644 --- a/patches/minecraft/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch +++ b/patches/minecraft/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java +++ b/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java @@ -371,7 +_,7 @@ - if (f_16111_.contains(optional.get().getSecond())) { + if (DAMAGE_IDS.contains(optional.get().getSecond())) { Typed typed1 = p_16119_.getOrCreateTyped(opticfinder1); Dynamic dynamic1 = typed1.get(DSL.remainderFinder()); - dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i)); diff --git a/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch b/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch index 8d10f012..1cb2e361 100644 --- a/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch +++ b/patches/minecraft/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java +++ b/net/minecraft/util/datafix/fixes/StructuresBecomeConfiguredFix.java @@ -93,7 +_,10 @@ - private Dynamic m_207723_(Pair, Dynamic> p_207724_, Dynamic p_207725_) { + private Dynamic findUpdatedStructureType(Pair, Dynamic> p_207724_, Dynamic p_207725_) { String s = p_207724_.getFirst().asString("UNKNOWN").toLowerCase(Locale.ROOT); - StructuresBecomeConfiguredFix.Conversion structuresbecomeconfiguredfix$conversion = f_207676_.get(s); + StructuresBecomeConfiguredFix.Conversion structuresbecomeconfiguredfix$conversion = CONVERSION_MAP.get(s); + if (structuresbecomeconfiguredfix$conversion == null) structuresbecomeconfiguredfix$conversion = net.minecraftforge.common.ForgeHooks.getStructureConversion(s); // Forge: hook for mods to register conversions through RegisterStructureConversionsEvent if (structuresbecomeconfiguredfix$conversion == null) { + if (net.minecraftforge.common.ForgeHooks.checkStructureNamespace(s)) return p_207724_.getSecond().createString(s); // Forge: pass-through structure IDs which have a non-"minecraft" namespace diff --git a/patches/minecraft/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/patches/minecraft/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index 39648978..17cd82fb 100644 --- a/patches/minecraft/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/patches/minecraft/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -1,24 +1,21 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java @@ -50,7 +_,8 @@ - private volatile int f_18807_; - private volatile int f_18808_; - private volatile int f_18809_; -- private final Object2FloatMap> f_18810_ = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap<>(Util.m_137583_())); -+ private final Object2FloatMap> f_18810_ = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.m_137583_())); // CraftBukkit + private volatile int totalChunks; + private volatile int converted; + private volatile int skipped; +- private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap<>(Util.identityStrategy())); ++ private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit + - private volatile Component f_18811_ = new TranslatableComponent("optimizeWorld.stage.counting"); - private static final Pattern f_18812_ = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); - private final DimensionDataStorage f_18813_; -@@ -123,9 +_,9 @@ - if (compoundtag != null) { - int j = ChunkStorage.m_63505_(compoundtag); - ChunkGenerator chunkgenerator = this.f_185925_.m_204655_().m_6246_(WorldGenSettings.m_190052_(resourcekey2)).m_63990_(); -- CompoundTag compoundtag1 = chunkstorage.m_188288_(resourcekey2, () -> { -+ CompoundTag compoundtag1 = chunkstorage.upgradeChunkTag(resourcekey2, () -> { - return this.f_18813_; -- }, compoundtag, chunkgenerator.m_187743_()); -+ }, compoundtag, chunkgenerator.m_187743_(),chunkpos, null); // Magma - maybe fix this?! - ChunkPos chunkpos1 = new ChunkPos(compoundtag1.m_128451_("xPos"), compoundtag1.m_128451_("zPos")); + private volatile Component status = new TranslatableComponent("optimizeWorld.stage.counting"); + private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); + private final DimensionDataStorage overworldDataStorage; +@@ -125,7 +_,7 @@ + ChunkGenerator chunkgenerator = this.worldGenSettings.dimensions().get(WorldGenSettings.levelToLevelStem(resourcekey2)).generator(); + CompoundTag compoundtag1 = chunkstorage.upgradeChunkTag(resourcekey2, () -> { + return this.overworldDataStorage; +- }, compoundtag, chunkgenerator.getTypeNameForDataFixer()); ++ }, compoundtag, chunkgenerator.getTypeNameForDataFixer(),chunkpos, null); // Magma - maybe fix this?! + ChunkPos chunkpos1 = new ChunkPos(compoundtag1.getInt("xPos"), compoundtag1.getInt("zPos")); if (!chunkpos1.equals(chunkpos)) { - f_18797_.warn("Chunk {} has invalid position {}", chunkpos, chunkpos1); + LOGGER.warn("Chunk {} has invalid position {}", chunkpos, chunkpos1); diff --git a/patches/minecraft/net/minecraft/world/CompoundContainer.java.patch b/patches/minecraft/net/minecraft/world/CompoundContainer.java.patch index 96a2ab60..cce79822 100644 --- a/patches/minecraft/net/minecraft/world/CompoundContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/CompoundContainer.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/world/CompoundContainer.java +++ b/net/minecraft/world/CompoundContainer.java @@ -7,6 +_,48 @@ - public final Container f_18910_; - public final Container f_18911_; + public final Container container1; + public final Container container2; + // CraftBukkit start - add fields and methods + public java.util.List transaction = new java.util.ArrayList(); + + public java.util.List getContents() { -+ java.util.List result = new java.util.ArrayList(this.m_6643_()); -+ for (int i = 0; i < this.m_6643_(); i++) { -+ result.add(this.m_8020_(i)); ++ java.util.List result = new java.util.ArrayList(this.getContainerSize()); ++ for (int i = 0; i < this.getContainerSize(); i++) { ++ result.add(this.getItem(i)); + } + return result; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { -+ this.f_18910_.onOpen(who); -+ this.f_18911_.onOpen(who); ++ this.container1.onOpen(who); ++ this.container2.onOpen(who); + transaction.add(who); + } + + public void onClose(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { -+ this.f_18910_.onClose(who); -+ this.f_18911_.onClose(who); ++ this.container1.onClose(who); ++ this.container2.onClose(who); + transaction.remove(who); + } + @@ -36,25 +36,25 @@ + } + + public void setMaxStackSize(int size) { -+ this.f_18910_.setMaxStackSize(size); -+ this.f_18911_.setMaxStackSize(size); ++ this.container1.setMaxStackSize(size); ++ this.container2.setMaxStackSize(size); + } + + @Override + public org.bukkit.Location getLocation() { -+ return f_18910_.getLocation(); // TODO: right? ++ return container1.getLocation(); // TODO: right? + } + // CraftBukkit end + public CompoundContainer(Container p_18913_, Container p_18914_) { - this.f_18910_ = p_18913_; - this.f_18911_ = p_18914_; + this.container1 = p_18913_; + this.container2 = p_18914_; @@ -46,7 +_,7 @@ } - public int m_6893_() { -- return this.f_18910_.m_6893_(); -+ return Math.min(this.f_18910_.m_6893_(), this.f_18911_.m_6893_()); // CraftBukkit - check both sides + public int getMaxStackSize() { +- return this.container1.getMaxStackSize(); ++ return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides } - public void m_6596_() { + public void setChanged() { diff --git a/patches/minecraft/net/minecraft/world/LockCode.java.patch b/patches/minecraft/net/minecraft/world/LockCode.java.patch index 9754c6a7..c5538bcc 100644 --- a/patches/minecraft/net/minecraft/world/LockCode.java.patch +++ b/patches/minecraft/net/minecraft/world/LockCode.java.patch @@ -3,21 +3,21 @@ @@ -15,7 +_,19 @@ } - public boolean m_19107_(ItemStack p_19108_) { -- return this.f_19103_.isEmpty() || !p_19108_.m_41619_() && p_19108_.m_41788_() && this.f_19103_.equals(p_19108_.m_41786_().getString()); + public boolean unlocksWith(ItemStack p_19108_) { +- return this.key.isEmpty() || !p_19108_.isEmpty() && p_19108_.hasCustomHoverName() && this.key.equals(p_19108_.getHoverName().getString()); + // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes -+ if (this.f_19103_.isEmpty()) return true; -+ if (!p_19108_.m_41619_() && p_19108_.m_41788_()) { -+ if (this.f_19103_.indexOf(org.bukkit.ChatColor.COLOR_CHAR) == -1) { ++ if (this.key.isEmpty()) return true; ++ if (!p_19108_.isEmpty() && p_19108_.hasCustomHoverName()) { ++ if (this.key.indexOf(org.bukkit.ChatColor.COLOR_CHAR) == -1) { + // The lock key contains no color codes, so let's ignore colors in the item display name (vanilla Minecraft behavior): -+ return this.f_19103_.equals(p_19108_.m_41786_().getString()); ++ return this.key.equals(p_19108_.getHoverName().getString()); + } else { + // The lock key contains color codes, so let's take them into account: -+ return this.f_19103_.equals(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(p_19108_.m_41786_())); ++ return this.key.equals(org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromComponent(p_19108_.getHoverName())); + } + } + return false; + // CraftBukkit end } - public void m_19109_(CompoundTag p_19110_) { + public void addToTag(CompoundTag p_19110_) { diff --git a/patches/minecraft/net/minecraft/world/SimpleContainer.java.patch b/patches/minecraft/net/minecraft/world/SimpleContainer.java.patch index 3e6b101b..b4b372ca 100644 --- a/patches/minecraft/net/minecraft/world/SimpleContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/SimpleContainer.java.patch @@ -3,11 +3,11 @@ @@ -15,11 +_,62 @@ public class SimpleContainer implements Container, StackedContentsCompatible { - private final int f_19146_; -- private final NonNullList f_19147_; -+ public final NonNullList f_19147_; //Magma - private -> public + private final int size; +- private final NonNullList items; ++ public final NonNullList items; //Magma - private -> public @Nullable - private List f_19148_; + private List listeners; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -15,7 +15,7 @@ + protected org.bukkit.inventory.InventoryHolder bukkitOwner; + + public List getContents() { -+ return this.f_19147_; ++ return this.items; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -35,7 +35,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -50,8 +50,8 @@ + + + public SimpleContainer(SimpleContainer original) { -+ this(original.f_19146_); -+ java.util.stream.IntStream.range(0, original.f_19146_).forEach(i -> this.f_19147_.set(i, original.f_19147_.get(i).m_41777_())); ++ this(original.size); ++ java.util.stream.IntStream.range(0, original.size).forEach(i -> this.items.set(i, original.items.get(i).copy())); + } + public SimpleContainer(int p_19150_) { @@ -61,6 +61,6 @@ + public SimpleContainer(int p_19150_, org.bukkit.inventory.InventoryHolder owner) { + this.bukkitOwner = owner; + // CraftBukkit end - this.f_19146_ = p_19150_; - this.f_19147_ = NonNullList.m_122780_(p_19150_, ItemStack.f_41583_); + this.size = p_19150_; + this.items = NonNullList.withSize(p_19150_, ItemStack.EMPTY); } diff --git a/patches/minecraft/net/minecraft/world/damagesource/DamageSource.java.patch b/patches/minecraft/net/minecraft/world/damagesource/DamageSource.java.patch index 1b02f112..4054f8c5 100644 --- a/patches/minecraft/net/minecraft/world/damagesource/DamageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/damagesource/DamageSource.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java @@ -51,6 +_,18 @@ - private boolean f_146700_; - private boolean f_181119_; - public final String f_19326_; + private boolean isFall; + private boolean noAggro; + public final String msgId; + // CraftBukkit start + private boolean sweep; + @@ -17,5 +17,5 @@ + } + // CraftBukkit end - public static DamageSource m_19364_(LivingEntity p_19365_) { + public static DamageSource sting(LivingEntity p_19365_) { return new EntityDamageSource("sting", p_19365_); diff --git a/patches/minecraft/net/minecraft/world/damagesource/IndirectEntityDamageSource.java.patch b/patches/minecraft/net/minecraft/world/damagesource/IndirectEntityDamageSource.java.patch index 96aad370..d88a1e06 100644 --- a/patches/minecraft/net/minecraft/world/damagesource/IndirectEntityDamageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/damagesource/IndirectEntityDamageSource.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/world/damagesource/IndirectEntityDamageSource.java @@ -33,4 +_,11 @@ String s1 = s + ".item"; - return !itemstack.m_41619_() && itemstack.m_41788_() ? new TranslatableComponent(s1, p_19410_.m_5446_(), component, itemstack.m_41611_()) : new TranslatableComponent(s, p_19410_.m_5446_(), component); + return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? new TranslatableComponent(s1, p_19410_.getDisplayName(), component, itemstack.getDisplayName()) : new TranslatableComponent(s, p_19410_.getDisplayName(), component); } + + // CraftBukkit start + public Entity getProximateDamageSource() { -+ return super.m_7639_(); ++ return super.getEntity(); + } + // CraftBukkit end + diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch index 7c1d3112..8141cd5c 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch @@ -6,57 +6,57 @@ -public class MobEffect { +public class MobEffect extends net.minecraftforge.registries.ForgeRegistryEntry implements net.minecraftforge.common.extensions.IForgeMobEffect { - private final Map f_19446_ = Maps.newHashMap(); - private final MobEffectCategory f_19447_; - private final int f_19448_; + private final Map attributeModifiers = Maps.newHashMap(); + private final MobEffectCategory category; + private final int color; @@ -37,30 +_,45 @@ protected MobEffect(MobEffectCategory p_19451_, int p_19452_) { - this.f_19447_ = p_19451_; - this.f_19448_ = p_19452_; + this.category = p_19451_; + this.color = p_19452_; + initClient(); } - public void m_6742_(LivingEntity p_19467_, int p_19468_) { - if (this == MobEffects.f_19605_) { - if (p_19467_.m_21223_() < p_19467_.m_21233_()) { + public void applyEffectTick(LivingEntity p_19467_, int p_19468_) { + if (this == MobEffects.REGENERATION) { + if (p_19467_.getHealth() < p_19467_.getMaxHealth()) { + p_19467_.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); - p_19467_.m_5634_(1.0F); + p_19467_.heal(1.0F); } - } else if (this == MobEffects.f_19614_) { - if (p_19467_.m_21223_() > 1.0F) { -- p_19467_.m_6469_(DamageSource.f_19319_, 1.0F); -+ p_19467_.m_6469_(org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.POISON + } else if (this == MobEffects.POISON) { + if (p_19467_.getHealth() > 1.0F) { +- p_19467_.hurt(DamageSource.MAGIC, 1.0F); ++ p_19467_.hurt(org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.POISON } - } else if (this == MobEffects.f_19615_) { - p_19467_.m_6469_(DamageSource.f_19320_, 1.0F); -- } else if (this == MobEffects.f_19612_ && p_19467_ instanceof Player) { -- ((Player)p_19467_).m_36399_(0.005F * (float)(p_19468_ + 1)); -+ } else if (this == MobEffects.f_19612_ && p_19467_ instanceof Player player) { + } else if (this == MobEffects.WITHER) { + p_19467_.hurt(DamageSource.WITHER, 1.0F); +- } else if (this == MobEffects.HUNGER && p_19467_ instanceof Player) { +- ((Player)p_19467_).causeFoodExhaustion(0.005F * (float)(p_19468_ + 1)); ++ } else if (this == MobEffects.HUNGER && p_19467_ instanceof Player player) { + player.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); -+ player.m_36399_(0.005F * (float)(p_19468_ + 1)); - } else if (this == MobEffects.f_19618_ && p_19467_ instanceof Player) { - if (!p_19467_.f_19853_.f_46443_) { -- ((Player)p_19467_).m_36324_().m_38707_(p_19468_ + 1, 1.0F); ++ player.causeFoodExhaustion(0.005F * (float)(p_19468_ + 1)); + } else if (this == MobEffects.SATURATION && p_19467_ instanceof Player) { + if (!p_19467_.level.isClientSide) { +- ((Player)p_19467_).getFoodData().eat(p_19468_ + 1, 1.0F); + // CraftBukkit start + Player entityhuman = (Player) p_19467_; -+ int oldFoodLevel = entityhuman.m_36324_().f_38696_; ++ int oldFoodLevel = entityhuman.getFoodData().foodLevel; + + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, p_19468_ + 1 + oldFoodLevel); + + if (!event.isCancelled()) { -+ entityhuman.m_36324_().m_38707_(event.getFoodLevel() - oldFoodLevel, 1.0F); ++ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); + } + -+ ((net.minecraft.server.level.ServerPlayer) entityhuman).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundSetHealthPacket(((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.m_36324_().f_38696_, entityhuman.m_36324_().f_38697_)); ++ ((net.minecraft.server.level.ServerPlayer) entityhuman).connection.send(new net.minecraft.network.protocol.game.ClientboundSetHealthPacket(((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.f_19601_ || p_19467_.m_21222_()) && (this != MobEffects.f_19602_ || !p_19467_.m_21222_())) { - if (this == MobEffects.f_19602_ && !p_19467_.m_21222_() || this == MobEffects.f_19601_ && p_19467_.m_21222_()) { - p_19467_.m_6469_(DamageSource.f_19319_, (float)(6 << p_19468_)); + } else if ((this != MobEffects.HEAL || p_19467_.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !p_19467_.isInvertedHealAndHarm())) { + if (this == MobEffects.HARM && !p_19467_.isInvertedHealAndHarm() || this == MobEffects.HEAL && p_19467_.isInvertedHealAndHarm()) { + p_19467_.hurt(DamageSource.MAGIC, (float)(6 << p_19468_)); } } else { + p_19467_.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); - p_19467_.m_5634_((float)Math.max(4 << p_19468_, 0)); + p_19467_.heal((float)Math.max(4 << p_19468_, 0)); } @@ -80,6 +_,7 @@ @@ -64,12 +64,12 @@ } else { int i = (int)(p_19466_ * (double)(4 << p_19465_) + 0.5D); + p_19464_.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); - p_19464_.m_5634_((float)i); + p_19464_.heal((float)i); } @@ -179,4 +_,29 @@ - public boolean m_19486_() { - return this.f_19447_ == MobEffectCategory.BENEFICIAL; + public boolean isBeneficial() { + return this.category == MobEffectCategory.BENEFICIAL; } + + // FORGE START diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch index 8ddba771..0d54c472 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -6,66 +6,66 @@ -public class MobEffectInstance implements Comparable { +public class MobEffectInstance implements Comparable, net.minecraftforge.common.extensions.IForgeMobEffectInstance { - private static final Logger f_19501_ = LogUtils.getLogger(); - private final MobEffect f_19502_; - private int f_19503_; + private static final Logger LOGGER = LogUtils.getLogger(); + private final MobEffect effect; + private int duration; @@ -60,6 +_,7 @@ - this.f_19506_ = p_19549_.f_19506_; - this.f_19508_ = p_19549_.f_19508_; - this.f_19509_ = p_19549_.f_19509_; + this.ambient = p_19549_.ambient; + this.visible = p_19549_.visible; + this.showIcon = p_19549_.showIcon; + this.curativeItems = p_19549_.curativeItems == null ? null : new java.util.ArrayList(p_19549_.curativeItems); } - public boolean m_19558_(MobEffectInstance p_19559_) { + public boolean update(MobEffectInstance p_19559_) { @@ -108,7 +_,7 @@ } - public MobEffect m_19544_() { -- return this.f_19502_; -+ return this.f_19502_ == null ? null : this.f_19502_.delegate.get(); + public MobEffect getEffect() { +- return this.effect; ++ return this.effect == null ? null : this.effect.delegate.get(); } - public int m_19557_() { + public int getDuration() { @@ -206,6 +_,7 @@ - public CompoundTag m_19555_(CompoundTag p_19556_) { - p_19556_.m_128344_("Id", (byte)MobEffect.m_19459_(this.m_19544_())); -+ net.minecraftforge.common.ForgeHooks.saveMobEffect(p_19556_, "forge:id", this.m_19544_()); - this.m_19567_(p_19556_); + public CompoundTag save(CompoundTag p_19556_) { + p_19556_.putByte("Id", (byte)MobEffect.getId(this.getEffect())); ++ net.minecraftforge.common.ForgeHooks.saveMobEffect(p_19556_, "forge:id", this.getEffect()); + this.writeDetailsTo(p_19556_); return p_19556_; } @@ -221,13 +_,15 @@ - this.f_19510_.m_19555_(compoundtag); - p_19568_.m_128365_("HiddenEffect", compoundtag); + this.hiddenEffect.save(compoundtag); + p_19568_.put("HiddenEffect", compoundtag); } + writeCurativeItems(p_19568_); } @Nullable - public static MobEffectInstance m_19560_(CompoundTag p_19561_) { -- int i = p_19561_.m_128445_("Id"); -+ int i = p_19561_.m_128445_("Id") & 0xFF; - MobEffect mobeffect = MobEffect.m_19453_(i); + public static MobEffectInstance load(CompoundTag p_19561_) { +- int i = p_19561_.getByte("Id"); ++ int i = p_19561_.getByte("Id") & 0xFF; + MobEffect mobeffect = MobEffect.byId(i); + mobeffect = net.minecraftforge.common.ForgeHooks.loadMobEffect(p_19561_, "forge:id", mobeffect); - return mobeffect == null ? null : m_19545_(mobeffect, p_19561_); + return mobeffect == null ? null : loadSpecifiedEffect(mobeffect, p_19561_); } @@ -250,7 +_,7 @@ - mobeffectinstance = m_19545_(p_19546_, p_19547_.m_128469_("HiddenEffect")); + mobeffectinstance = loadSpecifiedEffect(p_19546_, p_19547_.getCompound("HiddenEffect")); } - return new MobEffectInstance(p_19546_, j, i < 0 ? 0 : i, flag, flag1, flag2, mobeffectinstance); + return readCurativeItems(new MobEffectInstance(p_19546_, j, i < 0 ? 0 : i, flag, flag1, flag2, mobeffectinstance), p_19547_); } - public void m_19562_(boolean p_19563_) { + public void setNoCounter(boolean p_19563_) { @@ -263,6 +_,32 @@ public int compareTo(MobEffectInstance p_19566_) { int i = 32147; -- return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result(); -+ return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result(); +- return (this.getDuration() <= 32147 || p_19566_.getDuration() <= 32147) && (!this.isAmbient() || !p_19566_.isAmbient()) ? ComparisonChain.start().compare(this.isAmbient(), p_19566_.isAmbient()).compare(this.getDuration(), p_19566_.getDuration()).compare(this.getEffect().getColor(), p_19566_.getEffect().getColor()).result() : ComparisonChain.start().compare(this.isAmbient(), p_19566_.isAmbient()).compare(this.getEffect().getColor(), p_19566_.getEffect().getColor()).result(); ++ return (this.getDuration() <= 32147 || p_19566_.getDuration() <= 32147) && (!this.isAmbient() || !p_19566_.isAmbient()) ? ComparisonChain.start().compare(this.isAmbient(), p_19566_.isAmbient()).compare(this.getDuration(), p_19566_.getDuration()).compare(this.getEffect().getSortOrder(this), p_19566_.getEffect().getSortOrder(this)).result() : ComparisonChain.start().compare(this.isAmbient(), p_19566_.isAmbient()).compare(this.getEffect().getSortOrder(this), p_19566_.getEffect().getSortOrder(this)).result(); + } + + //======================= FORGE START =========================== @@ -74,7 +74,7 @@ + @Override + public java.util.List getCurativeItems() { + if (this.curativeItems == null) //Lazy load this so that we don't create a circular dep on Items. -+ this.curativeItems = m_19544_().getCurativeItems(); ++ this.curativeItems = getEffect().getCurativeItems(); + return this.curativeItems; + } + @Override @@ -82,11 +82,11 @@ + this.curativeItems = curativeItems; + } + private static MobEffectInstance readCurativeItems(MobEffectInstance effect, CompoundTag nbt) { -+ if (nbt.m_128425_("CurativeItems", net.minecraft.nbt.Tag.f_178202_)) { ++ if (nbt.contains("CurativeItems", net.minecraft.nbt.Tag.TAG_LIST)) { + java.util.List items = new java.util.ArrayList(); -+ net.minecraft.nbt.ListTag list = nbt.m_128437_("CurativeItems", net.minecraft.nbt.Tag.f_178203_); ++ net.minecraft.nbt.ListTag list = nbt.getList("CurativeItems", net.minecraft.nbt.Tag.TAG_COMPOUND); + for (int i = 0; i < list.size(); i++) { -+ items.add(net.minecraft.world.item.ItemStack.m_41712_(list.m_128728_(i))); ++ items.add(net.minecraft.world.item.ItemStack.of(list.getCompound(i))); + } + effect.setCurativeItems(items); + } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch index f426e0c7..e11f3619 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffects.java.patch @@ -6,5 +6,5 @@ +@net.minecraftforge.registries.ObjectHolder("minecraft") public class MobEffects { - public static final MobEffect f_19596_ = m_19623_(1, "speed", (new MobEffect(MobEffectCategory.BENEFICIAL, 8171462)).m_19472_(Attributes.f_22279_, "91AEAA56-376B-4498-935B-2F7F68070635", (double)0.2F, AttributeModifier.Operation.MULTIPLY_TOTAL)); - public static final MobEffect f_19597_ = m_19623_(2, "slowness", (new MobEffect(MobEffectCategory.HARMFUL, 5926017)).m_19472_(Attributes.f_22279_, "7107DE5E-7CE8-4030-940E-514C1F160890", (double)-0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL)); + public static final MobEffect MOVEMENT_SPEED = register(1, "speed", (new MobEffect(MobEffectCategory.BENEFICIAL, 8171462)).addAttributeModifier(Attributes.MOVEMENT_SPEED, "91AEAA56-376B-4498-935B-2F7F68070635", (double)0.2F, AttributeModifier.Operation.MULTIPLY_TOTAL)); + public static final MobEffect MOVEMENT_SLOWDOWN = register(2, "slowness", (new MobEffect(MobEffectCategory.HARMFUL, 5926017)).addAttributeModifier(Attributes.MOVEMENT_SPEED, "7107DE5E-7CE8-4030-940E-514C1F160890", (double)-0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL)); diff --git a/patches/minecraft/net/minecraft/world/entity/AgeableMob.java.patch b/patches/minecraft/net/minecraft/world/entity/AgeableMob.java.patch index 748ef9aa..a28bdf1a 100644 --- a/patches/minecraft/net/minecraft/world/entity/AgeableMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/AgeableMob.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java @@ -18,11 +_,32 @@ - protected int f_146733_; - protected int f_146734_; - protected int f_146735_; + protected int age; + protected int forcedAge; + protected int forcedAgeTimer; + public boolean ageLocked; // CraftBukkit protected AgeableMob(EntityType p_146738_, Level p_146739_) { @@ -14,46 +14,46 @@ + @Override + public void inactiveTick() { + super.inactiveTick(); -+ if (this.f_19853_.f_46443_ || this.ageLocked) { // CraftBukkit -+ this.m_6210_(); ++ if (this.level.isClientSide || this.ageLocked) { // CraftBukkit ++ this.refreshDimensions(); + } else { -+ int i = this.m_146764_(); ++ int i = this.getAge(); + + if (i < 0) { + ++i; -+ this.m_146762_(i); ++ this.setAge(i); + } else if (i > 0) { + --i; -+ this.m_146762_(i); ++ this.setAge(i); + } + } + } + // Spigot end + - public SpawnGroupData m_6518_(ServerLevelAccessor p_146746_, DifficultyInstance p_146747_, MobSpawnType p_146748_, @Nullable SpawnGroupData p_146749_, @Nullable CompoundTag p_146750_) { + public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_146746_, DifficultyInstance p_146747_, MobSpawnType p_146748_, @Nullable SpawnGroupData p_146749_, @Nullable CompoundTag p_146750_) { if (p_146749_ == null) { p_146749_ = new AgeableMob.AgeableMobGroupData(true); @@ -97,12 +_,14 @@ - super.m_7380_(p_146761_); - p_146761_.m_128405_("Age", this.m_146764_()); - p_146761_.m_128405_("ForcedAge", this.f_146734_); -+ p_146761_.m_128379_("AgeLocked", this.ageLocked); // CraftBukkit + super.addAdditionalSaveData(p_146761_); + p_146761_.putInt("Age", this.getAge()); + p_146761_.putInt("ForcedAge", this.forcedAge); ++ p_146761_.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit } - public void m_7378_(CompoundTag p_146752_) { - super.m_7378_(p_146752_); - this.m_146762_(p_146752_.m_128451_("Age")); - this.f_146734_ = p_146752_.m_128451_("ForcedAge"); -+ this.ageLocked = p_146752_.m_128471_("AgeLocked"); // CraftBukkit + public void readAdditionalSaveData(CompoundTag p_146752_) { + super.readAdditionalSaveData(p_146752_); + this.setAge(p_146752_.getInt("Age")); + this.forcedAge = p_146752_.getInt("ForcedAge"); ++ this.ageLocked = p_146752_.getBoolean("AgeLocked"); // CraftBukkit } - public void m_7350_(EntityDataAccessor p_146754_) { + public void onSyncedDataUpdated(EntityDataAccessor p_146754_) { @@ -115,7 +_,7 @@ - public void m_8107_() { - super.m_8107_(); -- if (this.f_19853_.f_46443_) { -+ if (this.f_19853_.f_46443_ || ageLocked) { // CraftBukkit - if (this.f_146735_ > 0) { - if (this.f_146735_ % 4 == 0) { - this.f_19853_.m_7106_(ParticleTypes.f_123748_, this.m_20208_(1.0D), this.m_20187_() + 0.5D, this.m_20262_(1.0D), 0.0D, 0.0D, 0.0D); + public void aiStep() { + super.aiStep(); +- if (this.level.isClientSide) { ++ if (this.level.isClientSide || ageLocked) { // CraftBukkit + if (this.forcedAgeTimer > 0) { + if (this.forcedAgeTimer % 4 == 0) { + this.level.addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D); diff --git a/patches/minecraft/net/minecraft/world/entity/AreaEffectCloud.java.patch b/patches/minecraft/net/minecraft/world/entity/AreaEffectCloud.java.patch index 2444aad0..53d10786 100644 --- a/patches/minecraft/net/minecraft/world/entity/AreaEffectCloud.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/AreaEffectCloud.java.patch @@ -6,50 +6,50 @@ + // CraftBukkit start accessor methods + public void refreshEffects() { -+ if (!this.f_19690_) { -+ this.m_20088_().m_135381_(f_19698_, PotionUtils.m_43564_((java.util.Collection) PotionUtils.m_43561_(this.f_19701_, (java.util.Collection) this.f_19685_))); // PAIL: rename ++ if (!this.fixedColor) { ++ this.getEntityData().set(DATA_COLOR, PotionUtils.getColor((java.util.Collection) PotionUtils.getAllEffects(this.potion, (java.util.Collection) this.effects))); // PAIL: rename + } + } + + public String getPotionType() { -+ return ((net.minecraft.resources.ResourceLocation) Registry.f_122828_.m_7981_(this.f_19701_)).toString(); ++ return ((net.minecraft.resources.ResourceLocation) Registry.POTION.getKey(this.potion)).toString(); + } + + public void setPotionType(String string) { -+ m_19722_(Registry.f_122828_.m_7745_(new net.minecraft.resources.ResourceLocation(string))); ++ setPotion(Registry.POTION.get(new net.minecraft.resources.ResourceLocation(string))); + } + // CraftBukkit end + - public int m_19744_() { - return this.m_20088_().m_135370_(f_19698_); + public int getColor() { + return this.getEntityData().get(DATA_COLOR); } @@ -148,6 +_,17 @@ - this.f_19687_ = p_19735_; + this.duration = p_19735_; } + // Spigot start - copied from below + @Override + public void inactiveTick() { + super.inactiveTick(); -+ if (this.f_19797_ >= this.f_19688_ + this.f_19687_) { -+ this.m_146870_(); ++ if (this.tickCount >= this.waitTime + this.duration) { ++ this.discard(); + return; + } + } + // Spigot end + - public void m_8119_() { - super.m_8119_(); - boolean flag = this.m_19747_(); + public void tick() { + super.tick(); + boolean flag = this.isWaiting(); @@ -237,19 +_,32 @@ } else { - List list1 = this.f_19853_.m_45976_(LivingEntity.class, this.m_142469_()); + List list1 = this.level.getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); if (!list1.isEmpty()) { + List entities = new java.util.ArrayList(); // CraftBukkit for(LivingEntity livingentity : list1) { - if (!this.f_19686_.containsKey(livingentity) && livingentity.m_5801_()) { - double d8 = livingentity.m_20185_() - this.m_20185_(); - double d1 = livingentity.m_20189_() - this.m_20189_(); + if (!this.victims.containsKey(livingentity) && livingentity.isAffectedByPotions()) { + double d8 = livingentity.getX() - this.getX(); + double d1 = livingentity.getZ() - this.getZ(); double d3 = d8 * d8 + d1 * d1; if (d3 <= (double)(f * f)) { + // CraftBukkit start @@ -63,15 +63,15 @@ + if (entity instanceof org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) { + LivingEntity livingentity = ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) entity).getHandle(); + // CraftBukkit end - this.f_19686_.put(livingentity, this.f_19797_ + this.f_19689_); + this.victims.put(livingentity, this.tickCount + this.reapplicationDelay); for(MobEffectInstance mobeffectinstance1 : list) { - if (mobeffectinstance1.m_19544_().m_8093_()) { - mobeffectinstance1.m_19544_().m_19461_(this, this.m_19749_(), livingentity, mobeffectinstance1.m_19564_(), 0.5D); + if (mobeffectinstance1.getEffect().isInstantenous()) { + mobeffectinstance1.getEffect().applyInstantenousEffect(this, this.getOwner(), livingentity, mobeffectinstance1.getAmplifier(), 0.5D); } else { -- livingentity.m_147207_(new MobEffectInstance(mobeffectinstance1), this); +- livingentity.addEffect(new MobEffectInstance(mobeffectinstance1), this); + livingentity.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); //Magma -+ livingentity.m_147207_(new MobEffectInstance(mobeffectinstance1), this); // CraftBukkit ++ livingentity.addEffect(new MobEffectInstance(mobeffectinstance1), this); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index 1577740b..af44c9cf 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -11,14 +11,14 @@ + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; + static boolean isLevelAtLeast(CompoundTag tag, int level) { -+ return tag.m_128441_("Bukkit.updateLevel") && tag.m_128451_("Bukkit.updateLevel") >= level; ++ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; + } + + private org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity bukkitEntity; + + public org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity getBukkitEntity() { + if (bukkitEntity == null) { -+ bukkitEntity = org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity.getEntity(f_19853_.getCraftServer(), this); ++ bukkitEntity = org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity.getEntity(level.getCraftServer(), this); + } + return bukkitEntity; + } @@ -49,39 +49,39 @@ + + // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + public int getDefaultMaxAirSupply() { -+ return f_146818_; ++ return TOTAL_AIR_SUPPLY; + } + // CraftBukkit end + - private static final Logger f_19849_ = LogUtils.getLogger(); - public static final String f_146815_ = "id"; - public static final String f_146816_ = "Passengers"; + private static final Logger LOGGER = LogUtils.getLogger(); + public static final String ID_TAG = "id"; + public static final String PASSENGERS_TAG = "Passengers"; @@ -135,6 +_,7 @@ - private static final double f_146812_ = 0.0023333333333333335D; - public static final String f_146824_ = "UUID"; - private static double f_19846_ = 1.0D; + private static final double LAVA_SLOW_FLOW_SCALE = 0.0023333333333333335D; + public static final String UUID_TAG = "UUID"; + private static double viewScale = 1.0D; + @Deprecated // Forge: Use the getter to allow overriding in mods - private final EntityType f_19847_; - private int f_19848_ = f_19843_.incrementAndGet(); - public boolean f_19850_; + private final EntityType type; + private int id = ENTITY_COUNTER.incrementAndGet(); + public boolean blocksBuilding; @@ -175,12 +_,13 @@ - public double f_19790_; - public double f_19791_; - public double f_19792_; + public double xOld; + public double yOld; + public double zOld; + @Deprecated // Forge - see IForgeEntity#getStepHeight - public float f_19793_; - public boolean f_19794_; - protected final Random f_19796_ = new Random(); - public int f_19797_; - public int f_19831_ = -this.m_6101_(); -- protected boolean f_19798_; -+ public boolean f_19798_; - protected Object2DoubleMap> f_19799_ = new Object2DoubleArrayMap<>(2); - protected boolean f_19800_; - private final Set> f_19801_ = new HashSet<>(); + public float maxUpStep; + public boolean noPhysics; + protected final Random random = new Random(); + public int tickCount; + public int remainingFireTicks = -this.getFireImmuneTicks(); +- protected boolean wasTouchingWater; ++ public boolean wasTouchingWater; + protected Object2DoubleMap> fluidHeight = new Object2DoubleArrayMap<>(2); + protected boolean wasEyeInWater; + private final Set> fluidOnEyes = new HashSet<>(); @@ -228,7 +_,40 @@ @Nullable - private BlockState f_185934_ = null; + private BlockState feetBlockState = null; + // CraftBukkit start + public boolean persist = true; @@ -102,11 +102,11 @@ + + + public float getBukkitYaw() { -+ return this.f_19857_; ++ return this.yRot; + } + + public boolean isChunkLoaded() { -+ return f_19853_.m_7232_((int) Math.floor(this.m_20185_()) >> 4, (int) Math.floor(this.m_20189_()) >> 4); ++ return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); + } + // CraftBukkit end + @@ -117,39 +117,39 @@ + public Entity(EntityType p_19870_, Level p_19871_) { + super(Entity.class); - this.f_19847_ = p_19870_; - this.f_19853_ = p_19871_; - this.f_19815_ = p_19870_.m_20680_(); + this.type = p_19870_; + this.level = p_19871_; + this.dimensions = p_19870_.getDimensions(); @@ -236,6 +_,13 @@ - this.f_19826_ = BlockPos.f_121853_; - this.f_185933_ = ChunkPos.f_186419_; - this.f_19838_ = Vec3.f_82478_; + this.blockPosition = BlockPos.ZERO; + this.chunkPosition = ChunkPos.ZERO; + this.packetCoordinates = Vec3.ZERO; + // Spigot start -+ if (f_19853_ != null) { -+ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, f_19853_.spigotConfig); ++ if (level != null) { ++ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, level.spigotConfig); + } else { + this.defaultActivationState = false; + } + // Spigot end - this.f_19804_ = new SynchedEntityData(this); - this.f_19804_.m_135372_(f_19805_, (byte)0); - this.f_19804_.m_135372_(f_19832_, this.m_6062_()); + this.entityData = new SynchedEntityData(this); + this.entityData.define(DATA_SHARED_FLAGS_ID, (byte)0); + this.entityData.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply()); @@ -247,7 +_,11 @@ - this.f_19804_.m_135372_(f_146800_, 0); - this.m_8097_(); - this.m_6034_(0.0D, 0.0D, 0.0D); -- this.f_19816_ = this.m_6380_(Pose.STANDING, this.f_19815_); -+ net.minecraftforge.event.entity.EntityEvent.Size sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, Pose.STANDING, this.f_19815_, this.m_6380_(Pose.STANDING, this.f_19815_)); -+ this.f_19815_ = sizeEvent.getNewSize(); -+ this.f_19816_ = sizeEvent.getNewEyeHeight(); + this.entityData.define(DATA_TICKS_FROZEN, 0); + this.defineSynchedData(); + this.setPos(0.0D, 0.0D, 0.0D); +- this.eyeHeight = this.getEyeHeight(Pose.STANDING, this.dimensions); ++ net.minecraftforge.event.entity.EntityEvent.Size sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, Pose.STANDING, this.dimensions, this.getEyeHeight(Pose.STANDING, this.dimensions)); ++ this.dimensions = sizeEvent.getNewSize(); ++ this.eyeHeight = sizeEvent.getNewEyeHeight(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); + this.gatherCapabilities(); } - public boolean m_20039_(BlockPos p_20040_, BlockState p_20041_) { + public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) { @@ -343,6 +_,7 @@ if (p_146834_ == Entity.RemovalReason.KILLED) { - this.m_146850_(GameEvent.f_157809_); + this.gameEvent(GameEvent.ENTITY_KILLED); } + this.invalidateCaps(); @@ -158,9 +158,9 @@ @@ -350,6 +_,23 @@ } - public void m_20124_(Pose p_20125_) { + public void setPose(Pose p_20125_) { + // CraftBukkit start -+ if (p_20125_ == this.m_20089_()) { ++ if (p_20125_ == this.getPose()) { + return; + } + @@ -172,17 +172,17 @@ + pose = org.bukkit.entity.Pose.MODDED; + } + -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityPoseChangeEvent(this.getBukkitEntity(), pose)); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityPoseChangeEvent(this.getBukkitEntity(), pose)); + //Magma end + + // CraftBukkit end - this.f_19804_.m_135381_(f_19806_, p_20125_); + this.entityData.set(DATA_POSE, p_20125_); } @@ -365,6 +_,33 @@ } - protected void m_19915_(float p_19916_, float p_19917_) { + protected void setRot(float p_19916_, float p_19917_) { + // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0 + if (Float.isNaN(p_19916_)) { + p_19916_ = 0; @@ -190,7 +190,7 @@ + + if (p_19916_ == Float.POSITIVE_INFINITY || p_19916_ == Float.NEGATIVE_INFINITY) { + if (this instanceof ServerPlayer) { -+ this.f_19853_.getCraftServer().getLogger().warning(this.m_6302_() + " was caught trying to crash the server with an invalid yaw"); ++ this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid yaw"); + ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); + } + p_19916_ = 0; @@ -203,64 +203,64 @@ + + if (p_19917_ == Float.POSITIVE_INFINITY || p_19917_ == Float.NEGATIVE_INFINITY) { + if (this instanceof ServerPlayer) { -+ this.f_19853_.getCraftServer().getLogger().warning(this.m_6302_() + " was caught trying to crash the server with an invalid pitch"); ++ this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid pitch"); + ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); + } + p_19917_ = 0; + } + // CraftBukkit end + - this.m_146922_(p_19916_ % 360.0F); - this.m_146926_(p_19917_ % 360.0F); + this.setYRot(p_19916_ % 360.0F); + this.setXRot(p_19917_ % 360.0F); } @@ -405,6 +_,15 @@ - this.m_6075_(); + this.baseTick(); } + // CraftBukkit start + public void postTick() { + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle + if (!(this instanceof ServerPlayer)) { -+ this.m_20157_(); ++ this.handleNetherPortal(); + } + } + // CraftBukkit end + - public void m_6075_() { - this.f_19853_.m_46473_().m_6180_("entityBaseTick"); - this.f_185934_ = null; + public void baseTick() { + this.level.getProfiler().push("entityBaseTick"); + this.feetBlockState = null; @@ -419,7 +_,7 @@ - this.f_19867_ = this.f_19787_; - this.f_19860_ = this.m_146909_(); - this.f_19859_ = this.m_146908_(); -- this.m_20157_(); -+ if (this instanceof ServerPlayer) this.m_20157_(); // CraftBukkit - // Moved up to postTick - if (this.m_5843_()) { - this.m_20076_(); + this.walkDistO = this.walkDist; + this.xRotO = this.getXRot(); + this.yRotO = this.getYRot(); +- this.handleNetherPortal(); ++ if (this instanceof ServerPlayer) this.handleNetherPortal(); // CraftBukkit - // Moved up to postTick + if (this.canSpawnSprintParticle()) { + this.spawnSprintParticle(); } @@ -454,6 +_,10 @@ - if (this.m_20077_()) { - this.m_20093_(); - this.f_19789_ *= 0.5F; + if (this.isInLava()) { + this.lavaHurt(); + this.fallDistance *= 0.5F; + // CraftBukkit start + } else { + this.lastLavaContact = null; + // CraftBukkit end } - this.m_146871_(); + this.checkOutOfWorld(); @@ -497,15 +_,45 @@ - public void m_20093_() { - if (!this.m_5825_()) { -- this.m_20254_(15); + public void lavaHurt() { + if (!this.fireImmune()) { +- this.setSecondsOnFire(15); + // CraftBukkit start - Fallen in lava TODO: this event spams! -+ if (this instanceof LivingEntity && f_19831_ <= 0) { ++ if (this instanceof LivingEntity && remainingFireTicks <= 0) { + // not on fire yet -+ org.bukkit.block.Block damager = (lastLavaContact == null) ? null : org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(f_19853_, lastLavaContact); ++ org.bukkit.block.Block damager = (lastLavaContact == null) ? null : org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, lastLavaContact); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + org.bukkit.event.entity.EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(combustEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(combustEvent); + if (!combustEvent.isCancelled()) { + this.setSecondsOnFire(combustEvent.getDuration(), false); + } @@ -268,9 +268,9 @@ + // This will be called every single tick the entity is in lava, so don't throw an event + this.setSecondsOnFire(15, false); + } -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = (lastLavaContact) == null ? null : org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(f_19853_, lastLavaContact); - if (this.m_6469_(DamageSource.f_19308_, 4.0F)) { - this.m_5496_(SoundEvents.f_11909_, 0.4F, 2.0F + this.f_19796_.nextFloat() * 0.4F); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = (lastLavaContact) == null ? null : org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, lastLavaContact); + if (this.hurt(DamageSource.LAVA, 4.0F)) { + this.playSound(SoundEvents.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; + // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls @@ -278,7 +278,7 @@ } } - public void m_20254_(int p_20255_) { + public void setSecondsOnFire(int p_20255_) { + // CraftBukkit start + this.setSecondsOnFire(p_20255_, true); + } @@ -286,7 +286,7 @@ + public void setSecondsOnFire(int p_20255_, boolean callEvent) { + if (callEvent) { + org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustEvent(this.getBukkitEntity(), p_20255_); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } @@ -295,243 +295,243 @@ + // CraftBukkit end int i = p_20255_ * 20; if (this instanceof LivingEntity) { - i = ProtectionEnchantment.m_45138_((LivingEntity)this, i); + i = ProtectionEnchantment.getFireAfterDampener((LivingEntity)this, i); @@ -612,6 +_,28 @@ - block.m_5548_(this.f_19853_, this); + block.updateEntityAfterFallOn(this.level, this); } + // CraftBukkit start -+ if (f_19862_ && getBukkitEntity() instanceof org.bukkit.entity.Vehicle) { ++ if (horizontalCollision && getBukkitEntity() instanceof org.bukkit.entity.Vehicle) { + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); -+ org.bukkit.block.Block bl = this.f_19853_.getWorld().getBlockAt(Mth.m_14107_(this.m_20185_()), Mth.m_14107_(this.m_20186_()), Mth.m_14107_(this.m_20189_())); ++ org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ())); + -+ if (p_19974_.f_82479_ > vec3.f_82479_) { ++ if (p_19974_.x > vec3.x) { + bl = bl.getRelative(org.bukkit.block.BlockFace.EAST); -+ } else if (p_19974_.f_82479_ < vec3.f_82479_) { ++ } else if (p_19974_.x < vec3.x) { + bl = bl.getRelative(org.bukkit.block.BlockFace.WEST); -+ } else if (p_19974_.f_82481_ > vec3.f_82481_) { ++ } else if (p_19974_.z > vec3.z) { + bl = bl.getRelative(org.bukkit.block.BlockFace.SOUTH); -+ } else if (p_19974_.f_82481_ < vec3.f_82481_) { ++ } else if (p_19974_.z < vec3.z) { + bl = bl.getRelative(org.bukkit.block.BlockFace.NORTH); + } + + if (!bl.getType().isAir()) { + org.bukkit.event.vehicle.VehicleBlockCollisionEvent event = new org.bukkit.event.vehicle.VehicleBlockCollisionEvent(vehicle, bl); -+ f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ level.getCraftServer().getPluginManager().callEvent(event); + } + } + // CraftBukkit end + - if (this.f_19861_ && !this.m_20161_()) { - block.m_141947_(this.f_19853_, blockpos, blockstate, this); + if (this.onGround && !this.isSteppingCarefully()) { + block.stepOn(this.level, blockpos, blockstate, this); } @@ -621,12 +_,12 @@ - double d1 = vec3.f_82479_; - double d2 = vec3.f_82480_; - double d3 = vec3.f_82481_; -- this.f_146794_ += (float)(vec3.m_82553_() * 0.6D); -+ this.f_146794_ = (float) ((double) this.f_146794_ + vec3.m_82553_() * 0.6D); - if (!blockstate.m_204336_(BlockTags.f_13082_) && !blockstate.m_60713_(Blocks.f_152499_)) { + double d1 = vec3.x; + double d2 = vec3.y; + double d3 = vec3.z; +- this.flyDist += (float)(vec3.length() * 0.6D); ++ this.flyDist = (float) ((double) this.flyDist + vec3.length() * 0.6D); + if (!blockstate.is(BlockTags.CLIMBABLE) && !blockstate.is(Blocks.POWDER_SNOW)) { d2 = 0.0D; } -- this.f_19787_ += (float)vec3.m_165924_() * 0.6F; -+ this.f_19787_ += (float) vec3.m_165924_() * 0.6F; - this.f_19788_ += (float)Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3) * 0.6F; - if (this.f_19788_ > this.f_19829_ && !blockstate.m_60795_()) { - this.f_19829_ = this.m_6059_(); +- this.walkDist += (float)vec3.horizontalDistance() * 0.6F; ++ this.walkDist += (float) vec3.horizontalDistance() * 0.6F; + this.moveDist += (float)Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3) * 0.6F; + if (this.moveDist > this.nextStep && !blockstate.isAir()) { + this.nextStep = this.nextStep(); @@ -659,25 +_,23 @@ - this.m_146872_(); - float f2 = this.m_6041_(); -- this.m_20256_(this.m_20184_().m_82542_((double)f2, 1.0D, (double)f2)); -- if (this.f_19853_.m_46847_(this.m_142469_().m_82406_(1.0E-6D)).noneMatch((p_20127_) -> { -- return p_20127_.m_204336_(BlockTags.f_13076_) || p_20127_.m_60713_(Blocks.f_49991_); + this.tryCheckInsideBlocks(); + float f2 = this.getBlockSpeedFactor(); +- this.setDeltaMovement(this.getDeltaMovement().multiply((double)f2, 1.0D, (double)f2)); +- if (this.level.getBlockStatesIfLoaded(this.getBoundingBox().deflate(1.0E-6D)).noneMatch((p_20127_) -> { +- return p_20127_.is(BlockTags.FIRE) || p_20127_.is(Blocks.LAVA); - })) { -- if (this.f_19831_ <= 0) { -- this.m_7311_(-this.m_6101_()); +- if (this.remainingFireTicks <= 0) { +- this.setRemainingFireTicks(-this.getFireImmuneTicks()); - } - -- if (this.f_146810_ && (this.f_146808_ || this.m_20071_())) { -- this.m_146873_(); +- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { +- this.playEntityOnFireExtinguishedSound(); - } - } - -- if (this.m_6060_() && (this.f_146808_ || this.m_20071_())) { -+ this.m_20256_(this.m_20184_().m_82542_((double) f2, 1.0D, (double) f2)); +- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ this.setDeltaMovement(this.getDeltaMovement().multiply((double) f2, 1.0D, (double) f2)); + } -+ if (this.f_19853_.m_46847_(this.m_142469_().m_82406_(1.0E-6D)).noneMatch((p_20127_) -> p_20127_.m_204336_(BlockTags.f_13076_) || p_20127_.m_60713_(Blocks.f_49991_))) { -+ if (this.f_19831_ <= 0) { - this.m_7311_(-this.m_6101_()); ++ if (this.level.getBlockStatesIfLoaded(this.getBoundingBox().deflate(1.0E-6D)).noneMatch((p_20127_) -> p_20127_.is(BlockTags.FIRE) || p_20127_.is(Blocks.LAVA))) { ++ if (this.remainingFireTicks <= 0) { + this.setRemainingFireTicks(-this.getFireImmuneTicks()); } -- this.f_19853_.m_46473_().m_7238_(); +- this.level.getProfiler().pop(); - } -+ if (this.f_146810_ && (this.f_146808_ || this.m_20071_())) { -+ this.m_146873_(); ++ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ this.playEntityOnFireExtinguishedSound(); + } + } + -+ if (this.m_6060_() && (this.f_146808_ || this.m_20071_())) { -+ this.m_7311_(-this.m_6101_()); ++ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ this.setRemainingFireTicks(-this.getFireImmuneTicks()); + } + -+ this.f_19853_.m_46473_().m_7238_(); ++ this.level.getProfiler().pop(); } } @@ -715,10 +_,10 @@ - int j = Mth.m_14107_(this.f_19825_.f_82480_ - (double)0.2F); - int k = Mth.m_14107_(this.f_19825_.f_82481_); + int j = Mth.floor(this.position.y - (double)0.2F); + int k = Mth.floor(this.position.z); BlockPos blockpos = new BlockPos(i, j, k); -- if (this.f_19853_.m_8055_(blockpos).m_60795_()) { -+ if (this.f_19853_.m_46859_(blockpos)) { - BlockPos blockpos1 = blockpos.m_7495_(); - BlockState blockstate = this.f_19853_.m_8055_(blockpos1); -- if (blockstate.m_204336_(BlockTags.f_13039_) || blockstate.m_204336_(BlockTags.f_13032_) || blockstate.m_60734_() instanceof FenceGateBlock) { -+ if (blockstate.collisionExtendsVertically(this.f_19853_, blockpos1, this)) { +- if (this.level.getBlockState(blockpos).isAir()) { ++ if (this.level.isEmptyBlock(blockpos)) { + BlockPos blockpos1 = blockpos.below(); + BlockState blockstate = this.level.getBlockState(blockpos1); +- if (blockstate.is(BlockTags.FENCES) || blockstate.is(BlockTags.WALLS) || blockstate.getBlock() instanceof FenceGateBlock) { ++ if (blockstate.collisionExtendsVertically(this.level, blockpos1, this)) { return blockpos1; } } @@ -791,10 +_,11 @@ - boolean flag1 = p_20273_.f_82480_ != vec3.f_82480_; - boolean flag2 = p_20273_.f_82481_ != vec3.f_82481_; - boolean flag3 = this.f_19861_ || flag1 && p_20273_.f_82480_ < 0.0D; -- if (this.f_19793_ > 0.0F && flag3 && (flag || flag2)) { -- Vec3 vec31 = m_198894_(this, new Vec3(p_20273_.f_82479_, (double)this.f_19793_, p_20273_.f_82481_), aabb, this.f_19853_, list); -- Vec3 vec32 = m_198894_(this, new Vec3(0.0D, (double)this.f_19793_, 0.0D), aabb.m_82363_(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), this.f_19853_, list); -- if (vec32.f_82480_ < (double)this.f_19793_) { + boolean flag1 = p_20273_.y != vec3.y; + boolean flag2 = p_20273_.z != vec3.z; + boolean flag3 = this.onGround || flag1 && p_20273_.y < 0.0D; +- if (this.maxUpStep > 0.0F && flag3 && (flag || flag2)) { +- Vec3 vec31 = collideBoundingBox(this, new Vec3(p_20273_.x, (double)this.maxUpStep, p_20273_.z), aabb, this.level, list); +- Vec3 vec32 = collideBoundingBox(this, new Vec3(0.0D, (double)this.maxUpStep, 0.0D), aabb.expandTowards(p_20273_.x, 0.0D, p_20273_.z), this.level, list); +- if (vec32.y < (double)this.maxUpStep) { + float stepHeight = getStepHeight(); + if (stepHeight > 0.0F && flag3 && (flag || flag2)) { -+ Vec3 vec31 = m_198894_(this, new Vec3(p_20273_.f_82479_, (double)stepHeight, p_20273_.f_82481_), aabb, this.f_19853_, list); -+ Vec3 vec32 = m_198894_(this, new Vec3(0.0D, (double)stepHeight, 0.0D), aabb.m_82363_(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), this.f_19853_, list); -+ if (vec32.f_82480_ < (double)stepHeight) { - Vec3 vec33 = m_198894_(this, new Vec3(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), aabb.m_82383_(vec32), this.f_19853_, list).m_82549_(vec32); - if (vec33.m_165925_() > vec31.m_165925_()) { ++ Vec3 vec31 = collideBoundingBox(this, new Vec3(p_20273_.x, (double)stepHeight, p_20273_.z), aabb, this.level, list); ++ Vec3 vec32 = collideBoundingBox(this, new Vec3(0.0D, (double)stepHeight, 0.0D), aabb.expandTowards(p_20273_.x, 0.0D, p_20273_.z), this.level, list); ++ if (vec32.y < (double)stepHeight) { + Vec3 vec33 = collideBoundingBox(this, new Vec3(p_20273_.x, 0.0D, p_20273_.z), aabb.move(vec32), this.level, list).add(vec32); + if (vec33.horizontalDistanceSqr() > vec31.horizontalDistanceSqr()) { vec31 = vec33; @@ -929,7 +_,7 @@ - protected void m_7355_(BlockPos p_20135_, BlockState p_20136_) { - if (!p_20136_.m_60767_().m_76332_()) { - BlockState blockstate = this.f_19853_.m_8055_(p_20135_.m_7494_()); -- SoundType soundtype = blockstate.m_204336_(BlockTags.f_144271_) ? blockstate.m_60827_() : p_20136_.m_60827_(); -+ SoundType soundtype = blockstate.m_60713_(Blocks.f_50125_) ? blockstate.getSoundType(f_19853_, p_20135_, this) : p_20136_.getSoundType(f_19853_, p_20135_, this); - this.m_5496_(soundtype.m_56776_(), soundtype.m_56773_() * 0.15F, soundtype.m_56774_()); + protected void playStepSound(BlockPos p_20135_, BlockState p_20136_) { + if (!p_20136_.getMaterial().isLiquid()) { + BlockState blockstate = this.level.getBlockState(p_20135_.above()); +- SoundType soundtype = blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) ? blockstate.getSoundType() : p_20136_.getSoundType(); ++ SoundType soundtype = blockstate.is(Blocks.SNOW) ? blockstate.getSoundType(level, p_20135_, this) : p_20136_.getSoundType(level, p_20135_, this); + this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); } } @@ -1035,6 +_,8 @@ - return this.m_20069_() || this.m_20285_(); + return this.isInWater() || this.isInRain(); } -+ @Deprecated public final boolean isInWaterOrRainOrBubble() { return m_20071_(); } // Paper - OBFHELPER ++ @Deprecated public final boolean isInWaterOrRainOrBubble() { return isInWaterRainOrBubble(); } // Paper - OBFHELPER + - public boolean m_20071_() { - return this.m_20069_() || this.m_20285_() || this.m_20305_(); + public boolean isInWaterRainOrBubble() { + return this.isInWater() || this.isInRain() || this.isInBubbleColumn(); } @@ -1144,9 +_,10 @@ - int k = Mth.m_14107_(this.m_20189_()); + int k = Mth.floor(this.getZ()); BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.f_19853_.m_8055_(blockpos); -+ if(!blockstate.addRunningEffects(f_19853_, blockpos, this)) - if (blockstate.m_60799_() != RenderShape.INVISIBLE) { - Vec3 vec3 = this.m_20184_(); -- this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate), this.m_20185_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, this.m_20186_() + 0.1D, this.m_20189_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, vec3.f_82479_ * -4.0D, 1.5D, vec3.f_82481_ * -4.0D); -+ this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate).setPos(blockpos), this.m_20185_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, this.m_20186_() + 0.1D, this.m_20189_() + (this.f_19796_.nextDouble() - 0.5D) * (double)this.f_19815_.f_20377_, vec3.f_82479_ * -4.0D, 1.5D, vec3.f_82481_ * -4.0D); + BlockState blockstate = this.level.getBlockState(blockpos); ++ if(!blockstate.addRunningEffects(level, blockpos, this)) + if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { + Vec3 vec3 = this.getDeltaMovement(); +- this.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockstate), this.getX() + (this.random.nextDouble() - 0.5D) * (double)this.dimensions.width, this.getY() + 0.1D, this.getZ() + (this.random.nextDouble() - 0.5D) * (double)this.dimensions.width, vec3.x * -4.0D, 1.5D, vec3.z * -4.0D); ++ this.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockstate).setPos(blockpos), this.getX() + (this.random.nextDouble() - 0.5D) * (double)this.dimensions.width, this.getY() + 0.1D, this.getZ() + (this.random.nextDouble() - 0.5D) * (double)this.dimensions.width, vec3.x * -4.0D, 1.5D, vec3.z * -4.0D); } } @@ -1195,6 +_,7 @@ - this.f_19855_ = p_20250_; - this.f_19856_ = d1; - this.m_6034_(d0, p_20250_, d1); -+ if (valid) f_19853_.m_6325_((int) Math.floor(this.m_20185_()) >> 4, (int) Math.floor(this.m_20189_()) >> 4); // CraftBukkit + this.yo = p_20250_; + this.zo = d1; + this.setPos(d0, p_20250_, d1); ++ if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit } - public void m_20219_(Vec3 p_20220_) { + public void moveTo(Vec3 p_20220_) { @@ -1376,6 +_,12 @@ return false; } + // CraftBukkit start - collidable API + public boolean canCollideWithBukkit(Entity entity) { -+ return m_6094_(); ++ return isPushable(); + } + // CraftBukkit end + - public void m_5993_(Entity p_19953_, int p_19954_, DamageSource p_19955_) { + public void awardKillScore(Entity p_19953_, int p_19954_, DamageSource p_19955_) { if (p_19953_ instanceof ServerPlayer) { - CriteriaTriggers.f_10569_.m_48104_((ServerPlayer)p_19953_, this, p_19955_); + CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer)p_19953_, this, p_19955_); @@ -1406,7 +_,7 @@ return false; } else { - String s = this.m_20078_(); + String s = this.getEncodeId(); - if (s == null) { + if (!this.persist || s == null) { // CraftBukkit - persist flag return false; } else { - p_20087_.m_128359_("id", s); + p_20087_.putString("id", s); @@ -1430,6 +_,18 @@ - Vec3 vec3 = this.m_20184_(); - p_20241_.m_128365_("Motion", this.m_20063_(vec3.f_82479_, vec3.f_82480_, vec3.f_82481_)); + Vec3 vec3 = this.getDeltaMovement(); + p_20241_.put("Motion", this.newDoubleList(vec3.x, vec3.y, vec3.z)); + + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // TODO: make sure this is the best way to address this. -+ if (Float.isNaN(this.f_19857_)) { -+ this.f_19857_ = 0; ++ if (Float.isNaN(this.yRot)) { ++ this.yRot = 0; + } + -+ if (Float.isNaN(this.f_19858_)) { -+ this.f_19858_ = 0; ++ if (Float.isNaN(this.xRot)) { ++ this.xRot = 0; + } + // CraftBukkit end + - p_20241_.m_128365_("Rotation", this.m_20065_(this.m_146908_(), this.m_146909_())); - p_20241_.m_128350_("FallDistance", this.f_19789_); - p_20241_.m_128376_("Fire", (short)this.f_19831_); + p_20241_.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); + p_20241_.putFloat("FallDistance", this.fallDistance); + p_20241_.putShort("Fire", (short)this.remainingFireTicks); @@ -1438,6 +_,25 @@ - p_20241_.m_128379_("Invulnerable", this.f_19840_); - p_20241_.m_128405_("PortalCooldown", this.f_19839_); - p_20241_.m_128362_("UUID", this.m_142081_()); + p_20241_.putBoolean("Invulnerable", this.invulnerable); + p_20241_.putInt("PortalCooldown", this.portalCooldown); + p_20241_.putUUID("UUID", this.getUUID()); + + // CraftBukkit start + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast -+ p_20241_.m_128356_("WorldUUIDLeast", ((ServerLevel) this.f_19853_).getWorld().getUID().getLeastSignificantBits()); -+ p_20241_.m_128356_("WorldUUIDMost", ((ServerLevel) this.f_19853_).getWorld().getUID().getMostSignificantBits()); -+ p_20241_.m_128405_("Bukkit.updateLevel", CURRENT_LEVEL); ++ p_20241_.putLong("WorldUUIDLeast", ((ServerLevel) this.level).getWorld().getUID().getLeastSignificantBits()); ++ p_20241_.putLong("WorldUUIDMost", ((ServerLevel) this.level).getWorld().getUID().getMostSignificantBits()); ++ p_20241_.putInt("Bukkit.updateLevel", CURRENT_LEVEL); + if (!this.persist) { -+ p_20241_.m_128379_("Bukkit.persist", this.persist); ++ p_20241_.putBoolean("Bukkit.persist", this.persist); + } + if (this.persistentInvisibility) { -+ p_20241_.m_128379_("Bukkit.invisible", this.persistentInvisibility); ++ p_20241_.putBoolean("Bukkit.invisible", this.persistentInvisibility); + } + // SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + if (maxAirTicks != getDefaultMaxAirSupply()) { -+ p_20241_.m_128405_("Bukkit.MaxAirSupply", m_6062_()); ++ p_20241_.putInt("Bukkit.MaxAirSupply", getMaxAirSupply()); + } -+ p_20241_.m_128405_("Spigot.ticksLived", this.f_19797_); ++ p_20241_.putInt("Spigot.ticksLived", this.tickCount); + // CraftBukkit end + - Component component = this.m_7770_(); + Component component = this.getCustomName(); if (component != null) { - p_20241_.m_128359_("CustomName", Component.Serializer.m_130703_(component)); + p_20241_.putString("CustomName", Component.Serializer.toJson(component)); @@ -1467,6 +_,7 @@ - if (this.f_146813_) { - p_20241_.m_128379_("HasVisualFire", this.f_146813_); + if (this.hasVisualFire) { + p_20241_.putBoolean("HasVisualFire", this.hasVisualFire); } -+ p_20241_.m_128379_("CanUpdate", canUpdate); ++ p_20241_.putBoolean("CanUpdate", canUpdate); - if (!this.f_19841_.isEmpty()) { + if (!this.tags.isEmpty()) { ListTag listtag = new ListTag(); @@ -1478,6 +_,10 @@ - p_20241_.m_128365_("Tags", listtag); + p_20241_.put("Tags", listtag); } + CompoundTag caps = serializeCaps(); -+ if (caps != null) p_20241_.m_128365_("ForgeCaps", caps); -+ if (persistentData != null) p_20241_.m_128365_("ForgeData", persistentData.m_6426_()); ++ if (caps != null) p_20241_.put("ForgeCaps", caps); ++ if (persistentData != null) p_20241_.put("ForgeData", persistentData.copy()); + - this.m_7380_(p_20241_); - if (this.m_20160_()) { + this.addAdditionalSaveData(p_20241_); + if (this.isVehicle()) { ListTag listtag1 = new ListTag(); @@ -1494,6 +_,11 @@ } @@ -544,17 +544,17 @@ + // CraftBukkit end return p_20241_; } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.m_127521_(throwable, "Saving entity NBT"); + CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); @@ -1552,6 +_,9 @@ - this.m_146915_(p_20259_.m_128471_("Glowing")); - this.m_146917_(p_20259_.m_128451_("TicksFrozen")); - this.f_146813_ = p_20259_.m_128471_("HasVisualFire"); -+ if (p_20259_.m_128425_("ForgeData", 10)) persistentData = p_20259_.m_128469_("ForgeData"); -+ if (p_20259_.m_128425_("CanUpdate", 99)) this.canUpdate(p_20259_.m_128471_("CanUpdate")); -+ if (p_20259_.m_128425_("ForgeCaps", 10)) deserializeCaps(p_20259_.m_128469_("ForgeCaps")); - if (p_20259_.m_128425_("Tags", 9)) { - this.f_19841_.clear(); - ListTag listtag3 = p_20259_.m_128437_("Tags", 8); + this.setGlowingTag(p_20259_.getBoolean("Glowing")); + this.setTicksFrozen(p_20259_.getInt("TicksFrozen")); + this.hasVisualFire = p_20259_.getBoolean("HasVisualFire"); ++ if (p_20259_.contains("ForgeData", 10)) persistentData = p_20259_.getCompound("ForgeData"); ++ if (p_20259_.contains("CanUpdate", 99)) this.canUpdate(p_20259_.getBoolean("CanUpdate")); ++ if (p_20259_.contains("ForgeCaps", 10)) deserializeCaps(p_20259_.getCompound("ForgeCaps")); + if (p_20259_.contains("Tags", 9)) { + this.tags.clear(); + ListTag listtag3 = p_20259_.getList("Tags", 8); @@ -1573,6 +_,49 @@ } else { throw new IllegalStateException("Entity has invalid position"); @@ -563,13 +563,13 @@ + // CraftBukkit start + // Spigot start + if (this instanceof LivingEntity) { -+ this.f_19797_ = p_20259_.m_128451_("Spigot.ticksLived"); ++ this.tickCount = p_20259_.getInt("Spigot.ticksLived"); + } + // Spigot end -+ this.persist = !p_20259_.m_128441_("Bukkit.persist") || p_20259_.m_128471_("Bukkit.persist"); ++ this.persist = !p_20259_.contains("Bukkit.persist") || p_20259_.getBoolean("Bukkit.persist"); + // SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ if (p_20259_.m_128441_("Bukkit.MaxAirSupply")) { -+ maxAirTicks = p_20259_.m_128451_("Bukkit.MaxAirSupply"); ++ if (p_20259_.contains("Bukkit.MaxAirSupply")) { ++ maxAirTicks = p_20259_.getInt("Bukkit.MaxAirSupply"); + } + // CraftBukkit end + @@ -579,37 +579,37 @@ + org.bukkit.World bworld = null; + + // TODO: Remove World related checks, replaced with WorldUID -+ String worldName = p_20259_.m_128461_("world"); ++ String worldName = p_20259_.getString("world"); + -+ if (p_20259_.m_128441_("WorldUUIDMost") && p_20259_.m_128441_("WorldUUIDLeast")) { -+ UUID uid = new UUID(p_20259_.m_128454_("WorldUUIDMost"), p_20259_.m_128454_("WorldUUIDLeast")); ++ if (p_20259_.contains("WorldUUIDMost") && p_20259_.contains("WorldUUIDLeast")) { ++ UUID uid = new UUID(p_20259_.getLong("WorldUUIDMost"), p_20259_.getLong("WorldUUIDLeast")); + bworld = server.getWorld(uid); + } else { + bworld = server.getWorld(worldName); + } + + if (bworld == null) { -+ bworld = ((org.bukkit.craftbukkit.v1_18_R2.CraftServer) server).getServer().m_129880_(Level.f_46428_).getWorld(); ++ bworld = ((org.bukkit.craftbukkit.v1_18_R2.CraftServer) server).getServer().getLevel(Level.OVERWORLD).getWorld(); + } + -+ ((ServerPlayer) this).m_143425_(bworld == null ? null : ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) bworld).getHandle()); ++ ((ServerPlayer) this).setLevel(bworld == null ? null : ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) bworld).getHandle()); + } + this.getBukkitEntity().readBukkitValues(p_20259_); -+ if (p_20259_.m_128441_("Bukkit.invisible")) { -+ boolean bukkitInvisible = p_20259_.m_128471_("Bukkit.invisible"); -+ this.m_6842_(bukkitInvisible); ++ if (p_20259_.contains("Bukkit.invisible")) { ++ boolean bukkitInvisible = p_20259_.getBoolean("Bukkit.invisible"); ++ this.setInvisible(bukkitInvisible); + this.persistentInvisibility = bukkitInvisible; + } + // CraftBukkit end + } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.m_127521_(throwable, "Loading entity NBT"); - CrashReportCategory crashreportcategory = crashreport.m_127514_("Entity being loaded"); + CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Entity being loaded"); @@ -1640,7 +_,19 @@ } else { - ItemEntity itementity = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_() + (double)p_19986_, this.m_20189_(), p_19985_); - itementity.m_32060_(); -- this.f_19853_.m_7967_(itementity); + ItemEntity itementity = new ItemEntity(this.level, this.getX(), this.getY() + (double)p_19986_, this.getZ(), p_19985_); + itementity.setDefaultPickUpDelay(); +- this.level.addFreshEntity(itementity); + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itementity.getBukkitEntity()); + org.bukkit.Bukkit.getPluginManager().callEvent(event); @@ -621,59 +621,59 @@ + if (captureDrops() != null) { + captureDrops().add(itementity); + } else { -+ this.f_19853_.m_7967_(itementity); ++ this.level.addFreshEntity(itementity); + } return itementity; } } @@ -1676,6 +_,7 @@ - public void m_6083_() { - this.m_20256_(Vec3.f_82478_); + public void rideTick() { + this.setDeltaMovement(Vec3.ZERO); + if (canUpdate()) - this.m_8119_(); - if (this.m_20159_()) { - this.m_20202_().m_7332_(this); + this.tick(); + if (this.isPassenger()) { + this.getVehicle().positionRider(this); @@ -1722,6 +_,7 @@ } } + if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_19966_, true)) return false; - if (p_19967_ || this.m_7341_(p_19966_) && p_19966_.m_7310_(this)) { - if (this.m_20159_()) { - this.m_8127_(); + if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { + if (this.isPassenger()) { + this.stopRiding(); @@ -1729,7 +_,7 @@ - this.m_20124_(Pose.STANDING); - this.f_19824_ = p_19966_; -- this.f_19824_.m_20348_(this); -+ if (!this.f_19824_.addPassenger(this)) this.f_19824_ = null; // CraftBukkit - p_19966_.m_146920_().filter((p_185984_) -> { + this.setPose(Pose.STANDING); + this.vehicle = p_19966_; +- this.vehicle.addPassenger(this); ++ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit + p_19966_.getIndirectPassengersStream().filter((p_185984_) -> { return p_185984_ instanceof ServerPlayer; }).forEach((p_185982_) -> { @@ -1760,8 +_,9 @@ - public void m_6038_() { - if (this.f_19824_ != null) { - Entity entity = this.f_19824_; + public void removeVehicle() { + if (this.vehicle != null) { + Entity entity = this.vehicle; + if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entity, false)) return; - this.f_19824_ = null; -- entity.m_20351_(this); -+ if (!entity.removePassenger(this)) this.f_19824_ = entity; // CraftBukkit + this.vehicle = null; +- entity.removePassenger(this); ++ if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit } } @@ -1770,10 +_,43 @@ - this.m_6038_(); + this.removeVehicle(); } -- protected void m_20348_(Entity p_20349_) { +- protected void addPassenger(Entity p_20349_) { + protected boolean addPassenger(Entity p_20349_) { // CraftBukkit - void -> boolean - if (p_20349_.m_20202_() != this) { + if (p_20349_.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { + + // CraftBukkit start -+ com.google.common.base.Preconditions.checkState(!p_20349_.f_19823_.contains(this), "Circular entity riding! %s %s", this, p_20349_); ++ com.google.common.base.Preconditions.checkState(!p_20349_.passengers.contains(this), "Circular entity riding! %s %s", this, p_20349_); + org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity craft = (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) p_20349_.getBukkitEntity().getVehicle(); + Entity orig = craft == null ? null : craft.getHandle(); + if (getBukkitEntity() instanceof org.bukkit.entity.Vehicle && p_20349_.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { @@ -704,8 +704,8 @@ + } + // Spigot end + - if (this.f_19823_.isEmpty()) { - this.f_19823_ = ImmutableList.of(p_20349_); + if (this.passengers.isEmpty()) { + this.passengers = ImmutableList.of(p_20349_); } else { @@ -1788,12 +_,42 @@ } @@ -714,9 +714,9 @@ + return true; // CraftBukkit } -- protected void m_20351_(Entity p_20352_) { +- protected void removePassenger(Entity p_20352_) { + protected boolean removePassenger(Entity p_20352_) { // CraftBukkit - void -> boolean - if (p_20352_.m_20202_() == this) { + if (p_20352_.getVehicle() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { + // CraftBukkit start @@ -748,109 +748,109 @@ + return false; + } + // Spigot end - if (this.f_19823_.size() == 1 && this.f_19823_.get(0) == p_20352_) { - this.f_19823_ = ImmutableList.of(); + if (this.passengers.size() == 1 && this.passengers.get(0) == p_20352_) { + this.passengers = ImmutableList.of(); } else { @@ -1804,6 +_,7 @@ - p_20352_.f_19851_ = 60; + p_20352_.boardingCooldown = 60; } + return true; // CraftBukkit } - protected boolean m_7310_(Entity p_20354_) { + protected boolean canAddPassenger(Entity p_20354_) { @@ -1870,7 +_,13 @@ - this.f_19853_.m_46473_().m_6180_("portal"); - this.f_19818_ = i; - this.m_20091_(); -- this.m_5489_(serverlevel1); + this.level.getProfiler().push("portal"); + this.portalTime = i; + this.setPortalCooldown(); +- this.changeDimension(serverlevel1); + // CraftBukkit start + if (this instanceof ServerPlayer) { + ((ServerPlayer) this).changeDimension(serverlevel1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); + } else { -+ this.m_5489_(serverlevel1); ++ this.changeDimension(serverlevel1); + } + // CraftBukkit end - this.f_19853_.m_46473_().m_7238_(); + this.level.getProfiler().pop(); } @@ -1936,6 +_,7 @@ - return !this.f_19823_.isEmpty(); + return !this.passengers.isEmpty(); } + @Deprecated //Forge: Use rider sensitive version - public boolean m_6146_() { + public boolean rideableUnderWater() { return true; } @@ -1989,6 +_,13 @@ } - public void m_20282_(boolean p_20283_) { + public void setSwimming(boolean p_20283_) { + // CraftBukkit start -+ if (valid && this.m_6069_() != p_20283_ && this instanceof LivingEntity) { ++ if (valid && this.isSwimming() != p_20283_ && this instanceof LivingEntity) { + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleSwimEvent((LivingEntity) this, p_20283_).isCancelled()) { + return; + } + } + // CraftBukkit end - this.m_20115_(4, p_20283_); + this.setSharedFlag(4, p_20283_); } @@ -2036,8 +_,12 @@ - return this.m_5647_() != null ? this.m_5647_().m_83536_(p_20032_) : false; + return this.getTeam() != null ? this.getTeam().isAlliedTo(p_20032_) : false; } + // CraftBukkit - start - public void m_6842_(boolean p_20304_) { -- this.m_20115_(5, p_20304_); + public void setInvisible(boolean p_20304_) { +- this.setSharedFlag(5, p_20304_); + if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag -+ this.m_20115_(5, p_20304_); ++ this.setSharedFlag(5, p_20304_); + } + // CraftBukkit - end } - public boolean m_20291_(int p_20292_) { + public boolean getSharedFlag(int p_20292_) { @@ -2055,7 +_,7 @@ } - public int m_6062_() { + public int getMaxAirSupply() { - return 300; + return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement org.bukkit.entity.LivingEntity#setMaximumAir() } - public int m_20146_() { + public int getAirSupply() { @@ -2063,7 +_,18 @@ } - public void m_20301_(int p_20302_) { -- this.f_19804_.m_135381_(f_19832_, p_20302_); + public void setAirSupply(int p_20302_) { +- this.entityData.set(DATA_AIR_SUPPLY_ID, p_20302_); + // CraftBukkit start + org.bukkit.event.entity.EntityAirChangeEvent event = new org.bukkit.event.entity.EntityAirChangeEvent(this.getBukkitEntity(), p_20302_); + // Suppress during worldgen + if (this.valid) { + event.getEntity().getServer().getPluginManager().callEvent(event); + } -+ if (event.isCancelled() && this.m_20146_() != p_20302_) { -+ this.f_19804_.markDirty(Entity.f_19832_); ++ if (event.isCancelled() && this.getAirSupply() != p_20302_) { ++ this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); + return; + } -+ this.f_19804_.m_135381_(Entity.f_19832_, event.getAmount()); ++ this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount()); + // CraftBukkit end } - public int m_146888_() { + public int getTicksFrozen() { @@ -2089,11 +_,39 @@ - public void m_8038_(ServerLevel p_19927_, LightningBolt p_19928_) { - this.m_7311_(this.f_19831_ + 1); + public void thunderHit(ServerLevel p_19927_, LightningBolt p_19928_) { + this.setRemainingFireTicks(this.remainingFireTicks + 1); + // CraftBukkit start + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); + final org.bukkit.entity.Entity stormBukkitEntity = p_19928_.getBukkitEntity(); + final org.bukkit.plugin.PluginManager pluginManager = org.bukkit.Bukkit.getPluginManager(); + // CraftBukkit end + - if (this.f_19831_ == 0) { -- this.m_20254_(8); + if (this.remainingFireTicks == 0) { +- this.setSecondsOnFire(8); + // CraftBukkit start - Call a combust event when lightning strikes + org.bukkit.event.entity.EntityCombustByEntityEvent entityCombustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); + pluginManager.callEvent(entityCombustEvent); @@ -868,33 +868,33 @@ + } } -- this.m_6469_(DamageSource.f_19306_, 5.0F); -+ if (this.m_5825_()) { +- this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F); ++ if (this.fireImmune()) { + return; + } + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = p_19928_; -+ if (!this.m_6469_(DamageSource.f_19306_, 5.0F)) { ++ if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; + return; + } + // CraftBukkit end } - public void m_6845_(boolean p_20313_) { + public void onAboveBubbleCol(boolean p_20313_) { @@ -2181,7 +_,7 @@ } - protected Component m_5677_() { -- return this.f_19847_.m_20676_(); -+ return this.m_6095_().m_20676_(); // Forge: Use getter to allow overriding by mods + protected Component getTypeName() { +- return this.type.getDescription(); ++ return this.getType().getDescription(); // Forge: Use getter to allow overriding by mods } - public boolean m_7306_(Entity p_20356_) { + public boolean is(Entity p_20356_) { @@ -2237,37 +_,87 @@ @Nullable - public Entity m_5489_(ServerLevel p_20118_) { -+ return this.changeDimension(p_20118_, p_20118_.m_8871_()); + public Entity changeDimension(ServerLevel p_20118_) { ++ return this.changeDimension(p_20118_, p_20118_.getPortalForcer()); + } + + //Magma start - fix mixin inject @@ -903,50 +903,50 @@ + public Entity changeDimension(ServerLevel p_20118_, net.minecraftforge.common.util.ITeleporter teleporter) { + BlockPos blockPos = this.changeDimension_blockpos; + this.changeDimension_blockpos = null; -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_20118_.m_46472_())) return null; ++ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_20118_.dimension())) return null; + java.util.concurrent.atomic.AtomicReference serverLevel = new java.util.concurrent.atomic.AtomicReference<>( p_20118_ ); - if (this.f_19853_ instanceof ServerLevel && !this.m_146910_()) { - this.f_19853_.m_46473_().m_6180_("changeDimension"); -- this.m_19877_(); + if (this.level instanceof ServerLevel && !this.isRemoved()) { + this.level.getProfiler().push("changeDimension"); +- this.unRide(); + //this.unRide(); + // CraftBukkit start + if (serverLevel.get() == null) { + return null; + } + // CraftBukkit end - this.f_19853_.m_46473_().m_6180_("reposition"); -- PortalInfo portalinfo = this.m_7937_(p_20118_); + this.level.getProfiler().push("reposition"); +- PortalInfo portalinfo = this.findDimensionEntryPoint(p_20118_); - if (portalinfo == null) { - return null; - } else { -+ PortalInfo portalinfo = (blockPos == null) ? teleporter.getPortalInfo( this, serverLevel.get(), this::m_7937_ ) : -+ new PortalInfo( new Vec3( blockPos.m_123341_(), blockPos.m_123342_(), blockPos.m_123343_() ), Vec3.f_82478_, this.f_19858_, this.f_19858_ ); ++ PortalInfo portalinfo = (blockPos == null) ? teleporter.getPortalInfo( this, serverLevel.get(), this::findDimensionEntryPoint ) : ++ new PortalInfo( new Vec3( blockPos.getX(), blockPos.getY(), blockPos.getZ() ), Vec3.ZERO, this.xRot, this.xRot ); + if(portalinfo == null) return null; //Magma - fix dead entites + portalinfo.setCBPortalEvent(serverLevel.get(), null); + //CraftBukkit start + serverLevel.set( portalinfo.world ); -+ if (serverLevel.get() == f_19853_) { ++ if (serverLevel.get() == level) { + //SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in -+ m_7678_( portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_, portalinfo.f_77678_, portalinfo.f_77679_ ); -+ m_20256_( portalinfo.f_77677_ ); ++ moveTo( portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.yRot, portalinfo.xRot ); ++ setDeltaMovement( portalinfo.speed ); + return this; + } -+ this.m_19877_(); ++ this.unRide(); + // CraftBukkit end + -+ Entity transportedEntity = teleporter.placeEntity( this, (ServerLevel) this.f_19853_, serverLevel.get(), this.f_19857_, spawnPortal -> { //Forge: Start vanilla logic - this.f_19853_.m_46473_().m_6182_("reloading"); -- Entity entity = this.m_6095_().m_20615_(p_20118_); -+ Entity entity = this.m_6095_().m_20615_( serverLevel.get() ); ++ Entity transportedEntity = teleporter.placeEntity( this, (ServerLevel) this.level, serverLevel.get(), this.yRot, spawnPortal -> { //Forge: Start vanilla logic + this.level.getProfiler().popPush("reloading"); +- Entity entity = this.getType().create(p_20118_); ++ Entity entity = this.getType().create( serverLevel.get() ); if (entity != null) { - entity.m_20361_(this); - entity.m_7678_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_, portalinfo.f_77678_, entity.m_146909_()); - entity.m_20256_(portalinfo.f_77677_); -- p_20118_.m_143334_(entity); -- if (p_20118_.m_46472_() == Level.f_46430_) { -- ServerLevel.m_8617_(p_20118_); -+ serverLevel.get().m_143334_( entity ); -+ if (spawnPortal && serverLevel.get().m_46472_() == Level.f_46430_) { + entity.restoreFrom(this); + entity.moveTo(portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.yRot, entity.getXRot()); + entity.setDeltaMovement(portalinfo.speed); +- p_20118_.addDuringTeleport(entity); +- if (p_20118_.dimension() == Level.END) { +- ServerLevel.makeObsidianPlatform(p_20118_); ++ serverLevel.get().addDuringTeleport( entity ); ++ if (spawnPortal && serverLevel.get().dimension() == Level.END) { + ServerLevel.makeObsidianPlatform( serverLevel.get(), this ); } - } @@ -954,24 +954,24 @@ + this.getBukkitEntity().setHandle( entity ); + entity.bukkitEntity = this.getBukkitEntity(); -- this.m_6089_(); -- this.f_19853_.m_46473_().m_7238_(); -- ((ServerLevel)this.f_19853_).m_8886_(); -- p_20118_.m_8886_(); -- this.f_19853_.m_46473_().m_7238_(); +- this.removeAfterChangingDimensions(); +- this.level.getProfiler().pop(); +- ((ServerLevel)this.level).resetEmptyTime(); +- p_20118_.resetEmptyTime(); +- this.level.getProfiler().pop(); + if (this instanceof Mob) { -+ ((Mob) this).m_21455_( true, false ); //Unleash to prevent duping of leads ++ ((Mob) this).dropLeash( true, false ); //Unleash to prevent duping of leads + } + } return entity; - } + }); //Forge: End vanilla logic + -+ this.m_6089_(); -+ this.f_19853_.m_46473_().m_7238_(); -+ ((ServerLevel)this.f_19853_).m_8886_(); -+ serverLevel.get().m_8886_(); -+ this.f_19853_.m_46473_().m_7238_(); ++ this.removeAfterChangingDimensions(); ++ this.level.getProfiler().pop(); ++ ((ServerLevel)this.level).resetEmptyTime(); ++ serverLevel.get().resetEmptyTime(); ++ this.level.getProfiler().pop(); + return transportedEntity; } else { return null; @@ -981,7 +981,7 @@ + + @Nullable + public Entity teleportTo(ServerLevel p_20118_, BlockPos blockPos) { -+ return this.teleportTo( p_20118_, blockPos, p_20118_.m_8871_() ); ++ return this.teleportTo( p_20118_, blockPos, p_20118_.getPortalForcer() ); + } + + //Magma start - fix NPE when teleporting to the end with a null blockPos @@ -992,58 +992,58 @@ + } + //Magma end - protected void m_6089_() { - this.m_142467_(Entity.RemovalReason.CHANGED_DIMENSION); + protected void removeAfterChangingDimensions() { + this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); @@ -2275,17 +_,33 @@ @Nullable - protected PortalInfo m_7937_(ServerLevel p_19923_) { + protected PortalInfo findDimensionEntryPoint(ServerLevel p_19923_) { + java.util.concurrent.atomic.AtomicReference serverLevel = new java.util.concurrent.atomic.AtomicReference<>( p_19923_ ); + // CraftBukkit start + if (serverLevel.get() == null) return null; + - boolean flag = this.f_19853_.m_46472_() == Level.f_46430_ && p_19923_.m_46472_() == Level.f_46428_; - boolean flag1 = p_19923_.m_46472_() == Level.f_46430_; + boolean flag = this.level.dimension() == Level.END && p_19923_.dimension() == Level.OVERWORLD; + boolean flag1 = p_19923_.dimension() == Level.END; + // CraftBukkit end + if (!flag && !flag1) { - boolean flag2 = p_19923_.m_46472_() == Level.f_46429_; - if (this.f_19853_.m_46472_() != Level.f_46429_ && !flag2) { + boolean flag2 = p_19923_.dimension() == Level.NETHER; + if (this.level.dimension() != Level.NETHER && !flag2) { return null; } else { - WorldBorder worldborder = p_19923_.m_6857_(); -- double d0 = DimensionType.m_63908_(this.f_19853_.m_6042_(), p_19923_.m_6042_()); -+ double d0 = DimensionType.m_63908_( this.f_19853_.m_6042_(), serverLevel.get().m_6042_() ); - BlockPos blockpos1 = worldborder.m_187569_(this.m_20185_() * d0, this.m_20186_(), this.m_20189_() * d0); -- return this.m_183318_(p_19923_, blockpos1, flag2, worldborder).map((p_185941_) -> { + WorldBorder worldborder = p_19923_.getWorldBorder(); +- double d0 = DimensionType.getTeleportationScale(this.level.dimensionType(), p_19923_.dimensionType()); ++ double d0 = DimensionType.getTeleportationScale( this.level.dimensionType(), serverLevel.get().dimensionType() ); + BlockPos blockpos1 = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0); +- return this.getExitPortal(p_19923_, blockpos1, flag2, worldborder).map((p_185941_) -> { + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent event = callPortalEvent( this, serverLevel.get(), blockpos1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16 ); + if (event == null) { + return null; + } + serverLevel.set( ((org.bukkit.craftbukkit.v1_18_R2.CraftWorld) event.getTo().getWorld()).getHandle() ); -+ worldborder = serverLevel.get().m_6857_(); -+ blockpos1 = worldborder.m_187569_( event.getTo().getX(), event.getTo().getY(), event.getTo().getZ() ); ++ worldborder = serverLevel.get().getWorldBorder(); ++ blockpos1 = worldborder.clampToBounds( event.getTo().getX(), event.getTo().getY(), event.getTo().getZ() ); + + return this.getExitPortal( p_19923_, blockpos1, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius() ).map( (p_185941_) -> { + // CraftBukkit end - BlockState blockstate = this.f_19853_.m_8055_(this.f_19819_); + BlockState blockstate = this.level.getBlockState(this.portalEntrancePos); Direction.Axis direction$axis; Vec3 vec3; @@ -2300,7 +_,7 @@ vec3 = new Vec3(0.5D, 0.0D, 0.0D); } -- return PortalShape.m_77699_(p_19923_, p_185941_, direction$axis, vec3, this.m_6972_(this.m_20089_()), this.m_20184_(), this.m_146908_(), this.m_146909_()); -+ return PortalShape.createPortalInfo( serverLevel.get(), p_185941_, direction$axis, vec3, this.m_6972_( this.m_20089_() ), this.m_20184_(), this.m_146908_(), this.m_146909_(), event ); //CraftBukkit +- return PortalShape.createPortalInfo(p_19923_, p_185941_, direction$axis, vec3, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot()); ++ return PortalShape.createPortalInfo( serverLevel.get(), p_185941_, direction$axis, vec3, this.getDimensions( this.getPose() ), this.getDeltaMovement(), this.getYRot(), this.getXRot(), event ); //CraftBukkit }).orElse((PortalInfo)null); } } else { @@ -2311,7 +_,16 @@ - blockpos = p_19923_.m_5452_(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, p_19923_.m_8900_()); + blockpos = p_19923_.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, p_19923_.getSharedSpawnPos()); } -- return new PortalInfo(new Vec3((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_(), (double)blockpos.m_123343_() + 0.5D), this.m_20184_(), this.m_146908_(), this.m_146909_()); +- return new PortalInfo(new Vec3((double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot()); + //CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent event = callPortalEvent( this, serverLevel.get(), blockpos, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0 ); + if (event == null) { @@ -1051,104 +1051,104 @@ + } + blockpos = new BlockPos( event.getTo().getX(), event.getTo().getY(), event.getTo().getZ() ); + -+ PortalInfo info = new PortalInfo( new Vec3( (double) blockpos.m_123341_() + 0.5D, (double) blockpos.m_123342_(), (double) blockpos.m_123343_() + 0.5D ), this.m_20184_(), this.m_146908_(), this.m_146909_() ); ++ PortalInfo info = new PortalInfo( new Vec3( (double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D ), this.getDeltaMovement(), this.getYRot(), this.getXRot() ); + info.setCBPortalEvent( p_19923_, event ); + return info; } } @@ -2319,6 +_,25 @@ - return PortalShape.m_77738_(p_20046_, p_20045_, this.m_20182_(), this.m_6972_(this.m_20089_())); + return PortalShape.getRelativePosition(p_20046_, p_20045_, this.position(), this.getDimensions(this.getPose())); } + // CraftBukkit start + protected org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent callPortalEvent(Entity entity, ServerLevel exitServerLevel, BlockPos exitPosition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); + org.bukkit.Location enter = bukkitEntity.getLocation(); -+ org.bukkit.Location exit = new org.bukkit.Location( exitServerLevel.getWorld(), exitPosition.m_123341_(), exitPosition.m_123342_(), exitPosition.m_123343_() ); ++ org.bukkit.Location exit = new org.bukkit.Location( exitServerLevel.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ() ); + + org.bukkit.event.entity.EntityPortalEvent event = new org.bukkit.event.entity.EntityPortalEvent( bukkitEntity, enter, exit, searchRadius ); + event.getEntity().getServer().getPluginManager().callEvent( event ); -+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.m_6084_()) { ++ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) { + return null; + } + return new org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent( event ); + } + + protected Optional getExitPortal(ServerLevel worldserver, BlockPos blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { -+ return worldserver.m_8871_().findPortalAround( blockposition, worldborder, searchRadius ); ++ return worldserver.getPortalForcer().findPortalAround( blockposition, worldborder, searchRadius ); + // CraftBukkit end + } + - protected Optional m_183318_(ServerLevel p_185935_, BlockPos p_185936_, boolean p_185937_, WorldBorder p_185938_) { - return p_185935_.m_8871_().m_192985_(p_185936_, p_185937_, p_185938_); + protected Optional getExitPortal(ServerLevel p_185935_, BlockPos p_185936_, boolean p_185937_, WorldBorder p_185938_) { + return p_185935_.getPortalForcer().findPortalAround(p_185936_, p_185937_, p_185938_); } @@ -2463,8 +_,10 @@ - EntityDimensions entitydimensions = this.f_19815_; - Pose pose = this.m_20089_(); - EntityDimensions entitydimensions1 = this.m_6972_(pose); -+ net.minecraftforge.event.entity.EntityEvent.Size sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, pose, entitydimensions, entitydimensions1, this.m_6380_(pose, entitydimensions1)); + EntityDimensions entitydimensions = this.dimensions; + Pose pose = this.getPose(); + EntityDimensions entitydimensions1 = this.getDimensions(pose); ++ net.minecraftforge.event.entity.EntityEvent.Size sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, pose, entitydimensions, entitydimensions1, this.getEyeHeight(pose, entitydimensions1)); + entitydimensions1 = sizeEvent.getNewSize(); - this.f_19815_ = entitydimensions1; -- this.f_19816_ = this.m_6380_(pose, entitydimensions1); -+ this.f_19816_ = sizeEvent.getNewEyeHeight(); - this.m_20090_(); - boolean flag = (double)entitydimensions1.f_20377_ <= 4.0D && (double)entitydimensions1.f_20378_ <= 4.0D; - if (!this.f_19853_.f_46443_ && !this.f_19803_ && !this.f_19794_ && flag && (entitydimensions1.f_20377_ > entitydimensions.f_20377_ || entitydimensions1.f_20378_ > entitydimensions.f_20378_) && !(this instanceof Player)) { + this.dimensions = entitydimensions1; +- this.eyeHeight = this.getEyeHeight(pose, entitydimensions1); ++ this.eyeHeight = sizeEvent.getNewEyeHeight(); + this.reapplyPosition(); + boolean flag = (double)entitydimensions1.width <= 4.0D && (double)entitydimensions1.height <= 4.0D; + if (!this.level.isClientSide && !this.firstTick && !this.noPhysics && flag && (entitydimensions1.width > entitydimensions.width || entitydimensions1.height > entitydimensions.height) && !(this instanceof Player)) { @@ -2472,8 +_,9 @@ - double d0 = (double)Math.max(0.0F, entitydimensions1.f_20377_ - entitydimensions.f_20377_) + 1.0E-6D; - double d1 = (double)Math.max(0.0F, entitydimensions1.f_20378_ - entitydimensions.f_20378_) + 1.0E-6D; - VoxelShape voxelshape = Shapes.m_83064_(AABB.m_165882_(vec3, d0, d1, d0)); + double d0 = (double)Math.max(0.0F, entitydimensions1.width - entitydimensions.width) + 1.0E-6D; + double d1 = (double)Math.max(0.0F, entitydimensions1.height - entitydimensions.height) + 1.0E-6D; + VoxelShape voxelshape = Shapes.create(AABB.ofSize(vec3, d0, d1, d0)); + EntityDimensions finalEntitydimensions = entitydimensions1; - this.f_19853_.m_151418_(this, voxelshape, vec3, (double)entitydimensions1.f_20377_, (double)entitydimensions1.f_20378_, (double)entitydimensions1.f_20377_).ifPresent((p_185956_) -> { -- this.m_146884_(p_185956_.m_82520_(0.0D, (double)(-entitydimensions1.f_20378_) / 2.0D, 0.0D)); -+ this.m_146884_(p_185956_.m_82520_(0.0D, (double)(-finalEntitydimensions.f_20378_) / 2.0D, 0.0D)); + this.level.findFreePosition(this, voxelshape, vec3, (double)entitydimensions1.width, (double)entitydimensions1.height, (double)entitydimensions1.width).ifPresent((p_185956_) -> { +- this.setPos(p_185956_.add(0.0D, (double)(-entitydimensions1.height) / 2.0D, 0.0D)); ++ this.setPos(p_185956_.add(0.0D, (double)(-finalEntitydimensions.height) / 2.0D, 0.0D)); }); } @@ -2512,7 +_,24 @@ } - public final void m_20011_(AABB p_20012_) { -- this.f_19828_ = p_20012_; + public final void setBoundingBox(AABB p_20012_) { +- this.bb = p_20012_; + // CraftBukkit start - block invalid bounding boxes -+ double minX = p_20012_.f_82288_, -+ minY = p_20012_.f_82289_, -+ minZ = p_20012_.f_82290_, -+ maxX = p_20012_.f_82291_, -+ maxY = p_20012_.f_82292_, -+ maxZ = p_20012_.f_82293_; -+ double len = p_20012_.f_82291_ - p_20012_.f_82288_; ++ double minX = p_20012_.minX, ++ minY = p_20012_.minY, ++ minZ = p_20012_.minZ, ++ maxX = p_20012_.maxX, ++ maxY = p_20012_.maxY, ++ maxZ = p_20012_.maxZ; ++ double len = p_20012_.maxX - p_20012_.minX; + if (len < 0) maxX = minX; + if (len > 64) maxX = minX + 64.0; -+ len = p_20012_.f_82292_ - p_20012_.f_82289_; ++ len = p_20012_.maxY - p_20012_.minY; + if (len < 0) maxY = minY; + if (len > 64) maxY = minY + 64.0; -+ len = p_20012_.f_82293_ - p_20012_.f_82290_; ++ len = p_20012_.maxZ - p_20012_.minZ; + if (len < 0) maxZ = minZ; + if (len > 64) maxZ = minZ + 64.0; -+ this.f_19828_ = new AABB(minX, minY, minZ, maxX, maxY, maxZ); ++ this.bb = new AABB(minX, minY, minZ, maxX, maxY, maxZ); + // CraftBukkit end } - protected float m_6380_(Pose p_19976_, EntityDimensions p_19977_) { + protected float getEyeHeight(Pose p_19976_, EntityDimensions p_19977_) { @@ -2781,6 +_,11 @@ - vec3 = vec3.m_82549_(vec31); + vec3 = vec3.add(vec31); ++k1; } + // CraftBukkit start - store last lava contact location -+ if (p_204032_ == FluidTags.f_13132_) { -+ this.lastLavaContact = blockpos$mutableblockpos.m_7949_(); ++ if (p_204032_ == FluidTags.LAVA) { ++ this.lastLavaContact = blockpos$mutableblockpos.immutable(); + } + // CraftBukkit end } } } @@ -2950,6 +_,7 @@ - gameeventlistenerregistrar.m_157862_(this.f_19853_); + gameeventlistenerregistrar.onListenerMove(this.level); } } -+ if (this.isAddedToWorld() && !this.f_19853_.f_46443_ && !this.m_146910_()) this.f_19853_.m_6325_((int) Math.floor(p_20344_) >> 4, (int) Math.floor(p_20346_) >> 4); // Forge - ensure target chunk is loaded. ++ if (this.isAddedToWorld() && !this.level.isClientSide && !this.isRemoved()) this.level.getChunk((int) Math.floor(p_20344_) >> 4, (int) Math.floor(p_20346_) >> 4); // Forge - ensure target chunk is loaded. } @@ -1189,10 +1189,10 @@ + } + @Override + public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) { -+ return f_19853_.f_46441_.nextFloat() < fallDistance - 0.5F ++ return level.random.nextFloat() < fallDistance - 0.5F + && this instanceof LivingEntity -+ && (this instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(f_19853_, this)) -+ && this.m_20205_() * this.m_20205_() * this.m_20206_() > 0.512F; ++ && (this instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this)) ++ && this.getBbWidth() * this.getBbWidth() * this.getBbHeight() > 0.512F; + } + + /** @@ -1213,7 +1213,7 @@ + + @Override + public void revive() { -+ this.m_146912_(); ++ this.unsetRemoved(); + this.reviveCaps(); + } + @@ -1222,19 +1222,19 @@ + * Accessor method for {@link #getEyeHeight(Pose, EntityDimensions)} + */ + public float getEyeHeightAccess(Pose pose, EntityDimensions size) { -+ return this.m_6380_(pose, size); ++ return this.getEyeHeight(pose, size); + } + + /* ================================== Forge End =====================================*/ + + - public Level m_183503_() { - return this.f_19853_; + public Level getLevel() { + return this.level; } - @FunctionalInterface + + @FunctionalInterface public interface MoveFunction { - void m_20372_(Entity p_20373_, double p_20374_, double p_20375_, double p_20376_); + void accept(Entity p_20373_, double p_20374_, double p_20375_, double p_20376_); } diff --git a/patches/minecraft/net/minecraft/world/entity/EntitySelector.java.patch b/patches/minecraft/net/minecraft/world/entity/EntitySelector.java.patch index b230e256..5a36fca2 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntitySelector.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntitySelector.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/EntitySelector.java +++ b/net/minecraft/world/entity/EntitySelector.java @@ -41,7 +_,7 @@ - Team team = p_20422_.m_5647_(); - Team.CollisionRule team$collisionrule = team == null ? Team.CollisionRule.ALWAYS : team.m_7156_(); - return (Predicate)(team$collisionrule == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : f_20408_.and((p_20430_) -> { -- if (!p_20430_.m_6094_()) { + Team team = p_20422_.getTeam(); + Team.CollisionRule team$collisionrule = team == null ? Team.CollisionRule.ALWAYS : team.getCollisionRule(); + return (Predicate)(team$collisionrule == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : NO_SPECTATORS.and((p_20430_) -> { +- if (!p_20430_.isPushable()) { + if (!p_20430_.canCollideWithBukkit(p_20422_) || !p_20422_.canCollideWithBukkit(p_20430_)) { // CraftBukkit - collidable API return false; - } else if (!p_20422_.f_19853_.f_46443_ || p_20430_ instanceof Player && ((Player)p_20430_).m_7578_()) { - Team team1 = p_20430_.m_5647_(); + } else if (!p_20422_.level.isClientSide || p_20430_ instanceof Player && ((Player)p_20430_).isLocalPlayer()) { + Team team1 = p_20430_.getTeam(); diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index 2304d2e0..32079588 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -6,29 +6,29 @@ -public class EntityType implements EntityTypeTest { +public class EntityType extends net.minecraftforge.registries.ForgeRegistryEntry> implements EntityTypeTest { - private static final Logger f_20534_ = LogUtils.getLogger(); - public static final String f_147037_ = "EntityTag"; - private final Holder.Reference> f_204038_ = Registry.f_122826_.m_203693_(this); - private static final float f_147038_ = 1.3964844F; -- public static final EntityType f_20476_ = m_20634_("area_effect_cloud", EntityType.Builder.m_20704_(AreaEffectCloud::new, MobCategory.MISC).m_20719_().m_20699_(6.0F, 0.5F).m_20702_(10).m_20717_(Integer.MAX_VALUE)); -+ public static final EntityType f_20476_ = m_20634_("area_effect_cloud", EntityType.Builder.m_20704_(AreaEffectCloud::new, MobCategory.MISC).m_20719_().m_20699_(6.0F, 0.5F).m_20702_(10).m_20717_(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds - public static final EntityType f_20529_ = m_20634_("armor_stand", EntityType.Builder.m_20704_(ArmorStand::new, MobCategory.MISC).m_20699_(0.5F, 1.975F).m_20702_(10)); - public static final EntityType f_20548_ = m_20634_("arrow", EntityType.Builder.m_20704_(Arrow::new, MobCategory.MISC).m_20699_(0.5F, 0.5F).m_20702_(4).m_20717_(20)); - public static final EntityType f_147039_ = m_20634_("axolotl", EntityType.Builder.m_20704_(Axolotl::new, MobCategory.AXOLOTLS).m_20699_(0.75F, 0.42F).m_20702_(10)); + private static final Logger LOGGER = LogUtils.getLogger(); + public static final String ENTITY_TAG = "EntityTag"; + private final Holder.Reference> builtInRegistryHolder = Registry.ENTITY_TYPE.createIntrusiveHolder(this); + private static final float MAGIC_HORSE_WIDTH = 1.3964844F; +- public static final EntityType AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityType.Builder.of(AreaEffectCloud::new, MobCategory.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)); ++ public static final EntityType AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityType.Builder.of(AreaEffectCloud::new, MobCategory.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds + public static final EntityType ARMOR_STAND = register("armor_stand", EntityType.Builder.of(ArmorStand::new, MobCategory.MISC).sized(0.5F, 1.975F).clientTrackingRange(10)); + public static final EntityType ARROW = register("arrow", EntityType.Builder.of(Arrow::new, MobCategory.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20)); + public static final EntityType AXOLOTL = register("axolotl", EntityType.Builder.of(Axolotl::new, MobCategory.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10)); @@ -283,6 +_,11 @@ - private ResourceLocation f_20546_; - private final EntityDimensions f_20547_; + private ResourceLocation lootTable; + private final EntityDimensions dimensions; + private final java.util.function.Predicate> velocityUpdateSupplier; + private final java.util.function.ToIntFunction> trackingRangeSupplier; + private final java.util.function.ToIntFunction> updateIntervalSupplier; + private final java.util.function.BiFunction customClientFactory; + - private static EntityType m_20634_(String p_20635_, EntityType.Builder p_20636_) { - return Registry.m_122961_(Registry.f_122826_, p_20635_, p_20636_.m_20712_(p_20635_)); + private static EntityType register(String p_20635_, EntityType.Builder p_20636_) { + return Registry.register(Registry.ENTITY_TYPE, p_20635_, p_20636_.build(p_20635_)); } @@ -295,7 +_,19 @@ - return Registry.f_122826_.m_6612_(ResourceLocation.m_135820_(p_20633_)); + return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(p_20633_)); } + // Paper start - add id @@ -44,13 +44,13 @@ + + public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory, String id) { + // Paper end - this.f_20535_ = p_20574_; - this.f_20536_ = p_20575_; - this.f_20541_ = p_20579_; + this.factory = p_20574_; + this.category = p_20575_; + this.canSpawnFarFromPlayer = p_20579_; @@ -306,17 +_,39 @@ - this.f_20547_ = p_20581_; - this.f_20542_ = p_20582_; - this.f_20543_ = p_20583_; + this.dimensions = p_20581_; + this.clientTrackingRange = p_20582_; + this.updateInterval = p_20583_; + this.velocityUpdateSupplier = velocityUpdateSupplier; + this.trackingRangeSupplier = trackingRangeSupplier; + this.updateIntervalSupplier = updateIntervalSupplier; @@ -66,9 +66,9 @@ } @Nullable - public Entity m_20592_(ServerLevel p_20593_, @Nullable ItemStack p_20594_, @Nullable Player p_20595_, BlockPos p_20596_, MobSpawnType p_20597_, boolean p_20598_, boolean p_20599_) { + public Entity spawn(ServerLevel p_20593_, @Nullable ItemStack p_20594_, @Nullable Player p_20595_, BlockPos p_20596_, MobSpawnType p_20597_, boolean p_20598_, boolean p_20599_) { + this.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); - return this.m_20600_(p_20593_, p_20594_ == null ? null : p_20594_.m_41783_(), p_20594_ != null && p_20594_.m_41788_() ? p_20594_.m_41786_() : null, p_20595_, p_20596_, p_20597_, p_20598_, p_20599_); + return this.spawn(p_20593_, p_20594_ == null ? null : p_20594_.getTag(), p_20594_ != null && p_20594_.hasCustomHoverName() ? p_20594_.getHoverName() : null, p_20595_, p_20596_, p_20597_, p_20598_, p_20599_); } + //Magma start - spawn reason @@ -79,31 +79,31 @@ + //Magma end + @Nullable - public T m_20600_(ServerLevel p_20601_, @Nullable CompoundTag p_20602_, @Nullable Component p_20603_, @Nullable Player p_20604_, BlockPos p_20605_, MobSpawnType p_20606_, boolean p_20607_, boolean p_20608_) { - T t = this.m_20655_(p_20601_, p_20602_, p_20603_, p_20604_, p_20605_, p_20606_, p_20607_, p_20608_); + public T spawn(ServerLevel p_20601_, @Nullable CompoundTag p_20602_, @Nullable Component p_20603_, @Nullable Player p_20604_, BlockPos p_20605_, MobSpawnType p_20606_, boolean p_20607_, boolean p_20608_) { + T t = this.create(p_20601_, p_20602_, p_20603_, p_20604_, p_20605_, p_20606_, p_20607_, p_20608_); if (t != null) { + p_20601_.prepareEntity(t, spawn_spawnReason); //Magma - add spawn reason + prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); //Magma - reset spawn reason - p_20601_.m_47205_(t); + p_20601_.addFreshEntityWithPassengers(t); } @@ -342,6 +_,7 @@ Mob mob = (Mob)t; - mob.f_20885_ = mob.m_146908_(); - mob.f_20883_ = mob.m_146908_(); -+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, p_20656_, (float) mob.m_20185_(), (float) mob.m_20186_(), (float) mob.m_20189_(), null, p_20661_)) - mob.m_6518_(p_20656_, p_20656_.m_6436_(mob.m_142538_()), p_20661_, (SpawnGroupData)null, p_20657_); - mob.m_8032_(); + mob.yHeadRot = mob.getYRot(); + mob.yBodyRot = mob.getYRot(); ++ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, p_20656_, (float) mob.getX(), (float) mob.getY(), (float) mob.getZ(), null, p_20661_)) + mob.finalizeSpawn(p_20656_, p_20656_.getCurrentDifficultyAt(mob.blockPosition()), p_20661_, (SpawnGroupData)null, p_20657_); + mob.playAmbientSound(); } @@ -350,7 +_,11 @@ - t.m_6593_(p_20658_); + t.setCustomName(p_20658_); } -- m_20620_(p_20656_, p_20659_, t, p_20657_); +- updateCustomEntityTag(p_20656_, p_20659_, t, p_20657_); + try { -+ m_20620_(p_20656_, p_20659_, t, p_20657_); ++ updateCustomEntityTag(p_20656_, p_20659_, t, p_20657_); + } catch (Throwable t0) { -+ f_20534_.warn("Error loading spawn eg NBT", t0); ++ LOGGER.warn("Error loading spawn eg NBT", t0); + } return t; } @@ -111,18 +111,18 @@ @@ -544,14 +_,29 @@ } - public int m_20681_() { + public int clientTrackingRange() { + return trackingRangeSupplier.applyAsInt(this); + } + private int defaultTrackingRangeSupplier() { - return this.f_20542_; + return this.clientTrackingRange; } - public int m_20682_() { + public int updateInterval() { + return updateIntervalSupplier.applyAsInt(this); + } + private int defaultUpdateIntervalSupplier() { - return this.f_20543_; + return this.updateInterval; } + // Paper start - timings @@ -131,29 +131,29 @@ + public final co.aikar.timings.Timing passengerTickTimer; + public final co.aikar.timings.Timing passengerInactiveTickTimer; + // Paper end - public boolean m_20683_() { + public boolean trackDeltas() { + return velocityUpdateSupplier.test(this); + } + private boolean defaultVelocitySupplier() { - return this != f_20532_ && this != f_20467_ && this != f_20496_ && this != f_20549_ && this != f_20462_ && this != f_147033_ && this != f_20464_ && this != f_20506_ && this != f_20564_ && this != f_20569_; + return this != PLAYER && this != LLAMA_SPIT && this != WITHER && this != BAT && this != ITEM_FRAME && this != GLOW_ITEM_FRAME && this != LEASH_KNOT && this != PAINTING && this != END_CRYSTAL && this != EVOKER_FANGS; } @@ -574,6 +_,12 @@ - return this.f_204038_; + return this.builtInRegistryHolder; } + public T customClientSpawn(net.minecraftforge.network.PlayMessages.SpawnEntity packet, Level world) { -+ if (customClientFactory == null) return this.m_20615_(world); ++ if (customClientFactory == null) return this.create(world); + return customClientFactory.apply(packet, world); + } -+ public Stream>> getTags() {return this.m_204041_().m_203616_();} ++ public Stream>> getTags() {return this.builtInRegistryHolder().tags();} + public static class Builder { - private final EntityType.EntityFactory f_20685_; - private final MobCategory f_20686_; + private final EntityType.EntityFactory factory; + private final MobCategory category; @@ -586,6 +_,11 @@ - private int f_20693_ = 3; - private EntityDimensions f_20694_ = EntityDimensions.m_20395_(0.6F, 1.8F); + private int updateInterval = 3; + private EntityDimensions dimensions = EntityDimensions.scalable(0.6F, 1.8F); + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; @@ -161,8 +161,8 @@ + private java.util.function.BiFunction customClientFactory; + private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { - this.f_20685_ = p_20696_; - this.f_20686_ = p_20697_; + this.factory = p_20696_; + this.category = p_20697_; @@ -642,16 +_,46 @@ return this; } @@ -191,23 +191,23 @@ + return this; + } + - public EntityType m_20712_(String p_20713_) { - if (this.f_20688_) { - Util.m_137456_(References.f_16785_, p_20713_); + public EntityType build(String p_20713_) { + if (this.serialize) { + Util.fetchChoiceType(References.ENTITY_TREE, p_20713_); } -- return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_); -+ return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory, p_20713_); // Paper - add id +- return new EntityType<>(this.factory, this.category, this.serialize, this.summon, this.fireImmune, this.canSpawnFarFromPlayer, this.immuneTo, this.dimensions, this.clientTrackingRange, this.updateInterval); ++ return new EntityType<>(this.factory, this.category, this.serialize, this.summon, this.fireImmune, this.canSpawnFarFromPlayer, this.immuneTo, this.dimensions, this.clientTrackingRange, this.updateInterval, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory, p_20713_); // Paper - add id } } public interface EntityFactory { - T m_20721_(EntityType p_20722_, Level p_20723_); + T create(EntityType p_20722_, Level p_20723_); } + + // Paper start + public static java.util.Set getEntityNameList() { -+ return Registry.f_122826_.m_6566_(); ++ return Registry.ENTITY_TYPE.keySet(); + } + // Paper end } diff --git a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch index be0df0f0..f24bf5c8 100644 --- a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -2,73 +2,73 @@ +++ b/net/minecraft/world/entity/ExperienceOrb.java @@ -52,6 +_,7 @@ - public void m_8119_() { - super.m_8119_(); -+ Player prevTarget = this.f_20771_;// CraftBukkit - store old target - this.f_19854_ = this.m_20185_(); - this.f_19855_ = this.m_20186_(); - this.f_19856_ = this.m_20189_(); + public void tick() { + super.tick(); ++ Player prevTarget = this.followingPlayer;// CraftBukkit - store old target + this.xo = this.getX(); + this.yo = this.getY(); + this.zo = this.getZ(); @@ -77,7 +_,21 @@ - this.f_20771_ = null; + this.followingPlayer = null; } -- if (this.f_20771_ != null) { +- if (this.followingPlayer != null) { + // CraftBukkit start + boolean cancelled = false; -+ if (this.f_20771_ != prevTarget) { -+ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(this, f_20771_, (f_20771_ != null) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); ++ if (this.followingPlayer != prevTarget) { ++ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(this, followingPlayer, (followingPlayer != null) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); + LivingEntity target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) event.getTarget()).getHandle(); + cancelled = event.isCancelled(); + if (cancelled) { -+ f_20771_ = prevTarget; ++ followingPlayer = prevTarget; + } else { -+ f_20771_ = (target instanceof Player) ? (Player) target : null; ++ followingPlayer = (target instanceof Player) ? (Player) target : null; + } + } + -+ if (this.f_20771_ != null && !cancelled) { ++ if (this.followingPlayer != null && !cancelled) { + // CraftBukkit end - Vec3 vec3 = new Vec3(this.f_20771_.m_20185_() - this.m_20185_(), this.f_20771_.m_20186_() + (double)this.f_20771_.m_20192_() / 2.0D - this.m_20186_(), this.f_20771_.m_20189_() - this.m_20189_()); - double d0 = vec3.m_82556_(); + Vec3 vec3 = new Vec3(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double)this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); + double d0 = vec3.lengthSqr(); if (d0 < 64.0D) { @@ -89,7 +_,8 @@ - this.m_6478_(MoverType.SELF, this.m_20184_()); + this.move(MoverType.SELF, this.getDeltaMovement()); float f = 0.98F; - if (this.f_19861_) { -- f = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.98F; -+ BlockPos pos =new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_()); -+ f = this.f_19853_.m_8055_(pos).getFriction(this.f_19853_, pos, this) * 0.98F; + if (this.onGround) { +- f = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ())).getBlock().getFriction() * 0.98F; ++ BlockPos pos =new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ()); ++ f = this.level.getBlockState(pos).getFriction(this.level, pos, this) * 0.98F; } - this.m_20256_(this.m_20184_().m_82542_((double)f, 0.98D, (double)f)); + this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98D, (double)f)); @@ -167,6 +_,7 @@ } - public boolean m_6469_(DamageSource p_20785_, float p_20786_) { -+ if (this.f_19853_.f_46443_ || this.m_146910_()) return false; //Forge: Fixes MC-53850 - if (this.m_6673_(p_20785_)) { + 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.f_19853_.f_46443_) { + } else if (this.level.isClientSide) { @@ -199,11 +_,12 @@ - public void m_6123_(Player p_20792_) { - if (!this.f_19853_.f_46443_) { - if (p_20792_.f_36101_ == 0) { + public void playerTouch(Player p_20792_) { + if (!this.level.isClientSide) { + if (p_20792_.takeXpDelay == 0) { + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerXpEvent.PickupXp(p_20792_, this))) return; - p_20792_.f_36101_ = 2; - p_20792_.m_7938_(this, 1); - int i = this.m_147092_(p_20792_, this.f_20770_); + p_20792_.takeXpDelay = 2; + p_20792_.take(this, 1); + int i = this.repairPlayerItems(p_20792_, this.value); if (i > 0) { -- p_20792_.m_6756_(i); -+ p_20792_.m_6756_(org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerExpChangeEvent(p_20792_, i).getAmount()); // CraftBukkit - this.value -> event.getAmount() +- p_20792_.giveExperiencePoints(i); ++ p_20792_.giveExperiencePoints(org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerExpChangeEvent(p_20792_, i).getAmount()); // CraftBukkit - this.value -> event.getAmount() } - --this.f_147072_; + --this.count; @@ -219,9 +_,19 @@ - Entry entry = EnchantmentHelper.m_44839_(Enchantments.f_44962_, p_147093_, ItemStack::m_41768_); + Entry entry = EnchantmentHelper.getRandomItemWith(Enchantments.MENDING, p_147093_, ItemStack::isDamaged); if (entry != null) { ItemStack itemstack = entry.getValue(); -- int i = Math.min(this.m_20798_(this.f_20770_), itemstack.m_41773_()); -+ int i = Math.min((int) (this.f_20770_ * itemstack.getXpRepairRatio()), itemstack.m_41773_()); +- int i = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue()); ++ int i = Math.min((int) (this.value * itemstack.getXpRepairRatio()), itemstack.getDamageValue()); + + // CraftBukkit start + org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerItemMendEvent(p_147093_, this, itemstack, i); @@ -78,16 +78,16 @@ + } + // CraftBukkit end + - itemstack.m_41721_(itemstack.m_41773_() - i); - int j = p_147094_ - this.m_20793_(i); -+ this.f_20770_ = j; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls - return j > 0 ? this.m_147092_(p_147093_, j) : 0; + itemstack.setDamageValue(itemstack.getDamageValue() - i); + int j = p_147094_ - this.durabilityToXp(i); ++ this.value = j; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls + return j > 0 ? this.repairPlayerItems(p_147093_, j) : 0; } else { return p_147094_; @@ -265,6 +_,24 @@ } - public static int m_20782_(int p_20783_) { + public static int getExperienceValue(int p_20783_) { + // CraftBukkit start + if (p_20783_ > 162670129) return p_20783_ - 100000; + if (p_20783_ > 81335063) return 81335063; diff --git a/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch b/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch index 16700883..2cd8fda4 100644 --- a/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/entity/FlyingMob.java +++ b/net/minecraft/world/entity/FlyingMob.java @@ -28,15 +_,16 @@ - this.m_6478_(MoverType.SELF, this.m_20184_()); - this.m_20256_(this.m_20184_().m_82490_(0.5D)); + this.move(MoverType.SELF, this.getDeltaMovement()); + this.setDeltaMovement(this.getDeltaMovement().scale(0.5D)); } else { -+ BlockPos ground = new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_()); ++ BlockPos ground = new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ()); float f = 0.91F; - if (this.f_19861_) { -- f = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.91F; -+ f = this.f_19853_.m_8055_(ground).getFriction(this.f_19853_, ground, this) * 0.91F; + if (this.onGround) { +- f = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ())).getBlock().getFriction() * 0.91F; ++ f = this.level.getBlockState(ground).getFriction(this.level, ground, this) * 0.91F; } float f1 = 0.16277137F / (f * f * f); f = 0.91F; - if (this.f_19861_) { -- f = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.91F; -+ f = this.f_19853_.m_8055_(ground).getFriction(this.f_19853_, ground, this) * 0.91F; + if (this.onGround) { +- f = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ())).getBlock().getFriction() * 0.91F; ++ f = this.level.getBlockState(ground).getFriction(this.level, ground, this) * 0.91F; } - this.m_19920_(this.f_19861_ ? 0.1F * f1 : 0.02F, p_20818_); + this.moveRelative(this.onGround ? 0.1F * f1 : 0.02F, p_20818_); diff --git a/patches/minecraft/net/minecraft/world/entity/ItemBasedSteering.java.patch b/patches/minecraft/net/minecraft/world/entity/ItemBasedSteering.java.patch index 26c145c8..f1914d19 100644 --- a/patches/minecraft/net/minecraft/world/entity/ItemBasedSteering.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ItemBasedSteering.java.patch @@ -6,12 +6,12 @@ + // CraftBukkit add setBoostTicks(int) + public void setBoostTicks(int ticks) { -+ this.f_20834_ = true; -+ this.f_20835_ = 0; -+ this.f_20836_ = ticks; -+ this.f_20837_.m_135381_(this.f_20838_, this.f_20836_); ++ this.boosting = true; ++ this.boostTime = 0; ++ this.boostTimeTotal = ticks; ++ this.entityData.set(this.boostTimeAccessor, this.boostTimeTotal); + } + // CraftBukkit end - public void m_20847_(CompoundTag p_20848_) { - p_20848_.m_128379_("Saddle", this.m_20851_()); + public void addAdditionalSaveData(CompoundTag p_20848_) { + p_20848_.putBoolean("Saddle", this.hasSaddle()); } diff --git a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch index 01f8cf2a..561de071 100644 --- a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java @@ -40,6 +_,9 @@ - private final Set f_147134_ = Sets.newHashSet(); - private int f_147135_; + private final Set hitEntities = Sets.newHashSet(); + private int blocksSetOnFire; + public boolean isSilent = false; // Spigot + private float damage = 5.0F; + public LightningBolt(EntityType p_20865_, Level p_20866_) { super(p_20865_, p_20866_); - this.f_19811_ = true; + this.noCulling = true; @@ -74,9 +_,17 @@ } @@ -22,53 +22,53 @@ + return this.damage; + } + - public void m_8119_() { - super.m_8119_(); -- if (this.f_20860_ == 2) { -+ if (!isSilent && this.f_20860_ == 2) { // Spigot - if (this.f_19853_.m_5776_()) { - this.f_19853_.m_7785_(this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12090_, SoundSource.WEATHER, 10000.0F, 0.8F + this.f_19796_.nextFloat() * 0.2F, false); - this.f_19853_.m_7785_(this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12089_, SoundSource.WEATHER, 2.0F, 0.5F + this.f_19796_.nextFloat() * 0.2F, false); + public void tick() { + super.tick(); +- if (this.life == 2) { ++ if (!isSilent && this.life == 2) { // Spigot + if (this.level.isClientSide()) { + this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F, false); + this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F, false); @@ -116,13 +_,14 @@ } } -- if (this.f_20860_ >= 0) { -+ if (this.f_20860_ >= 0 && !this.f_20862_) { // CraftBukkit - add !this.visualOnly - if (!(this.f_19853_ instanceof ServerLevel)) { - this.f_19853_.m_6580_(2); - } else if (!this.f_20862_) { - List list1 = this.f_19853_.m_6249_(this, new AABB(this.m_20185_() - 3.0D, this.m_20186_() - 3.0D, this.m_20189_() - 3.0D, this.m_20185_() + 3.0D, this.m_20186_() + 6.0D + 3.0D, this.m_20189_() + 3.0D), Entity::m_6084_); +- if (this.life >= 0) { ++ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly + if (!(this.level instanceof ServerLevel)) { + this.level.setSkyFlashTime(2); + } else if (!this.visualOnly) { + List list1 = this.level.getEntities(this, new AABB(this.getX() - 3.0D, this.getY() - 3.0D, this.getZ() - 3.0D, this.getX() + 3.0D, this.getY() + 6.0D + 3.0D, this.getZ() + 3.0D), Entity::isAlive); for(Entity entity : list1) { + if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) - entity.m_8038_((ServerLevel)this.f_19853_, this); + entity.thunderHit((ServerLevel)this.level, this); } @@ -145,16 +_,24 @@ - BlockPos blockpos = this.m_142538_(); - BlockState blockstate = BaseFireBlock.m_49245_(this.f_19853_, blockpos); - if (this.f_19853_.m_8055_(blockpos).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos)) { -- this.f_19853_.m_46597_(blockpos, blockstate); -- ++this.f_147135_; + BlockPos blockpos = this.blockPosition(); + BlockState blockstate = BaseFireBlock.getState(this.level, blockpos); + if (this.level.getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level, blockpos)) { +- this.level.setBlockAndUpdate(blockpos, blockstate); +- ++this.blocksSetOnFire; + // CraftBukkit start - add "!visualOnly" -+ if (!f_20862_ && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(f_19853_, blockpos, this).isCancelled()) { -+ this.f_19853_.m_46597_(blockpos, blockstate); -+ ++this.f_147135_; ++ if (!visualOnly && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, this).isCancelled()) { ++ this.level.setBlockAndUpdate(blockpos, blockstate); ++ ++this.blocksSetOnFire; + } + // CraftBukkit end } for(int i = 0; i < p_20871_; ++i) { - BlockPos blockpos1 = blockpos.m_142082_(this.f_19796_.nextInt(3) - 1, this.f_19796_.nextInt(3) - 1, this.f_19796_.nextInt(3) - 1); - blockstate = BaseFireBlock.m_49245_(this.f_19853_, blockpos1); - if (this.f_19853_.m_8055_(blockpos1).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos1)) { -- this.f_19853_.m_46597_(blockpos1, blockstate); -- ++this.f_147135_; + BlockPos blockpos1 = blockpos.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); + blockstate = BaseFireBlock.getState(this.level, blockpos1); + if (this.level.getBlockState(blockpos1).isAir() && blockstate.canSurvive(this.level, blockpos1)) { +- this.level.setBlockAndUpdate(blockpos1, blockstate); +- ++this.blocksSetOnFire; + // CraftBukkit start - add "!visualOnly" -+ if (!f_20862_ && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(f_19853_, blockpos1, this).isCancelled()) { -+ this.f_19853_.m_46597_(blockpos1, blockstate); -+ ++this.f_147135_; ++ if (!visualOnly && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos1, this).isCancelled()) { ++ this.level.setBlockAndUpdate(blockpos1, blockstate); ++ ++this.blocksSetOnFire; + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index afa2b4a6..0a38331f 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -122,7 +_,9 @@ - private static final UUID f_20929_ = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); - private static final UUID f_20959_ = UUID.fromString("87f46a96-686f-4796-b035-22e16ee9e038"); - private static final UUID f_147184_ = UUID.fromString("1eaf83ff-7207-4596-b37a-d7a07b3ec4ce"); + private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); + private static final UUID SPEED_MODIFIER_SOUL_SPEED_UUID = UUID.fromString("87f46a96-686f-4796-b035-22e16ee9e038"); + private static final UUID SPEED_MODIFIER_POWDER_SNOW_UUID = UUID.fromString("1eaf83ff-7207-4596-b37a-d7a07b3ec4ce"); + private static final UUID SLOW_FALLING_ID = UUID.fromString("A5B6CF2A-2F7C-31EF-9022-7C3E7D5E6ABA"); - private static final AttributeModifier f_20960_ = new AttributeModifier(f_20929_, "Sprinting speed boost", (double)0.3F, AttributeModifier.Operation.MULTIPLY_TOTAL); + private static final AttributeModifier SPEED_MODIFIER_SPRINTING = new AttributeModifier(SPEED_MODIFIER_SPRINTING_UUID, "Sprinting speed boost", (double)0.3F, AttributeModifier.Operation.MULTIPLY_TOTAL); + private static final AttributeModifier SLOW_FALLING = new AttributeModifier(SLOW_FALLING_ID, "Slow falling acceleration reduction", -0.07, AttributeModifier.Operation.ADDITION); // Add -0.07 to 0.08 so we get the vanilla default of 0.01 - public static final int f_147166_ = 2; - public static final int f_147167_ = 4; - public static final int f_147168_ = 98; + public static final int HAND_SLOTS = 2; + public static final int ARMOR_SLOTS = 4; + public static final int EQUIPMENT_SLOT_OFFSET = 98; @@ -226,10 +_,29 @@ - private float f_20932_; - protected Brain f_20939_; + private float swimAmountO; + protected Brain brain; + // CraftBukkit start + public int expToDrop; @@ -25,7 +25,7 @@ + + @Override + public float getBukkitYaw() { -+ return m_6080_(); ++ return getYHeadRot(); + } + // CraftBukkit end + @@ -33,34 +33,34 @@ + protected LivingEntity(EntityType p_20966_, Level p_20967_) { super(p_20966_, p_20967_); - this.f_20943_ = new AttributeMap(DefaultAttributes.m_22297_(p_20966_)); -- this.m_21153_(this.m_21233_()); -+ this.craftAttributes = new org.bukkit.craftbukkit.v1_18_R2.attribute.CraftAttributeMap(f_20943_); // CraftBukkit + this.attributes = new AttributeMap(DefaultAttributes.getSupplier(p_20966_)); +- this.setHealth(this.getMaxHealth()); ++ this.craftAttributes = new org.bukkit.craftbukkit.v1_18_R2.attribute.CraftAttributeMap(attributes); // CraftBukkit + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor -+ this.f_19804_.m_135381_(LivingEntity.f_20961_, (float) this.m_21051_(Attributes.f_22276_).m_22135_()); - this.f_19850_ = true; - this.f_20928_ = (float)((Math.random() + 1.0D) * (double)0.01F); - this.m_20090_(); ++ this.entityData.set(LivingEntity.DATA_HEALTH_ID, (float) this.getAttribute(Attributes.MAX_HEALTH).getValue()); + this.blocksBuilding = true; + this.rotA = (float)((Math.random() + 1.0D) * (double)0.01F); + this.reapplyPosition(); @@ -272,7 +_,7 @@ } - public static AttributeSupplier.Builder m_21183_() { -- return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_); -+ return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_).m_22266_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22266_(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).m_22266_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()).m_22266_(net.minecraftforge.common.ForgeMod.STEP_HEIGHT_ADDITION.get()); + public static AttributeSupplier.Builder createLivingAttributes() { +- return AttributeSupplier.builder().add(Attributes.MAX_HEALTH).add(Attributes.KNOCKBACK_RESISTANCE).add(Attributes.MOVEMENT_SPEED).add(Attributes.ARMOR).add(Attributes.ARMOR_TOUGHNESS); ++ return AttributeSupplier.builder().add(Attributes.MAX_HEALTH).add(Attributes.KNOCKBACK_RESISTANCE).add(Attributes.MOVEMENT_SPEED).add(Attributes.ARMOR).add(Attributes.ARMOR_TOUGHNESS).add(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).add(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).add(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()).add(net.minecraftforge.common.ForgeMod.STEP_HEIGHT_ADDITION.get()); } - protected void m_7840_(double p_20990_, boolean p_20991_, BlockState p_20992_, BlockPos p_20993_) { + protected void checkFallDamage(double p_20990_, boolean p_20991_, BlockState p_20992_, BlockPos p_20993_) { @@ -290,7 +_,14 @@ - if (!p_20992_.m_60795_()) { + if (!p_20992_.isAir()) { double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D); int i = (int)(150.0D * d0); -- ((ServerLevel)this.f_19853_).m_8767_(new BlockParticleOption(ParticleTypes.f_123794_, p_20992_), this.m_20185_(), this.m_20186_(), this.m_20189_(), i, 0.0D, 0.0D, 0.0D, (double)0.15F); -+ if (!p_20992_.addLandingEffects((ServerLevel)this.f_19853_, p_20993_, p_20992_, this, i)) +- ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, (double)0.15F); ++ if (!p_20992_.addLandingEffects((ServerLevel)this.level, p_20993_, p_20992_, this, i)) + // CraftBukkit start - visiblity api + if (this instanceof ServerPlayer) { -+ ((ServerLevel) this.f_19853_).sendParticles((ServerPlayer) this, new BlockParticleOption(ParticleTypes.f_123794_, p_20992_), this.m_20185_(), this.m_20186_(), this.m_20189_(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); ++ ((ServerLevel) this.level).sendParticles((ServerPlayer) this, new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); + } else { -+ ((ServerLevel) this.f_19853_).m_8767_(new BlockParticleOption(ParticleTypes.f_123794_, p_20992_), this.m_20185_(), this.m_20186_(), this.m_20189_(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ ((ServerLevel) this.level).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } + // CraftBukkit end } @@ -70,13 +70,13 @@ } } -- if (!this.f_19853_.f_46443_ && this.m_20159_() && this.m_20202_() != null && !this.m_20202_().m_6146_()) { -+ if (!this.f_19853_.f_46443_ && this.m_20159_() && this.m_20202_() != null && !this.m_20202_().canBeRiddenInWater(this)) { - this.m_8127_(); +- if (!this.level.isClientSide && this.isPassenger() && this.getVehicle() != null && !this.getVehicle().rideableUnderWater()) { ++ if (!this.level.isClientSide && this.isPassenger() && this.getVehicle() != null && !this.getVehicle().canBeRiddenInWater(this)) { + this.stopRiding(); } - } else if (this.m_20146_() < this.m_6062_()) { + } else if (this.getAirSupply() < this.getMaxAirSupply()) { @@ -618,13 +_,29 @@ - this.f_147183_ = p_147245_; + this.discardFriction = p_147245_; } + //Magma start - add function for silencing equip sounds @@ -86,13 +86,13 @@ + silentEquipSound = silent; + } + - protected void m_147218_(ItemStack p_147219_) { - SoundEvent soundevent = p_147219_.m_150920_(); -- if (!p_147219_.m_41619_() && soundevent != null && !this.m_5833_()) { -+ if (!p_147219_.m_41619_() && soundevent != null && !this.m_5833_() && !silentEquipSound) { + protected void equipEventAndSound(ItemStack p_147219_) { + SoundEvent soundevent = p_147219_.getEquipSound(); +- if (!p_147219_.isEmpty() && soundevent != null && !this.isSpectator()) { ++ if (!p_147219_.isEmpty() && soundevent != null && !this.isSpectator() && !silentEquipSound) { + // CraftBukkit end - this.m_146850_(GameEvent.f_157811_); - this.m_5496_(soundevent, 1.0F, 1.0F); + this.gameEvent(GameEvent.EQUIP); + this.playSound(soundevent, 1.0F, 1.0F); } - } + silenceEquipSound(false); @@ -100,30 +100,30 @@ + + protected void equipEventAndSound(ItemStack p_147219_, boolean silent) { + silenceEquipSound(silent); -+ m_147218_(p_147219_); ++ equipEventAndSound(p_147219_); + silenceEquipSound(false); //reset + } + //Magma end - public void m_7380_(CompoundTag p_21145_) { - p_21145_.m_128350_("Health", this.m_21223_()); + public void addAdditionalSaveData(CompoundTag p_21145_) { + p_21145_.putFloat("Health", this.getHealth()); @@ -673,6 +_,17 @@ } } + // CraftBukkit start -+ if (p_21096_.m_128441_("Bukkit.MaxHealth")) { -+ net.minecraft.nbt.Tag nbtbase = p_21096_.m_128423_("Bukkit.MaxHealth"); -+ if (nbtbase.m_7060_() == 5) { -+ this.m_21051_(Attributes.f_22276_).m_22100_(((net.minecraft.nbt.FloatTag) nbtbase).m_7061_()); -+ } else if (nbtbase.m_7060_() == 3) { -+ this.m_21051_(Attributes.f_22276_).m_22100_(((net.minecraft.nbt.IntTag) nbtbase).m_7061_()); ++ if (p_21096_.contains("Bukkit.MaxHealth")) { ++ net.minecraft.nbt.Tag nbtbase = p_21096_.get("Bukkit.MaxHealth"); ++ if (nbtbase.getId() == 5) { ++ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(((net.minecraft.nbt.FloatTag) nbtbase).getAsDouble()); ++ } else if (nbtbase.getId() == 3) { ++ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(((net.minecraft.nbt.IntTag) nbtbase).getAsDouble()); + } + } + // CraftBukkit end + - if (p_21096_.m_128425_("Health", 99)) { - this.m_21153_(p_21096_.m_128457_("Health")); + if (p_21096_.contains("Health", 99)) { + this.setHealth(p_21096_.getFloat("Health")); } @@ -708,9 +_,32 @@ @@ -151,19 +151,19 @@ + } + // CraftBukkit end + - protected void m_21217_() { - Iterator iterator = this.f_20945_.keySet().iterator(); + protected void tickEffects() { + Iterator iterator = this.activeEffects.keySet().iterator(); + isTickingEffects = true; // CraftBukkit try { while(iterator.hasNext()) { MobEffect mobeffect = iterator.next(); @@ -718,7 +_,13 @@ - if (!mobeffectinstance.m_19552_(this, () -> { - this.m_141973_(mobeffectinstance, true, (Entity)null); + if (!mobeffectinstance.tick(this, () -> { + this.onEffectUpdated(mobeffectinstance, true, (Entity)null); })) { -- if (!this.f_19853_.f_46443_) { -+ if (!this.f_19853_.f_46443_ && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionExpiryEvent(this, mobeffectinstance))) { +- if (!this.level.isClientSide) { ++ if (!this.level.isClientSide && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionExpiryEvent(this, mobeffectinstance))) { + // CraftBukkit start + org.bukkit.event.entity.EntityPotionEffectEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffectinstance, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION); + if (event.isCancelled()) { @@ -171,7 +171,7 @@ + } + // CraftBukkit end iterator.remove(); - this.m_7285_(mobeffectinstance); + this.onEffectRemoved(mobeffectinstance); } @@ -729,6 +_,18 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { @@ -189,20 +189,20 @@ + effectsToProcess.clear(); + // CraftBukkit end + - if (this.f_20948_) { - if (!this.f_19853_.f_46443_) { - this.m_8034_(); + if (this.effectsDirty) { + if (!this.level.isClientSide) { + this.updateInvisibilityStatus(); @@ -768,8 +_,10 @@ - this.m_6842_(false); + this.setInvisible(false); } else { - Collection collection = this.f_20945_.values(); -- this.f_19804_.m_135381_(f_20963_, m_21179_(collection)); -- this.f_19804_.m_135381_(f_20962_, PotionUtils.m_43564_(collection)); -+ net.minecraftforge.event.entity.living.PotionColorCalculationEvent event = new net.minecraftforge.event.entity.living.PotionColorCalculationEvent(this, PotionUtils.m_43564_(collection), m_21179_(collection), collection); + Collection collection = this.activeEffects.values(); +- this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(collection)); +- this.entityData.set(DATA_EFFECT_COLOR_ID, PotionUtils.getColor(collection)); ++ net.minecraftforge.event.entity.living.PotionColorCalculationEvent event = new net.minecraftforge.event.entity.living.PotionColorCalculationEvent(this, PotionUtils.getColor(collection), areAllEffectsAmbient(collection), collection); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ this.f_19804_.m_135381_(f_20963_, event.areParticlesHidden()); -+ this.f_19804_.m_135381_(f_20962_, event.getColor()); - this.m_6842_(this.m_21023_(MobEffects.f_19609_)); ++ this.entityData.set(DATA_EFFECT_AMBIENCE_ID, event.areParticlesHidden()); ++ this.entityData.set(DATA_EFFECT_COLOR_ID, event.getColor()); + this.setInvisible(this.hasEffect(MobEffects.INVISIBILITY)); } @@ -805,7 +_,7 @@ @@ -215,24 +215,24 @@ } @@ -840,7 +_,13 @@ - this.f_19804_.m_135381_(f_20962_, 0); + this.entityData.set(DATA_EFFECT_COLOR_ID, 0); } + // CraftBukkit start - public boolean m_21219_() { + public boolean removeAllEffects() { + return removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } + + public boolean removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { + // CraftBukkit end - if (this.f_19853_.f_46443_) { + if (this.level.isClientSide) { return false; } else { @@ -848,7 +_,15 @@ boolean flag; for(flag = false; iterator.hasNext(); flag = true) { -- this.m_7285_(iterator.next()); +- this.onEffectRemoved(iterator.next()); + MobEffectInstance effect = iterator.next(); + if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) continue; + // CraftBukkit start @@ -240,13 +240,13 @@ + if (event.isCancelled()) { + continue; + } -+ this.m_7285_(effect); ++ this.onEffectRemoved(effect); + // CraftBukkit end iterator.remove(); } @@ -877,17 +_,58 @@ - return this.m_147207_(p_21165_, (Entity)null); + return this.addEffect(p_21165_, (Entity)null); } + // CraftBukkit start @@ -260,7 +260,7 @@ + this.effectCause = cause; + } + - public boolean m_147207_(MobEffectInstance p_147208_, @Nullable Entity p_147209_) { + public boolean addEffect(MobEffectInstance p_147208_, @Nullable Entity p_147209_) { + org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause = effectCause; + effectCause = org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN; //reset + return this.addEffect(p_147208_, p_147209_, cause); @@ -274,16 +274,16 @@ + return true; + } + // CraftBukkit end - if (!this.m_7301_(p_147208_)) { + if (!this.canBeAffected(p_147208_)) { return false; } else { - MobEffectInstance mobeffectinstance = this.f_20945_.get(p_147208_.m_19544_()); + MobEffectInstance mobeffectinstance = this.activeEffects.get(p_147208_.getEffect()); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionAddedEvent(this, mobeffectinstance, p_147208_, p_147209_)); + + // CraftBukkit start + boolean override = false; + if (mobeffectinstance != null) { -+ override = new MobEffectInstance(mobeffectinstance).m_19558_(p_147208_); ++ override = new MobEffectInstance(mobeffectinstance).update(p_147208_); + } + + org.bukkit.event.entity.EntityPotionEffectEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffectinstance, p_147208_, cause, override); @@ -293,14 +293,14 @@ + // CraftBukkit end + if (mobeffectinstance == null) { - this.f_20945_.put(p_147208_.m_19544_(), p_147208_); - this.m_142540_(p_147208_, p_147209_); + this.activeEffects.put(p_147208_.getEffect(), p_147208_); + this.onEffectAdded(p_147208_, p_147209_); return true; -- } else if (mobeffectinstance.m_19558_(p_147208_)) { +- } else if (mobeffectinstance.update(p_147208_)) { + // CraftBukkit start + } else if (event.isOverride()) { -+ mobeffectinstance.m_19558_(p_147208_); - this.m_141973_(mobeffectinstance, true, p_147209_); ++ mobeffectinstance.update(p_147208_); + this.onEffectUpdated(mobeffectinstance, true, p_147209_); + // CraftBukkit end return true; } else { @@ -308,20 +308,20 @@ @@ -896,6 +_,9 @@ } - public boolean m_7301_(MobEffectInstance p_21197_) { + public boolean canBeAffected(MobEffectInstance p_21197_) { + net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_21197_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() != net.minecraftforge.eventbus.api.Event.Result.DEFAULT) return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW; - if (this.m_6336_() == MobType.f_21641_) { - MobEffect mobeffect = p_21197_.m_19544_(); - if (mobeffect == MobEffects.f_19605_ || mobeffect == MobEffects.f_19614_) { + if (this.getMobType() == MobType.UNDEAD) { + MobEffect mobeffect = p_21197_.getEffect(); + if (mobeffect == MobEffects.REGENERATION || mobeffect == MobEffects.POISON) { @@ -922,13 +_,39 @@ - return this.m_6336_() == MobType.f_21641_; + return this.getMobType() == MobType.UNDEAD; } + // CraftBukkit start @Nullable - public MobEffectInstance m_6234_(@Nullable MobEffect p_21164_) { + public MobEffectInstance removeEffectNoUpdate(@Nullable MobEffect p_21164_) { + + return removeEffectNoUpdate(p_21164_, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } @@ -332,7 +332,7 @@ + effectsToProcess.add(new ProcessableEffect(p_21164_, cause)); + return null; + } -+ MobEffectInstance effect = this.f_20945_.get(p_21164_); ++ MobEffectInstance effect = this.activeEffects.get(p_21164_); + if (effect == null) { + return null; + } @@ -341,11 +341,11 @@ + return null; + } + - return this.f_20945_.remove(p_21164_); + return this.activeEffects.remove(p_21164_); } - public boolean m_21195_(MobEffect p_21196_) { -- MobEffectInstance mobeffectinstance = this.m_6234_(p_21196_); + public boolean removeEffect(MobEffect p_21196_) { +- MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(p_21196_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, p_21196_))) return false; + return removeEffect(p_21196_, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } @@ -354,7 +354,7 @@ + MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(mobeffectlist, cause); + // CraftBukkit end if (mobeffectinstance != null) { - this.m_7285_(mobeffectinstance); + this.onEffectRemoved(mobeffectinstance); return true; @@ -963,19 +_,63 @@ @@ -367,7 +367,7 @@ + public void setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason reason) { + this.regainReason = reason; + } - public void m_5634_(float p_21116_) { + public void heal(float p_21116_) { + heal(p_21116_, regainReason); + this.regainReason = org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.CUSTOM; //Reset + } @@ -376,16 +376,16 @@ + + p_21116_ = net.minecraftforge.event.ForgeEventFactory.onLivingHeal(this, p_21116_); + if (p_21116_ <= 0) return; - float f = this.m_21223_(); + float f = this.getHealth(); if (f > 0.0F) { -- this.m_21153_(f + p_21116_); +- this.setHealth(f + p_21116_); + org.bukkit.event.entity.EntityRegainHealthEvent event = new org.bukkit.event.entity.EntityRegainHealthEvent(this.getBukkitEntity(), p_21116_, regainReason); + // Suppress during worldgen + if (this.valid) { -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + } + if (!event.isCancelled()) { -+ this.m_21153_((float) (this.m_21223_() + event.getAmount())); ++ this.setHealth((float) (this.getHealth() + event.getAmount())); + } + // CraftBukkit end } @@ -393,16 +393,16 @@ } + //Magma end - public float m_21223_() { + public float getHealth() { + // CraftBukkit start - Use unscaled health + if (this instanceof ServerPlayer) { + return (float) ((ServerPlayer) this).getBukkitEntity().getHealth(); + } + // CraftBukkit end - return this.f_19804_.m_135370_(f_20961_); + return this.entityData.get(DATA_HEALTH_ID); } - public void m_21153_(float p_21154_) { + public void setHealth(float p_21154_) { + // CraftBukkit start - Handle scaled health + if (this instanceof ServerPlayer) { + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer player = ((ServerPlayer) this).getBukkitEntity(); @@ -418,43 +418,43 @@ + return; + } + // CraftBukkit end - this.f_19804_.m_135381_(f_20961_, Mth.m_14036_(p_21154_, 0.0F, this.m_21233_())); + this.entityData.set(DATA_HEALTH_ID, Mth.clamp(p_21154_, 0.0F, this.getMaxHealth())); } @@ -984,11 +_,12 @@ } - public boolean m_6469_(DamageSource p_21016_, float p_21017_) { + public boolean hurt(DamageSource p_21016_, float p_21017_) { + if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_21016_, p_21017_)) return false; - if (this.m_6673_(p_21016_)) { + if (this.isInvulnerableTo(p_21016_)) { return false; - } else if (this.f_19853_.f_46443_) { + } else if (this.level.isClientSide) { return false; -- } else if (this.m_21224_()) { -+ } else if (this.m_146910_() || this.f_20890_ || this.m_21223_() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die +- } else if (this.isDeadOrDying()) { ++ } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die return false; - } else if (p_21016_.m_19384_() && this.m_21023_(MobEffects.f_19607_)) { + } else if (p_21016_.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; @@ -999,12 +_,15 @@ - this.f_20891_ = 0; + this.noActionTime = 0; float f = p_21017_; - boolean flag = false; -+ boolean flag = f > 0.0F && this.m_21275_(p_21016_); // Copied from below ++ boolean flag = f > 0.0F && this.isDamageSourceBlocked(p_21016_); // Copied from below float f1 = 0.0F; -- if (p_21017_ > 0.0F && this.m_21275_(p_21016_)) { -- this.m_7909_(p_21017_); +- if (p_21017_ > 0.0F && this.isDamageSourceBlocked(p_21016_)) { +- this.hurtCurrentlyUsedShield(p_21017_); - f1 = p_21017_; - p_21017_ = 0.0F; + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && f > 0.0F && this.m_21275_(p_21016_)) { ++ if (false && f > 0.0F && this.isDamageSourceBlocked(p_21016_)) { + net.minecraftforge.event.entity.living.ShieldBlockEvent ev = net.minecraftforge.common.ForgeHooks.onShieldBlock(this, p_21016_, p_21017_); + if(!ev.isCanceled()) { -+ if(ev.shieldTakesDamage()) this.m_7909_(p_21017_); ++ if(ev.shieldTakesDamage()) this.hurtCurrentlyUsedShield(p_21017_); + f1 = ev.getBlockedDamage(); + p_21017_ -= ev.getBlockedDamage(); - if (!p_21016_.m_19360_()) { - Entity entity = p_21016_.m_7640_(); + if (!p_21016_.isProjectile()) { + Entity entity = p_21016_.getDirectEntity(); if (entity instanceof LivingEntity) { @@ -1014,30 +_,71 @@ @@ -462,43 +462,43 @@ } + } - this.f_20924_ = 1.5F; + this.animationSpeed = 1.5F; boolean flag1 = true; -- if ((float)this.f_19802_ > 10.0F) { -+ if ((float) this.f_19802_ > (float) this.f_20926_ / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks - if (p_21017_ <= this.f_20898_) { +- if ((float)this.invulnerableTime > 10.0F) { ++ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks + if (p_21017_ <= this.lastHurt) { return false; } -- this.m_6475_(p_21016_, p_21017_ - this.f_20898_); +- this.actuallyHurt(p_21016_, p_21017_ - this.lastHurt); + //Magma start - calculate player hurt damage in their class + if (this instanceof Player) { -+ this.m_6475_(p_21016_, p_21017_ - this.f_20898_); ++ this.actuallyHurt(p_21016_, p_21017_ - this.lastHurt); + if (cancelDamage){ + cancelDamage = false; + return false; + } + } else { + // CraftBukkit start -+ this.m_6475_(p_21016_, p_21017_ - this.f_20898_); ++ this.actuallyHurt(p_21016_, p_21017_ - this.lastHurt); + if (!damageEntity0) + return false; + // CraftBukkit end + } + //Magma end - this.f_20898_ = p_21017_; + this.lastHurt = p_21017_; flag1 = false; } else { + //Magma start - calculate player hurt damage in their class + if (this instanceof Player) { -+ this.m_6475_(p_21016_, f); ++ this.actuallyHurt(p_21016_, f); + if (cancelDamage){ + cancelDamage = false; + return false; + } + } else { + // CraftBukkit start -+ this.m_6475_(p_21016_, f); ++ this.actuallyHurt(p_21016_, f); + if (!damageEntity0) + return false; + // CraftBukkit end @@ -506,55 +506,55 @@ + //Magma end + + // CraftBukkit start - this.f_20898_ = p_21017_; -- this.f_19802_ = 20; -- this.m_6475_(p_21016_, p_21017_); -+ this.f_19802_ = this.f_20926_; // CraftBukkit - restore use of maxNoDamageTicks - this.f_20917_ = 10; - this.f_20916_ = this.f_20917_; + this.lastHurt = p_21017_; +- this.invulnerableTime = 20; +- this.actuallyHurt(p_21016_, p_21017_); ++ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks + this.hurtDuration = 10; + this.hurtTime = this.hurtDuration; } -- if (p_21016_.m_146705_() && !this.m_6844_(EquipmentSlot.HEAD).m_41619_()) { +- if (p_21016_.isDamageHelmet() && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && p_21016_.m_146705_() && !this.m_6844_(EquipmentSlot.HEAD).m_41619_()) { - this.m_142642_(p_21016_, p_21017_); ++ if (false && p_21016_.isDamageHelmet() && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { + this.hurtHelmet(p_21016_, p_21017_); p_21017_ *= 0.75F; } + // CraftBukkit start + if (this instanceof net.minecraft.world.entity.animal.Animal) { -+ ((net.minecraft.world.entity.animal.Animal) this).m_27594_(); ++ ((net.minecraft.world.entity.animal.Animal) this).resetLove(); + if (this instanceof TamableAnimal) { -+ ((TamableAnimal) this).m_21839_(false); ++ ((TamableAnimal) this).setOrderedToSit(false); + } + } + // CraftBukkit end + - this.f_20918_ = 0.0F; - Entity entity1 = p_21016_.m_7639_(); + this.hurtDir = 0.0F; + Entity entity1 = p_21016_.getEntity(); if (entity1 != null) { @@ -1048,11 +_,11 @@ if (entity1 instanceof Player) { - this.f_20889_ = 100; - this.f_20888_ = (Player)entity1; + this.lastHurtByPlayerTime = 100; + this.lastHurtByPlayer = (Player)entity1; - } else if (entity1 instanceof Wolf) { - Wolf wolf = (Wolf)entity1; -- if (wolf.m_21824_()) { +- if (wolf.isTame()) { + } else if (entity1 instanceof net.minecraft.world.entity.TamableAnimal) { + net.minecraft.world.entity.TamableAnimal tamableEntity = (net.minecraft.world.entity.TamableAnimal)entity1; -+ if (tamableEntity.m_21824_()) { - this.f_20889_ = 100; -- LivingEntity livingentity = wolf.m_142480_(); -+ LivingEntity livingentity = tamableEntity.m_142480_(); - if (livingentity != null && livingentity.m_6095_() == EntityType.f_20532_) { - this.f_20888_ = (Player)livingentity; ++ if (tamableEntity.isTame()) { + this.lastHurtByPlayerTime = 100; +- LivingEntity livingentity = wolf.getOwner(); ++ LivingEntity livingentity = tamableEntity.getOwner(); + if (livingentity != null && livingentity.getType() == EntityType.PLAYER) { + this.lastHurtByPlayer = (Player)livingentity; } else { @@ -1125,7 +_,7 @@ if (this instanceof ServerPlayer) { - CriteriaTriggers.f_10574_.m_35174_((ServerPlayer)this, p_21016_, f, p_21017_, flag); + CriteriaTriggers.ENTITY_HURT_PLAYER.trigger((ServerPlayer)this, p_21016_, f, p_21017_, flag); if (f1 > 0.0F && f1 < 3.4028235E37F) { -- ((ServerPlayer)this).m_36222_(Stats.f_12932_, Math.round(f1 * 10.0F)); -+ ((ServerPlayer)this).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12932_), Math.round(f1 * 10.0F)); +- ((ServerPlayer)this).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)); } } @@ -563,12 +563,12 @@ ItemStack itemstack = null; + // CraftBukkit start -+ ItemStack itemstack1 = ItemStack.f_41583_; ++ ItemStack itemstack1 = ItemStack.EMPTY; for(InteractionHand interactionhand : InteractionHand.values()) { -- ItemStack itemstack1 = this.m_21120_(interactionhand); -+ itemstack1 = this.m_21120_(interactionhand); - if (itemstack1.m_150930_(Items.f_42747_)) { - itemstack = itemstack1.m_41777_(); +- ItemStack itemstack1 = this.getItemInHand(interactionhand); ++ itemstack1 = this.getItemInHand(interactionhand); + if (itemstack1.is(Items.TOTEM_OF_UNDYING)) { + itemstack = itemstack1.copy(); + // itemstack1.shrink(1); // CraftBukkit + break; + } @@ -576,11 +576,11 @@ + + org.bukkit.event.entity.EntityResurrectEvent event = new org.bukkit.event.entity.EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity()); + event.setCancelled(itemstack == null); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ if (!itemstack1.m_41619_()) { - itemstack1.m_41774_(1); ++ if (!itemstack1.isEmpty()) { + itemstack1.shrink(1); - break; } - } @@ -590,23 +590,23 @@ + if (itemstack != null && this instanceof ServerPlayer) { + // CraftBukkit end ServerPlayer serverplayer = (ServerPlayer)this; -- serverplayer.m_36246_(Stats.f_12982_.m_12902_(Items.f_42747_)); -+ serverplayer.m_6278_(Stats.f_12982_.m_12902_(Items.f_42747_), 1); - CriteriaTriggers.f_10551_.m_74431_(serverplayer, itemstack); +- serverplayer.awardStat(Stats.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); ++ serverplayer.awardStat(Stats.ITEM_USED.get(Items.TOTEM_OF_UNDYING), 1); + CriteriaTriggers.USED_TOTEM.trigger(serverplayer, itemstack); } - this.m_21153_(1.0F); -- this.m_21219_(); -- this.m_7292_(new MobEffectInstance(MobEffects.f_19605_, 900, 1)); -- this.m_7292_(new MobEffectInstance(MobEffects.f_19617_, 100, 1)); -- this.m_7292_(new MobEffectInstance(MobEffects.f_19607_, 800, 0)); + this.setHealth(1.0F); +- this.removeAllEffects(); +- this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 900, 1)); +- this.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1)); +- this.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 0)); + // CraftBukkit start + this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19605_, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19617_, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19607_, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); ++ this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); ++ this.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); ++ this.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + // CraftBukkit end - this.f_19853_.m_7605_(this, (byte)35); + this.level.broadcastEntityEvent(this, (byte)35); } - return itemstack != null; @@ -617,40 +617,40 @@ @@ -1233,6 +_,7 @@ } - public void m_6667_(DamageSource p_21014_) { + public void die(DamageSource p_21014_) { + if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_21014_)) return; - if (!this.m_146910_() && !this.f_20890_) { - Entity entity = p_21014_.m_7639_(); - LivingEntity livingentity = this.m_21232_(); + if (!this.isRemoved() && !this.dead) { + Entity entity = p_21014_.getEntity(); + LivingEntity livingentity = this.getKillCredit(); @@ -1245,7 +_,7 @@ } - if (!this.f_19853_.f_46443_ && this.m_8077_()) { -- f_201943_.info("Named entity {} died: {}", this, this.m_21231_().m_19293_().getString()); -+ if (org.spigotmc.SpigotConfig.logNamedDeaths) f_201943_.info("Named entity {} died: {}", this, this.m_21231_().m_19293_().getString()); // Spigot + if (!this.level.isClientSide && this.hasCustomName()) { +- LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); ++ if (org.spigotmc.SpigotConfig.logNamedDeaths) LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot } - this.f_20890_ = true; + this.dead = true; @@ -1268,17 +_,27 @@ - if (!this.f_19853_.f_46443_) { + if (!this.level.isClientSide) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { -- if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, p_21269_)) { - BlockPos blockpos = this.m_142538_(); - BlockState blockstate = Blocks.f_50070_.m_49966_(); -- if (this.f_19853_.m_8055_(blockpos).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos)) { -- this.f_19853_.m_7731_(blockpos, blockstate, 3); +- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, p_21269_)) { + BlockPos blockpos = this.blockPosition(); + BlockState blockstate = Blocks.WITHER_ROSE.defaultBlockState(); +- if (this.level.getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level, blockpos)) { +- this.level.setBlock(blockpos, blockstate, 3); - flag = true; -+ if (this.f_19853_.m_46859_(blockpos) && blockstate.m_60710_(this.f_19853_, blockpos)) { ++ if (this.level.isEmptyBlock(blockpos) && blockstate.canSurvive(this.level, blockpos)) { + // CraftBukkit start - call EntityBlockFormEvent for Wither Rose -+ flag = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(this.f_19853_, blockpos, blockstate, 3, this); ++ flag = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(this.level, blockpos, blockstate, 3, this); + // CraftBukkit end } } if (!flag) { - ItemEntity itementity = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_(), this.m_20189_(), new ItemStack(Items.f_41951_)); + ItemEntity itementity = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), new ItemStack(Items.WITHER_ROSE)); + + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itementity.getBukkitEntity()); @@ -660,7 +660,7 @@ + } + // CraftBukkit end + - this.f_19853_.m_7967_(itementity); + this.level.addFreshEntity(itementity); } } @@ -1286,32 +_,89 @@ @@ -682,15 +682,15 @@ + + protected void setForgeCaptures(ServerPlayer player, ListTag tag) { + if (forgeCaptures == null) forgeCaptures = new net.minecraft.world.entity.player.Inventory(player); -+ else forgeCaptures.m_6211_(); -+ forgeCaptures.m_36035_(tag); ++ else forgeCaptures.clearContent(); ++ forgeCaptures.load(tag); + } + - protected void m_6668_(DamageSource p_21192_) { - Entity entity = p_21192_.m_7639_(); + protected void dropAllDeathLoot(DamageSource p_21192_) { + Entity entity = p_21192_.getEntity(); - int i; - if (entity instanceof Player) { -- i = EnchantmentHelper.m_44930_((LivingEntity)entity); +- i = EnchantmentHelper.getMobLooting((LivingEntity)entity); - } else { - i = 0; - } @@ -698,25 +698,25 @@ + int i = net.minecraftforge.common.ForgeHooks.getLootingLevel(this, entity, p_21192_); + this.captureDrops(Lists.newArrayList()); - boolean flag = this.f_20889_ > 0; -+ this.m_5907_(); // CraftBukkit - from below - if (this.m_6125_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46135_)) { - this.m_7625_(p_21192_, flag); - this.m_7472_(p_21192_, i, flag); + boolean flag = this.lastHurtByPlayerTime > 0; ++ this.dropEquipment(); // CraftBukkit - from below + if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + this.dropFromLootTable(p_21192_, flag); + this.dropCustomDeathLoot(p_21192_, i, flag); } + Collection drops = captureDrops(null); + this.expToDrop = this.getExpReward(); -- this.m_5907_(); -- this.m_21226_(); +- this.dropEquipment(); +- this.dropExperience(); + //Magma - ForgeCaptures will store the inventory temporarily, until the after the death event + if (this instanceof ServerPlayer player){ + forgeCaptures = new net.minecraft.world.entity.player.Inventory(player); -+ forgeCaptures.m_36006_(player.m_150109_()); -+ player.m_150109_().m_6211_(); ++ forgeCaptures.replaceWith(player.getInventory()); ++ player.getInventory().clearContent(); + } -+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_21192_, drops, i, f_20889_ > 0)) { -+ drops.forEach(drop -> this.drops.add(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(drop.m_32055_()))); ++ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_21192_, drops, i, lastHurtByPlayerTime > 0)) { ++ drops.forEach(drop -> this.drops.add(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(drop.getItem()))); + if (!(this instanceof ServerPlayer))//Magma - in this situation the org.bukkit.event.entity.EntityDeathEvent would be called twice, because org.bukkit.event.entity.PlayerDeathEvent also inherits from EntityDeathEvent + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityDeathEvent(this, this.drops); + } @@ -724,28 +724,28 @@ + if(this instanceof ServerPlayer player){ + //Magma - get player inventory + net.minecraft.world.entity.player.Inventory temp = new net.minecraft.world.entity.player.Inventory(player); -+ temp.m_36006_(player.m_150109_()); ++ temp.replaceWith(player.getInventory()); + //Magma - restore player inventory to the state before the capture -+ player.m_150109_().m_6211_(); -+ player.m_150109_().m_36006_(forgeCaptures); ++ player.getInventory().clearContent(); ++ player.getInventory().replaceWith(forgeCaptures); + //Magma - set the captures to the added items during the death event -+ forgeCaptures.m_6211_(); -+ forgeCaptures.m_36006_(temp); ++ forgeCaptures.clearContent(); ++ forgeCaptures.replaceWith(temp); + } } + //Magma end - protected void m_5907_() { + protected void dropEquipment() { } -- protected void m_21226_() { +- protected void dropExperience() { + // CraftBukkit start + public int getExpReward() { - if (this.f_19853_ instanceof ServerLevel && (this.m_6124_() || this.f_20889_ > 0 && this.m_6149_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46135_))) { -- ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), this.m_6552_(this.f_20888_)); + if (this.level instanceof ServerLevel && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { +- ExperienceOrb.award((ServerLevel)this.level, this.position(), this.getExperienceReward(this.lastHurtByPlayer)); - } -+ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.f_20888_, this.m_6552_(this.f_20888_)); -+ int i = this.m_6552_(this.f_20888_); ++ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(this.lastHurtByPlayer)); ++ int i = this.getExperienceReward(this.lastHurtByPlayer); + return i; + } else { + return 0; @@ -753,11 +753,11 @@ + } + + // CraftBukkit end -+ public void m_21226_() { //Magma - protected -> public ++ public void dropExperience() { //Magma - protected -> public + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + if (true) { -+ int i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.f_20888_, this.expToDrop); -+ ExperienceOrb.m_147082_((ServerLevel) this.f_19853_, this.m_20182_(), i); //Magma - revert to award, fixes mixin inject ++ int i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.lastHurtByPlayer, this.expToDrop); ++ ExperienceOrb.award((ServerLevel) this.level, this.position(), i); //Magma - revert to award, fixes mixin inject + this.expToDrop = 0; + } + // CraftBukkit end @@ -765,42 +765,42 @@ } @@ -1326,7 +_,8 @@ - ResourceLocation resourcelocation = this.m_5743_(); - LootTable loottable = this.f_19853_.m_142572_().m_129898_().m_79217_(resourcelocation); - LootContext.Builder lootcontext$builder = this.m_7771_(p_21022_, p_21021_); -- loottable.m_79148_(lootcontext$builder.m_78975_(LootContextParamSets.f_81415_), this::m_19983_); -+ LootContext ctx = lootcontext$builder.m_78975_(LootContextParamSets.f_81415_); -+ loottable.m_79129_(ctx).forEach(this::m_19983_); + ResourceLocation resourcelocation = this.getLootTable(); + LootTable loottable = this.level.getServer().getLootTables().get(resourcelocation); + LootContext.Builder lootcontext$builder = this.createLootContext(p_21022_, p_21021_); +- loottable.getRandomItems(lootcontext$builder.create(LootContextParamSets.ENTITY), this::spawnAtLocation); ++ LootContext ctx = lootcontext$builder.create(LootContextParamSets.ENTITY); ++ loottable.getRandomItems(ctx).forEach(this::spawnAtLocation); } - protected LootContext.Builder m_7771_(boolean p_21105_, DamageSource p_21106_) { + protected LootContext.Builder createLootContext(boolean p_21105_, DamageSource p_21106_) { @@ -1339,6 +_,11 @@ } - public void m_147240_(double p_147241_, double p_147242_, double p_147243_) { + public void knockback(double p_147241_, double p_147242_, double p_147243_) { + net.minecraftforge.event.entity.living.LivingKnockBackEvent event = net.minecraftforge.common.ForgeHooks.onLivingKnockBack(this, (float) p_147241_, p_147242_, p_147243_); + if(event.isCanceled()) return; + p_147241_ = event.getStrength(); + p_147242_ = event.getRatioX(); + p_147243_ = event.getRatioZ(); - p_147241_ *= 1.0D - this.m_21133_(Attributes.f_22278_); + p_147241_ *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0D)) { - this.f_19812_ = true; + this.hasImpulse = true; @@ -1392,15 +_,9 @@ } else { - BlockPos blockpos = this.m_142538_(); - BlockState blockstate = this.m_146900_(); -- if (blockstate.m_204336_(BlockTags.f_13082_)) { -- this.f_20957_ = Optional.of(blockpos); + BlockPos blockpos = this.blockPosition(); + BlockState blockstate = this.getFeetBlockState(); +- if (blockstate.is(BlockTags.CLIMBABLE)) { +- this.lastClimbablePos = Optional.of(blockpos); - return true; -- } else if (blockstate.m_60734_() instanceof TrapDoorBlock && this.m_21176_(blockpos, blockstate)) { -- this.f_20957_ = Optional.of(blockpos); +- } else if (blockstate.getBlock() instanceof TrapDoorBlock && this.trapdoorUsableAsLadder(blockpos, blockstate)) { +- this.lastClimbablePos = Optional.of(blockpos); - return true; - } else { - return false; - } -+ Optional ladderPos = net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, f_19853_, blockpos, this); -+ if (ladderPos.isPresent()) this.f_20957_ = ladderPos; ++ Optional ladderPos = net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, level, blockpos, this); ++ if (ladderPos.isPresent()) this.lastClimbablePos = ladderPos; + return ladderPos.isPresent(); } } @@ -808,78 +808,78 @@ @@ -1420,12 +_,22 @@ } - public boolean m_142535_(float p_147187_, float p_147188_, DamageSource p_147189_) { + public boolean causeFallDamage(float p_147187_, float p_147188_, DamageSource p_147189_) { + float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, p_147187_, p_147188_); + if (ret == null) return false; + p_147187_ = ret[0]; + p_147188_ = ret[1]; + - boolean flag = super.m_142535_(p_147187_, p_147188_, p_147189_); - int i = this.m_5639_(p_147187_, p_147188_); + boolean flag = super.causeFallDamage(p_147187_, p_147188_, p_147189_); + int i = this.calculateFallDamage(p_147187_, p_147188_); if (i > 0) { + // CraftBukkit start -+ if (!this.m_6469_(p_147189_, (float) i)) { ++ if (!this.hurt(p_147189_, (float) i)) { + return true; + } + // CraftBukkit end - this.m_5496_(this.m_5896_(i), 1.0F, 1.0F); - this.m_21229_(); -- this.m_6469_(p_147189_, (float)i); + this.playSound(this.getFallDamageSound(i), 1.0F, 1.0F); + this.playBlockFallSound(); +- this.hurt(p_147189_, (float)i); + // this.hurt(p_147189_, (float)i); // CraftBukkit - moved up return true; } else { return flag; @@ -1443,9 +_,10 @@ - int i = Mth.m_14107_(this.m_20185_()); - int j = Mth.m_14107_(this.m_20186_() - (double)0.2F); - int k = Mth.m_14107_(this.m_20189_()); -- BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); + int i = Mth.floor(this.getX()); + int j = Mth.floor(this.getY() - (double)0.2F); + int k = Mth.floor(this.getZ()); +- BlockState blockstate = this.level.getBlockState(new BlockPos(i, j, k)); + BlockPos pos = new BlockPos(i, j, k); -+ BlockState blockstate = this.f_19853_.m_8055_(pos); - if (!blockstate.m_60795_()) { -- SoundType soundtype = blockstate.m_60827_(); -+ SoundType soundtype = blockstate.getSoundType(f_19853_, pos, this); - this.m_5496_(soundtype.m_56779_(), soundtype.m_56773_() * 0.5F, soundtype.m_56774_() * 0.75F); ++ BlockState blockstate = this.level.getBlockState(pos); + if (!blockstate.isAir()) { +- SoundType soundtype = blockstate.getSoundType(); ++ SoundType soundtype = blockstate.getSoundType(level, pos, this); + this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } @@ -1471,9 +_,17 @@ - protected void m_7909_(float p_21316_) { + protected void hurtCurrentlyUsedShield(float p_21316_) { } + public boolean isDamageAfterArmorabsorbHurt = false; // Magma - protected float m_21161_(DamageSource p_21162_, float p_21163_) { - if (!p_21162_.m_19376_()) { -- this.m_6472_(p_21162_, p_21163_); + protected float getDamageAfterArmorAbsorb(DamageSource p_21162_, float p_21163_) { + if (!p_21162_.isBypassArmor()) { +- this.hurtArmor(p_21162_, p_21163_); + if (net.minecraftforge.fml.ModList.get().isLoaded("the_vault")) //Magma - prevent mixin inject, just don't use the bukkit hurt event if the_vault is loaded + // Magma start - Fix mixin issues + if (isDamageAfterArmorabsorbHurt) { -+ this.m_6472_(p_21162_, p_21163_); ++ this.hurtArmor(p_21162_, p_21163_); + isDamageAfterArmorabsorbHurt = false; + return 0.0F; + } + // Magma end - p_21163_ = CombatRules.m_19272_(p_21163_, (float)this.m_21230_(), (float)this.m_21133_(Attributes.f_22285_)); + p_21163_ = CombatRules.getDamageAfterAbsorb(p_21163_, (float)this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); } @@ -1484,7 +_,8 @@ - if (p_21193_.m_19379_()) { + if (p_21193_.isBypassMagic()) { return p_21194_; } else { -- if (this.m_21023_(MobEffects.f_19606_) && p_21193_ != DamageSource.f_19317_) { +- if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && p_21193_ != DamageSource.OUT_OF_WORLD) { + // CraftBukkit - Moved to damageEntity0(DamageSource, float) -+ if (false && this.m_21023_(MobEffects.f_19606_) && p_21193_ != DamageSource.f_19317_) { - int i = (this.m_21124_(MobEffects.f_19606_).m_19564_() + 1) * 5; ++ if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && p_21193_ != DamageSource.OUT_OF_WORLD) { + int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f = p_21194_ * (float)j; @@ -1493,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { -- ((ServerPlayer)this).m_36222_(Stats.f_12934_, Math.round(f2 * 10.0F)); -+ ((ServerPlayer)this).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12934_), Math.round(f2 * 10.0F)); - } else if (p_21193_.m_7639_() instanceof ServerPlayer) { -- ((ServerPlayer)p_21193_.m_7639_()).m_36222_(Stats.f_12930_, Math.round(f2 * 10.0F)); -+ ((ServerPlayer)p_21193_.m_7639_()).m_6278_(Stats.f_12988_.m_12902_(Stats.f_12930_), Math.round(f2 * 10.0F)); +- ((ServerPlayer)this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f2 * 10.0F)); ++ ((ServerPlayer)this).awardStat(Stats.CUSTOM.get(Stats.DAMAGE_RESISTED), Math.round(f2 * 10.0F)); + } else if (p_21193_.getEntity() instanceof ServerPlayer) { +- ((ServerPlayer)p_21193_.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f2 * 10.0F)); ++ ((ServerPlayer)p_21193_.getEntity()).awardStat(Stats.CUSTOM.get(Stats.DAMAGE_DEALT_RESISTED), Math.round(f2 * 10.0F)); } } } @@ -888,15 +888,15 @@ } + public boolean damageEntity0; - protected void m_6475_(DamageSource p_21240_, float p_21241_) { - if (!this.m_6673_(p_21240_)) { -- p_21241_ = this.m_21161_(p_21240_, p_21241_); -- p_21241_ = this.m_6515_(p_21240_, p_21241_); -- float f2 = Math.max(p_21241_ - this.m_6103_(), 0.0F); -- this.m_7911_(this.m_6103_() - (p_21241_ - f2)); + protected void actuallyHurt(DamageSource p_21240_, float p_21241_) { + if (!this.isInvulnerableTo(p_21240_)) { +- p_21241_ = this.getDamageAfterArmorAbsorb(p_21240_, p_21241_); +- p_21241_ = this.getDamageAfterMagicAbsorb(p_21240_, p_21241_); +- float f2 = Math.max(p_21241_ - this.getAbsorptionAmount(), 0.0F); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - (p_21241_ - f2)); - float f = p_21241_ - f2; -- if (f > 0.0F && f < 3.4028235E37F && p_21240_.m_7639_() instanceof ServerPlayer) { -- ((ServerPlayer)p_21240_.m_7639_()).m_36222_(Stats.f_12929_, Math.round(f * 10.0F)); +- if (f > 0.0F && f < 3.4028235E37F && p_21240_.getEntity() instanceof ServerPlayer) { +- ((ServerPlayer)p_21240_.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); - } - - if (f2 != 0.0F) { @@ -918,7 +918,7 @@ + // Cauldron end + + com.google.common.base.Function hardHat = f -> { -+ if (p_21240_.m_146705_() && !LivingEntity.this.m_6844_(EquipmentSlot.HEAD).m_41619_()) { ++ if (p_21240_.isDamageHelmet() && !LivingEntity.this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { + return -(f - (f * 0.75F)); + } + return -0.0; @@ -926,17 +926,17 @@ + float hardHatModifier = hardHat.apply((double) p_21241_).floatValue(); + p_21241_ += hardHatModifier; + -+ com.google.common.base.Function blocking = f -> -((LivingEntity.this.m_21275_(p_21240_)) ? f : 0.0); ++ com.google.common.base.Function blocking = f -> -((LivingEntity.this.isDamageSourceBlocked(p_21240_)) ? f : 0.0); + float blockingModifier = blocking.apply((double) p_21241_).floatValue(); + p_21241_ += blockingModifier; + -+ com.google.common.base.Function armor = f -> -(f - LivingEntity.this.m_21161_(p_21240_, f.floatValue())); ++ com.google.common.base.Function armor = f -> -(f - LivingEntity.this.getDamageAfterArmorAbsorb(p_21240_, f.floatValue())); + float armorModifier = armor.apply((double) p_21241_).floatValue(); + p_21241_ += armorModifier; + + com.google.common.base.Function resistance = f -> { -+ if (!p_21240_.m_19379_() && LivingEntity.this.m_21023_(MobEffects.f_19606_) && p_21240_ != DamageSource.f_19317_) { -+ int i = (LivingEntity.this.m_21124_(MobEffects.f_19606_).m_19564_() + 1) * 5; ++ if (!p_21240_.isBypassMagic() && LivingEntity.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && p_21240_ != DamageSource.OUT_OF_WORLD) { ++ int i = (LivingEntity.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; + int j = 25 - i; + float f1 = f.floatValue() * (float) j; + return -(f - (f1 / 25.0F)); @@ -946,16 +946,16 @@ + float resistanceModifier = resistance.apply((double) p_21241_).floatValue(); + p_21241_ += resistanceModifier; + -+ com.google.common.base.Function magic = f -> -(f - LivingEntity.this.m_6515_(p_21240_, f.floatValue())); ++ com.google.common.base.Function magic = f -> -(f - LivingEntity.this.getDamageAfterMagicAbsorb(p_21240_, f.floatValue())); + float magicModifier = magic.apply((double) p_21241_).floatValue(); + p_21241_ += magicModifier; + -+ com.google.common.base.Function absorption = f -> -(Math.max(f - Math.max(f - LivingEntity.this.m_6103_(), 0.0F), 0.0F)); ++ com.google.common.base.Function absorption = f -> -(Math.max(f - Math.max(f - LivingEntity.this.getAbsorptionAmount(), 0.0F), 0.0F)); + float absorptionModifier = absorption.apply((double) p_21241_).floatValue(); + + org.bukkit.event.entity.EntityDamageEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleLivingEntityDamageEvent(this, p_21240_, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); -+ if (p_21240_.m_7639_() instanceof Player) { -+ ((Player) p_21240_.m_7639_()).m_36334_(); // Moved from Player in order to make the cooldown reset get called after the damage event is fired ++ if (p_21240_.getEntity() instanceof Player) { ++ ((Player) p_21240_.getEntity()).resetAttackStrengthTicker(); // Moved from Player in order to make the cooldown reset get called after the damage event is fired + } + if (event.isCancelled()) { + cancelDamage = true; @@ -975,44 +975,44 @@ + float f3 = (float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.RESISTANCE); + if (f3 > 0.0F && f3 < 3.4028235E37F) { + if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).m_36222_(Stats.f_12934_, Math.round(f3 * 10.0F)); -+ } else if (p_21240_.m_7639_() instanceof ServerPlayer) { -+ ((ServerPlayer) p_21240_.m_7639_()).m_36222_(Stats.f_12930_, Math.round(f3 * 10.0F)); ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); ++ } else if (p_21240_.getEntity() instanceof ServerPlayer) { ++ ((ServerPlayer) p_21240_.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F)); + } + } + } + + // Apply damage to helmet -+ if (p_21240_.m_146705_() && !this.m_6844_(EquipmentSlot.HEAD).m_41619_()) { -+ this.m_142642_(p_21240_, p_21241_); ++ if (p_21240_.isDamageHelmet() && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { ++ this.hurtHelmet(p_21240_, p_21241_); + } + + // Apply damage to armor -+ if (!p_21240_.m_19376_() && !net.minecraftforge.fml.ModList.get().isLoaded("the_vault")) { //Magma - skip armor damage if the_vault is loaded ++ if (!p_21240_.isBypassArmor() && !net.minecraftforge.fml.ModList.get().isLoaded("the_vault")) { //Magma - skip armor damage if the_vault is loaded + float armorDamage = (float) (event.getDamage() + event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING) + event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.HARD_HAT)); + this.isDamageAfterArmorabsorbHurt = true; // Magma -+ this.m_21161_(p_21240_, armorDamage); // Magma ++ this.getDamageAfterArmorAbsorb(p_21240_, armorDamage); // Magma + } + + // Apply blocking code // PAIL: steal from above + if (event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING) < 0) { -+ this.f_19853_.m_7605_(this, (byte) 29); // SPIGOT-4635 - shield damage sound -+ this.m_7909_((float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING)); -+ Entity entity = p_21240_.m_7640_(); ++ this.level.broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound ++ this.hurtCurrentlyUsedShield((float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING)); ++ Entity entity = p_21240_.getDirectEntity(); + if (entity instanceof LivingEntity) { -+ this.m_6728_((LivingEntity) entity); ++ this.blockUsingShield((LivingEntity) entity); + } + } + + absorptionModifier = (float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.ABSORPTION); -+ this.m_7911_(Math.max(this.m_6103_() - absorptionModifier, 0.0F)); ++ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; + + if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof Player) { -+ ((Player) this).m_36222_(Stats.f_12933_, Math.round(f2 * 10.0F)); ++ ((Player) this).awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); + } -+ if (f2 > 0.0F && f2 < 3.4028235E37F && p_21240_.m_7639_() instanceof ServerPlayer) { -+ ((ServerPlayer) p_21240_.m_7639_()).m_36222_(Stats.f_12929_, Math.round(f2 * 10.0F)); ++ if (f2 > 0.0F && f2 < 3.4028235E37F && p_21240_.getEntity() instanceof ServerPlayer) { ++ ((ServerPlayer) p_21240_.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); + } + + p_21241_ = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_21240_, p_21241_); @@ -1021,23 +1021,23 @@ + if (human) { + // PAIL: Be sure to drag all this code from the Player subclass each update. + ((Player) this).setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); -+ ((Player) this).m_36399_(p_21240_.m_19377_()); ++ ((Player) this).causeFoodExhaustion(p_21240_.getFoodExhaustion()); + if (p_21241_ < 3.4028235E37F) { -+ ((Player) this).m_36222_(Stats.f_12931_, Math.round(p_21241_ * 10.0F)); ++ ((Player) this).awardStat(Stats.DAMAGE_TAKEN, Math.round(p_21241_ * 10.0F)); + } + } + // CraftBukkit end - float f1 = this.m_21223_(); -- this.m_21153_(f1 - f2); -- this.m_21231_().m_19289_(p_21240_, f1, f2); -- this.m_7911_(this.m_6103_() - f2); -+ this.m_21231_().m_19289_(p_21240_, f1, p_21241_); -+ this.m_21153_(f1 - p_21241_); // Forge: moved to fix MC-121048 + float f1 = this.getHealth(); +- this.setHealth(f1 - f2); +- this.getCombatTracker().recordDamage(p_21240_, f1, f2); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - f2); ++ this.getCombatTracker().recordDamage(p_21240_, f1, p_21241_); ++ this.setHealth(f1 - p_21241_); // Forge: moved to fix MC-121048 + // CraftBukkit start + if (!human) { -+ this.m_7911_(this.m_6103_() - p_21241_); ++ this.setAbsorptionAmount(this.getAbsorptionAmount() - p_21241_); + } - this.m_146852_(GameEvent.f_157808_, p_21240_.m_7639_()); + this.gameEvent(GameEvent.ENTITY_DAMAGED, p_21240_.getEntity()); + + damageEntity0 = true; + return; @@ -1045,14 +1045,14 @@ + // Duplicate triggers if blocking + if (event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING) < 0) { + if (this instanceof ServerPlayer) { -+ CriteriaTriggers.f_10574_.m_35174_((ServerPlayer) this, p_21240_, p_21241_, originalDamage, true); ++ CriteriaTriggers.ENTITY_HURT_PLAYER.trigger((ServerPlayer) this, p_21240_, p_21241_, originalDamage, true); + f2 = (float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING); + if (f2 > 0.0F && f2 < 3.4028235E37F) { -+ ((ServerPlayer) this).m_36222_(Stats.f_12932_, Math.round(originalDamage * 10.0F)); ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F)); + } + } -+ if (p_21240_.m_7639_() instanceof ServerPlayer) { -+ CriteriaTriggers.f_10573_.m_60112_((ServerPlayer) p_21240_.m_7639_(), this, p_21240_, p_21241_, originalDamage, true); ++ if (p_21240_.getEntity() instanceof ServerPlayer) { ++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer) p_21240_.getEntity(), this, p_21240_, p_21241_, originalDamage, true); + } + damageEntity0 = false; + return; @@ -1066,316 +1066,316 @@ + damageEntity0 = false; } - public CombatTracker m_21231_() { + public CombatTracker getCombatTracker() { @@ -1558,8 +_,19 @@ } - public final void m_21317_(int p_21318_) { -- this.f_19804_.m_135381_(f_20940_, p_21318_); + public final void setArrowCount(int p_21318_) { +- this.entityData.set(DATA_ARROW_COUNT_ID, p_21318_); - } + // CraftBukkit start + setArrowCount( p_21318_, false ); + } + + public final void setArrowCount(int p_21318_, boolean flag){ -+ org.bukkit.event.entity.ArrowBodyCountChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callArrowBodyCountChangeEvent( this, m_21234_(), p_21318_, flag ); ++ org.bukkit.event.entity.ArrowBodyCountChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callArrowBodyCountChangeEvent( this, getArrowCount(), p_21318_, flag ); + if(event.isCancelled()){ + return; + } + -+ this.f_19804_.m_135381_(f_20940_, event.getNewAmount()); ++ this.entityData.set(DATA_ARROW_COUNT_ID, event.getNewAmount()); + } + // CraftBukkit end - public final int m_21235_() { - return this.f_19804_.m_135370_(f_20941_); + public final int getStingerCount() { + return this.entityData.get(DATA_STINGER_COUNT_ID); @@ -1582,6 +_,8 @@ } - public void m_21011_(InteractionHand p_21012_, boolean p_21013_) { -+ ItemStack stack = this.m_21120_(p_21012_); -+ if (!stack.m_41619_() && stack.onEntitySwing(this)) return; - if (!this.f_20911_ || this.f_20913_ >= this.m_21304_() / 2 || this.f_20913_ < 0) { - this.f_20913_ = -1; - this.f_20911_ = true; + public void swing(InteractionHand p_21012_, boolean p_21013_) { ++ ItemStack stack = this.getItemInHand(p_21012_); ++ if (!stack.isEmpty() && stack.onEntitySwing(this)) return; + if (!this.swinging || this.swingTime >= this.getCurrentSwingDuration() / 2 || this.swingTime < 0) { + this.swingTime = -1; + this.swinging = true; @@ -1847,6 +_,12 @@ - public abstract ItemStack m_6844_(EquipmentSlot p_21127_); + public abstract ItemStack getItemBySlot(EquipmentSlot p_21127_); + // CraftBukkit start + public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemstack, boolean silent) { -+ this.m_8061_(equipmentSlot, itemstack); ++ this.setItemSlot(equipmentSlot, itemstack); + } + // CraftBukkit end + - public abstract void m_8061_(EquipmentSlot p_21036_, ItemStack p_21037_); + public abstract void setItemSlot(EquipmentSlot p_21036_, ItemStack p_21037_); - protected void m_181122_(ItemStack p_181123_) { + protected void verifyEquippedItem(ItemStack p_181123_) { @@ -1941,14 +_,15 @@ } - this.f_19812_ = true; + this.hasImpulse = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } - protected void m_21208_() { -- this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)-0.04F, 0.0D)); -+ this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)-0.04F * this.m_21051_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22135_(), 0.0D)); + protected void goDownInWater() { +- this.setDeltaMovement(this.getDeltaMovement().add(0.0D, (double)-0.04F, 0.0D)); ++ this.setDeltaMovement(this.getDeltaMovement().add(0.0D, (double)-0.04F * this.getAttribute(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).getValue(), 0.0D)); } - protected void m_203347_(TagKey p_204043_) { -- this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)0.04F, 0.0D)); -+ this.m_20256_(this.m_20184_().m_82520_(0.0D, (double)0.04F * this.m_21051_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22135_(), 0.0D)); + protected void jumpInLiquid(TagKey p_204043_) { +- this.setDeltaMovement(this.getDeltaMovement().add(0.0D, (double)0.04F, 0.0D)); ++ this.setDeltaMovement(this.getDeltaMovement().add(0.0D, (double)0.04F * this.getAttribute(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).getValue(), 0.0D)); } - protected float m_6108_() { + protected float getWaterSlowDown() { @@ -1962,11 +_,15 @@ - public void m_7023_(Vec3 p_21280_) { - if (this.m_6142_() || this.m_6109_()) { + public void travel(Vec3 p_21280_) { + if (this.isEffectiveAi() || this.isControlledByLocalInstance()) { double d0 = 0.08D; -+ AttributeInstance gravity = this.m_21051_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); - boolean flag = this.m_20184_().f_82480_ <= 0.0D; - if (flag && this.m_21023_(MobEffects.f_19591_)) { ++ AttributeInstance gravity = this.getAttribute(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()); + boolean flag = this.getDeltaMovement().y <= 0.0D; + if (flag && this.hasEffect(MobEffects.SLOW_FALLING)) { - d0 = 0.01D; -+ if (!gravity.m_22109_(SLOW_FALLING)) gravity.m_22118_(SLOW_FALLING); - this.m_183634_(); -+ } else if (gravity.m_22109_(SLOW_FALLING)) { -+ gravity.m_22130_(SLOW_FALLING); ++ if (!gravity.hasModifier(SLOW_FALLING)) gravity.addTransientModifier(SLOW_FALLING); + this.resetFallDistance(); ++ } else if (gravity.hasModifier(SLOW_FALLING)) { ++ gravity.removeModifier(SLOW_FALLING); } -+ d0 = gravity.m_22135_(); ++ d0 = gravity.getValue(); - FluidState fluidstate = this.f_19853_.m_6425_(this.m_142538_()); - if (this.m_20069_() && this.m_6129_() && !this.m_203441_(fluidstate)) { + FluidState fluidstate = this.level.getFluidState(this.blockPosition()); + if (this.isInWater() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { @@ -1991,6 +_,7 @@ f4 = 0.96F; } -+ f5 *= (float)this.m_21051_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22135_(); - this.m_19920_(f5, p_21280_); - this.m_6478_(MoverType.SELF, this.m_20184_()); - Vec3 vec36 = this.m_20184_(); ++ f5 *= (float)this.getAttribute(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).getValue(); + this.moveRelative(f5, p_21280_); + this.move(MoverType.SELF, this.getDeltaMovement()); + Vec3 vec36 = this.getDeltaMovement(); @@ -2065,11 +_,12 @@ } - if (this.f_19861_ && !this.f_19853_.f_46443_) { -+ if (m_20291_(7) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit - this.m_20115_(7, false); + if (this.onGround && !this.level.isClientSide) { ++ if (getSharedFlag(7) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit + this.setSharedFlag(7, false); } } else { - BlockPos blockpos = this.m_20099_(); -- float f2 = this.f_19853_.m_8055_(blockpos).m_60734_().m_49958_(); -+ float f2 = this.f_19853_.m_8055_(this.m_20099_()).getFriction(f_19853_, this.m_20099_(), this); - float f3 = this.f_19861_ ? f2 * 0.91F : 0.91F; - Vec3 vec35 = this.m_21074_(p_21280_, f2); - double d2 = vec35.f_82480_; + BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); +- float f2 = this.level.getBlockState(blockpos).getBlock().getFriction(); ++ float f2 = this.level.getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getFriction(level, this.getBlockPosBelowThatAffectsMyMovement(), this); + float f3 = this.onGround ? f2 * 0.91F : 0.91F; + Vec3 vec35 = this.handleRelativeFrictionAndCalculateMovement(p_21280_, f2); + double d2 = vec35.y; @@ -2145,7 +_,7 @@ - double d0 = Mth.m_14008_(p_21298_.f_82479_, (double)-0.15F, (double)0.15F); - double d1 = Mth.m_14008_(p_21298_.f_82481_, (double)-0.15F, (double)0.15F); - double d2 = Math.max(p_21298_.f_82480_, (double)-0.15F); -- if (d2 < 0.0D && !this.m_146900_().m_60713_(Blocks.f_50616_) && this.m_5791_() && this instanceof Player) { -+ if (d2 < 0.0D && !this.m_146900_().isScaffolding(this) && this.m_5791_() && this instanceof Player) { + double d0 = Mth.clamp(p_21298_.x, (double)-0.15F, (double)0.15F); + double d1 = Mth.clamp(p_21298_.z, (double)-0.15F, (double)0.15F); + double d2 = Math.max(p_21298_.y, (double)-0.15F); +- if (d2 < 0.0D && !this.getFeetBlockState().is(Blocks.SCAFFOLDING) && this.isSuppressingSlidingDownLadder() && this instanceof Player) { ++ if (d2 < 0.0D && !this.getFeetBlockState().isScaffolding(this) && this.isSuppressingSlidingDownLadder() && this instanceof Player) { d2 = 0.0D; } @@ -2173,6 +_,7 @@ } - public void m_8119_() { + public void tick() { + if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return; - super.m_8119_(); - this.m_21329_(); - this.m_21333_(); + super.tick(); + this.updatingUsingItem(); + this.updateSwimAmount(); @@ -2321,6 +_,7 @@ - ItemStack itemstack1 = this.m_6844_(equipmentslot); - if (!ItemStack.m_41728_(itemstack1, itemstack)) { + ItemStack itemstack1 = this.getItemBySlot(equipmentslot); + if (!ItemStack.matches(itemstack1, itemstack)) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent(this, equipmentslot, itemstack, itemstack1)); if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } @@ -2501,7 +_,9 @@ - this.f_20902_ *= 0.98F; - this.m_21323_(); - AABB aabb = this.m_142469_(); + this.zza *= 0.98F; + this.updateFallFlying(); + AABB aabb = this.getBoundingBox(); + // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper - this.m_7023_(new Vec3((double)this.f_20900_, (double)this.f_20901_, (double)this.f_20902_)); + this.travel(new Vec3((double)this.xxa, (double)this.yya, (double)this.zza)); + // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper - this.f_19853_.m_46473_().m_7238_(); - this.f_19853_.m_46473_().m_6180_("freezing"); - boolean flag = this.m_6095_().m_204039_(EntityTypeTags.f_144295_); + this.level.getProfiler().pop(); + this.level.getProfiler().push("freezing"); + boolean flag = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); @@ -2544,6 +_,8 @@ - boolean flag = this.m_20291_(7); - if (flag && !this.f_19861_ && !this.m_20159_() && !this.m_21023_(MobEffects.f_19620_)) { - ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); -+ flag = itemstack.canElytraFly(this) && itemstack.elytraFlightTick(this, this.f_20937_); + 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.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { + if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { flag = true; - int i = this.f_20937_ + 1; + int i = this.fallFlyTicks + 1; @@ -2565,6 +_,7 @@ } - if (!this.f_19853_.f_46443_) { -+ if (flag != this.m_20291_(7) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit - this.m_20115_(7, flag); + if (!this.level.isClientSide) { ++ if (flag != this.getSharedFlag(7) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit + this.setSharedFlag(7, flag); } @@ -2714,12 +_,19 @@ } - public boolean m_6087_() { -- return !this.m_146910_(); -+ return !this.m_146910_() && this.collides; // CraftBukkit + public boolean isPickable() { +- return !this.isRemoved(); ++ return !this.isRemoved() && this.collides; // CraftBukkit } - public boolean m_6094_() { -- return this.m_6084_() && !this.m_5833_() && !this.m_6147_(); + public boolean isPushable() { +- return this.isAlive() && !this.isSpectator() && !this.onClimbable(); - } -+ return this.m_6084_() && !this.m_5833_() && !this.m_6147_() && this.collides; // CraftBukkit ++ return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit + } + + // CraftBukkit start - collidable API + @Override + public boolean canCollideWithBukkit(Entity entity) { -+ return m_6094_() && this.collides != this.collidableExemptions.contains(entity.m_142081_()); ++ return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); + } + // CraftBukkit end - public float m_6080_() { - return this.f_20885_; + public float getYHeadRot() { + return this.yHeadRot; @@ -2775,8 +_,16 @@ - private void m_21329_() { - if (this.m_6117_()) { -- if (ItemStack.m_41758_(this.m_21120_(this.m_7655_()), this.f_20935_)) { -- this.f_20935_ = this.m_21120_(this.m_7655_()); -+ ItemStack itemStack = this.m_21120_(this.m_7655_()); -+ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.f_20935_, itemStack)) this.f_20935_ = itemStack; -+ if (itemStack == this.f_20935_) { -+ -+ if (!this.f_20935_.m_41619_()) { -+ f_20936_ = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, f_20935_, f_20936_); -+ if (f_20936_ > 0) -+ f_20935_.onUsingTick(this, f_20936_); + private void updatingUsingItem() { + if (this.isUsingItem()) { +- if (ItemStack.isSameIgnoreDurability(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { +- this.useItem = this.getItemInHand(this.getUsedItemHand()); ++ ItemStack itemStack = this.getItemInHand(this.getUsedItemHand()); ++ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.useItem, itemStack)) this.useItem = itemStack; ++ if (itemStack == this.useItem) { ++ ++ if (!this.useItem.isEmpty()) { ++ useItemRemaining = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, useItem, useItemRemaining); ++ if (useItemRemaining > 0) ++ useItem.onUsingTick(this, useItemRemaining); + } + - this.m_142106_(this.f_20935_); + this.updateUsingItem(this.useItem); } else { - this.m_5810_(); + this.stopUsingItem(); @@ -2799,7 +_,7 @@ - private boolean m_21332_() { - int i = this.m_21212_(); -- FoodProperties foodproperties = this.f_20935_.m_41720_().m_41473_(); -+ FoodProperties foodproperties = this.f_20935_.getFoodProperties(this); - boolean flag = foodproperties != null && foodproperties.m_38748_(); - flag |= i <= this.f_20935_.m_41779_() - 7; + private boolean shouldTriggerItemUseEffects() { + int i = this.getUseItemRemainingTicks(); +- FoodProperties foodproperties = this.useItem.getItem().getFoodProperties(); ++ FoodProperties foodproperties = this.useItem.getFoodProperties(this); + boolean flag = foodproperties != null && foodproperties.isFastFood(); + flag |= i <= this.useItem.getUseDuration() - 7; return flag && i % 4 == 0; @@ -2829,8 +_,10 @@ - public void m_6672_(InteractionHand p_21159_) { - ItemStack itemstack = this.m_21120_(p_21159_); - if (!itemstack.m_41619_() && !this.m_6117_()) { -+ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.m_41779_()); + public void startUsingItem(InteractionHand p_21159_) { + ItemStack itemstack = this.getItemInHand(p_21159_); + if (!itemstack.isEmpty() && !this.isUsingItem()) { ++ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.getUseDuration()); + if (duration <= 0) return; - this.f_20935_ = itemstack; -- this.f_20936_ = itemstack.m_41779_(); -+ this.f_20936_ = duration; - if (!this.f_19853_.f_46443_) { - this.m_21155_(1, true); - this.m_21155_(2, p_21159_ == InteractionHand.OFF_HAND); + this.useItem = itemstack; +- this.useItemRemaining = itemstack.getUseDuration(); ++ this.useItemRemaining = duration; + if (!this.level.isClientSide) { + this.setLivingEntityFlag(1, true); + this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); @@ -2890,6 +_,9 @@ - vec31 = vec31.m_82496_(-this.m_146909_() * ((float)Math.PI / 180F)); - vec31 = vec31.m_82524_(-this.m_146908_() * ((float)Math.PI / 180F)); - vec31 = vec31.m_82520_(this.m_20185_(), this.m_20188_(), this.m_20189_()); -+ if (this.f_19853_ instanceof ServerLevel) //Forge: Fix MC-2518 spawnParticle is nooped on server, need to use server specific variant -+ ((ServerLevel)this.f_19853_).m_8767_(new ItemParticleOption(ParticleTypes.f_123752_, p_21061_), vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, 1, vec3.f_82479_, vec3.f_82480_ + 0.05D, vec3.f_82481_, 0.0D); + vec31 = vec31.xRot(-this.getXRot() * ((float)Math.PI / 180F)); + vec31 = vec31.yRot(-this.getYRot() * ((float)Math.PI / 180F)); + vec31 = vec31.add(this.getX(), this.getEyeY(), this.getZ()); ++ if (this.level instanceof ServerLevel) //Forge: Fix MC-2518 spawnParticle is nooped on server, need to use server specific variant ++ ((ServerLevel)this.level).sendParticles(new ItemParticleOption(ParticleTypes.ITEM, p_21061_), vec31.x, vec31.y, vec31.z, 1, vec3.x, vec3.y + 0.05D, vec3.z, 0.0D); + else - this.f_19853_.m_7106_(new ItemParticleOption(ParticleTypes.f_123752_, p_21061_), vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, vec3.f_82479_, vec3.f_82480_ + 0.05D, vec3.f_82481_); + this.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, p_21061_), vec31.x, vec31.y, vec31.z, vec3.x, vec3.y + 0.05D, vec3.z); } @@ -2902,8 +_,28 @@ - this.m_21253_(); + this.releaseUsingItem(); } else { - if (!this.f_20935_.m_41619_() && this.m_6117_()) { -+ ItemStack copy = this.f_20935_.m_41777_(); - this.m_21137_(this.f_20935_, 16); -- ItemStack itemstack = this.f_20935_.m_41671_(this.f_19853_, this); -+ ItemStack stack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, m_21212_(), this.f_20935_.m_41671_(this.f_19853_, this)); + if (!this.useItem.isEmpty() && this.isUsingItem()) { ++ ItemStack copy = this.useItem.copy(); + this.triggerItemUseEffects(this.useItem, 16); +- ItemStack itemstack = this.useItem.finishUsingItem(this.level, this); ++ ItemStack stack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, getUseItemRemainingTicks(), this.useItem.finishUsingItem(this.level, this)); + + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof ServerPlayer) { + org.bukkit.inventory.ItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(copy); + org.bukkit.event.player.PlayerItemConsumeEvent event = new org.bukkit.event.player.PlayerItemConsumeEvent((org.bukkit.entity.Player) this.getBukkitEntity(), craftItem); -+ f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + // Update client + ((ServerPlayer) this).getBukkitEntity().updateInventory(); + ((ServerPlayer) this).getBukkitEntity().updateScaledHealth(); + return; + } -+ itemstack = (craftItem.equals(event.getItem())) ? stack : org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()).m_41671_(f_19853_, this); ++ itemstack = (craftItem.equals(event.getItem())) ? stack : org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(level, this); + } else { -+ itemstack = this.f_20935_.m_41671_(this.f_19853_, this); ++ itemstack = this.useItem.finishUsingItem(this.level, this); + } + // CraftBukkit end + - if (itemstack != this.f_20935_) { - this.m_21008_(interactionhand, itemstack); + if (itemstack != this.useItem) { + this.setItemInHand(interactionhand, itemstack); } @@ -2929,7 +_,11 @@ - public void m_21253_() { - if (!this.f_20935_.m_41619_()) { -+ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, f_20935_, this.m_21212_())) { -+ ItemStack copy = this instanceof Player ? f_20935_.m_41777_() : null; - this.f_20935_.m_41674_(this.f_19853_, this, this.m_21212_()); -+ if (copy != null && f_20935_.m_41619_()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((Player)this, copy, m_7655_()); + public void releaseUsingItem() { + if (!this.useItem.isEmpty()) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, useItem, this.getUseItemRemainingTicks())) { ++ ItemStack copy = this instanceof Player ? useItem.copy() : null; + this.useItem.releaseUsing(this.level, this, this.getUseItemRemainingTicks()); ++ if (copy != null && useItem.isEmpty()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((Player)this, copy, getUsedItemHand()); + } - if (this.f_20935_.m_41781_()) { - this.m_21329_(); + if (this.useItem.useOnRelease()) { + this.updatingUsingItem(); } @@ -2977,6 +_,12 @@ } - public boolean m_20984_(double p_20985_, double p_20986_, double p_20987_, boolean p_20988_) { + public boolean randomTeleport(double p_20985_, double p_20986_, double p_20987_, boolean p_20988_) { + // CraftBukkit start + return this.randomTeleport(p_20985_, p_20986_, p_20987_, p_20988_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN).orElse(false); + } + + public Optional randomTeleport(double p_20985_, double p_20986_, double p_20987_, boolean p_20988_, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end - double d0 = this.m_20185_(); - double d1 = this.m_20186_(); - double d2 = this.m_20189_(); + double d0 = this.getX(); + double d1 = this.getY(); + double d2 = this.getZ(); @@ -2999,16 +_,40 @@ } if (flag1) { -- this.m_6021_(p_20985_, d3, p_20987_); +- this.teleportTo(p_20985_, d3, p_20987_); + // CraftBukkit start - Teleport event + // this.teleportTo(p_20985_, d3, p_20987_); + // first set position, to check if the place to teleport is valid -+ this.m_6034_(p_20985_, d3, p_20987_); - if (level.m_45786_(this) && !level.m_46855_(this.m_142469_())) { ++ this.setPos(p_20985_, d3, p_20987_); + if (level.noCollision(this) && !level.containsAnyLiquid(this.getBoundingBox())) { flag = true; } + + // now revert and call event if the teleport place is valid -+ this.m_6034_(d0, d1, d2); ++ this.setPos(d0, d1, d2); + if (flag1) { + if (!(this instanceof ServerPlayer)) { -+ org.bukkit.event.entity.EntityTeleportEvent teleport = new org.bukkit.event.entity.EntityTeleportEvent(this.getBukkitEntity(), new org.bukkit.Location(this.f_19853_.getWorld(), d0, d1, d2), new org.bukkit.Location(this.f_19853_.getWorld(), p_20985_, d3, p_20987_)); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(teleport); ++ org.bukkit.event.entity.EntityTeleportEvent teleport = new org.bukkit.event.entity.EntityTeleportEvent(this.getBukkitEntity(), new org.bukkit.Location(this.level.getWorld(), d0, d1, d2), new org.bukkit.Location(this.level.getWorld(), p_20985_, d3, p_20987_)); ++ this.level.getCraftServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled()) { + org.bukkit.Location to = teleport.getTo(); -+ this.m_6021_(to.getX(), to.getY(), to.getZ()); ++ this.teleportTo(to.getX(), to.getY(), to.getZ()); + } else { + return Optional.empty(); + } + } else { + // player teleport event is called in the underlining code -+ if (((ServerPlayer) this).f_8906_.teleport(d0, d3, d2, this.m_146908_(), this.m_146909_(), java.util.Collections.emptySet(), false, cause)) { return Optional.empty(); ++ if (((ServerPlayer) this).connection.teleport(d0, d3, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) { return Optional.empty(); + } + } + } @@ -1385,15 +1385,15 @@ } if (!flag) { -- this.m_6021_(d0, d1, d2); +- this.teleportTo(d0, d1, d2); - return false; + // this.teleportTo(d0, d1, d2); // CraftBukkit - already set the location back + return Optional.of(false); // CraftBukkit } else { if (p_20988_) { - level.m_7605_(this, (byte)46); + level.broadcastEntityEvent(this, (byte)46); @@ -3018,7 +_,7 @@ - ((PathfinderMob)this).m_21573_().m_26573_(); + ((PathfinderMob)this).getNavigation().stop(); } - return true; @@ -1404,66 +1404,66 @@ @@ -3076,8 +_,8 @@ } - BlockState blockstate = this.f_19853_.m_8055_(p_21141_); -- if (blockstate.m_60734_() instanceof BedBlock) { -- this.f_19853_.m_7731_(p_21141_, blockstate.m_61124_(BedBlock.f_49441_, Boolean.valueOf(true)), 3); -+ if (blockstate.isBed(f_19853_, p_21141_, this)) { -+ blockstate.setBedOccupied(f_19853_, p_21141_, this, true); + BlockState blockstate = this.level.getBlockState(p_21141_); +- if (blockstate.getBlock() instanceof BedBlock) { +- this.level.setBlock(p_21141_, blockstate.setValue(BedBlock.OCCUPIED, Boolean.valueOf(true)), 3); ++ if (blockstate.isBed(level, p_21141_, this)) { ++ blockstate.setBedOccupied(level, p_21141_, this, true); } - this.m_20124_(Pose.SLEEPING); + this.setPose(Pose.SLEEPING); @@ -3093,15 +_,15 @@ - private boolean m_21334_() { - return this.m_21257_().map((p_147236_) -> { -- return this.f_19853_.m_8055_(p_147236_).m_60734_() instanceof BedBlock; + private boolean checkBedExists() { + return this.getSleepingPos().map((p_147236_) -> { +- return this.level.getBlockState(p_147236_).getBlock() instanceof BedBlock; + return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_147236_); }).orElse(false); } - public void m_5796_() { - this.m_21257_().filter(this.f_19853_::m_46805_).ifPresent((p_147228_) -> { - BlockState blockstate = this.f_19853_.m_8055_(p_147228_); -- if (blockstate.m_60734_() instanceof BedBlock) { -- this.f_19853_.m_7731_(p_147228_, blockstate.m_61124_(BedBlock.f_49441_, Boolean.valueOf(false)), 3); -+ if (blockstate.isBed(f_19853_, p_147228_, this)) { -+ blockstate.setBedOccupied(f_19853_, p_147228_, this, false); - Vec3 vec31 = BedBlock.m_49458_(this.m_6095_(), this.f_19853_, p_147228_, this.m_146908_()).orElseGet(() -> { - BlockPos blockpos = p_147228_.m_7494_(); - return new Vec3((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.1D, (double)blockpos.m_123343_() + 0.5D); + public void stopSleeping() { + this.getSleepingPos().filter(this.level::hasChunkAt).ifPresent((p_147228_) -> { + BlockState blockstate = this.level.getBlockState(p_147228_); +- if (blockstate.getBlock() instanceof BedBlock) { +- this.level.setBlock(p_147228_, blockstate.setValue(BedBlock.OCCUPIED, Boolean.valueOf(false)), 3); ++ if (blockstate.isBed(level, p_147228_, this)) { ++ blockstate.setBedOccupied(level, p_147228_, this, false); + Vec3 vec31 = BedBlock.findStandUpPosition(this.getType(), this.level, p_147228_, this.getYRot()).orElseGet(() -> { + BlockPos blockpos = p_147228_.above(); + return new Vec3((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.1D, (double)blockpos.getZ() + 0.5D); @@ -3123,7 +_,9 @@ @Nullable - public Direction m_21259_() { - BlockPos blockpos = this.m_21257_().orElse((BlockPos)null); -- return blockpos != null ? BedBlock.m_49485_(this.f_19853_, blockpos) : null; + public Direction getBedOrientation() { + BlockPos blockpos = this.getSleepingPos().orElse((BlockPos)null); +- return blockpos != null ? BedBlock.getBedOrientation(this.level, blockpos) : null; + if (blockpos == null) return Direction.UP; -+ BlockState state = this.f_19853_.m_8055_(blockpos); -+ return !state.isBed(f_19853_, blockpos, this) ? Direction.UP : state.getBedDirection(f_19853_, blockpos); ++ BlockState state = this.level.getBlockState(blockpos); ++ return !state.isBed(level, blockpos, this) ? Direction.UP : state.getBedDirection(level, blockpos); } - public boolean m_5830_() { + public boolean isInWall() { @@ -3139,7 +_,7 @@ } - public ItemStack m_6298_(ItemStack p_21272_) { -- return ItemStack.f_41583_; -+ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_21272_, ItemStack.f_41583_); + public ItemStack getProjectile(ItemStack p_21272_) { +- return ItemStack.EMPTY; ++ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_21272_, ItemStack.EMPTY); } - public ItemStack m_5584_(Level p_21067_, ItemStack p_21068_) { + public ItemStack eat(Level p_21067_, ItemStack p_21068_) { @@ -3160,8 +_,9 @@ - private void m_21063_(ItemStack p_21064_, Level p_21065_, LivingEntity p_21066_) { - Item item = p_21064_.m_41720_(); - if (item.m_41472_()) { -- for(Pair pair : item.m_41473_().m_38749_()) { -+ for(Pair pair : p_21064_.getFoodProperties(this).m_38749_()) { - if (!p_21065_.f_46443_ && pair.getFirst() != null && p_21065_.f_46441_.nextFloat() < pair.getSecond()) { + private void addEatEffect(ItemStack p_21064_, Level p_21065_, LivingEntity p_21066_) { + Item item = p_21064_.getItem(); + if (item.isEdible()) { +- for(Pair pair : item.getFoodProperties().getEffects()) { ++ for(Pair pair : p_21064_.getFoodProperties(this).getEffects()) { + if (!p_21065_.isClientSide && pair.getFirst() != null && p_21065_.random.nextFloat() < pair.getSecond()) { + p_21066_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit - p_21066_.m_7292_(new MobEffectInstance(pair.getFirst())); + p_21066_.addEffect(new MobEffectInstance(pair.getFirst())); } } @@ -3196,6 +_,64 @@ - this.m_21166_(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND); + this.broadcastBreakEvent(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND); } + /* ==== FORGE START ==== */ @@ -1472,17 +1472,17 @@ + * @param curativeItem The itemstack we are using to cure potion effects + */ + public boolean curePotionEffects(ItemStack curativeItem) { -+ if (this.f_19853_.f_46443_) ++ if (this.level.isClientSide) + return false; + boolean ret = false; -+ Iterator itr = this.f_20945_.values().iterator(); ++ Iterator itr = this.activeEffects.values().iterator(); + while (itr.hasNext()) { + MobEffectInstance effect = itr.next(); + if (effect.isCurativeItem(curativeItem) && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) { -+ this.m_7285_(effect); ++ this.onEffectRemoved(effect); + itr.remove(); + ret = true; -+ this.f_20948_ = true; ++ this.effectsDirty = true; + } + } + return ret; @@ -1503,10 +1503,10 @@ + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (this.isAlive() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (facing == null) return handlers[2].cast(); -+ else if (facing.m_122434_().m_122478_()) return handlers[0].cast(); -+ else if (facing.m_122434_().m_122479_()) return handlers[1].cast(); ++ else if (facing.getAxis().isVertical()) return handlers[0].cast(); ++ else if (facing.getAxis().isHorizontal()) return handlers[1].cast(); + } + return super.getCapability(capability, facing); + } @@ -1524,34 +1524,34 @@ + handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this); + } + - public AABB m_6921_() { - if (this.m_6844_(EquipmentSlot.HEAD).m_150930_(Items.f_42683_)) { + public AABB getBoundingBoxForCulling() { + if (this.getItemBySlot(EquipmentSlot.HEAD).is(Items.DRAGON_HEAD)) { float f = 0.5F; @@ -3206,6 +_,8 @@ } - public static EquipmentSlot m_147233_(ItemStack p_147234_) { + public static 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 - Item item = p_147234_.m_41720_(); - if (!p_147234_.m_150930_(Items.f_42047_) && (!(item instanceof BlockItem) || !(((BlockItem)item).m_40614_() instanceof AbstractSkullBlock))) { + Item item = p_147234_.getItem(); + if (!p_147234_.is(Items.CARVED_PUMPKIN) && (!(item instanceof BlockItem) || !(((BlockItem)item).getBlock() instanceof AbstractSkullBlock))) { if (item instanceof ArmorItem) { @@ -3213,7 +_,7 @@ - } else if (p_147234_.m_150930_(Items.f_42741_)) { + } else if (p_147234_.is(Items.ELYTRA)) { return EquipmentSlot.CHEST; } else { -- return p_147234_.m_150930_(Items.f_42740_) ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND; +- return p_147234_.is(Items.SHIELD) ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND; + return p_147234_.canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK) ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND; } } else { return EquipmentSlot.HEAD; @@ -3278,6 +_,8 @@ - this.m_20334_((double)((float)p_147206_.m_131560_() / 8000.0F), (double)((float)p_147206_.m_131561_() / 8000.0F), (double)((float)p_147206_.m_131562_() / 8000.0F)); + this.setDeltaMovement((double)((float)p_147206_.getXd() / 8000.0F), (double)((float)p_147206_.getYd() / 8000.0F), (double)((float)p_147206_.getZd() / 8000.0F)); } -- public static record Fallsounds(SoundEvent f_196626_, SoundEvent f_196627_) { +- public static record Fallsounds(SoundEvent small, SoundEvent big) { + + -+ public static record Fallsounds(SoundEvent f_196626_, SoundEvent f_196627_) { ++ public static record Fallsounds(SoundEvent small, SoundEvent big) { } } diff --git a/patches/minecraft/net/minecraft/world/entity/Marker.java.patch b/patches/minecraft/net/minecraft/world/entity/Marker.java.patch index b976bbaf..5da0d92d 100644 --- a/patches/minecraft/net/minecraft/world/entity/Marker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Marker.java.patch @@ -4,10 +4,10 @@ throw new IllegalStateException("Markers should never be sent"); } -- protected void m_20348_(Entity p_147260_) { +- protected void addPassenger(Entity p_147260_) { + protected boolean addPassenger(Entity p_147260_) { - p_147260_.m_8127_(); + p_147260_.stopRiding(); + return false; } - public PushReaction m_7752_() { + public PushReaction getPistonPushReaction() { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index ffd3e028..cded6eb9 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,49 +1,49 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -90,6 +_,7 @@ - private final BodyRotationControl f_21361_; - protected PathNavigation f_21344_; - public GoalSelector f_21345_; + private final BodyRotationControl bodyRotationControl; + protected PathNavigation navigation; + public GoalSelector goalSelector; + @Nullable public net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper - public GoalSelector f_21346_; + public GoalSelector targetSelector; @Nullable - private LivingEntity f_21362_; + private LivingEntity target; @@ -112,6 +_,8 @@ - private BlockPos f_21360_ = BlockPos.f_121853_; - private float f_21341_ = -1.0F; + private BlockPos restrictCenter = BlockPos.ZERO; + private float restrictRadius = -1.0F; + public boolean aware = true; // CraftBukkit + protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); - this.f_21345_ = new GoalSelector(p_21369_.m_46658_()); + this.goalSelector = new GoalSelector(p_21369_.getProfilerSupplier()); @@ -127,8 +_,13 @@ - if (p_21369_ != null && !p_21369_.f_46443_) { - this.m_8099_(); + if (p_21369_ != null && !p_21369_.isClientSide) { + this.registerGoals(); } + } + // CraftBukkit start + public void setPersistenceRequired(boolean persistenceRequired) { -+ this.f_21353_ = persistenceRequired; ++ this.persistenceRequired = persistenceRequired; } + // CraftBukkit end - protected void m_8099_() { + protected void registerGoals() { } @@ -205,7 +_,42 @@ } - public void m_6710_(@Nullable LivingEntity p_21544_) { + public void setTarget(@Nullable LivingEntity p_21544_) { + // CraftBukkit start + setTarget(p_21544_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true); + } + + public boolean setTarget(@Nullable LivingEntity p_21544_, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { -+ if(m_5448_() == p_21544_) return false; ++ if(getTarget() == p_21544_) return false; + if(fireEvent) { -+ if (reason == org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN && m_5448_() != null && p_21544_ == null) { -+ reason = m_5448_().m_6084_() ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET : org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED; ++ if (reason == org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN && getTarget() != null && p_21544_ == null) { ++ reason = getTarget().isAlive() ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET : org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED; + } + if (reason == org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN) { + net.minecraftforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.minecraftforge.common.ForgeHooks.onLivingChangeTarget(this, p_21544_, net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.MOB_TARGET); @@ -57,7 +57,7 @@ + craftLivingEntity = (org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) p_21544_.getBukkitEntity(); + } + org.bukkit.event.entity.EntityTargetLivingEntityEvent event = new org.bukkit.event.entity.EntityTargetLivingEntityEvent(this.getBukkitEntity(), craftLivingEntity, reason); -+ f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } @@ -68,180 +68,180 @@ + } + } + - this.f_21362_ = p_21544_; + this.target = p_21544_; + return true; + // CraftBukkit end } - public boolean m_6549_(EntityType p_21399_) { + public boolean canAttackType(EntityType p_21399_) { @@ -402,15 +_,25 @@ - p_21484_.m_128379_("NoAI", this.m_21525_()); + p_21484_.putBoolean("NoAI", this.isNoAi()); } -+ p_21484_.m_128379_("Bukkit.Aware", this.aware); // CraftBukkit ++ p_21484_.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit } - public void m_7378_(CompoundTag p_21450_) { - super.m_7378_(p_21450_); + public void readAdditionalSaveData(CompoundTag p_21450_) { + super.readAdditionalSaveData(p_21450_); + + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it - if (p_21450_.m_128425_("CanPickUpLoot", 1)) { -- this.m_21553_(p_21450_.m_128471_("CanPickUpLoot")); -+ boolean data = p_21450_.m_128471_("CanPickUpLoot"); + if (p_21450_.contains("CanPickUpLoot", 1)) { +- this.setCanPickUpLoot(p_21450_.getBoolean("CanPickUpLoot")); ++ boolean data = p_21450_.getBoolean("CanPickUpLoot"); + if (isLevelAtLeast(p_21450_, 1) || data) { -+ this.m_21553_(data); ++ this.setCanPickUpLoot(data); + } } -- this.f_21353_ = p_21450_.m_128471_("PersistenceRequired"); -+ boolean data = p_21450_.m_128471_("PersistenceRequired"); +- this.persistenceRequired = p_21450_.getBoolean("PersistenceRequired"); ++ boolean data = p_21450_.getBoolean("PersistenceRequired"); + if (isLevelAtLeast(p_21450_, 1) || data) { -+ this.f_21353_ = data; ++ this.persistenceRequired = data; + } + // CraftBukkit end - if (p_21450_.m_128425_("ArmorItems", 9)) { - ListTag listtag = p_21450_.m_128437_("ArmorItems", 10); + if (p_21450_.contains("ArmorItems", 9)) { + ListTag listtag = p_21450_.getList("ArmorItems", 10); @@ -454,6 +_,11 @@ } - this.m_21557_(p_21450_.m_128471_("NoAI")); + this.setNoAi(p_21450_.getBoolean("NoAI")); + // CraftBukkit start -+ if (p_21450_.m_128441_("Bukkit.Aware")) { -+ this.aware = p_21450_.m_128471_("Bukkit.Aware"); ++ if (p_21450_.contains("Bukkit.Aware")) { ++ this.aware = p_21450_.getBoolean("Bukkit.Aware"); + } + // CraftBukkit end } - protected void m_7625_(DamageSource p_21389_, boolean p_21390_) { + protected void dropFromLootTable(DamageSource p_21389_, boolean p_21390_) { @@ -493,7 +_,7 @@ - public void m_8107_() { - super.m_8107_(); - this.f_19853_.m_46473_().m_6180_("looting"); -- if (!this.f_19853_.f_46443_ && this.m_21531_() && this.m_6084_() && !this.f_20890_ && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (!this.f_19853_.f_46443_ && this.m_21531_() && this.m_6084_() && !this.f_20890_ && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { - for(ItemEntity itementity : this.f_19853_.m_45976_(ItemEntity.class, this.m_142469_().m_82377_(1.0D, 0.0D, 1.0D))) { - if (!itementity.m_146910_() && !itementity.m_32055_().m_41619_() && !itementity.m_32063_() && this.m_7243_(itementity.m_32055_())) { - this.m_7581_(itementity); + 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)) { + for(ItemEntity itementity : this.level.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(1.0D, 0.0D, 1.0D))) { + if (!itementity.isRemoved() && !itementity.getItem().isEmpty() && !itementity.hasPickUpDelay() && this.wantsToPickUp(itementity.getItem())) { + this.pickUpItem(itementity); @@ -506,7 +_,7 @@ - protected void m_7581_(ItemEntity p_21471_) { - ItemStack itemstack = p_21471_.m_32055_(); -- if (this.m_21540_(itemstack)) { + protected void pickUpItem(ItemEntity p_21471_) { + ItemStack itemstack = p_21471_.getItem(); +- if (this.equipItemIfPossible(itemstack)) { + if (this.equipItemIfPossible(itemstack, p_21471_)) { // CraftBukkit - add item - this.m_21053_(p_21471_); - this.m_7938_(p_21471_, itemstack.m_41613_()); - p_21471_.m_146870_(); + this.onItemPickup(p_21471_); + this.take(p_21471_, itemstack.getCount()); + p_21471_.discard(); @@ -515,13 +_,27 @@ } - public boolean m_21540_(ItemStack p_21541_) { + public boolean equipItemIfPossible(ItemStack p_21541_) { + // CraftBukkit start - add item + return this.equipItemIfPossible(p_21541_, null); + } + + public boolean equipItemIfPossible(ItemStack p_21541_, ItemEntity entityitem) { + // CraftBukkit end - EquipmentSlot equipmentslot = m_147233_(p_21541_); - ItemStack itemstack = this.m_6844_(equipmentslot); - boolean flag = this.m_7808_(p_21541_, itemstack); -- if (flag && this.m_7252_(p_21541_)) { + EquipmentSlot equipmentslot = getEquipmentSlotForItem(p_21541_); + ItemStack itemstack = this.getItemBySlot(equipmentslot); + boolean flag = this.canReplaceCurrentItem(p_21541_, itemstack); +- if (flag && this.canHoldItem(p_21541_)) { + // CraftBukkit start -+ boolean canPickup = flag && this.m_7252_(itemstack); ++ boolean canPickup = flag && this.canHoldItem(itemstack); + if (entityitem != null) { + canPickup = !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled(); + } + if (canPickup) { + // CraftBukkit end - double d0 = (double)this.m_21519_(equipmentslot); - if (!itemstack.m_41619_() && (double)Math.max(this.f_19796_.nextFloat() - 0.1F, 0.0F) < d0) { + double d0 = (double)this.getEquipmentDropChance(equipmentslot); + if (!itemstack.isEmpty() && (double)Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { + this.forceDrops = true; // CraftBukkit - this.m_19983_(itemstack); + this.spawnAtLocation(itemstack); + this.forceDrops = false; // CraftBukkit } - this.m_21468_(equipmentslot, p_21541_); + this.setItemSlotAndDropWhenKilled(equipmentslot, p_21541_); @@ -646,17 +_,25 @@ - this.m_146870_(); - } else if (!this.m_21532_() && !this.m_8023_()) { - Entity entity = this.f_19853_.m_45930_(this, -1.0D); + this.discard(); + } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { + Entity entity = this.level.getNearestPlayer(this, -1.0D); + net.minecraftforge.eventbus.api.Event.Result result = net.minecraftforge.event.ForgeEventFactory.canEntityDespawn(this); + if (result == net.minecraftforge.eventbus.api.Event.Result.DENY) { -+ f_20891_ = 0; ++ noActionTime = 0; + entity = null; + } else if (result == net.minecraftforge.eventbus.api.Event.Result.ALLOW) { -+ this.m_146870_(); ++ this.discard(); + entity = null; + } if (entity != null) { - double d0 = entity.m_20280_(this); -- int i = this.m_6095_().m_20674_().m_21611_(); -+ int i = this.f_19853_.paperConfig.hardDespawnDistances.getInt(this.m_6095_().m_20674_()); // Paper - custom despawn distances + double d0 = entity.distanceToSqr(this); +- int i = this.getType().getCategory().getDespawnDistance(); ++ int i = this.level.paperConfig.hardDespawnDistances.getInt(this.getType().getCategory()); // Paper - custom despawn distances int j = i * i; -- if (d0 > (double)j && this.m_6785_(d0)) { -+ if (d0 > (double) j && this.m_6785_(d0)) { - this.m_146870_(); +- if (d0 > (double)j && this.removeWhenFarAway(d0)) { ++ if (d0 > (double) j && this.removeWhenFarAway(d0)) { + this.discard(); } -- int k = this.m_6095_().m_20674_().m_21612_(); -+ int k = this.f_19853_.paperConfig.softDespawnDistances.getInt(this.m_6095_().m_20674_()); // Paper - custom despawn distances +- int k = this.getType().getCategory().getNoDespawnDistance(); ++ int k = this.level.paperConfig.softDespawnDistances.getInt(this.getType().getCategory()); // Paper - custom despawn distances int l = k * k; -- if (this.f_20891_ > 600 && this.f_19796_.nextInt(800) == 0 && d0 > (double)l && this.m_6785_(d0)) { -+ if (this.f_20891_ > 600 && this.f_19796_.nextInt(800) == 0 && d0 > (double) l && this.m_6785_(d0)) { - this.m_146870_(); +- if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double)l && this.removeWhenFarAway(d0)) { ++ if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.removeWhenFarAway(d0)) { + this.discard(); } else if (d0 < (double)l) { - this.f_20891_ = 0; + this.noActionTime = 0; @@ -670,6 +_,17 @@ - protected final void m_6140_() { - ++this.f_20891_; + protected final void serverAiStep() { + ++this.noActionTime; + if (!this.aware) { // Paper start - Allow nerfed mobs to jump, float and take water damage + if (goalFloat != null) { -+ if (goalFloat.m_8036_()) goalFloat.m_8037_(); -+ this.m_21569_().m_8124_(); ++ if (goalFloat.canUse()) goalFloat.tick(); ++ this.getJumpControl().tick(); + } -+ if (this.m_6126_() && m_20071_()) { -+ m_6469_(DamageSource.f_19312_, 1.0F); ++ if (this.isSensitiveToWater() && isInWaterRainOrBubble()) { ++ hurt(DamageSource.DROWN, 1.0F); + } + return; + } + // Paper end - this.f_19853_.m_46473_().m_6180_("sensing"); - this.f_21349_.m_26789_(); - this.f_19853_.m_46473_().m_7238_(); + this.level.getProfiler().push("sensing"); + this.sensing.tick(); + this.level.getProfiler().pop(); @@ -1032,6 +_,12 @@ - if (!this.m_6084_()) { + if (!this.isAlive()) { return InteractionResult.PASS; - } else if (this.m_21524_() == p_21420_) { + } else if (this.getLeashHolder() == p_21420_) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerUnleashEntityEvent(this, p_21420_).isCancelled()) { -+ ((net.minecraft.server.level.ServerPlayer) p_21420_).f_8906_.m_141995_(new ClientboundSetEntityLinkPacket(this, this.m_21524_())); ++ ((net.minecraft.server.level.ServerPlayer) p_21420_).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder())); + return InteractionResult.PASS; + } + // CraftBukkit end - this.m_21455_(true, !p_21420_.m_150110_().f_35937_); - return InteractionResult.m_19078_(this.f_19853_.f_46443_); + this.dropLeash(true, !p_21420_.getAbilities().instabuild); + return InteractionResult.sidedSuccess(this.level.isClientSide); } else { @@ -1048,6 +_,12 @@ - private InteractionResult m_21499_(Player p_21500_, InteractionHand p_21501_) { - ItemStack itemstack = p_21500_.m_21120_(p_21501_); - if (itemstack.m_150930_(Items.f_42655_) && this.m_6573_(p_21500_)) { + private InteractionResult checkAndHandleImportantInteractions(Player p_21500_, InteractionHand p_21501_) { + ItemStack itemstack = p_21500_.getItemInHand(p_21501_); + if (itemstack.is(Items.LEAD) && this.canBeLeashed(p_21500_)) { + // CraftBukkit start - fire PlayerLeashEntityEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerLeashEntityEvent(this, p_21500_, p_21500_).isCancelled()) { -+ ((net.minecraft.server.level.ServerPlayer) p_21500_).f_8906_.m_141995_(new ClientboundSetEntityLinkPacket(this, this.m_21524_())); ++ ((net.minecraft.server.level.ServerPlayer) p_21500_).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder())); + return InteractionResult.PASS; + } + // CraftBukkit end - this.m_21463_(p_21500_, true); - itemstack.m_41774_(1); - return InteractionResult.m_19078_(this.f_19853_.f_46443_); + this.setLeashedTo(p_21500_, true); + itemstack.shrink(1); + return InteractionResult.sidedSuccess(this.level.isClientSide); @@ -1116,8 +_,16 @@ - return this.f_21341_ != -1.0F; + return this.restrictRadius != -1.0F; } + // CraftBukkit start @Nullable - public T m_21406_(EntityType p_21407_, boolean p_21408_) { + public T convertTo(EntityType p_21407_, boolean p_21408_) { + + return this.convertTo(p_21407_, p_21408_, org.bukkit.event.entity.EntityTransformEvent.TransformReason.UNKNOWN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } @@ -249,7 +249,7 @@ + @Nullable + public T convertTo(EntityType p_21407_, boolean p_21408_, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end - if (this.m_146910_()) { + if (this.isRemoved()) { return (T)null; } else { @@ -1148,7 +_,13 @@ @@ -260,53 +260,53 @@ + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTransformEvent(this, t, transformReason).isCancelled()) { + return null; + } -+ this.f_19853_.prepareEntity(t, spawnReason); //Magma - add spawn reason - this.f_19853_.m_7967_(t); ++ this.level.prepareEntity(t, spawnReason); //Magma - add spawn reason + this.level.addFreshEntity(t); + // CraftBukkit end - if (this.m_20159_()) { - Entity entity = this.m_20202_(); - this.m_8127_(); + if (this.isPassenger()) { + Entity entity = this.getVehicle(); + this.stopRiding(); @@ -1167,6 +_,7 @@ - if (this.f_21357_ != null) { - if (!this.m_6084_() || !this.f_21357_.m_6084_()) { -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), (!this.m_6084_()) ? org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH : org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.HOLDER_GONE)); // CraftBukkit - this.m_21455_(true, true); + if (this.leashHolder != null) { + if (!this.isAlive() || !this.leashHolder.isAlive()) { ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH : org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.HOLDER_GONE)); // CraftBukkit + this.dropLeash(true, true); } @@ -1178,7 +_,9 @@ - this.f_21357_ = null; - this.f_21359_ = null; - if (!this.f_19853_.f_46443_ && p_21457_) { + this.leashHolder = null; + this.leashInfoTag = null; + if (!this.level.isClientSide && p_21457_) { + this.forceDrops = true; // CraftBukkit - this.m_19998_(Items.f_42655_); + this.spawnAtLocation(Items.LEAD); + this.forceDrops = false; // CraftBukkit } - if (!this.f_19853_.f_46443_ && p_21456_ && this.f_19853_ instanceof ServerLevel) { + if (!this.level.isClientSide && p_21456_ && this.level instanceof ServerLevel) { @@ -1226,6 +_,7 @@ - public boolean m_7998_(Entity p_21396_, boolean p_21397_) { - boolean flag = super.m_7998_(p_21396_, p_21397_); - if (flag && this.m_21523_()) { -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.UNKNOWN)); // CraftBukkit - this.m_21455_(true, true); + public boolean startRiding(Entity p_21396_, boolean p_21397_) { + boolean flag = super.startRiding(p_21396_, p_21397_); + if (flag && this.isLeashed()) { ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.UNKNOWN)); // CraftBukkit + this.dropLeash(true, true); } @@ -1248,7 +_,9 @@ } - if (this.f_19797_ > 100) { + if (this.tickCount > 100) { + this.forceDrops = true; // CraftBukkit - this.m_19998_(Items.f_42655_); + this.spawnAtLocation(Items.LEAD); + this.forceDrops = false; // CraftBukkit - this.f_21359_ = null; + this.leashInfoTag = null; } } @@ -1311,7 +_,14 @@ - int i = EnchantmentHelper.m_44914_(this); + int i = EnchantmentHelper.getFireAspect(this); if (i > 0) { -- p_21372_.m_20254_(i * 4); +- p_21372_.setSecondsOnFire(i * 4); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item + org.bukkit.event.entity.EntityCombustByEntityEvent combustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), p_21372_.getBukkitEntity(), i * 4); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); @@ -317,16 +317,16 @@ + // CraftBukkit end } - boolean flag = p_21372_.m_6469_(DamageSource.m_19370_(this), f); + boolean flag = p_21372_.hurt(DamageSource.mobAttack(this), f); @@ -1373,9 +_,10 @@ - protected void m_6089_() { - super.m_6089_(); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.UNKNOWN)); // CraftBukkit - this.m_21455_(true, false); - this.m_20158_().forEach((p_181125_) -> { -- p_181125_.m_41764_(0); -+ if (!p_181125_.m_41619_()) p_181125_.m_41764_(0); // CraftBukkit + protected void removeAfterChangingDimensions() { + super.removeAfterChangingDimensions(); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.UNKNOWN)); // CraftBukkit + this.dropLeash(true, false); + this.getAllSlots().forEach((p_181125_) -> { +- p_181125_.setCount(0); ++ if (!p_181125_.isEmpty()) p_181125_.setCount(0); // CraftBukkit }); } diff --git a/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch b/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch index 3335563a..f0f4a78b 100644 --- a/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch @@ -13,15 +13,15 @@ WATER_AMBIENT("water_ambient", 20, true, false, 64), MISC("misc", -1, true, true, 128); -- public static final Codec f_21584_ = StringRepresentable.m_14350_(MobCategory::values, MobCategory::m_21605_); -+ public static final Codec f_21584_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(MobCategory::values, MobCategory::m_21605_); - private static final Map f_21585_ = Arrays.stream(values()).collect(Collectors.toMap(MobCategory::m_21607_, (p_21604_) -> { +- public static final Codec CODEC = StringRepresentable.fromEnum(MobCategory::values, MobCategory::byName); ++ public static final Codec CODEC = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(MobCategory::values, MobCategory::byName); + private static final Map BY_NAME = Arrays.stream(values()).collect(Collectors.toMap(MobCategory::getName, (p_21604_) -> { return p_21604_; })); @@ -57,6 +_,16 @@ - public boolean m_21610_() { - return this.f_21588_; + public boolean isPersistent() { + return this.isPersistent; + } + + public static MobCategory create(String name, String id, int maxNumberOfCreatureIn, boolean isPeacefulCreatureIn, boolean isAnimalIn, int despawnDistance) { @@ -31,7 +31,7 @@ + @Override + @Deprecated + public void init() { -+ f_21585_.put(this.m_21607_(), this); ++ BY_NAME.put(this.getName(), this); } - public int m_21611_() { + public int getDespawnDistance() { diff --git a/patches/minecraft/net/minecraft/world/entity/NeutralMob.java.patch b/patches/minecraft/net/minecraft/world/entity/NeutralMob.java.patch index 94e11731..ef10dd20 100644 --- a/patches/minecraft/net/minecraft/world/entity/NeutralMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/NeutralMob.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/NeutralMob.java +++ b/net/minecraft/world/entity/NeutralMob.java @@ -108,7 +_,7 @@ - default void m_21662_() { - this.m_6703_((LivingEntity)null); - this.m_6925_((UUID)null); -- this.m_6710_((LivingEntity)null); + default void stopBeingAngry() { + this.setLastHurtByMob((LivingEntity)null); + this.setPersistentAngerTarget((UUID)null); +- this.setTarget((LivingEntity)null); + this.setTarget((LivingEntity) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - this.m_7870_(0); + this.setRemainingPersistentAngerTime(0); } @@ -120,6 +_,8 @@ - void m_6598_(@Nullable Player p_21680_); + void setLastHurtByPlayer(@Nullable Player p_21680_); - void m_6710_(@Nullable LivingEntity p_21681_); + void setTarget(@Nullable LivingEntity p_21681_); + + boolean setTarget(@Nullable LivingEntity entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit - boolean m_6779_(LivingEntity p_181126_); + boolean canAttack(LivingEntity p_181126_); diff --git a/patches/minecraft/net/minecraft/world/entity/PathfinderMob.java.patch b/patches/minecraft/net/minecraft/world/entity/PathfinderMob.java.patch index 25e8a764..973e5e75 100644 --- a/patches/minecraft/net/minecraft/world/entity/PathfinderMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/PathfinderMob.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/entity/PathfinderMob.java +++ b/net/minecraft/world/entity/PathfinderMob.java @@ -38,6 +_,7 @@ - float f = this.m_20270_(entity); - if (this instanceof TamableAnimal && ((TamableAnimal)this).m_21825_()) { + float f = this.distanceTo(entity); + if (this instanceof TamableAnimal && ((TamableAnimal)this).isInSittingPose()) { if (f > 10.0F) { -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.m_21455_(true, true); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit + this.dropLeash(true, true); } @@ -46,6 +_,7 @@ - this.m_7880_(f); + this.onLeashDistance(f); if (f > 10.0F) { -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.m_21455_(true, true); - this.f_21345_.m_25355_(Goal.Flag.MOVE); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit + this.dropLeash(true, true); + this.goalSelector.disableControlFlag(Goal.Flag.MOVE); } else if (f > 6.0F) { diff --git a/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch b/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch index b3b180c7..45810abc 100644 --- a/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch @@ -7,8 +7,8 @@ +@Deprecated // Forge: Use IForgeShearable public interface Shearable { + @Deprecated // Forge: Use IForgeShearable - void m_5851_(SoundSource p_21749_); + void shear(SoundSource p_21749_); + @Deprecated // Forge: Use IForgeShearable - boolean m_6220_(); + 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 6d8eda00..affafdad 100644 --- a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/SpawnPlacements.java +++ b/net/minecraft/world/entity/SpawnPlacements.java @@ -153,10 +_,26 @@ - boolean m_21780_(EntityType p_21781_, ServerLevelAccessor p_21782_, MobSpawnType p_21783_, BlockPos p_21784_, Random p_21785_); + boolean test(EntityType p_21781_, ServerLevelAccessor p_21782_, MobSpawnType p_21783_, BlockPos p_21784_, Random p_21785_); } - public static enum Type { diff --git a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch index 9dbafaa6..55f010f1 100644 --- a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch @@ -3,18 +3,18 @@ @@ -197,11 +_,15 @@ } - public void m_6667_(DamageSource p_21809_) { + 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.m_21231_().m_19293_(); -+ super.m_6667_(p_21809_); ++ net.minecraft.network.chat.Component deathMessage = this.getCombatTracker().getDeathMessage(); ++ super.die(p_21809_); + -+ if (this.f_20890_) - if (!this.f_19853_.f_46443_ && this.f_19853_.m_46469_().m_46207_(GameRules.f_46142_) && this.m_142480_() instanceof ServerPlayer) { -- this.m_142480_().m_6352_(this.m_21231_().m_19293_(), Util.f_137441_); -+ this.m_142480_().m_6352_(deathMessage, Util.f_137441_); ++ if (this.dead) + if (!this.level.isClientSide && this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) && this.getOwner() instanceof ServerPlayer) { +- this.getOwner().sendMessage(this.getCombatTracker().getDeathMessage(), Util.NIL_UUID); ++ this.getOwner().sendMessage(deathMessage, Util.NIL_UUID); } -- super.m_6667_(p_21809_); +- super.die(p_21809_); } - public boolean m_21827_() { + public boolean isOrderedToSit() { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch index fa718719..f8ad4f62 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attribute.java.patch @@ -5,6 +5,6 @@ -public class Attribute { +public class Attribute extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final int f_147357_ = 64; - private final double f_22076_; - private boolean f_22077_; + public static final int MAX_NAME_LENGTH = 64; + private final double defaultValue; + private boolean syncable; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch index 96b0a122..53333a79 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch @@ -2,32 +2,32 @@ +++ b/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java @@ -69,6 +_,22 @@ public static class Builder { - private final Map f_22262_ = Maps.newHashMap(); - private boolean f_22263_; + private final Map builder = Maps.newHashMap(); + private boolean instanceFrozen; + private final java.util.List others = new java.util.ArrayList<>(); + + public Builder() { } + + public Builder(AttributeSupplier attributeMap) { -+ this.f_22262_.putAll(attributeMap.f_22241_); ++ this.builder.putAll(attributeMap.instances); + } + + public void combine(Builder other) { -+ this.f_22262_.putAll(other.f_22262_); ++ this.builder.putAll(other.builder); + others.add(other); + } + + public boolean hasAttribute(Attribute attribute) { -+ return this.f_22262_.containsKey(attribute); ++ return this.builder.containsKey(attribute); + } - private AttributeInstance m_22274_(Attribute p_22275_) { + private AttributeInstance create(Attribute p_22275_) { AttributeInstance attributeinstance = new AttributeInstance(p_22275_, (p_22273_) -> { @@ -93,6 +_,7 @@ - public AttributeSupplier m_22265_() { - this.f_22263_ = true; -+ others.forEach(p_70141_ -> p_70141_.f_22263_ = true); - return new AttributeSupplier(this.f_22262_); + public AttributeSupplier build() { + this.instanceFrozen = true; ++ others.forEach(p_70141_ -> p_70141_.instanceFrozen = true); + return new AttributeSupplier(this.builder); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attributes.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attributes.java.patch index 6e17f53b..5db3d4e6 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attributes.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/Attributes.java.patch @@ -4,15 +4,15 @@ import net.minecraft.core.Registry; public class Attributes { -- public static final Attribute f_22276_ = m_22290_("generic.max_health", (new RangedAttribute("attribute.name.generic.max_health", 20.0D, 1.0D, 1024.0D)).m_22084_(true)); -+ public static final Attribute f_22276_ = m_22290_("generic.max_health", (new RangedAttribute("attribute.name.generic.max_health", 20.0D, 1.0D, org.spigotmc.SpigotConfig.maxHealth)).m_22084_(true)); - public static final Attribute f_22277_ = m_22290_("generic.follow_range", new RangedAttribute("attribute.name.generic.follow_range", 32.0D, 0.0D, 2048.0D)); - public static final Attribute f_22278_ = m_22290_("generic.knockback_resistance", new RangedAttribute("attribute.name.generic.knockback_resistance", 0.0D, 0.0D, 1.0D)); -- public static final Attribute f_22279_ = m_22290_("generic.movement_speed", (new RangedAttribute("attribute.name.generic.movement_speed", (double)0.7F, 0.0D, 1024.0D)).m_22084_(true)); -+ public static final Attribute f_22279_ = m_22290_("generic.movement_speed", (new RangedAttribute("attribute.name.generic.movement_speed", (double)0.7F, 0.0D, org.spigotmc.SpigotConfig.movementSpeed)).m_22084_(true)); - public static final Attribute f_22280_ = m_22290_("generic.flying_speed", (new RangedAttribute("attribute.name.generic.flying_speed", (double)0.4F, 0.0D, 1024.0D)).m_22084_(true)); -- public static final Attribute f_22281_ = m_22290_("generic.attack_damage", new RangedAttribute("attribute.name.generic.attack_damage", 2.0D, 0.0D, 2048.0D)); -+ public static final Attribute f_22281_ = m_22290_("generic.attack_damage", new RangedAttribute("attribute.name.generic.attack_damage", 2.0D, 0.0D, org.spigotmc.SpigotConfig.attackDamage)); - public static final Attribute f_22282_ = m_22290_("generic.attack_knockback", new RangedAttribute("attribute.name.generic.attack_knockback", 0.0D, 0.0D, 5.0D)); - public static final Attribute f_22283_ = m_22290_("generic.attack_speed", (new RangedAttribute("attribute.name.generic.attack_speed", 4.0D, 0.0D, 1024.0D)).m_22084_(true)); - public static final Attribute f_22284_ = m_22290_("generic.armor", (new RangedAttribute("attribute.name.generic.armor", 0.0D, 0.0D, 30.0D)).m_22084_(true)); +- public static final Attribute MAX_HEALTH = register("generic.max_health", (new RangedAttribute("attribute.name.generic.max_health", 20.0D, 1.0D, 1024.0D)).setSyncable(true)); ++ public static final Attribute MAX_HEALTH = register("generic.max_health", (new RangedAttribute("attribute.name.generic.max_health", 20.0D, 1.0D, org.spigotmc.SpigotConfig.maxHealth)).setSyncable(true)); + public static final Attribute FOLLOW_RANGE = register("generic.follow_range", new RangedAttribute("attribute.name.generic.follow_range", 32.0D, 0.0D, 2048.0D)); + public static final Attribute KNOCKBACK_RESISTANCE = register("generic.knockback_resistance", new RangedAttribute("attribute.name.generic.knockback_resistance", 0.0D, 0.0D, 1.0D)); +- public static final Attribute MOVEMENT_SPEED = register("generic.movement_speed", (new RangedAttribute("attribute.name.generic.movement_speed", (double)0.7F, 0.0D, 1024.0D)).setSyncable(true)); ++ public static final Attribute MOVEMENT_SPEED = register("generic.movement_speed", (new RangedAttribute("attribute.name.generic.movement_speed", (double)0.7F, 0.0D, org.spigotmc.SpigotConfig.movementSpeed)).setSyncable(true)); + public static final Attribute FLYING_SPEED = register("generic.flying_speed", (new RangedAttribute("attribute.name.generic.flying_speed", (double)0.4F, 0.0D, 1024.0D)).setSyncable(true)); +- public static final Attribute ATTACK_DAMAGE = register("generic.attack_damage", new RangedAttribute("attribute.name.generic.attack_damage", 2.0D, 0.0D, 2048.0D)); ++ public static final Attribute ATTACK_DAMAGE = register("generic.attack_damage", new RangedAttribute("attribute.name.generic.attack_damage", 2.0D, 0.0D, org.spigotmc.SpigotConfig.attackDamage)); + public static final Attribute ATTACK_KNOCKBACK = register("generic.attack_knockback", new RangedAttribute("attribute.name.generic.attack_knockback", 0.0D, 0.0D, 5.0D)); + public static final Attribute ATTACK_SPEED = register("generic.attack_speed", (new RangedAttribute("attribute.name.generic.attack_speed", 4.0D, 0.0D, 1024.0D)).setSyncable(true)); + public static final Attribute ARMOR = register("generic.armor", (new RangedAttribute("attribute.name.generic.armor", 0.0D, 0.0D, 30.0D)).setSyncable(true)); 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 15f13c9a..8d27f4d2 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,17 +1,17 @@ --- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java +++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java @@ -77,11 +_,12 @@ - private static final Map, AttributeSupplier> f_22294_ = ImmutableMap., AttributeSupplier>builder().put(EntityType.f_20529_, LivingEntity.m_21183_().m_22265_()).put(EntityType.f_147039_, Axolotl.m_149176_().m_22265_()).put(EntityType.f_20549_, Bat.m_27455_().m_22265_()).put(EntityType.f_20550_, Bee.m_27858_().m_22265_()).put(EntityType.f_20551_, Blaze.m_32238_().m_22265_()).put(EntityType.f_20553_, Cat.m_28168_().m_22265_()).put(EntityType.f_20554_, CaveSpider.m_32267_().m_22265_()).put(EntityType.f_20555_, Chicken.m_28263_().m_22265_()).put(EntityType.f_20556_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20557_, Cow.m_28307_().m_22265_()).put(EntityType.f_20558_, Creeper.m_32318_().m_22265_()).put(EntityType.f_20559_, Dolphin.m_28379_().m_22265_()).put(EntityType.f_20560_, AbstractChestedHorse.m_30501_().m_22265_()).put(EntityType.f_20562_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20563_, ElderGuardian.m_32471_().m_22265_()).put(EntityType.f_20566_, EnderMan.m_32541_().m_22265_()).put(EntityType.f_20567_, Endermite.m_32619_().m_22265_()).put(EntityType.f_20565_, EnderDragon.m_31167_().m_22265_()).put(EntityType.f_20568_, Evoker.m_32657_().m_22265_()).put(EntityType.f_20452_, Fox.m_28553_().m_22265_()).put(EntityType.f_20453_, Ghast.m_32752_().m_22265_()).put(EntityType.f_20454_, Giant.m_32796_().m_22265_()).put(EntityType.f_147034_, GlowSquid.m_29988_().m_22265_()).put(EntityType.f_147035_, Goat.m_149401_().m_22265_()).put(EntityType.f_20455_, Guardian.m_32853_().m_22265_()).put(EntityType.f_20456_, Hoglin.m_34551_().m_22265_()).put(EntityType.f_20457_, AbstractHorse.m_30627_().m_22265_()).put(EntityType.f_20458_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20459_, Illusioner.m_32931_().m_22265_()).put(EntityType.f_20460_, IronGolem.m_28883_().m_22265_()).put(EntityType.f_20466_, Llama.m_30824_().m_22265_()).put(EntityType.f_20468_, MagmaCube.m_33000_().m_22265_()).put(EntityType.f_20504_, Cow.m_28307_().m_22265_()).put(EntityType.f_20503_, AbstractChestedHorse.m_30501_().m_22265_()).put(EntityType.f_20505_, Ocelot.m_29036_().m_22265_()).put(EntityType.f_20507_, Panda.m_29157_().m_22265_()).put(EntityType.f_20508_, Parrot.m_29438_().m_22265_()).put(EntityType.f_20509_, Monster.m_33035_().m_22265_()).put(EntityType.f_20510_, Pig.m_29503_().m_22265_()).put(EntityType.f_20511_, Piglin.m_34770_().m_22265_()).put(EntityType.f_20512_, PiglinBrute.m_35075_().m_22265_()).put(EntityType.f_20513_, Pillager.m_33307_().m_22265_()).put(EntityType.f_20532_, Player.m_36340_().m_22265_()).put(EntityType.f_20514_, PolarBear.m_29560_().m_22265_()).put(EntityType.f_20516_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20517_, Rabbit.m_29717_().m_22265_()).put(EntityType.f_20518_, Ravager.m_33371_().m_22265_()).put(EntityType.f_20519_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20520_, Sheep.m_29873_().m_22265_()).put(EntityType.f_20521_, Shulker.m_33477_().m_22265_()).put(EntityType.f_20523_, Silverfish.m_33551_().m_22265_()).put(EntityType.f_20524_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20525_, SkeletonHorse.m_30918_().m_22265_()).put(EntityType.f_20526_, Monster.m_33035_().m_22265_()).put(EntityType.f_20528_, SnowGolem.m_29934_().m_22265_()).put(EntityType.f_20479_, Spider.m_33815_().m_22265_()).put(EntityType.f_20480_, Squid.m_29988_().m_22265_()).put(EntityType.f_20481_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20482_, Strider.m_33937_().m_22265_()).put(EntityType.f_20488_, Llama.m_30824_().m_22265_()).put(EntityType.f_20489_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20490_, Turtle.m_30207_().m_22265_()).put(EntityType.f_20491_, Vex.m_34040_().m_22265_()).put(EntityType.f_20492_, Villager.m_35503_().m_22265_()).put(EntityType.f_20493_, Vindicator.m_34104_().m_22265_()).put(EntityType.f_20494_, Mob.m_21552_().m_22265_()).put(EntityType.f_20495_, Witch.m_34155_().m_22265_()).put(EntityType.f_20496_, WitherBoss.m_31501_().m_22265_()).put(EntityType.f_20497_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20499_, Wolf.m_30425_().m_22265_()).put(EntityType.f_20500_, Zoglin.m_34257_().m_22265_()).put(EntityType.f_20501_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20502_, ZombieHorse.m_31008_().m_22265_()).put(EntityType.f_20530_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20531_, ZombifiedPiglin.m_34470_().m_22265_()).build(); + private static final Map, AttributeSupplier> SUPPLIERS = ImmutableMap., AttributeSupplier>builder().put(EntityType.ARMOR_STAND, LivingEntity.createLivingAttributes().build()).put(EntityType.AXOLOTL, Axolotl.createAttributes().build()).put(EntityType.BAT, Bat.createAttributes().build()).put(EntityType.BEE, Bee.createAttributes().build()).put(EntityType.BLAZE, Blaze.createAttributes().build()).put(EntityType.CAT, Cat.createAttributes().build()).put(EntityType.CAVE_SPIDER, CaveSpider.createCaveSpider().build()).put(EntityType.CHICKEN, Chicken.createAttributes().build()).put(EntityType.COD, AbstractFish.createAttributes().build()).put(EntityType.COW, Cow.createAttributes().build()).put(EntityType.CREEPER, Creeper.createAttributes().build()).put(EntityType.DOLPHIN, Dolphin.createAttributes().build()).put(EntityType.DONKEY, AbstractChestedHorse.createBaseChestedHorseAttributes().build()).put(EntityType.DROWNED, Zombie.createAttributes().build()).put(EntityType.ELDER_GUARDIAN, ElderGuardian.createAttributes().build()).put(EntityType.ENDERMAN, EnderMan.createAttributes().build()).put(EntityType.ENDERMITE, Endermite.createAttributes().build()).put(EntityType.ENDER_DRAGON, EnderDragon.createAttributes().build()).put(EntityType.EVOKER, Evoker.createAttributes().build()).put(EntityType.FOX, Fox.createAttributes().build()).put(EntityType.GHAST, Ghast.createAttributes().build()).put(EntityType.GIANT, Giant.createAttributes().build()).put(EntityType.GLOW_SQUID, GlowSquid.createAttributes().build()).put(EntityType.GOAT, Goat.createAttributes().build()).put(EntityType.GUARDIAN, Guardian.createAttributes().build()).put(EntityType.HOGLIN, Hoglin.createAttributes().build()).put(EntityType.HORSE, AbstractHorse.createBaseHorseAttributes().build()).put(EntityType.HUSK, Zombie.createAttributes().build()).put(EntityType.ILLUSIONER, Illusioner.createAttributes().build()).put(EntityType.IRON_GOLEM, IronGolem.createAttributes().build()).put(EntityType.LLAMA, Llama.createAttributes().build()).put(EntityType.MAGMA_CUBE, MagmaCube.createAttributes().build()).put(EntityType.MOOSHROOM, Cow.createAttributes().build()).put(EntityType.MULE, AbstractChestedHorse.createBaseChestedHorseAttributes().build()).put(EntityType.OCELOT, Ocelot.createAttributes().build()).put(EntityType.PANDA, Panda.createAttributes().build()).put(EntityType.PARROT, Parrot.createAttributes().build()).put(EntityType.PHANTOM, Monster.createMonsterAttributes().build()).put(EntityType.PIG, Pig.createAttributes().build()).put(EntityType.PIGLIN, Piglin.createAttributes().build()).put(EntityType.PIGLIN_BRUTE, PiglinBrute.createAttributes().build()).put(EntityType.PILLAGER, Pillager.createAttributes().build()).put(EntityType.PLAYER, Player.createAttributes().build()).put(EntityType.POLAR_BEAR, PolarBear.createAttributes().build()).put(EntityType.PUFFERFISH, AbstractFish.createAttributes().build()).put(EntityType.RABBIT, Rabbit.createAttributes().build()).put(EntityType.RAVAGER, Ravager.createAttributes().build()).put(EntityType.SALMON, AbstractFish.createAttributes().build()).put(EntityType.SHEEP, Sheep.createAttributes().build()).put(EntityType.SHULKER, Shulker.createAttributes().build()).put(EntityType.SILVERFISH, Silverfish.createAttributes().build()).put(EntityType.SKELETON, AbstractSkeleton.createAttributes().build()).put(EntityType.SKELETON_HORSE, SkeletonHorse.createAttributes().build()).put(EntityType.SLIME, Monster.createMonsterAttributes().build()).put(EntityType.SNOW_GOLEM, SnowGolem.createAttributes().build()).put(EntityType.SPIDER, Spider.createAttributes().build()).put(EntityType.SQUID, Squid.createAttributes().build()).put(EntityType.STRAY, AbstractSkeleton.createAttributes().build()).put(EntityType.STRIDER, Strider.createAttributes().build()).put(EntityType.TRADER_LLAMA, Llama.createAttributes().build()).put(EntityType.TROPICAL_FISH, AbstractFish.createAttributes().build()).put(EntityType.TURTLE, Turtle.createAttributes().build()).put(EntityType.VEX, Vex.createAttributes().build()).put(EntityType.VILLAGER, Villager.createAttributes().build()).put(EntityType.VINDICATOR, Vindicator.createAttributes().build()).put(EntityType.WANDERING_TRADER, Mob.createMobAttributes().build()).put(EntityType.WITCH, Witch.createAttributes().build()).put(EntityType.WITHER, WitherBoss.createAttributes().build()).put(EntityType.WITHER_SKELETON, AbstractSkeleton.createAttributes().build()).put(EntityType.WOLF, Wolf.createAttributes().build()).put(EntityType.ZOGLIN, Zoglin.createAttributes().build()).put(EntityType.ZOMBIE, Zombie.createAttributes().build()).put(EntityType.ZOMBIE_HORSE, ZombieHorse.createAttributes().build()).put(EntityType.ZOMBIE_VILLAGER, Zombie.createAttributes().build()).put(EntityType.ZOMBIFIED_PIGLIN, ZombifiedPiglin.createAttributes().build()).build(); - public static AttributeSupplier m_22297_(EntityType p_22298_) { -- return f_22294_.get(p_22298_); + public static AttributeSupplier getSupplier(EntityType p_22298_) { +- return SUPPLIERS.get(p_22298_); + AttributeSupplier supplier = net.minecraftforge.common.ForgeHooks.getAttributesView().get(p_22298_); -+ return supplier != null ? supplier : f_22294_.get(p_22298_); ++ return supplier != null ? supplier : SUPPLIERS.get(p_22298_); } - public static boolean m_22301_(EntityType p_22302_) { -- return f_22294_.containsKey(p_22302_); -+ return f_22294_.containsKey(p_22302_) || net.minecraftforge.common.ForgeHooks.getAttributesView().containsKey(p_22302_); + public static boolean hasSupplier(EntityType p_22302_) { +- return SUPPLIERS.containsKey(p_22302_); ++ return SUPPLIERS.containsKey(p_22302_) || net.minecraftforge.common.ForgeHooks.getAttributesView().containsKey(p_22302_); } - public static void m_22296_() { + public static void validate() { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/RangedAttribute.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/RangedAttribute.java.patch index 9035fa61..5b8ef763 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/RangedAttribute.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/RangedAttribute.java.patch @@ -3,18 +3,18 @@ @@ -4,7 +_,7 @@ public class RangedAttribute extends Attribute { - private final double f_22307_; -- private final double f_22308_; -+ public double f_22308_; // Spigot + private final double minValue; +- private final double maxValue; ++ public double maxValue; // Spigot public RangedAttribute(String p_22310_, double p_22311_, double p_22312_, double p_22313_) { super(p_22310_, p_22311_); @@ -28,6 +_,8 @@ } - public double m_6740_(double p_22315_) { -+ if (p_22315_ != p_22315_) return m_22082_(); // CraftBukkit + public double sanitizeValue(double p_22315_) { ++ if (p_22315_ != p_22315_) return getDefaultValue(); // CraftBukkit + - return Mth.m_14008_(p_22315_, this.f_22307_, this.f_22308_); + return Mth.clamp(p_22315_, this.minValue, this.maxValue); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch index 4e7ecdd2..3f8a0a9e 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java +++ b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java @@ -36,7 +_,13 @@ - return p_147412_.m_35622_() == p_22457_; + return p_147412_.getJobPoiType() == p_22457_; }).findFirst(); }).ifPresent((p_22464_) -> { -- p_22454_.m_141967_(p_22454_.m_7141_().m_35565_(p_22464_)); +- p_22454_.setVillagerData(p_22454_.getVillagerData().setProfession(p_22464_)); + // CraftBukkit start - Fire org.bukkit.event.entity.VillagerCareerChangeEvent where Villager gets employed + org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callVillagerCareerChangeEvent(p_22454_, org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.nmsToBukkitProfession(p_22464_), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.EMPLOYED); + if (event.isCancelled()) { + return; + } -+ p_22454_.m_141967_(p_22454_.m_7141_().m_35565_(org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.bukkitToNmsProfession(event.getProfession()))); ++ p_22454_.setVillagerData(p_22454_.getVillagerData().setProfession(org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - p_22454_.m_35483_(p_22453_); + p_22454_.refreshBrain(p_22453_); }); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java.patch index aeda82fc..ed2a9a89 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java.patch @@ -3,22 +3,22 @@ @@ -81,6 +_,7 @@ } - public static void m_22613_(LivingEntity p_22614_, ItemStack p_22615_, Vec3 p_22616_) { -+ if (p_22615_.m_41619_()) return; // CraftBukkit - SPIGOT-4940: no empty loot - double d0 = p_22614_.m_20188_() - (double)0.3F; - ItemEntity itementity = new ItemEntity(p_22614_.f_19853_, p_22614_.m_20185_(), d0, p_22614_.m_20189_(), p_22615_); + public static void throwItem(LivingEntity p_22614_, ItemStack p_22615_, Vec3 p_22616_) { ++ if (p_22615_.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot + double d0 = p_22614_.getEyeY() - (double)0.3F; + ItemEntity itementity = new ItemEntity(p_22614_.level, p_22614_.getX(), d0, p_22614_.getZ(), p_22615_); float f = 0.3F; @@ -88,6 +_,13 @@ - vec3 = vec3.m_82541_().m_82490_((double)0.3F); - itementity.m_20256_(vec3); - itementity.m_32060_(); + vec3 = vec3.normalize().scale((double)0.3F); + itementity.setDeltaMovement(vec3); + itementity.setDefaultPickUpDelay(); + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(p_22614_.getBukkitEntity(), (org.bukkit.entity.Item) itementity.getBukkitEntity()); -+ itementity.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ itementity.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - p_22614_.f_19853_.m_7967_(itementity); + p_22614_.level.addFreshEntity(itementity); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch index 689cada2..a8955439 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java.patch @@ -2,37 +2,37 @@ +++ b/net/minecraft/world/entity/ai/behavior/CrossbowAttack.java @@ -23,7 +_,7 @@ - protected boolean m_6114_(ServerLevel p_22778_, E p_22779_) { - LivingEntity livingentity = m_22784_(p_22779_); -- return p_22779_.m_21055_(Items.f_42717_) && BehaviorUtils.m_22667_(p_22779_, livingentity) && BehaviorUtils.m_22632_(p_22779_, livingentity, 0); -+ return p_22779_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem) && BehaviorUtils.m_22667_(p_22779_, livingentity) && BehaviorUtils.m_22632_(p_22779_, livingentity, 0); + protected boolean checkExtraStartConditions(ServerLevel p_22778_, E p_22779_) { + LivingEntity livingentity = getAttackTarget(p_22779_); +- return p_22779_.isHolding(Items.CROSSBOW) && BehaviorUtils.canSee(p_22779_, livingentity) && BehaviorUtils.isWithinAttackRange(p_22779_, livingentity, 0); ++ return p_22779_.isHolding(is -> is.getItem() instanceof CrossbowItem) && BehaviorUtils.canSee(p_22779_, livingentity) && BehaviorUtils.isWithinAttackRange(p_22779_, livingentity, 0); } - protected boolean m_6737_(ServerLevel p_22781_, E p_22782_, long p_22783_) { + protected boolean canStillUse(ServerLevel p_22781_, E p_22782_, long p_22783_) { @@ -41,7 +_,7 @@ - p_22806_.m_5810_(); + p_22806_.stopUsingItem(); } -- if (p_22806_.m_21055_(Items.f_42717_)) { -+ if (p_22806_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem)) { - p_22806_.m_6136_(false); - CrossbowItem.m_40884_(p_22806_.m_21211_(), false); +- if (p_22806_.isHolding(Items.CROSSBOW)) { ++ if (p_22806_.isHolding(is -> is.getItem() instanceof CrossbowItem)) { + p_22806_.setChargingCrossbow(false); + CrossbowItem.setCharged(p_22806_.getUseItem(), false); } @@ -50,7 +_,7 @@ - private void m_22786_(E p_22787_, LivingEntity p_22788_) { - if (this.f_22772_ == CrossbowAttack.CrossbowState.UNCHARGED) { -- p_22787_.m_6672_(ProjectileUtil.m_37297_(p_22787_, Items.f_42717_)); -+ p_22787_.m_6672_(ProjectileUtil.getWeaponHoldingHand(p_22787_, item -> item instanceof CrossbowItem)); - this.f_22772_ = CrossbowAttack.CrossbowState.CHARGING; - p_22787_.m_6136_(true); - } else if (this.f_22772_ == CrossbowAttack.CrossbowState.CHARGING) { + private void crossbowAttack(E p_22787_, LivingEntity p_22788_) { + if (this.crossbowState == CrossbowAttack.CrossbowState.UNCHARGED) { +- p_22787_.startUsingItem(ProjectileUtil.getWeaponHoldingHand(p_22787_, Items.CROSSBOW)); ++ p_22787_.startUsingItem(ProjectileUtil.getWeaponHoldingHand(p_22787_, item -> item instanceof CrossbowItem)); + this.crossbowState = CrossbowAttack.CrossbowState.CHARGING; + p_22787_.setChargingCrossbow(true); + } else if (this.crossbowState == CrossbowAttack.CrossbowState.CHARGING) { @@ -73,7 +_,7 @@ } - } else if (this.f_22772_ == CrossbowAttack.CrossbowState.READY_TO_ATTACK) { - p_22787_.m_6504_(p_22788_, 1.0F); -- ItemStack itemstack1 = p_22787_.m_21120_(ProjectileUtil.m_37297_(p_22787_, Items.f_42717_)); -+ ItemStack itemstack1 = p_22787_.m_21120_(ProjectileUtil.getWeaponHoldingHand(p_22787_, item -> item instanceof CrossbowItem)); - CrossbowItem.m_40884_(itemstack1, false); - this.f_22772_ = CrossbowAttack.CrossbowState.UNCHARGED; + } else if (this.crossbowState == CrossbowAttack.CrossbowState.READY_TO_ATTACK) { + p_22787_.performRangedAttack(p_22788_, 1.0F); +- ItemStack itemstack1 = p_22787_.getItemInHand(ProjectileUtil.getWeaponHoldingHand(p_22787_, Items.CROSSBOW)); ++ ItemStack itemstack1 = p_22787_.getItemInHand(ProjectileUtil.getWeaponHoldingHand(p_22787_, item -> item instanceof CrossbowItem)); + CrossbowItem.setCharged(itemstack1, false); + this.crossbowState = CrossbowAttack.CrossbowState.UNCHARGED; } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch index c9a2846a..88f4a7ab 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -3,57 +3,57 @@ @@ -38,7 +_,7 @@ } - protected boolean m_6114_(ServerLevel p_23174_, Villager p_23175_) { -- if (!p_23174_.m_46469_().m_46207_(GameRules.f_46132_)) { + protected boolean checkExtraStartConditions(ServerLevel p_23174_, Villager p_23175_) { +- if (!p_23174_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_23174_, p_23175_)) { return false; - } else if (p_23175_.m_7141_().m_35571_() != VillagerProfession.f_35590_) { + } else if (p_23175_.getVillagerData().getProfession() != VillagerProfession.FARMER) { return false; @@ -96,7 +_,11 @@ - Block block = blockstate.m_60734_(); - Block block1 = p_23196_.m_8055_(this.f_23159_.m_7495_()).m_60734_(); - if (block instanceof CropBlock && ((CropBlock)block).m_52307_(blockstate)) { -- p_23196_.m_46953_(this.f_23159_, true, p_23197_); + Block block = blockstate.getBlock(); + Block block1 = p_23196_.getBlockState(this.aboveFarmlandPos.below()).getBlock(); + if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockstate)) { +- p_23196_.destroyBlock(this.aboveFarmlandPos, true, p_23197_); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_23197_, this.f_23159_, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ p_23196_.m_46953_(this.f_23159_, true, p_23197_); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_23197_, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ p_23196_.destroyBlock(this.aboveFarmlandPos, true, p_23197_); + } + // CraftBukkit end } - if (blockstate.m_60795_() && block1 instanceof FarmBlock && p_23197_.m_35516_()) { + if (blockstate.isAir() && block1 instanceof FarmBlock && p_23197_.hasFarmSeeds()) { @@ -106,19 +_,33 @@ - ItemStack itemstack = simplecontainer.m_8020_(i); + ItemStack itemstack = simplecontainer.getItem(i); boolean flag = false; - if (!itemstack.m_41619_()) { + if (!itemstack.isEmpty()) { + // CraftBukkit start + Block planted = null; - if (itemstack.m_150930_(Items.f_42404_)) { -- p_23196_.m_7731_(this.f_23159_, Blocks.f_50092_.m_49966_(), 3); -+ planted = Blocks.f_50092_; + if (itemstack.is(Items.WHEAT_SEEDS)) { +- p_23196_.setBlock(this.aboveFarmlandPos, Blocks.WHEAT.defaultBlockState(), 3); ++ planted = Blocks.WHEAT; flag = true; - } else if (itemstack.m_150930_(Items.f_42620_)) { -- p_23196_.m_7731_(this.f_23159_, Blocks.f_50250_.m_49966_(), 3); -+ planted = Blocks.f_50250_; + } else if (itemstack.is(Items.POTATO)) { +- p_23196_.setBlock(this.aboveFarmlandPos, Blocks.POTATOES.defaultBlockState(), 3); ++ planted = Blocks.POTATOES; flag = true; - } else if (itemstack.m_150930_(Items.f_42619_)) { -- p_23196_.m_7731_(this.f_23159_, Blocks.f_50249_.m_49966_(), 3); -+ planted = Blocks.f_50249_; + } else if (itemstack.is(Items.CARROT)) { +- p_23196_.setBlock(this.aboveFarmlandPos, Blocks.CARROTS.defaultBlockState(), 3); ++ planted = Blocks.CARROTS; flag = true; - } else if (itemstack.m_150930_(Items.f_42733_)) { -- p_23196_.m_7731_(this.f_23159_, Blocks.f_50444_.m_49966_(), 3); -+ planted = Blocks.f_50444_; + } else if (itemstack.is(Items.BEETROOT_SEEDS)) { +- p_23196_.setBlock(this.aboveFarmlandPos, Blocks.BEETROOTS.defaultBlockState(), 3); ++ planted = Blocks.BEETROOTS; flag = true; - } -+ } else if (itemstack.m_41720_() instanceof net.minecraftforge.common.IPlantable) { -+ if (((net.minecraftforge.common.IPlantable)itemstack.m_41720_()).getPlantType(p_23196_, f_23159_) == net.minecraftforge.common.PlantType.CROP) { -+ p_23196_.m_7731_(f_23159_, ((net.minecraftforge.common.IPlantable)itemstack.m_41720_()).getPlant(p_23196_, f_23159_), 3); ++ } else if (itemstack.getItem() instanceof net.minecraftforge.common.IPlantable) { ++ if (((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlantType(p_23196_, aboveFarmlandPos) == net.minecraftforge.common.PlantType.CROP) { ++ p_23196_.setBlock(aboveFarmlandPos, ((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlant(p_23196_, aboveFarmlandPos), 3); + flag = true; + } + } + -+ if (planted != null && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_23197_, this.f_23159_, planted.m_49966_()).isCancelled()) { -+ p_23196_.m_7731_(this.f_23159_, planted.m_49966_(), 3); ++ if (planted != null && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_23197_, this.aboveFarmlandPos, planted.defaultBlockState()).isCancelled()) { ++ p_23196_.setBlock(this.aboveFarmlandPos, planted.defaultBlockState(), 3); + } else { + flag = false; + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java.patch index 5a4df3fc..91fab4bb 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java.patch @@ -2,29 +2,29 @@ +++ b/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java @@ -60,6 +_,13 @@ })) { - DoorBlock doorblock = (DoorBlock)blockstate.m_60734_(); - if (!doorblock.m_52815_(blockstate)) { + DoorBlock doorblock = (DoorBlock)blockstate.getBlock(); + if (!doorblock.isOpen(blockstate)) { + // CraftBukkit start - entities opening doors -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_23296_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_23296_.f_19853_, blockpos)); -+ p_23296_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_23296_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_23296_.level, blockpos)); ++ p_23296_.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - doorblock.m_153165_(p_23296_, p_23295_, blockstate, blockpos, true); + doorblock.setOpen(p_23296_, p_23295_, blockstate, blockpos, true); } @@ -73,6 +_,13 @@ })) { - DoorBlock doorblock1 = (DoorBlock)blockstate1.m_60734_(); - if (!doorblock1.m_52815_(blockstate1)) { + DoorBlock doorblock1 = (DoorBlock)blockstate1.getBlock(); + if (!doorblock1.isOpen(blockstate1)) { + // CraftBukkit start - entities opening doors -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_23296_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_23296_.f_19853_, blockpos1)); -+ p_23296_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_23296_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_23296_.level, blockpos1)); ++ p_23296_.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - doorblock1.m_153165_(p_23296_, p_23295_, blockstate1, blockpos1, true); - this.m_23325_(p_23295_, p_23296_, blockpos1); + doorblock1.setOpen(p_23296_, p_23295_, blockstate1, blockpos1, true); + this.rememberDoorToClose(p_23295_, p_23296_, blockpos1); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch index e873292c..86dba5c4 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java +++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java @@ -56,6 +_,13 @@ - return this.f_147718_.m_26885_(p_147737_, p_147789_); + return this.ramTargeting.test(p_147737_, p_147789_); }); }).ifPresent((p_147778_) -> { + // CraftBukkit start @@ -11,6 +11,6 @@ + } + p_147778_ = ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) event.getTarget()).getHandle(); + // CraftBukkit end - this.m_147765_(p_147737_, p_147778_); + this.chooseRamPosition(p_147737_, p_147778_); }); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch index 68511d18..9ee23eab 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch @@ -3,15 +3,15 @@ @@ -19,7 +_,13 @@ } - protected void m_6735_(ServerLevel p_23776_, Villager p_23777_, long p_23778_) { -- p_23777_.m_141967_(p_23777_.m_7141_().m_35565_(VillagerProfession.f_35585_)); + protected void start(ServerLevel p_23776_, Villager p_23777_, long p_23778_) { +- p_23777_.setVillagerData(p_23777_.getVillagerData().setProfession(VillagerProfession.NONE)); + // CraftBukkit start -+ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callVillagerCareerChangeEvent(p_23777_, org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.nmsToBukkitProfession(VillagerProfession.f_35585_), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); ++ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callVillagerCareerChangeEvent(p_23777_, org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.nmsToBukkitProfession(VillagerProfession.NONE), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); + if (event.isCancelled()) { + return; + } -+ p_23777_.m_141967_(p_23777_.m_7141_().m_35565_(org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.bukkitToNmsProfession(event.getProfession()))); ++ p_23777_.setVillagerData(p_23777_.getVillagerData().setProfession(org.bukkit.craftbukkit.v1_18_R2.entity.CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - p_23777_.m_35483_(p_23776_); + p_23777_.refreshBrain(p_23776_); } } 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 ad225442..c419b52d 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 @@ -3,9 +3,9 @@ @@ -42,7 +_,19 @@ } - private void m_24213_(E p_24214_, LivingEntity p_24215_) { -- p_24214_.m_6274_().m_21879_(MemoryModuleType.f_26372_, p_24215_); -- p_24214_.m_6274_().m_21936_(MemoryModuleType.f_26326_); + private void setAttackTarget(E p_24214_, LivingEntity p_24215_) { +- p_24214_.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, p_24215_); +- p_24214_.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); + // CraftBukkit start + org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(p_24214_, p_24215_, (p_24215_ instanceof net.minecraft.server.level.ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); + if (event.isCancelled()) { @@ -16,8 +16,8 @@ + + net.minecraftforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.minecraftforge.common.ForgeHooks.onLivingChangeTarget(p_24214_, p_24215_, net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); + if(!changeTargetEvent.isCanceled()) { -+ p_24214_.m_6274_().m_21879_(MemoryModuleType.f_26372_, changeTargetEvent.getNewTarget()); -+ p_24214_.m_6274_().m_21936_(MemoryModuleType.f_26326_); ++ p_24214_.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, changeTargetEvent.getNewTarget()); ++ p_24214_.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); + net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(p_24214_, changeTargetEvent.getNewTarget(), net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); // TODO: Remove in 1.20 + } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch index 43f2addd..2f465712 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch @@ -3,18 +3,18 @@ @@ -73,6 +_,17 @@ } - protected void m_24255_(E p_24256_) { + protected void clearAttackTarget(E p_24256_) { + // CraftBukkit start -+ LivingEntity old = p_24256_.m_6274_().m_21952_(MemoryModuleType.f_26372_).orElse(null); -+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(p_24256_, null, (old != null && !old.m_6084_()) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED : org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); ++ LivingEntity old = p_24256_.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); ++ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(p_24256_, null, (old != null && !old.isAlive()) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED : org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); + if (event.isCancelled()) { + return; + } + if (event.getTarget() != null) { -+ p_24256_.m_6274_().m_21879_(MemoryModuleType.f_26372_, ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) event.getTarget()).getHandle()); ++ p_24256_.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) event.getTarget()).getHandle()); + return; + } + // CraftBukkit end - this.f_147979_.accept(p_24256_); - p_24256_.m_6274_().m_21936_(MemoryModuleType.f_26372_); + this.onTargetErased.accept(p_24256_); + p_24256_.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch index 706980f4..4c6b2e2b 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch @@ -4,19 +4,19 @@ if (villager == null) { return Optional.empty(); } else { -- p_24657_.m_146762_(6000); -- p_24658_.m_146762_(6000); +- p_24657_.setAge(6000); +- p_24658_.setAge(6000); + // CraftBukkit start - call EntityBreedEvent - villager.m_146762_(-24000); - villager.m_7678_(p_24657_.m_20185_(), p_24657_.m_20186_(), p_24657_.m_20189_(), 0.0F, 0.0F); -- p_24656_.m_47205_(villager); + villager.setAge(-24000); + villager.moveTo(p_24657_.getX(), p_24657_.getY(), p_24657_.getZ(), 0.0F, 0.0F); +- p_24656_.addFreshEntityWithPassengers(villager); + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityBreedEvent(villager, p_24657_, p_24658_, null, null, 0).isCancelled()) { + return Optional.empty(); + } + // CraftBukkit end -+ p_24657_.m_146762_(6000); -+ p_24658_.m_146762_(6000); -+ p_24656_.m_47205_(villager); //Magma - fix villager breeding - p_24656_.m_7605_(villager, (byte)12); ++ p_24657_.setAge(6000); ++ p_24658_.setAge(6000); ++ p_24656_.addFreshEntityWithPassengers(villager); //Magma - fix villager breeding + p_24656_.broadcastEntityEvent(villager, (byte)12); return Optional.of(villager); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch index c75855c1..b9e087ab 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java +++ b/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java @@ -35,7 +_,7 @@ - private void m_24792_(ServerLevel p_24793_, Villager p_24794_, GlobalPos p_24795_, BlockState p_24796_) { - BlockPos blockpos = p_24795_.m_122646_(); - if (p_24796_.m_61143_(ComposterBlock.f_51913_) == 8) { -- p_24796_ = ComposterBlock.m_51998_(p_24796_, p_24793_, blockpos); + private void compostItems(ServerLevel p_24793_, Villager p_24794_, GlobalPos p_24795_, BlockState p_24796_) { + BlockPos blockpos = p_24795_.pos(); + if (p_24796_.getValue(ComposterBlock.LEVEL) == 8) { +- p_24796_ = ComposterBlock.extractProduce(p_24796_, p_24793_, blockpos); + p_24796_ = ComposterBlock.extractProduce(p_24796_, p_24793_, blockpos, p_24794_); // CraftBukkit } @@ -13,8 +13,8 @@ i -= l1; for(int i2 = 0; i2 < l1; ++i2) { -- blockstate = ComposterBlock.m_51929_(blockstate, p_24793_, itemstack, blockpos); +- blockstate = ComposterBlock.insertItem(blockstate, p_24793_, itemstack, blockpos); + blockstate = ComposterBlock.insertItem(blockstate, p_24793_, itemstack, blockpos, p_24794_); // CraftBukkit - if (blockstate.m_61143_(ComposterBlock.f_51913_) == 7) { - this.m_24797_(p_24793_, p_24796_, blockpos, blockstate); + if (blockstate.getValue(ComposterBlock.LEVEL) == 7) { + this.spawnComposterFillEffects(p_24793_, p_24796_, blockpos, blockstate); return; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/control/MoveControl.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/control/MoveControl.java.patch index a2dd305f..1efb4caf 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/control/MoveControl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/control/MoveControl.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/control/MoveControl.java +++ b/net/minecraft/world/entity/ai/control/MoveControl.java @@ -99,7 +_,7 @@ - BlockPos blockpos = this.f_24974_.m_142538_(); - BlockState blockstate = this.f_24974_.f_19853_.m_8055_(blockpos); - VoxelShape voxelshape = blockstate.m_60812_(this.f_24974_.f_19853_, blockpos); -- if (d2 > (double)this.f_24974_.f_19793_ && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.f_24974_.m_20205_()) || !voxelshape.m_83281_() && this.f_24974_.m_20186_() < voxelshape.m_83297_(Direction.Axis.Y) + (double)blockpos.m_123342_() && !blockstate.m_204336_(BlockTags.f_13103_) && !blockstate.m_204336_(BlockTags.f_13039_)) { -+ if (d2 > (double)this.f_24974_.getStepHeight() && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.f_24974_.m_20205_()) || !voxelshape.m_83281_() && this.f_24974_.m_20186_() < voxelshape.m_83297_(Direction.Axis.Y) + (double)blockpos.m_123342_() && !blockstate.m_204336_(BlockTags.f_13103_) && !blockstate.m_204336_(BlockTags.f_13039_)) { - this.f_24974_.m_21569_().m_24901_(); - this.f_24981_ = MoveControl.Operation.JUMPING; + BlockPos blockpos = this.mob.blockPosition(); + BlockState blockstate = this.mob.level.getBlockState(blockpos); + VoxelShape voxelshape = blockstate.getCollisionShape(this.mob.level, blockpos); +- if (d2 > (double)this.mob.maxUpStep && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.mob.getBbWidth()) || !voxelshape.isEmpty() && this.mob.getY() < voxelshape.max(Direction.Axis.Y) + (double)blockpos.getY() && !blockstate.is(BlockTags.DOORS) && !blockstate.is(BlockTags.FENCES)) { ++ if (d2 > (double)this.mob.getStepHeight() && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.mob.getBbWidth()) || !voxelshape.isEmpty() && this.mob.getY() < voxelshape.max(Direction.Axis.Y) + (double)blockpos.getY() && !blockstate.is(BlockTags.DOORS) && !blockstate.is(BlockTags.FENCES)) { + this.mob.getJumpControl().jump(); + this.operation = MoveControl.Operation.JUMPING; } 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 637c88f5..94926fb0 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,24 +1,24 @@ --- a/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java +++ b/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java @@ -30,7 +_,7 @@ - public boolean m_8036_() { - if (!super.m_8036_()) { + public boolean canUse() { + if (!super.canUse()) { return false; -- } else if (!this.f_25189_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ } else if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.f_25189_.f_19853_, this.f_25190_, this.f_25189_)) { +- } else if (!this.mob.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ } else if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.mob.level, this.doorPos, this.mob)) { return false; } else { - return this.m_25094_(this.f_25189_.f_19853_.m_46791_()) && !this.m_25200_(); + return this.isValidDifficulty(this.mob.level.getDifficulty()) && !this.isOpen(); @@ -68,6 +_,12 @@ } - if (this.f_25082_ == this.m_25100_() && this.m_25094_(this.f_25189_.f_19853_.m_46791_())) { + if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level.getDifficulty())) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityBreakDoorEvent(this.f_25189_, this.f_25190_).isCancelled()) { -+ this.m_8056_(); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos).isCancelled()) { ++ this.start(); + return; + } + // CraftBukkit end - this.f_25189_.f_19853_.m_7471_(this.f_25190_, false); - this.f_25189_.f_19853_.m_46796_(1021, this.f_25190_, 0); - this.f_25189_.f_19853_.m_46796_(2001, this.f_25190_, Block.m_49956_(this.f_25189_.f_19853_.m_8055_(this.f_25190_))); + this.mob.level.removeBlock(this.doorPos, false); + this.mob.level.levelEvent(1021, this.doorPos, 0); + this.mob.level.levelEvent(2001, this.doorPos, Block.getId(this.mob.level.getBlockState(this.doorPos))); 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 27d59ec6..4016063e 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 @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/ai/goal/EatBlockGoal.java +++ b/net/minecraft/world/entity/ai/goal/EatBlockGoal.java @@ -61,7 +_,7 @@ - if (this.f_25204_ == this.m_183277_(4)) { - BlockPos blockpos = this.f_25202_.m_142538_(); - if (f_25201_.test(this.f_25203_.m_8055_(blockpos))) { -- if (this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25203_, this.f_25202_) || (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_25202_, blockpos, Blocks.f_50016_.m_49966_(), !this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)).isCancelled())) { - this.f_25203_.m_46961_(blockpos, false); + 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) || (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockpos, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled())) { + this.level.destroyBlock(blockpos, false); } @@ -70,7 +_,7 @@ } else { - BlockPos blockpos1 = blockpos.m_7495_(); - if (this.f_25203_.m_8055_(blockpos1).m_60713_(Blocks.f_50440_)) { -- if (this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25203_, this.f_25202_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_25202_, blockpos1, Blocks.f_50016_.m_49966_(), !this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)).isCancelled()) { - this.f_25203_.m_46796_(2001, blockpos1, Block.m_49956_(Blocks.f_50440_.m_49966_())); - this.f_25203_.m_7731_(blockpos1, Blocks.f_50493_.m_49966_(), 2); + 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) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockpos1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { + 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/FloatGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch index 28e56f97..d323c25a 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch @@ -3,8 +3,8 @@ @@ -9,6 +_,7 @@ public FloatGoal(Mob p_25230_) { - this.f_25228_ = p_25230_; -+ if (f_25228_.m_20193_().paperConfig != null && f_25228_.m_20193_().paperConfig.nerfedMobsShouldJump) f_25228_.goalFloat = this; // Paper //Magma - null check - this.m_7021_(EnumSet.of(Goal.Flag.JUMP)); - p_25230_.m_21573_().m_7008_(true); + this.mob = p_25230_; ++ if (mob.getCommandSenderWorld().paperConfig != null && mob.getCommandSenderWorld().paperConfig.nerfedMobsShouldJump) mob.goalFloat = this; // Paper //Magma - null check + this.setFlags(EnumSet.of(Goal.Flag.JUMP)); + p_25230_.getNavigation().setCanFloat(true); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch index dbe68ba3..1c6fb9af 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java +++ b/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java @@ -117,7 +_,19 @@ - } else if (!this.m_25307_(new BlockPos(p_25304_, p_25305_, p_25306_))) { + } else if (!this.canTeleportTo(new BlockPos(p_25304_, p_25305_, p_25306_))) { return false; } else { -- this.f_25283_.m_7678_((double)p_25304_ + 0.5D, (double)p_25305_, (double)p_25306_ + 0.5D, this.f_25283_.m_146908_(), this.f_25283_.m_146909_()); +- this.tamable.moveTo((double)p_25304_ + 0.5D, (double)p_25305_, (double)p_25306_ + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); + // CraftBukkit start -+ org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity entity = this.f_25283_.getBukkitEntity(); -+ org.bukkit.Location to = new org.bukkit.Location(entity.getWorld(), (double) p_25304_ + 0.5D, (double) p_25305_, (double) p_25306_ + 0.5D, this.f_25283_.m_146908_(), this.f_25283_.m_146909_()); ++ org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity entity = this.tamable.getBukkitEntity(); ++ org.bukkit.Location to = new org.bukkit.Location(entity.getWorld(), (double) p_25304_ + 0.5D, (double) p_25305_, (double) p_25306_ + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); + org.bukkit.event.entity.EntityTeleportEvent event = new org.bukkit.event.entity.EntityTeleportEvent(entity, entity.getLocation(), to); -+ this.f_25283_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.tamable.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } + to = event.getTo(); + -+ this.f_25283_.m_7678_(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ this.tamable.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end + - this.f_25287_.m_26573_(); + this.navigation.stop(); return true; } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch index 00ea5e18..6b0ce180 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch @@ -1,39 +1,39 @@ --- a/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java +++ b/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java @@ -21,6 +_,8 @@ - private final int f_25549_ = 20; - private long f_25550_; - private static final long f_148125_ = 20L; + private final int attackInterval = 20; + private long lastCanUseCheck; + private static final long COOLDOWN_BETWEEN_CAN_USE_CHECKS = 20L; + private int failedPathFindingPenalty = 0; + private boolean canPenalize = false; public MeleeAttackGoal(PathfinderMob p_25552_, double p_25553_, boolean p_25554_) { - this.f_25540_ = p_25552_; + this.mob = p_25552_; @@ -41,6 +_,15 @@ - } else if (!livingentity.m_6084_()) { + } else if (!livingentity.isAlive()) { return false; } else { + if (canPenalize) { -+ if (--this.f_25547_ <= 0) { -+ this.f_25543_ = this.f_25540_.m_21573_().m_6570_(livingentity, 0); -+ this.f_25547_ = 4 + this.f_25540_.m_21187_().nextInt(7); -+ return this.f_25543_ != null; ++ if (--this.ticksUntilNextPathRecalculation <= 0) { ++ this.path = this.mob.getNavigation().createPath(livingentity, 0); ++ this.ticksUntilNextPathRecalculation = 4 + this.mob.getRandom().nextInt(7); ++ return this.path != null; + } else { + return true; + } + } - this.f_25543_ = this.f_25540_.m_21573_().m_6570_(livingentity, 0); - if (this.f_25543_ != null) { + this.path = this.mob.getNavigation().createPath(livingentity, 0); + if (this.path != null) { return true; @@ -98,6 +_,18 @@ - this.f_25545_ = livingentity.m_20186_(); - this.f_25546_ = livingentity.m_20189_(); - this.f_25547_ = 4 + this.f_25540_.m_21187_().nextInt(7); + this.pathedTargetY = livingentity.getY(); + this.pathedTargetZ = livingentity.getZ(); + this.ticksUntilNextPathRecalculation = 4 + this.mob.getRandom().nextInt(7); + if (this.canPenalize) { -+ this.f_25547_ += failedPathFindingPenalty; -+ if (this.f_25540_.m_21573_().m_26570_() != null) { -+ net.minecraft.world.level.pathfinder.Node finalPathPoint = this.f_25540_.m_21573_().m_26570_().m_77395_(); -+ if (finalPathPoint != null && livingentity.m_20275_(finalPathPoint.f_77271_, finalPathPoint.f_77272_, finalPathPoint.f_77273_) < 1) ++ this.ticksUntilNextPathRecalculation += failedPathFindingPenalty; ++ if (this.mob.getNavigation().getPath() != null) { ++ net.minecraft.world.level.pathfinder.Node finalPathPoint = this.mob.getNavigation().getPath().getEndNode(); ++ if (finalPathPoint != null && livingentity.distanceToSqr(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1) + failedPathFindingPenalty = 0; + else + failedPathFindingPenalty += 10; @@ -42,5 +42,5 @@ + } + } if (d0 > 1024.0D) { - this.f_25547_ += 10; + this.ticksUntilNextPathRecalculation += 10; } else if (d0 > 256.0D) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/PanicGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/PanicGoal.java.patch index c5943620..72db1bda 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/PanicGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/PanicGoal.java.patch @@ -3,13 +3,13 @@ @@ -73,6 +_,12 @@ } - public boolean m_8045_() { + public boolean canContinueToUse() { + // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly -+ if ((this.f_25684_.f_19797_ - this.f_25684_.f_20950_) > 100) { -+ this.f_25684_.m_6703_((net.minecraft.world.entity.LivingEntity) null); ++ if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) { ++ this.mob.setLastHurtByMob((net.minecraft.world.entity.LivingEntity) null); + return false; + } + // CraftBukkit end - return !this.f_25684_.m_21573_().m_26571_(); + return !this.mob.getNavigation().isDone(); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch index 29c76db0..12b87774 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch @@ -6,35 +6,35 @@ -public class RangedBowAttackGoal extends Goal { +public class RangedBowAttackGoal extends Goal { - private final T f_25782_; - private final double f_25783_; - private int f_25784_; + private final T mob; + private final double speedModifier; + private int attackIntervalMin; @@ -19,6 +_,10 @@ - private boolean f_25789_; - private int f_25790_ = -1; + private boolean strafingBackwards; + private int strafingTime = -1; + public RangedBowAttackGoal(M p_25792_, double p_25793_, int p_25794_, float p_25795_){ + this((T) p_25792_, p_25793_, p_25794_, p_25795_); + } + public RangedBowAttackGoal(T p_25792_, double p_25793_, int p_25794_, float p_25795_) { - this.f_25782_ = p_25792_; - this.f_25783_ = p_25793_; + this.mob = p_25792_; + this.speedModifier = p_25793_; @@ -36,7 +_,7 @@ } - protected boolean m_25803_() { -- return this.f_25782_.m_21055_(Items.f_42411_); -+ return this.f_25782_.m_21093_(is -> is.m_41720_() instanceof BowItem); + protected boolean isHoldingBow() { +- return this.mob.isHolding(Items.BOW); ++ return this.mob.isHolding(is -> is.getItem() instanceof BowItem); } - public boolean m_8045_() { + public boolean canContinueToUse() { @@ -121,7 +_,7 @@ } } - } else if (--this.f_25786_ <= 0 && this.f_25787_ >= -60) { -- this.f_25782_.m_6672_(ProjectileUtil.m_37297_(this.f_25782_, Items.f_42411_)); -+ this.f_25782_.m_6672_(ProjectileUtil.getWeaponHoldingHand(this.f_25782_, item -> item instanceof BowItem)); + } else if (--this.attackTime <= 0 && this.seeTime >= -60) { +- this.mob.startUsingItem(ProjectileUtil.getWeaponHoldingHand(this.mob, Items.BOW)); ++ this.mob.startUsingItem(ProjectileUtil.getWeaponHoldingHand(this.mob, item -> item instanceof BowItem)); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch index f72cfe47..781ea942 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch @@ -3,27 +3,27 @@ @@ -34,7 +_,7 @@ } - private boolean m_25821_() { -- return this.f_25805_.m_21055_(Items.f_42717_); -+ return this.f_25805_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem); + private boolean isHoldingCrossbow() { +- return this.mob.isHolding(Items.CROSSBOW); ++ return this.mob.isHolding(is -> is.getItem() instanceof CrossbowItem); } - public boolean m_8045_() { + public boolean canContinueToUse() { @@ -93,7 +_,7 @@ - this.f_25805_.m_21563_().m_24960_(livingentity, 30.0F, 30.0F); - if (this.f_25806_ == RangedCrossbowAttackGoal.CrossbowState.UNCHARGED) { + this.mob.getLookControl().setLookAt(livingentity, 30.0F, 30.0F); + if (this.crossbowState == RangedCrossbowAttackGoal.CrossbowState.UNCHARGED) { if (!flag2) { -- this.f_25805_.m_6672_(ProjectileUtil.m_37297_(this.f_25805_, Items.f_42717_)); -+ this.f_25805_.m_6672_(ProjectileUtil.getWeaponHoldingHand(this.f_25805_, item -> item instanceof CrossbowItem)); - this.f_25806_ = RangedCrossbowAttackGoal.CrossbowState.CHARGING; - this.f_25805_.m_6136_(true); +- this.mob.startUsingItem(ProjectileUtil.getWeaponHoldingHand(this.mob, Items.CROSSBOW)); ++ this.mob.startUsingItem(ProjectileUtil.getWeaponHoldingHand(this.mob, item -> item instanceof CrossbowItem)); + this.crossbowState = RangedCrossbowAttackGoal.CrossbowState.CHARGING; + this.mob.setChargingCrossbow(true); } @@ -117,7 +_,7 @@ } - } else if (this.f_25806_ == RangedCrossbowAttackGoal.CrossbowState.READY_TO_ATTACK && flag) { - this.f_25805_.m_6504_(livingentity, 1.0F); -- ItemStack itemstack1 = this.f_25805_.m_21120_(ProjectileUtil.m_37297_(this.f_25805_, Items.f_42717_)); -+ ItemStack itemstack1 = this.f_25805_.m_21120_(ProjectileUtil.getWeaponHoldingHand(this.f_25805_, item -> item instanceof CrossbowItem)); - CrossbowItem.m_40884_(itemstack1, false); - this.f_25806_ = RangedCrossbowAttackGoal.CrossbowState.UNCHARGED; + } else if (this.crossbowState == RangedCrossbowAttackGoal.CrossbowState.READY_TO_ATTACK && flag) { + this.mob.performRangedAttack(livingentity, 1.0F); +- ItemStack itemstack1 = this.mob.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this.mob, Items.CROSSBOW)); ++ ItemStack itemstack1 = this.mob.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this.mob, item -> item instanceof CrossbowItem)); + CrossbowItem.setCharged(itemstack1, false); + this.crossbowState = RangedCrossbowAttackGoal.CrossbowState.UNCHARGED; } 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 c0f16e7f..c015b6fe 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 @@ -3,35 +3,35 @@ @@ -34,7 +_,7 @@ } - public boolean m_8036_() { -- if (!this.f_25837_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25837_.f_19853_, this.f_25837_)) { + public boolean canUse() { +- if (!this.removerMob.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.removerMob.level, this.removerMob)) { return false; - } else if (this.f_25600_ > 0) { - --this.f_25600_; + } else if (this.nextStartTick > 0) { + --this.nextStartTick; @@ -93,6 +_,14 @@ } - if (this.f_25838_ > 60) { + if (this.ticksSinceReachedGoal > 60) { + // CraftBukkit start - Step on eggs -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(this.f_25837_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, blockpos1)); ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(this.removerMob.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, blockpos1)); + level.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) event); + + if (event.isCancelled()) { + return; + } + // CraftBukkit end - level.m_7471_(blockpos1, false); - if (!level.f_46443_) { + level.removeBlock(blockpos1, false); + if (!level.isClientSide) { for(int i = 0; i < 20; ++i) { @@ -133,7 +_,9 @@ if (chunkaccess == null) { return false; } else { -- return chunkaccess.m_8055_(p_25851_).m_60713_(this.f_25836_) && chunkaccess.m_8055_(p_25851_.m_7494_()).m_60795_() && chunkaccess.m_8055_(p_25851_.m_6630_(2)).m_60795_(); -+ net.minecraft.world.level.block.state.BlockState state = chunkaccess.m_8055_(p_25851_); -+ if (!(state.canEntityDestroy(p_25850_, p_25851_, this.f_25837_) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this.f_25837_, p_25851_, state))) return false; -+ return state.m_60713_(this.f_25836_) && chunkaccess.m_8055_(p_25851_.m_7494_()).m_60795_() && chunkaccess.m_8055_(p_25851_.m_6630_(2)).m_60795_(); +- return chunkaccess.getBlockState(p_25851_).is(this.blockToRemove) && chunkaccess.getBlockState(p_25851_.above()).isAir() && chunkaccess.getBlockState(p_25851_.above(2)).isAir(); ++ net.minecraft.world.level.block.state.BlockState state = chunkaccess.getBlockState(p_25851_); ++ if (!(state.canEntityDestroy(p_25850_, p_25851_, this.removerMob) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this.removerMob, p_25851_, state))) return false; ++ return state.is(this.blockToRemove) && chunkaccess.getBlockState(p_25851_.above()).isAir() && chunkaccess.getBlockState(p_25851_.above(2)).isAir(); } } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch index b5b9ff1f..c2de38d8 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java @@ -54,7 +_,8 @@ if (entity instanceof Player) { - int i = this.f_25884_.m_30624_(); - int j = this.f_25884_.m_7555_(); -- if (j > 0 && this.f_25884_.m_21187_().nextInt(j) < i) { + int i = this.horse.getTemper(); + int j = this.horse.getMaxTemper(); +- if (j > 0 && this.horse.getRandom().nextInt(j) < i) { + // CraftBukkit - fire EntityTameEvent -+ if (j > 0 && this.f_25884_.m_21187_().nextInt(j) < i && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(f_25884_, (Player)entity) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this.f_25884_, ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity) this.f_25884_.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { - this.f_25884_.m_30637_((Player)entity); ++ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(horse, (Player)entity) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { + this.horse.tameWithName((Player)entity); return; } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch index 2c673258..36cb620e 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java @@ -18,7 +_,7 @@ - public boolean m_8036_() { - if (!this.f_25896_.m_21824_()) { + public boolean canUse() { + if (!this.mob.isTame()) { - return false; -+ return this.f_25896_.m_21827_() && this.f_25896_.m_5448_() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.f_25896_.m_20072_()) { ++ return this.mob.isOrderedToSit() && this.mob.getTarget() == null; // CraftBukkit - Allow sitting for wild animals + } else if (this.mob.isInWaterOrBubble()) { return false; - } else if (!this.f_25896_.m_20096_()) { + } else if (!this.mob.isOnGround()) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch index a20d69d1..c4f16bd9 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/entity/ai/goal/TemptGoal.java +++ b/net/minecraft/world/entity/ai/goal/TemptGoal.java @@ -19,7 +_,7 @@ - private double f_25931_; - private double f_25932_; + private double pRotX; + private double pRotY; @Nullable -- protected Player f_25925_; -+ protected Player f_25925_; // CraftBukkit - private int f_25933_; - private boolean f_25934_; - private final Ingredient f_25935_; +- protected Player player; ++ protected Player player; // CraftBukkit + private int calmDown; + private boolean isRunning; + private final Ingredient items; @@ -40,6 +_,15 @@ return false; } else { - this.f_25925_ = this.f_25924_.f_19853_.m_45946_(this.f_148137_, this.f_25924_); + this.player = this.mob.level.getNearestPlayer(this.targetingConditions, this.mob); + // CraftBukkit start -+ if (this.f_25925_ != null) { -+ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(this.f_25924_, this.f_25925_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TEMPT); ++ if (this.player != null) { ++ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TEMPT); + if (event.isCancelled()) { + return false; + } -+ this.f_25925_ = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) event.getTarget()).getHandle(); // Magma - Quark Fix ++ this.player = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) event.getTarget()).getHandle(); // Magma - Quark Fix + } + // CraftBukkit end - return this.f_25925_ != null; + return this.player != null; } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch index 2be61cc2..3df7cad4 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch @@ -3,9 +3,9 @@ @@ -47,7 +_,7 @@ } - public void m_8056_() { -- this.f_26025_.m_6710_(this.f_26026_); -+ this.f_26025_.setTarget(this.f_26026_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason - super.m_8056_(); + public void start() { +- this.golem.setTarget(this.potentialTarget); ++ this.golem.setTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason + super.start(); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch index 1df8cf66..f6bbac2a 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch @@ -3,17 +3,17 @@ @@ -57,7 +_,7 @@ } - public void m_8056_() { -- this.f_26135_.m_6710_(this.f_26135_.m_142581_()); -+ this.f_26135_.setTarget(this.f_26135_.m_142581_(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason - this.f_26137_ = this.f_26135_.m_5448_(); - this.f_26034_ = this.f_26135_.m_21213_(); - this.f_26138_ = 300; + public void start() { +- this.mob.setTarget(this.mob.getLastHurtByMob()); ++ this.mob.setTarget(this.mob.getLastHurtByMob(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason + this.targetMob = this.mob.getTarget(); + this.timestamp = this.mob.getLastHurtByMobTimestamp(); + this.unseenMemoryTicks = 300; @@ -107,6 +_,6 @@ } - protected void m_5766_(Mob p_26042_, LivingEntity p_26043_) { -- p_26042_.m_6710_(p_26043_); + protected void alertOther(Mob p_26042_, LivingEntity p_26043_) { +- p_26042_.setTarget(p_26043_); + p_26042_.setTarget(p_26043_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch index 07723026..8084d06e 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch @@ -3,9 +3,9 @@ @@ -64,7 +_,7 @@ } - public void m_8056_() { -- this.f_26135_.m_6710_(this.f_26050_); -+ this.f_26135_.setTarget(this.f_26050_, f_26050_ instanceof ServerPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason - super.m_8056_(); + public void start() { +- this.mob.setTarget(this.target); ++ this.mob.setTarget(this.target, target instanceof ServerPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason + super.start(); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch index f1968896..bb25f4ef 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch @@ -3,9 +3,9 @@ @@ -33,7 +_,7 @@ } - public void m_8056_() { -- this.f_26135_.m_6710_(this.f_26104_); -+ this.f_26135_.setTarget(this.f_26104_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason - LivingEntity livingentity = this.f_26103_.m_142480_(); + public void start() { +- this.mob.setTarget(this.ownerLastHurtBy); ++ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason + LivingEntity livingentity = this.tameAnimal.getOwner(); if (livingentity != null) { - this.f_26105_ = livingentity.m_21213_(); + this.timestamp = livingentity.getLastHurtByMobTimestamp(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch index c9a6ae65..48cc003e 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch @@ -3,9 +3,9 @@ @@ -33,7 +_,7 @@ } - public void m_8056_() { -- this.f_26135_.m_6710_(this.f_26111_); -+ this.f_26135_.setTarget(this.f_26111_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason - LivingEntity livingentity = this.f_26110_.m_142480_(); + public void start() { +- this.mob.setTarget(this.ownerLastHurt); ++ this.mob.setTarget(this.ownerLastHurt, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason + LivingEntity livingentity = this.tameAnimal.getOwner(); if (livingentity != null) { - this.f_26112_ = livingentity.m_21215_(); + this.timestamp = livingentity.getLastHurtMobTimestamp(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch index 902f0949..f0936e52 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch @@ -4,17 +4,17 @@ } } -- this.f_26135_.m_6710_(livingentity); -+ this.f_26135_.setTarget(livingentity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit +- this.mob.setTarget(livingentity); ++ this.mob.setTarget(livingentity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit return true; } } @@ -80,7 +_,7 @@ } - public void m_8041_() { -- this.f_26135_.m_6710_((LivingEntity)null); -+ this.f_26135_.setTarget((LivingEntity)null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - this.f_26137_ = null; + public void stop() { +- this.mob.setTarget((LivingEntity)null); ++ this.mob.setTarget((LivingEntity)null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit + this.targetMob = null; } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch index 3998bb3b..09cee90a 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/memory/MemoryModuleType.java.patch @@ -6,6 +6,6 @@ -public class MemoryModuleType { +public class MemoryModuleType extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final MemoryModuleType f_26349_ = m_26388_("dummy"); - public static final MemoryModuleType f_26359_ = m_26390_("home", GlobalPos.f_122633_); - public static final MemoryModuleType f_26360_ = m_26390_("job_site", GlobalPos.f_122633_); + public static final MemoryModuleType DUMMY = register("dummy"); + public static final MemoryModuleType HOME = register("home", GlobalPos.CODEC); + public static final MemoryModuleType JOB_SITE = register("job_site", GlobalPos.CODEC); 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 0627cb0f..3d8fca1d 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,16 +1,16 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java @@ -225,10 +_,10 @@ - Vec3 vec3 = this.m_7475_(); - this.f_26505_ = this.f_26494_.m_20205_() > 0.75F ? this.f_26494_.m_20205_() / 2.0F : 0.75F - this.f_26494_.m_20205_() / 2.0F; - Vec3i vec3i = this.f_26496_.m_77400_(); -- double d0 = Math.abs(this.f_26494_.m_20185_() - ((double)vec3i.m_123341_() + 0.5D)); -+ double d0 = Math.abs(this.f_26494_.m_20185_() - ((double)vec3i.m_123341_() + (this.f_26494_.m_20205_() + 1) / 2D)); //Forge: Fix MC-94054 - double d1 = Math.abs(this.f_26494_.m_20186_() - (double)vec3i.m_123342_()); -- double d2 = Math.abs(this.f_26494_.m_20189_() - ((double)vec3i.m_123343_() + 0.5D)); -- boolean flag = d0 < (double)this.f_26505_ && d2 < (double)this.f_26505_ && d1 < 1.0D; -+ double d2 = Math.abs(this.f_26494_.m_20189_() - ((double)vec3i.m_123343_() + (this.f_26494_.m_20205_() + 1) / 2D)); //Forge: Fix MC-94054 -+ boolean flag = d0 <= (double)this.f_26505_ && d2 <= (double)this.f_26505_ && d1 < 1.0D; //Forge: Fix MC-94054 - if (flag || this.f_26494_.m_21481_(this.f_26496_.m_77401_().f_77282_) && this.m_26559_(vec3)) { - this.f_26496_.m_77374_(); + 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(); +- double d0 = Math.abs(this.mob.getX() - ((double)vec3i.getX() + 0.5D)); ++ double d0 = Math.abs(this.mob.getX() - ((double)vec3i.getX() + (this.mob.getBbWidth() + 1) / 2D)); //Forge: Fix MC-94054 + double d1 = Math.abs(this.mob.getY() - (double)vec3i.getY()); +- double d2 = Math.abs(this.mob.getZ() - ((double)vec3i.getZ() + 0.5D)); +- boolean flag = d0 < (double)this.maxDistanceToWaypoint && d2 < (double)this.maxDistanceToWaypoint && d1 < 1.0D; ++ double d2 = Math.abs(this.mob.getZ() - ((double)vec3i.getZ() + (this.mob.getBbWidth() + 1) / 2D)); //Forge: Fix MC-94054 ++ boolean flag = d0 <= (double)this.maxDistanceToWaypoint && d2 <= (double)this.maxDistanceToWaypoint && d1 < 1.0D; //Forge: Fix MC-94054 + if (flag || this.mob.canCutCorner(this.path.getNextNode().type) && this.shouldTargetNextNodeInDirection(vec3)) { + this.path.advance(); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch index c26f6f14..ed48a8d2 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java @@ -41,7 +_,8 @@ - super.m_7638_(); + super.tick(); } else { - if (this.f_26578_ != null) { -- if (!this.f_26578_.m_203195_(this.f_26494_.m_20182_(), (double)this.f_26494_.m_20205_()) && (!(this.f_26494_.m_20186_() > (double)this.f_26578_.m_123342_()) || !(new BlockPos((double)this.f_26578_.m_123341_(), this.f_26494_.m_20186_(), (double)this.f_26578_.m_123343_())).m_203195_(this.f_26494_.m_20182_(), (double)this.f_26494_.m_20205_()))) { + if (this.pathToPosition != null) { +- if (!this.pathToPosition.closerToCenterThan(this.mob.position(), (double)this.mob.getBbWidth()) && (!(this.mob.getY() > (double)this.pathToPosition.getY()) || !(new BlockPos((double)this.pathToPosition.getX(), this.mob.getY(), (double)this.pathToPosition.getZ())).closerToCenterThan(this.mob.position(), (double)this.mob.getBbWidth()))) { + // FORGE: Fix MC-94054 -+ if (!this.f_26578_.m_203195_(this.f_26494_.m_20182_(), Math.max((double)this.f_26494_.m_20205_(), 1.0D)) && (!(this.f_26494_.m_20186_() > (double)this.f_26578_.m_123342_()) || !(new BlockPos((double)this.f_26578_.m_123341_(), this.f_26494_.m_20186_(), (double)this.f_26578_.m_123343_())).m_203195_(this.f_26494_.m_20182_(), Math.max((double)this.f_26494_.m_20205_(), 1.0D)))) { - this.f_26494_.m_21566_().m_6849_((double)this.f_26578_.m_123341_(), (double)this.f_26578_.m_123342_(), (double)this.f_26578_.m_123343_(), this.f_26497_); ++ if (!this.pathToPosition.closerToCenterThan(this.mob.position(), Math.max((double)this.mob.getBbWidth(), 1.0D)) && (!(this.mob.getY() > (double)this.pathToPosition.getY()) || !(new BlockPos((double)this.pathToPosition.getX(), this.mob.getY(), (double)this.pathToPosition.getZ())).closerToCenterThan(this.mob.position(), Math.max((double)this.mob.getBbWidth(), 1.0D)))) { + this.mob.getMoveControl().setWantedPosition((double)this.pathToPosition.getX(), (double)this.pathToPosition.getY(), (double)this.pathToPosition.getZ(), this.speedModifier); } else { - this.f_26578_ = null; + this.pathToPosition = null; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch index a733b975..632781fe 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/sensing/SensorType.java.patch @@ -6,6 +6,6 @@ -public class SensorType> { +public class SensorType> extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final SensorType f_26809_ = m_26828_("dummy", DummySensor::new); - public static final SensorType f_26810_ = m_26828_("nearest_items", NearestItemSensor::new); - public static final SensorType f_26811_ = m_26828_("nearest_living_entities", NearestLivingEntitySensor::new); + public static final SensorType DUMMY = register("dummy", DummySensor::new); + public static final SensorType NEAREST_ITEMS = register("nearest_items", NearestItemSensor::new); + public static final SensorType NEAREST_LIVING_ENTITIES = register("nearest_living_entities", NearestLivingEntitySensor::new); 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 0407ad18..d009c7aa 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 @@ -1,30 +1,30 @@ --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java @@ -78,7 +_,9 @@ - this.f_27002_ = blockpos.m_123341_() + Mth.m_14143_(Mth.m_14089_(f) * 32.0F); - this.f_27003_ = blockpos.m_123342_(); - this.f_27004_ = blockpos.m_123343_() + Mth.m_14143_(Mth.m_14031_(f) * 32.0F); -- if (this.m_27009_(p_27008_, new BlockPos(this.f_27002_, this.f_27003_, this.f_27004_)) != null) { -+ Vec3 siegeLocation = this.m_27009_(p_27008_, new BlockPos(this.f_27002_, this.f_27003_, this.f_27004_)); + this.spawnX = blockpos.getX() + Mth.floor(Mth.cos(f) * 32.0F); + this.spawnY = blockpos.getY(); + this.spawnZ = blockpos.getZ() + Mth.floor(Mth.sin(f) * 32.0F); +- if (this.findRandomSpawnPos(p_27008_, new BlockPos(this.spawnX, this.spawnY, this.spawnZ)) != null) { ++ Vec3 siegeLocation = this.findRandomSpawnPos(p_27008_, new BlockPos(this.spawnX, this.spawnY, this.spawnZ)); + if (siegeLocation != null) { + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.village.VillageSiegeEvent(this, p_27008_, player, siegeLocation))) return false; - this.f_27001_ = 0; - this.f_27000_ = 20; + this.nextSpawnTime = 0; + this.zombiesToSpawn = 20; break; @@ -98,7 +_,7 @@ if (vec3 != null) { Zombie zombie; try { - zombie = new Zombie(p_27017_); -+ zombie = EntityType.f_20501_.m_20615_(p_27017_); //Forge: Direct Initialization is deprecated, use EntityType. - zombie.m_6518_(p_27017_, p_27017_.m_6436_(zombie.m_142538_()), MobSpawnType.EVENT, (SpawnGroupData)null, (CompoundTag)null); ++ zombie = EntityType.ZOMBIE.create(p_27017_); //Forge: Direct Initialization is deprecated, use EntityType. + zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.EVENT, (SpawnGroupData)null, (CompoundTag)null); } catch (Exception exception) { - f_26997_.warn("Failed to create zombie for village siege at {}", vec3, exception); + LOGGER.warn("Failed to create zombie for village siege at {}", vec3, exception); @@ -106,6 +_,7 @@ } - zombie.m_7678_(vec3.f_82479_, vec3.f_82480_, vec3.f_82481_, p_27017_.f_46441_.nextFloat() * 360.0F, 0.0F); + zombie.moveTo(vec3.x, vec3.y, vec3.z, p_27017_.random.nextFloat() * 360.0F, 0.0F); + p_27017_.prepareEntity(zombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); //Magma - add spawn reason - p_27017_.m_47205_(zombie); + p_27017_.addFreshEntityWithPassengers(zombie); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch index b591fcd1..7106e636 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiType.java.patch @@ -6,36 +6,36 @@ -public class PoiType { +public class PoiType extends net.minecraftforge.registries.ForgeRegistryEntry { - private static final Supplier> f_27353_ = Suppliers.memoize(() -> { - return Registry.f_122869_.m_123024_().map(VillagerProfession::m_35622_).collect(Collectors.toSet()); + private static final Supplier> ALL_JOB_POI_TYPES = Suppliers.memoize(() -> { + return Registry.VILLAGER_PROFESSION.stream().map(VillagerProfession::getJobPoiType).collect(Collectors.toSet()); }); @@ -39,7 +_,7 @@ - private static final Set f_148686_ = ImmutableList.of(Blocks.f_50256_, Blocks.f_152477_, Blocks.f_152476_, Blocks.f_152478_).stream().flatMap((p_148697_) -> { - return p_148697_.m_49965_().m_61056_().stream(); + private static final Set CAULDRONS = ImmutableList.of(Blocks.CAULDRON, Blocks.LAVA_CAULDRON, Blocks.WATER_CAULDRON, Blocks.POWDER_SNOW_CAULDRON).stream().flatMap((p_148697_) -> { + return p_148697_.getStateDefinition().getPossibleStates().stream(); }).collect(ImmutableSet.toImmutableSet()); -- private static final Map f_27323_ = Maps.newHashMap(); -+ private static final Map f_27323_ = net.minecraftforge.registries.GameData.getBlockStatePointOfInterestTypeMap(); - public static final PoiType f_27331_ = m_27379_("unemployed", ImmutableSet.of(), 1, f_27329_, 1); - public static final PoiType f_27332_ = m_27374_("armorer", m_27372_(Blocks.f_50620_), 1, 1); - public static final PoiType f_27333_ = m_27374_("butcher", m_27372_(Blocks.f_50619_), 1, 1); +- private static final Map TYPE_BY_STATE = Maps.newHashMap(); ++ private static final Map TYPE_BY_STATE = net.minecraftforge.registries.GameData.getBlockStatePointOfInterestTypeMap(); + public static final PoiType UNEMPLOYED = register("unemployed", ImmutableSet.of(), 1, ALL_JOBS, 1); + public static final PoiType ARMORER = register("armorer", getBlockStates(Blocks.BLAST_FURNACE), 1, 1); + public static final PoiType BUTCHER = register("butcher", getBlockStates(Blocks.SMOKER), 1, 1); @@ -124,16 +_,14 @@ } - private static PoiType m_27367_(PoiType p_27368_) { -- p_27368_.f_27325_.forEach((p_148691_) -> { -- PoiType poitype = f_27323_.put(p_148691_, p_27368_); + private static PoiType registerBlockStates(PoiType p_27368_) { +- p_27368_.matchingStates.forEach((p_148691_) -> { +- PoiType poitype = TYPE_BY_STATE.put(p_148691_, p_27368_); - if (poitype != null) { -- throw (IllegalStateException)Util.m_137570_(new IllegalStateException(String.format("%s is defined in too many tags", p_148691_))); +- throw (IllegalStateException)Util.pauseInIde(new IllegalStateException(String.format("%s is defined in too many tags", p_148691_))); - } - }); return p_27368_; } - public static Optional m_27390_(BlockState p_27391_) { - return Optional.ofNullable(f_27323_.get(p_27391_)); + public static Optional forState(BlockState p_27391_) { + return Optional.ofNullable(TYPE_BY_STATE.get(p_27391_)); + } + + public ImmutableSet getBlockStates() { -+ return ImmutableSet.copyOf(this.f_27325_); ++ return ImmutableSet.copyOf(this.matchingStates); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ambient/Bat.java.patch b/patches/minecraft/net/minecraft/world/entity/ambient/Bat.java.patch index 9f39688f..5f344c2a 100644 --- a/patches/minecraft/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ambient/Bat.java.patch @@ -3,12 +3,12 @@ @@ -123,16 +_,24 @@ } - if (this.f_19853_.m_45946_(f_27408_, this) != null) { + if (this.level.getNearestPlayer(BAT_RESTING_TARGETING, this) != null) { + // CraftBukkit Start - Call BatToggleSleepEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { -+ this.m_27456_(false); ++ this.setResting(false); + if (!flag) { -+ this.f_19853_.m_5898_((Player) null, 1025, blockpos, 0); ++ this.level.levelEvent((Player) null, 1025, blockpos, 0); + } + } + // CraftBukkit End @@ -16,28 +16,28 @@ + } else { + // CraftBukkit Start - Call BatToggleSleepEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { - this.m_27456_(false); + this.setResting(false); if (!flag) { - this.f_19853_.m_5898_((Player)null, 1025, blockpos, 0); + this.level.levelEvent((Player)null, 1025, blockpos, 0); } } - } else { -- this.m_27456_(false); +- this.setResting(false); - if (!flag) { -- this.f_19853_.m_5898_((Player)null, 1025, blockpos, 0); +- this.level.levelEvent((Player)null, 1025, blockpos, 0); - } + // CraftBukkit End - Call BatToggleSleepEvent } } else { - if (this.f_27409_ != null && (!this.f_19853_.m_46859_(this.f_27409_) || this.f_27409_.m_123342_() <= this.f_19853_.m_141937_())) { + if (this.targetPosition != null && (!this.level.isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) { @@ -154,7 +_,11 @@ - this.f_20902_ = 0.5F; - this.m_146922_(this.m_146908_() + f1); - if (this.f_19796_.nextInt(100) == 0 && this.f_19853_.m_8055_(blockpos1).m_60796_(this.f_19853_, blockpos1)) { -- this.m_27456_(true); + this.zza = 0.5F; + this.setYRot(this.getYRot() + f1); + if (this.random.nextInt(100) == 0 && this.level.getBlockState(blockpos1).isRedstoneConductor(this.level, blockpos1)) { +- this.setResting(true); + // CraftBukkit Start - Call BatToggleSleepEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBatToggleSleepEvent(this, false)) { -+ this.m_27456_(true); ++ this.setResting(true); + } + // CraftBukkit End } @@ -46,13 +46,13 @@ @@ -180,7 +_,11 @@ return false; } else { - if (!this.f_19853_.f_46443_ && this.m_27452_()) { -- this.m_27456_(false); + if (!this.level.isClientSide && this.isResting()) { +- this.setResting(false); + // CraftBukkit Start - Call BatToggleSleepEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { -+ this.m_27456_(false); ++ this.setResting(false); + } + // CraftBukkit End - Call BatToggleSleepEvent } - return super.m_6469_(p_27424_, p_27425_); + return super.hurt(p_27424_, p_27425_); 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 8ab6888a..0b1f214d 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,79 +1,74 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java @@ -35,6 +_,7 @@ - public int f_27554_; + public int inLove; @Nullable - public UUID f_27555_; + public UUID loveCause; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable protected Animal(EntityType p_27557_, Level p_27558_) { super(p_27557_, p_27558_); -@@ -68,14 +_,18 @@ +@@ -68,6 +_,9 @@ } -- public boolean m_6469_(DamageSource p_27567_, float p_27568_) { -- if (this.m_6673_(p_27567_)) { + /* CraftBukkit start + // Function disabled as it has no special function anymore after + // setSitting is disabled. -+ public boolean hurt(DamageSource p_27567_, float p_27568_) { -+ if (this.isInvulnerableTo(p_27567_)) { + public boolean hurt(DamageSource p_27567_, float p_27568_) { + if (this.isInvulnerableTo(p_27567_)) { return false; - } else { -- this.f_27554_ = 0; -- return super.m_6469_(p_27567_, p_27568_); -+ this.inLove = 0; -+ return super.hurt(p_27567_, p_27568_); +@@ -76,6 +_,7 @@ + return super.hurt(p_27567_, p_27568_); } } + // CraftBukkit end */ - public float m_5610_(BlockPos p_27573_, LevelReader p_27574_) { - return p_27574_.m_8055_(p_27573_.m_7495_()).m_60713_(Blocks.f_50440_) ? 10.0F : p_27574_.m_46863_(p_27573_) - 0.5F; + public float getWalkTargetValue(BlockPos p_27573_, LevelReader p_27574_) { + return p_27574_.getBlockState(p_27573_.below()).is(Blocks.GRASS_BLOCK) ? 10.0F : p_27574_.getBrightness(p_27573_) - 0.5F; @@ -162,9 +_,17 @@ } - public void m_27595_(@Nullable Player p_27596_) { + public void setInLove(@Nullable Player p_27596_) { + // CraftBukkit start + org.bukkit.event.entity.EntityEnterLoveModeEvent entityEnterLoveModeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityEnterLoveModeEvent(p_27596_, this, 600); + if (entityEnterLoveModeEvent.isCancelled()) { + return; + } -+ this.f_27554_ = entityEnterLoveModeEvent.getTicksInLove(); ++ this.inLove = entityEnterLoveModeEvent.getTicksInLove(); + // CraftBukkit end - this.f_27554_ = 600; + this.inLove = 600; if (p_27596_ != null) { - this.f_27555_ = p_27596_.m_142081_(); -+ this.breedItem = p_27596_.m_150109_().m_36056_(); // CraftBukkit //Magma - move inside if statement + this.loveCause = p_27596_.getUUID(); ++ this.breedItem = p_27596_.getInventory().getSelected(); // CraftBukkit //Magma - move inside if statement } - this.f_19853_.m_7605_(this, (byte)18); + this.level.broadcastEntityEvent(this, (byte)18); @@ -208,12 +_,34 @@ - public void m_27563_(ServerLevel p_27564_, Animal p_27565_) { - AgeableMob ageablemob = this.m_142606_(p_27564_, p_27565_); + public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) { + AgeableMob ageablemob = this.getBreedOffspring(p_27564_, p_27565_); + final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(this, p_27565_, ageablemob); + final boolean cancelled = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + ageablemob = event.getChild(); + if (cancelled) { + //Reset the "inLove" state for the animals -+ this.m_146762_(6000); -+ p_27565_.m_146762_(6000); -+ this.m_27594_(); -+ p_27565_.m_27594_(); ++ this.setAge(6000); ++ p_27565_.setAge(6000); ++ this.resetLove(); ++ p_27565_.resetLove(); + return; + } if (ageablemob != null) { - ServerPlayer serverplayer = this.m_27592_(); - if (serverplayer == null && p_27565_.m_27592_() != null) { - serverplayer = p_27565_.m_27592_(); + ServerPlayer serverplayer = this.getLoveCause(); + if (serverplayer == null && p_27565_.getLoveCause() != null) { + serverplayer = p_27565_.getLoveCause(); } + // CraftBukkit start - call EntityBreedEvent -+ ageablemob.m_6863_(true); -+ ageablemob.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), 0.0F, 0.0F); -+ int experience = this.m_21187_().nextInt(7) + 1; ++ ageablemob.setBaby(true); ++ ageablemob.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); ++ int experience = this.getRandom().nextInt(7) + 1; + org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityBreedEvent(ageablemob, this, p_27565_, serverplayer, this.breedItem, experience); + if (entityBreedEvent.isCancelled()) { + return; @@ -82,22 +77,22 @@ + // CraftBukkit end + if (serverplayer != null) { - serverplayer.m_36220_(Stats.f_12937_); - CriteriaTriggers.f_10581_.m_147278_(serverplayer, this, p_27565_, ageablemob); + serverplayer.awardStat(Stats.ANIMALS_BRED); + CriteriaTriggers.BRED_ANIMALS.trigger(serverplayer, this, p_27565_, ageablemob); @@ -223,12 +_,15 @@ - p_27565_.m_146762_(6000); - this.m_27594_(); - p_27565_.m_27594_(); -- ageablemob.m_6863_(true); -- ageablemob.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), 0.0F, 0.0F); + p_27565_.setAge(6000); + this.resetLove(); + p_27565_.resetLove(); +- ageablemob.setBaby(true); +- ageablemob.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); + p_27564_.prepareEntity(ageablemob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); //Magma - add spawn reason - p_27564_.m_47205_(ageablemob); - p_27564_.m_7605_(this, (byte)18); - if (p_27564_.m_46469_().m_46207_(GameRules.f_46135_)) { -- p_27564_.m_7967_(new ExperienceOrb(p_27564_, this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_21187_().nextInt(7) + 1)); + p_27564_.addFreshEntityWithPassengers(ageablemob); + p_27564_.broadcastEntityEvent(this, (byte)18); + if (p_27564_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- p_27564_.addFreshEntity(new ExperienceOrb(p_27564_, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ p_27564_.m_7967_(new ExperienceOrb(p_27564_, this.m_20185_(), this.m_20186_(), this.m_20189_(), experience)); ++ p_27564_.addFreshEntity(new ExperienceOrb(p_27564_, this.getX(), this.getY(), this.getZ(), experience)); + } + // CraftBukkit end } 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 ab61c09a..ed6ba368 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -4,53 +4,53 @@ } if (i > 0) { -- ((LivingEntity)p_27722_).m_147207_(new MobEffectInstance(MobEffects.f_19614_, i * 20, 0), this); +- ((LivingEntity)p_27722_).addEffect(new MobEffectInstance(MobEffects.POISON, i * 20, 0), this); + ((LivingEntity)p_27722_).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ ((LivingEntity)p_27722_).m_147207_(new MobEffectInstance(MobEffects.f_19614_, i * 20, 0), this); // CraftBukkit ++ ((LivingEntity)p_27722_).addEffect(new MobEffectInstance(MobEffects.POISON, i * 20, 0), this); // CraftBukkit } } @@ -471,7 +_,7 @@ return false; } else { - BlockEntity blockentity = this.f_19853_.m_7702_(this.f_27698_); -- return blockentity != null && blockentity.m_58903_() == BlockEntityType.f_58912_; + BlockEntity blockentity = this.level.getBlockEntity(this.hivePos); +- return blockentity != null && blockentity.getType() == BlockEntityType.BEEHIVE; + return blockentity instanceof BeehiveBlockEntity; } } @@ -601,11 +_,15 @@ - if (this.m_6673_(p_27762_)) { + if (this.isInvulnerableTo(p_27762_)) { return false; } else { -- if (!this.f_19853_.f_46443_) { +- if (!this.level.isClientSide) { + // CraftBukkit start -+ boolean result = super.m_6469_(p_27762_, p_27763_); ++ boolean result = super.hurt(p_27762_, p_27763_); + -+ if (result && !this.f_19853_.f_46443_) { - this.f_27699_.m_28087_(); ++ if (result && !this.level.isClientSide) { + this.beePollinateGoal.stopPollinating(); } -- return super.m_6469_(p_27762_, p_27763_); +- return super.hurt(p_27762_, p_27763_); + return result; + // CraftBukkit end } } @@ -917,7 +_,7 @@ - ((BonemealableBlock)blockstate.m_60734_()).m_7719_((ServerLevel)Bee.this.f_19853_, Bee.this.f_19796_, blockpos, blockstate); + ((BonemealableBlock)blockstate.getBlock()).performBonemeal((ServerLevel)Bee.this.level, Bee.this.random, blockpos, blockstate); } - if (flag) { -+ if (flag && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(Bee.this, blockpos, blockstate.m_61124_(integerproperty, (Integer) blockstate.m_61143_(integerproperty) + 1)).isCancelled()) { // Spigot - Bee.this.f_19853_.m_46796_(2005, blockpos, 0); - Bee.this.f_19853_.m_46597_(blockpos, blockstate.m_61124_(integerproperty, Integer.valueOf(blockstate.m_61143_(integerproperty) + 1))); - Bee.this.m_27871_(); ++ if (flag && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(Bee.this, blockpos, blockstate.setValue(integerproperty, (Integer) blockstate.getValue(integerproperty) + 1)).isCancelled()) { // Spigot + Bee.this.level.levelEvent(2005, blockpos, 0); + Bee.this.level.setBlockAndUpdate(blockpos, blockstate.setValue(integerproperty, Integer.valueOf(blockstate.getValue(integerproperty) + 1))); + Bee.this.incrementNumCropsGrownSincePollination(); @@ -940,7 +_,7 @@ - protected void m_5766_(Mob p_28035_, LivingEntity p_28036_) { - if (p_28035_ instanceof Bee && this.f_26135_.m_142582_(p_28036_)) { -- p_28035_.m_6710_(p_28036_); + protected void alertOther(Mob p_28035_, LivingEntity p_28036_) { + if (p_28035_ instanceof Bee && this.mob.hasLineOfSight(p_28036_)) { +- p_28035_.setTarget(p_28036_); + p_28035_.setTarget(p_28036_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bucketable.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Bucketable.java.patch index 6dd432c2..6d2ae5b9 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bucketable.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bucketable.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/entity/animal/Bucketable.java +++ b/net/minecraft/world/entity/animal/Bucketable.java @@ -91,9 +_,22 @@ - static Optional m_148828_(Player p_148829_, InteractionHand p_148830_, T p_148831_) { - ItemStack itemstack = p_148829_.m_21120_(p_148830_); - if (itemstack.m_41720_() == Items.f_42447_ && p_148831_.m_6084_()) { -- p_148831_.m_5496_(p_148831_.m_142623_(), 1.0F, 1.0F); + static Optional bucketMobPickup(Player p_148829_, InteractionHand p_148830_, T p_148831_) { + ItemStack itemstack = p_148829_.getItemInHand(p_148830_); + if (itemstack.getItem() == Items.WATER_BUCKET && p_148831_.isAlive()) { +- p_148831_.playSound(p_148831_.getPickupSound(), 1.0F, 1.0F); + // CraftBukkit start + // p_148831_.playSound(p_148831_.getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down - ItemStack itemstack1 = p_148831_.m_142563_(); - p_148831_.m_142146_(itemstack1); + ItemStack itemstack1 = p_148831_.getBucketItemStack(); + p_148831_.saveToBucketTag(itemstack1); + + org.bukkit.event.player.PlayerBucketEntityEvent playerBucketFishEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerFishBucketEvent(p_148831_, p_148829_, itemstack, itemstack1); + itemstack1 = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket()); + if (playerBucketFishEvent.isCancelled()) { -+ ((ServerPlayer) p_148829_).f_36096_.m_150429_(); // We need to update inventory to resync client's bucket -+ ((ServerPlayer) p_148829_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundAddMobPacket(p_148831_)); // We need to play out these packets as the client assumes the fish is gone -+ ((ServerPlayer) p_148829_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(p_148831_.m_142049_(), p_148831_.m_20088_(), true)); // Need to send data such as the display name to client ++ ((ServerPlayer) p_148829_).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket ++ ((ServerPlayer) p_148829_).connection.send(new net.minecraft.network.protocol.game.ClientboundAddMobPacket(p_148831_)); // We need to play out these packets as the client assumes the fish is gone ++ ((ServerPlayer) p_148829_).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(p_148831_.getId(), p_148831_.getEntityData(), true)); // Need to send data such as the display name to client + return Optional.of(InteractionResult.FAIL); + } -+ p_148831_.m_5496_(((Bucketable) p_148831_).m_142623_(), 1.0F, 1.0F); ++ p_148831_.playSound(((Bucketable) p_148831_).getPickupSound(), 1.0F, 1.0F); + // CraftBukkit end + - ItemStack itemstack2 = ItemUtils.m_41817_(itemstack, p_148829_, itemstack1, false); - p_148829_.m_21008_(p_148830_, itemstack2); - Level level = p_148831_.f_19853_; + ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_148829_, itemstack1, false); + p_148829_.setItemInHand(p_148830_, itemstack2); + Level level = p_148831_.level; 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 8f7e4d1b..22405fc8 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,38 +1,38 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java @@ -399,8 +_,9 @@ - if (this.m_21830_(p_28153_)) { + if (this.isOwnedBy(p_28153_)) { if (!(item instanceof DyeItem)) { - if (item.m_41472_() && this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) { + if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); //Magma -+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_()); - this.m_142075_(p_28153_, p_28154_, itemstack); -- this.m_5634_((float)item.m_41473_().m_38744_()); ++ this.heal((float)itemstack.getFoodProperties(this).getNutrition()); + this.usePlayerItem(p_28153_, p_28154_, itemstack); +- this.heal((float)item.getFoodProperties().getNutrition()); return InteractionResult.CONSUME; } @@ -425,7 +_,7 @@ } - } else if (this.m_6898_(itemstack)) { - this.m_142075_(p_28153_, p_28154_, itemstack); -- if (this.f_19796_.nextInt(3) == 0) { -+ if (this.f_19796_.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_28153_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_28153_).isCancelled()) { // CraftBukkit - this.m_21828_(p_28153_); - this.m_21839_(true); - this.f_19853_.m_7605_(this, (byte)7); + } else if (this.isFood(itemstack)) { + this.usePlayerItem(p_28153_, p_28154_, itemstack); +- if (this.random.nextInt(3) == 0) { ++ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_28153_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_28153_).isCancelled()) { // CraftBukkit + this.tame(p_28153_); + this.setOrderedToSit(true); + this.level.broadcastEntityEvent(this, (byte)7); @@ -580,7 +_,15 @@ - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_28198_.f_19853_)).m_78972_(LootContextParams.f_81460_, this.f_28198_.m_20182_()).m_78972_(LootContextParams.f_81455_, this.f_28198_).m_78977_(random); + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.cat.level)).withParameter(LootContextParams.ORIGIN, this.cat.position()).withParameter(LootContextParams.THIS_ENTITY, this.cat).withRandom(random); - for(ItemStack itemstack : loottable.m_79129_(lootcontext$builder.m_78975_(LootContextParamSets.f_81416_))) { -- this.f_28198_.f_19853_.m_7967_(new ItemEntity(this.f_28198_.f_19853_, (double)blockpos$mutableblockpos.m_123341_() - (double)Mth.m_14031_(this.f_28198_.f_20883_ * ((float)Math.PI / 180F)), (double)blockpos$mutableblockpos.m_123342_(), (double)blockpos$mutableblockpos.m_123343_() + (double)Mth.m_14089_(this.f_28198_.f_20883_ * ((float)Math.PI / 180F)), itemstack)); + for(ItemStack itemstack : loottable.getRandomItems(lootcontext$builder.create(LootContextParamSets.GIFT))) { +- this.cat.level.addFreshEntity(new ItemEntity(this.cat.level, (double)blockpos$mutableblockpos.getX() - (double)Mth.sin(this.cat.yBodyRot * ((float)Math.PI / 180F)), (double)blockpos$mutableblockpos.getY(), (double)blockpos$mutableblockpos.getZ() + (double)Mth.cos(this.cat.yBodyRot * ((float)Math.PI / 180F)), itemstack)); + // CraftBukkit start -+ ItemEntity entityitem = new ItemEntity(this.f_28198_.f_19853_, (double) blockpos$mutableblockpos.m_123341_() - (double) Mth.m_14031_(this.f_28198_.f_20883_ * 0.017453292F), (double) blockpos$mutableblockpos.m_123342_(), (double) blockpos$mutableblockpos.m_123343_() + (double) Mth.m_14089_(this.f_28198_.f_20883_ * 0.017453292F), itemstack); -+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.f_28198_.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ entityitem.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ ItemEntity entityitem = new ItemEntity(this.cat.level, (double) blockpos$mutableblockpos.getX() - (double) Mth.sin(this.cat.yBodyRot * 0.017453292F), (double) blockpos$mutableblockpos.getY(), (double) blockpos$mutableblockpos.getZ() + (double) Mth.cos(this.cat.yBodyRot * 0.017453292F), itemstack); ++ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ entityitem.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + continue; + } -+ this.f_28198_.f_19853_.m_7967_(entityitem); ++ this.cat.level.addFreshEntity(entityitem); + // CraftBukkit end } @@ -41,8 +41,8 @@ static class CatTemptGoal extends TemptGoal { @Nullable -- private Player f_28216_; -+ private LivingEntity f_28216_; // CraftBukkit - private final Cat f_28217_; +- private Player selectedPlayer; ++ private LivingEntity selectedPlayer; // CraftBukkit + private final Cat cat; public CatTemptGoal(Cat p_28219_, double p_28220_, Ingredient p_28221_, boolean p_28222_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Chicken.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Chicken.java.patch index 3de49b87..65ddbd3e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Chicken.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Chicken.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/animal/Chicken.java +++ b/net/minecraft/world/entity/animal/Chicken.java @@ -87,7 +_,9 @@ - this.f_28226_ += this.f_28230_ * 2.0F; - if (!this.f_19853_.f_46443_ && this.m_6084_() && !this.m_6162_() && !this.m_28264_() && --this.f_28231_ <= 0) { - this.m_5496_(SoundEvents.f_11752_, 1.0F, (this.f_19796_.nextFloat() - this.f_19796_.nextFloat()) * 0.2F + 1.0F); + this.flap += this.flapping * 2.0F; + if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { + this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit - this.m_19998_(Items.f_42521_); + this.spawnAtLocation(Items.EGG); + this.forceDrops = false; // CraftBukkit - this.f_28231_ = this.f_19796_.nextInt(6000) + 6000; + this.eggTime = this.random.nextInt(6000) + 6000; } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Cow.java.patch index 1af61e81..18e32a73 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cow.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/animal/Cow.java +++ b/net/minecraft/world/entity/animal/Cow.java @@ -73,8 +_,15 @@ - public InteractionResult m_6071_(Player p_28298_, InteractionHand p_28299_) { - ItemStack itemstack = p_28298_.m_21120_(p_28299_); - if (itemstack.m_150930_(Items.f_42446_) && !this.m_6162_()) { + public InteractionResult mobInteract(Player p_28298_, InteractionHand p_28299_) { + ItemStack itemstack = p_28298_.getItemInHand(p_28299_); + if (itemstack.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) p_28298_.f_19853_, p_28298_, this.m_142538_(), this.m_142538_(), null, itemstack, Items.f_42455_); ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) p_28298_.level, p_28298_, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET); + + if (event.isCancelled()) { + return InteractionResult.PASS; + } + // CraftBukkit end - p_28298_.m_5496_(SoundEvents.f_11833_, 1.0F, 1.0F); -- ItemStack itemstack1 = ItemUtils.m_41813_(itemstack, p_28298_, Items.f_42455_.m_7968_()); -+ ItemStack itemstack1 = ItemUtils.m_41813_(itemstack, p_28298_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - p_28298_.m_21008_(p_28299_, itemstack1); - return InteractionResult.m_19078_(this.f_19853_.f_46443_); + p_28298_.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F); +- ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, p_28298_, Items.MILK_BUCKET.getDefaultInstance()); ++ ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, p_28298_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + p_28298_.setItemInHand(p_28299_, itemstack1); + return InteractionResult.sidedSuccess(this.level.isClientSide); } else { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Dolphin.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Dolphin.java.patch index ae0e38cc..72af16c0 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Dolphin.java.patch @@ -8,60 +8,60 @@ + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override + public int getDefaultMaxAirSupply() { -+ return f_148892_; ++ return TOTAL_AIR_SUPPLY; + } + // CraftBukkit end - private static final EntityDataAccessor f_28312_ = SynchedEntityData.m_135353_(Dolphin.class, EntityDataSerializers.f_135038_); - private static final EntityDataAccessor f_28313_ = SynchedEntityData.m_135353_(Dolphin.class, EntityDataSerializers.f_135035_); - private static final EntityDataAccessor f_28310_ = SynchedEntityData.m_135353_(Dolphin.class, EntityDataSerializers.f_135028_); + private static final EntityDataAccessor TREASURE_POS = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BLOCK_POS); + private static final EntityDataAccessor GOT_FISH = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor MOISTNESS_LEVEL = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.INT); @@ -178,7 +_,7 @@ } - public int m_6062_() { + public int getMaxAirSupply() { - return 4800; + return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() } - protected int m_7305_(int p_28389_) { + protected int increaseAirSupply(int p_28389_) { @@ -214,6 +_,12 @@ - if (this.m_6844_(EquipmentSlot.MAINHAND).m_41619_()) { - ItemStack itemstack = p_28357_.m_32055_(); - if (this.m_7252_(itemstack)) { + if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { + ItemStack itemstack = p_28357_.getItem(); + if (this.canHoldItem(itemstack)) { + // CraftBukkit start - call EntityPickupItemEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_28357_, 0, false).isCancelled()) { + return; + } -+ itemstack = p_28357_.m_32055_(); // update ItemStack from event ++ itemstack = p_28357_.getItem(); // update ItemStack from event + // CraftBukkit end - this.m_21053_(p_28357_); - this.m_8061_(EquipmentSlot.MAINHAND, itemstack); - this.f_21347_[EquipmentSlot.MAINHAND.m_20749_()] = 2.0F; + this.onItemPickup(p_28357_); + this.setItemSlot(EquipmentSlot.MAINHAND, itemstack); + this.handDropChances[EquipmentSlot.MAINHAND.getIndex()] = 2.0F; @@ -356,7 +_,7 @@ } - public boolean m_8036_() { -- return this.f_28399_.m_28377_() && this.f_28399_.m_20146_() >= 100; -+ return this.f_28399_.m_28377_() && this.f_28399_.m_20146_() >= 100 && this.f_28399_.f_19853_.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false + public boolean canUse() { +- return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100; ++ return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100 && this.dolphin.level.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false } - public boolean m_8045_() { + public boolean canContinueToUse() { @@ -445,7 +_,8 @@ } - public void m_8056_() { -- this.f_28411_.m_147207_(new MobEffectInstance(MobEffects.f_19593_, 100), this.f_28409_); -+ this.f_28411_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); //Magma -+ this.f_28411_.m_147207_(new MobEffectInstance(MobEffects.f_19593_, 100), this.f_28409_); // CraftBukkit + public void start() { +- this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); ++ this.player.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); //Magma ++ this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); // CraftBukkit } - public void m_8041_() { + public void stop() { @@ -462,7 +_,8 @@ } - if (this.f_28411_.m_6069_() && this.f_28411_.f_19853_.f_46441_.nextInt(6) == 0) { -- this.f_28411_.m_147207_(new MobEffectInstance(MobEffects.f_19593_, 100), this.f_28409_); -+ this.f_28411_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); //Magma -+ this.f_28411_.m_147207_(new MobEffectInstance(MobEffects.f_19593_, 100), this.f_28409_); // CraftBukkit + if (this.player.isSwimming() && this.player.level.random.nextInt(6) == 0) { +- this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); ++ this.player.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); //Magma ++ this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); // CraftBukkit } } 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 88094aa8..33efc41f 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -2,59 +2,59 @@ +++ b/net/minecraft/world/entity/animal/Fox.java @@ -476,7 +_,8 @@ - protected void m_7581_(ItemEntity p_28514_) { - ItemStack itemstack = p_28514_.m_32055_(); -- if (this.m_7252_(itemstack)) { -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_28514_, itemstack.m_41613_() - 1, !this.m_7252_(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent -+ itemstack = p_28514_.m_32055_(); // CraftBukkit - update ItemStack from event - int i = itemstack.m_41613_(); + protected void pickUpItem(ItemEntity p_28514_) { + ItemStack itemstack = p_28514_.getItem(); +- if (this.canHoldItem(itemstack)) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_28514_, itemstack.getCount() - 1, !this.canHoldItem(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent ++ itemstack = p_28514_.getItem(); // CraftBukkit - update ItemStack from event + int i = itemstack.getCount(); if (i > 1) { - this.m_28605_(itemstack.m_41620_(i - 1)); + this.dropItemStack(itemstack.split(i - 1)); @@ -649,13 +_,16 @@ } - protected void m_6668_(DamageSource p_28536_) { -+ super.m_6668_(p_28536_); + protected void dropAllDeathLoot(DamageSource p_28536_) { ++ super.dropAllDeathLoot(p_28536_); + } -+ protected void m_5907_() { // Forge: move extra drops to dropEquipment to allow them to be captured by LivingDropsEvent -+ super.m_5907_(); - ItemStack itemstack = this.m_6844_(EquipmentSlot.MAINHAND); - if (!itemstack.m_41619_()) { - this.m_19983_(itemstack); - this.m_8061_(EquipmentSlot.MAINHAND, ItemStack.f_41583_); ++ protected void dropEquipment() { // Forge: move extra drops to dropEquipment to allow them to be captured by LivingDropsEvent ++ super.dropEquipment(); + ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND); + if (!itemstack.isEmpty()) { + this.spawnAtLocation(itemstack); + this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); } -- super.m_6668_(p_28536_); +- super.dropAllDeathLoot(p_28536_); } - public static boolean m_28471_(Fox p_28472_, LivingEntity p_28473_) { + public static boolean isPathClear(Fox p_28472_, LivingEntity p_28473_) { @@ -805,6 +_,17 @@ - protected void m_8026_() { - ServerLevel serverlevel = (ServerLevel)this.f_25114_; - Fox fox = (Fox)this.f_25113_.m_142606_(serverlevel, this.f_25115_); -+ final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(f_25113_, f_25115_, fox); + protected void breed() { + ServerLevel serverlevel = (ServerLevel)this.level; + Fox fox = (Fox)this.animal.getBreedOffspring(serverlevel, this.partner); ++ final net.minecraftforge.event.entity.living.BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(animal, partner, fox); + final boolean cancelled = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + fox = (Fox) event.getChild(); + if (cancelled) { + //Reset the "inLove" state for the animals -+ this.f_25113_.m_146762_(6000); -+ this.f_25115_.m_146762_(6000); -+ this.f_25113_.m_27594_(); -+ this.f_25115_.m_27594_(); ++ this.animal.setAge(6000); ++ this.partner.setAge(6000); ++ this.animal.resetLove(); ++ this.partner.resetLove(); + return; + } if (fox != null) { - ServerPlayer serverplayer = this.f_25113_.m_27592_(); - ServerPlayer serverplayer1 = this.f_25115_.m_27592_(); + ServerPlayer serverplayer = this.animal.getLoveCause(); + ServerPlayer serverplayer1 = this.partner.getLoveCause(); @@ -819,6 +_,17 @@ - fox.m_28515_(serverplayer1.m_142081_()); + fox.addTrustedUUID(serverplayer1.getUUID()); } + // CraftBukkit start - call EntityBreedEvent -+ fox.m_146762_(-24000); -+ fox.m_7678_(this.f_25113_.m_20185_(), this.f_25113_.m_20186_(), this.f_25113_.m_20189_(), 0.0F, 0.0F); -+ int experience = this.f_25113_.m_21187_().nextInt(7) + 1; -+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityBreedEvent(fox, f_25113_, f_25115_, serverplayer, this.f_25113_.breedItem, experience); ++ fox.setAge(-24000); ++ fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); ++ int experience = this.animal.getRandom().nextInt(7) + 1; ++ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityBreedEvent(fox, animal, partner, serverplayer, this.animal.breedItem, experience); + if (entityBreedEvent.isCancelled()) { + return; + } @@ -62,22 +62,22 @@ + // CraftBukkit end + if (serverplayer2 != null) { - serverplayer2.m_36220_(Stats.f_12937_); - CriteriaTriggers.f_10581_.m_147278_(serverplayer2, this.f_25113_, this.f_25115_, fox); + serverplayer2.awardStat(Stats.ANIMALS_BRED); + CriteriaTriggers.BRED_ANIMALS.trigger(serverplayer2, this.animal, this.partner, fox); @@ -828,12 +_,15 @@ - this.f_25115_.m_146762_(6000); - this.f_25113_.m_27594_(); - this.f_25115_.m_27594_(); -- fox.m_146762_(-24000); -- fox.m_7678_(this.f_25113_.m_20185_(), this.f_25113_.m_20186_(), this.f_25113_.m_20189_(), 0.0F, 0.0F); + this.partner.setAge(6000); + this.animal.resetLove(); + this.partner.resetLove(); +- fox.setAge(-24000); +- fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); + serverlevel.prepareEntity(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); //Magma - add spawn reason - serverlevel.m_47205_(fox); - this.f_25114_.m_7605_(this.f_25113_, (byte)18); - if (this.f_25114_.m_46469_().m_46207_(GameRules.f_46135_)) { -- this.f_25114_.m_7967_(new ExperienceOrb(this.f_25114_, this.f_25113_.m_20185_(), this.f_25113_.m_20186_(), this.f_25113_.m_20189_(), this.f_25113_.m_21187_().nextInt(7) + 1)); + serverlevel.addFreshEntityWithPassengers(fox); + this.level.broadcastEntityEvent(this.animal, (byte)18); + if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ this.f_25114_.m_7967_(new ExperienceOrb(this.f_25114_, this.f_25113_.m_20185_(), this.f_25113_.m_20186_(), this.f_25113_.m_20189_(), experience)); ++ this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience)); + } + // CraftBukkit end } @@ -86,29 +86,29 @@ @@ -876,7 +_,7 @@ } - protected void m_28686_() { -- if (Fox.this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Fox.this.f_19853_, Fox.this)) { - BlockState blockstate = Fox.this.f_19853_.m_8055_(this.f_25602_); - if (blockstate.m_60713_(Blocks.f_50685_)) { - this.m_148928_(blockstate); + protected void onReachedTarget() { +- if (Fox.this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Fox.this.level, Fox.this)) { + BlockState blockstate = Fox.this.level.getBlockState(this.blockPos); + if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) { + this.pickSweetBerries(blockstate); @@ -888,12 +_,18 @@ } - private void m_148926_(BlockState p_148927_) { -- CaveVines.m_152953_(p_148927_, Fox.this.f_19853_, this.f_25602_); + private void pickGlowBerry(BlockState p_148927_) { +- CaveVines.use(p_148927_, Fox.this.level, this.blockPos); + org.magmafoundation.magma.helpers.InterfaceHelper.tempNMSEntity.set(Fox.this); //Magma - set the entity to be used by the event -+ CaveVines.m_152953_(p_148927_, Fox.this.f_19853_, this.f_25602_); // CraftBukkit ++ CaveVines.use(p_148927_, Fox.this.level, this.blockPos); // CraftBukkit } - private void m_148928_(BlockState p_148929_) { - int i = p_148929_.m_61143_(SweetBerryBushBlock.f_57244_); - p_148929_.m_61124_(SweetBerryBushBlock.f_57244_, Integer.valueOf(1)); + private void pickSweetBerries(BlockState p_148929_) { + int i = p_148929_.getValue(SweetBerryBushBlock.AGE); + p_148929_.setValue(SweetBerryBushBlock.AGE, Integer.valueOf(1)); + // CraftBukkit start - call EntityChangeBlockEvent -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(Fox.this, this.f_25602_, p_148929_.m_61124_(SweetBerryBushBlock.f_57244_, 1)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(Fox.this, this.blockPos, p_148929_.setValue(SweetBerryBushBlock.AGE, 1)).isCancelled()) { + return; + } + // CraftBukkit end - int j = 1 + Fox.this.f_19853_.f_46441_.nextInt(2) + (i == 3 ? 1 : 0); - ItemStack itemstack = Fox.this.m_6844_(EquipmentSlot.MAINHAND); - if (itemstack.m_41619_()) { + int j = 1 + Fox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0); + ItemStack itemstack = Fox.this.getItemBySlot(EquipmentSlot.MAINHAND); + if (itemstack.isEmpty()) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch index cd45cdf2..6e78b42e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -2,23 +2,23 @@ +++ b/net/minecraft/world/entity/animal/IronGolem.java @@ -100,7 +_,7 @@ - protected void m_7324_(Entity p_28839_) { - if (p_28839_ instanceof Enemy && !(p_28839_ instanceof Creeper) && this.m_21187_().nextInt(20) == 0) { -- this.m_6710_((LivingEntity)p_28839_); + protected void doPush(Entity p_28839_) { + if (p_28839_ instanceof Enemy && !(p_28839_ instanceof Creeper) && this.getRandom().nextInt(20) == 0) { +- this.setTarget((LivingEntity)p_28839_); + this.setTarget((LivingEntity)p_28839_, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason } - super.m_7324_(p_28839_); + super.doPush(p_28839_); @@ -120,9 +_,10 @@ - int i = Mth.m_14107_(this.m_20185_()); - int j = Mth.m_14107_(this.m_20186_() - (double)0.2F); - int k = Mth.m_14107_(this.m_20189_()); -- BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); + int i = Mth.floor(this.getX()); + int j = Mth.floor(this.getY() - (double)0.2F); + int k = Mth.floor(this.getZ()); +- BlockState blockstate = this.level.getBlockState(new BlockPos(i, j, k)); + BlockPos pos = new BlockPos(i, j, k); -+ BlockState blockstate = this.f_19853_.m_8055_(pos); - if (!blockstate.m_60795_()) { -- this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate), this.m_20185_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), this.m_20186_() + 0.1D, this.m_20189_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), 4.0D * ((double)this.f_19796_.nextFloat() - 0.5D), 0.5D, ((double)this.f_19796_.nextFloat() - 0.5D) * 4.0D); -+ this.f_19853_.m_7106_(new BlockParticleOption(ParticleTypes.f_123794_, blockstate).setPos(pos), this.m_20185_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), this.m_20186_() + 0.1D, this.m_20189_() + ((double)this.f_19796_.nextFloat() - 0.5D) * (double)this.m_20205_(), 4.0D * ((double)this.f_19796_.nextFloat() - 0.5D), 0.5D, ((double)this.f_19796_.nextFloat() - 0.5D) * 4.0D); ++ BlockState blockstate = this.level.getBlockState(pos); + if (!blockstate.isAir()) { +- this.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockstate), this.getX() + ((double)this.random.nextFloat() - 0.5D) * (double)this.getBbWidth(), this.getY() + 0.1D, this.getZ() + ((double)this.random.nextFloat() - 0.5D) * (double)this.getBbWidth(), 4.0D * ((double)this.random.nextFloat() - 0.5D), 0.5D, ((double)this.random.nextFloat() - 0.5D) * 4.0D); ++ this.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockstate).setPos(pos), this.getX() + ((double)this.random.nextFloat() - 0.5D) * (double)this.getBbWidth(), this.getY() + 0.1D, this.getZ() + ((double)this.random.nextFloat() - 0.5D) * (double)this.getBbWidth(), 4.0D * ((double)this.random.nextFloat() - 0.5D), 0.5D, ((double)this.random.nextFloat() - 0.5D) * 4.0D); } } 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 a4793da5..47146e83 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -6,66 +6,66 @@ -public class MushroomCow extends Cow implements Shearable { +public class MushroomCow extends Cow implements Shearable, net.minecraftforge.common.IForgeShearable { - private static final EntityDataAccessor f_28908_ = SynchedEntityData.m_135353_(MushroomCow.class, EntityDataSerializers.f_135030_); - private static final int f_148934_ = 1024; + private static final EntityDataAccessor DATA_TYPE = SynchedEntityData.defineId(MushroomCow.class, EntityDataSerializers.STRING); + private static final int MUTATE_CHANCE = 1024; @Nullable @@ -104,7 +_,7 @@ - this.m_5496_(soundevent, 1.0F, 1.0F); - return InteractionResult.m_19078_(this.f_19853_.f_46443_); -- } else if (itemstack.m_150930_(Items.f_42574_) && this.m_6220_()) { -+ } else if (false && itemstack.m_41720_() == Items.f_42574_ && this.m_6220_()) { //Forge: Moved to onSheared - this.m_5851_(SoundSource.PLAYERS); - this.m_146852_(GameEvent.f_157781_, p_28941_); - if (!this.f_19853_.f_46443_) { + this.playSound(soundevent, 1.0F, 1.0F); + return InteractionResult.sidedSuccess(this.level.isClientSide); +- } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { ++ } else if (false && itemstack.getItem() == Items.SHEARS && this.readyForShearing()) { //Forge: Moved to onSheared + this.shear(SoundSource.PLAYERS); + this.gameEvent(GameEvent.SHEAR, p_28941_); + if (!this.level.isClientSide) { @@ -145,11 +_,21 @@ } } + @Override + public java.util.List onSheared(@javax.annotation.Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) { -+ this.m_146852_(GameEvent.f_157781_, player); ++ this.gameEvent(GameEvent.SHEAR, player); + return shearInternal(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS); + } + - public void m_5851_(SoundSource p_28924_) { -+ shearInternal(p_28924_).forEach(s -> this.f_19853_.m_7967_(new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), s))); + 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))); + } + + private java.util.List shearInternal(SoundSource p_28924_) { - this.f_19853_.m_6269_((Player)null, this, SoundEvents.f_12075_, p_28924_, 1.0F, 1.0F); - if (!this.f_19853_.m_5776_()) { - ((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123813_, this.m_20185_(), this.m_20227_(0.5D), this.m_20189_(), 1, 0.0D, 0.0D, 0.0D, 0.0D); -- this.m_146870_(); + this.level.playSound((Player)null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); + if (!this.level.isClientSide()) { + ((ServerLevel)this.level).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); +- this.discard(); + // this.discard(); // CraftBukkit - moved down - Cow cow = EntityType.f_20557_.m_20615_(this.f_19853_); - cow.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); - cow.m_21153_(this.m_21223_()); + Cow cow = EntityType.COW.create(this.level); + cow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + cow.setHealth(this.getHealth()); @@ -164,12 +_,32 @@ } - cow.m_20331_(this.m_20147_()); + cow.setInvulnerable(this.isInvulnerable()); + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTransformEvent(this, cow, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { + return java.util.Collections.emptyList(); + } -+ this.f_19853_.prepareEntity(cow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); //Magma - add spawn reason - this.f_19853_.m_7967_(cow); -+ this.m_146870_(); // CraftBukkit - from above ++ this.level.prepareEntity(cow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); //Magma - add spawn reason + this.level.addFreshEntity(cow); ++ this.discard(); // CraftBukkit - from above + // CraftBukkit end + java.util.List items = new java.util.ArrayList<>(); for(int i = 0; i < 5; ++i) { -- this.f_19853_.m_7967_(new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), new ItemStack(this.m_28955_().f_28961_.m_60734_()))); +- this.level.addFreshEntity(new ItemEntity(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock()))); + + // CraftBukkit start -+ ItemEntity entityitem = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), new ItemStack(this.m_28955_().f_28961_.m_60734_())); ++ ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock())); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + continue; + } -+ items.add(entityitem.m_32055_()); // Magma ++ items.add(entityitem.getItem()); // Magma + // CraftBukkit end + } @@ -76,21 +76,21 @@ } @@ -182,6 +_,7 @@ - p_28944_.m_128359_("Type", this.m_28955_().f_28960_); - if (this.f_28909_ != null) { - p_28944_.m_128344_("EffectId", (byte)MobEffect.m_19459_(this.f_28909_)); -+ net.minecraftforge.common.ForgeHooks.saveMobEffect(p_28944_, "forge:effect_id", this.f_28909_); - p_28944_.m_128405_("EffectDuration", this.f_28910_); + p_28944_.putString("Type", this.getMushroomType().type); + if (this.effect != null) { + p_28944_.putByte("EffectId", (byte)MobEffect.getId(this.effect)); ++ net.minecraftforge.common.ForgeHooks.saveMobEffect(p_28944_, "forge:effect_id", this.effect); + p_28944_.putInt("EffectDuration", this.effectDuration); } @@ -192,6 +_,7 @@ - this.m_28928_(MushroomCow.MushroomType.m_28976_(p_28936_.m_128461_("Type"))); - if (p_28936_.m_128425_("EffectId", 1)) { - this.f_28909_ = MobEffect.m_19453_(p_28936_.m_128445_("EffectId")); -+ this.f_28909_ = net.minecraftforge.common.ForgeHooks.loadMobEffect(p_28936_, "forge:effect_id", this.f_28909_); + this.setMushroomType(MushroomCow.MushroomType.byType(p_28936_.getString("Type"))); + if (p_28936_.contains("EffectId", 1)) { + this.effect = MobEffect.byId(p_28936_.getByte("EffectId")); ++ this.effect = net.minecraftforge.common.ForgeHooks.loadMobEffect(p_28936_, "forge:effect_id", this.effect); } - if (p_28936_.m_128425_("EffectDuration", 3)) { + if (p_28936_.contains("EffectDuration", 3)) { @@ -238,6 +_,11 @@ } @@ -99,7 +99,7 @@ + + @Override + public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) { -+ return m_6220_(); ++ return readyForShearing(); } public static enum MushroomType { 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 0fdae466..e8fe6049 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java @@ -164,7 +_,8 @@ - if ((this.f_28984_ == null || this.f_28984_.m_25955_()) && !this.m_29038_() && this.m_6898_(itemstack) && p_29021_.m_20280_(this) < 9.0D) { - this.m_142075_(p_29021_, p_29022_, itemstack); - if (!this.f_19853_.f_46443_) { -- if (this.f_19796_.nextInt(3) == 0) { + if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && p_29021_.distanceToSqr(this) < 9.0D) { + this.usePlayerItem(p_29021_, p_29022_, itemstack); + if (!this.level.isClientSide) { +- if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check -+ if (this.f_19796_.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29021_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_29021_).isCancelled()) { - this.m_29045_(true); - this.m_29047_(true); - this.f_19853_.m_7605_(this, (byte)41); ++ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29021_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_29021_).isCancelled()) { + this.setTrusting(true); + this.spawnTrustingParticles(true); + this.level.broadcastEntityEvent(this, (byte)41); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Panda.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Panda.java.patch index 33a6acad..ac090872 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Panda.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Panda.java.patch @@ -3,17 +3,17 @@ @@ -501,7 +_,7 @@ } - protected void m_7581_(ItemEntity p_29121_) { -- if (this.m_6844_(EquipmentSlot.MAINHAND).m_41619_() && f_29071_.test(p_29121_)) { -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_29121_, 0, !(this.m_6844_(EquipmentSlot.MAINHAND).m_41619_() && Panda.f_29071_.test(p_29121_))).isCancelled()) { // CraftBukkit - this.m_21053_(p_29121_); - ItemStack itemstack = p_29121_.m_32055_(); - this.m_8061_(EquipmentSlot.MAINHAND, itemstack); + protected void pickUpItem(ItemEntity p_29121_) { +- if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty() && PANDA_ITEMS.test(p_29121_)) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_29121_, 0, !(this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty() && Panda.PANDA_ITEMS.test(p_29121_))).isCancelled()) { // CraftBukkit + this.onItemPickup(p_29121_); + ItemStack itemstack = p_29121_.getItem(); + this.setItemSlot(EquipmentSlot.MAINHAND, itemstack); @@ -835,7 +_,7 @@ - protected void m_5766_(Mob p_29295_, LivingEntity p_29296_) { - if (p_29295_ instanceof Panda && ((Panda)p_29295_).m_5912_()) { -- p_29295_.m_6710_(p_29296_); + protected void alertOther(Mob p_29295_, LivingEntity p_29296_) { + if (p_29295_ instanceof Panda && ((Panda)p_29295_).isAggressive()) { +- p_29295_.setTarget(p_29296_); + p_29295_.setTarget(p_29296_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit } 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 bff20813..e6167ff3 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -3,36 +3,36 @@ @@ -240,7 +_,7 @@ } - if (!this.f_19853_.f_46443_) { -- if (this.f_19796_.nextInt(10) == 0) { -+ if (this.f_19796_.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29414_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_29414_).isCancelled()) { // CraftBukkit - this.m_21828_(p_29414_); - this.f_19853_.m_7605_(this, (byte)7); + if (!this.level.isClientSide) { +- if (this.random.nextInt(10) == 0) { ++ if (this.random.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_29414_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_29414_).isCancelled()) { // CraftBukkit + this.tame(p_29414_); + this.level.broadcastEntityEvent(this, (byte)7); } else { @@ -254,7 +_,7 @@ - itemstack.m_41774_(1); + itemstack.shrink(1); } -- this.m_7292_(new MobEffectInstance(MobEffects.f_19614_, 900)); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19614_, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit - if (p_29414_.m_7500_() || !this.m_20147_()) { - this.m_6469_(DamageSource.m_19344_(p_29414_), Float.MAX_VALUE); +- this.addEffect(new MobEffectInstance(MobEffects.POISON, 900)); ++ this.addEffect(new MobEffectInstance(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit + if (p_29414_.isCreative() || !this.isInvulnerable()) { + this.hurt(DamageSource.playerAttack(p_29414_), Float.MAX_VALUE); } @@ -351,7 +_,7 @@ } - public boolean m_6094_() { + public boolean isPushable() { - return true; -+ return super.m_6094_(); // CraftBukkit - collidable API ++ return super.isPushable(); // CraftBukkit - collidable API } - protected void m_7324_(Entity p_29367_) { + protected void doPush(Entity p_29367_) { @@ -365,7 +_,7 @@ return false; } else { - if (!this.f_19853_.f_46443_) { -- this.m_21839_(false); + if (!this.level.isClientSide) { +- this.setOrderedToSit(false); + // this.setOrderedToSit(false); // CraftBukkit - moved into LivingEntity.damageEntity(DamageSource, float) } - return super.m_6469_(p_29378_, p_29379_); + return super.hurt(p_29378_, p_29379_); 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 16037275..af8a9128 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -3,24 +3,24 @@ @@ -201,7 +_,7 @@ } - public void m_8038_(ServerLevel p_29473_, LightningBolt p_29474_) { -- if (p_29473_.m_46791_() != Difficulty.PEACEFUL) { -+ if (p_29473_.m_46791_() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20531_, (timer) -> {})) { - ZombifiedPiglin zombifiedpiglin = EntityType.f_20531_.m_20615_(p_29473_); - zombifiedpiglin.m_8061_(EquipmentSlot.MAINHAND, new ItemStack(Items.f_42430_)); - zombifiedpiglin.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); + 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_); + zombifiedpiglin.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); + zombifiedpiglin.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); @@ -213,7 +_,14 @@ } - zombifiedpiglin.m_21530_(); + zombifiedpiglin.setPersistenceRequired(); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPigZapEvent(this, p_29474_, zombifiedpiglin).isCancelled()) { + return; + } + p_29473_.prepareEntity(zombifiedpiglin, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); //Magma - add spawn reason - p_29473_.m_7967_(zombifiedpiglin); + p_29473_.addFreshEntity(zombifiedpiglin); + // CraftBukkit end - this.m_146870_(); + this.discard(); } else { - super.m_8038_(p_29473_, p_29474_); + super.thunderHit(p_29473_, p_29474_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Pufferfish.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pufferfish.java.patch index 24620dfc..3eb1addb 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pufferfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pufferfish.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/entity/animal/Pufferfish.java +++ b/net/minecraft/world/entity/animal/Pufferfish.java @@ -132,7 +_,8 @@ - private void m_29605_(Mob p_29606_) { - int i = this.m_29631_(); - if (p_29606_.m_6469_(DamageSource.m_19370_(this), (float)(1 + i))) { -- p_29606_.m_147207_(new MobEffectInstance(MobEffects.f_19614_, 60 * i, 0), this); + private void touch(Mob p_29606_) { + int i = this.getPuffState(); + if (p_29606_.hurt(DamageSource.mobAttack(this), (float)(1 + i))) { +- p_29606_.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this); + p_29606_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ p_29606_.m_147207_(new MobEffectInstance(MobEffects.f_19614_, 60 * i, 0), this); // CraftBukkit - this.m_5496_(SoundEvents.f_12295_, 1.0F, 1.0F); ++ p_29606_.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this); // CraftBukkit + this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F); } @@ -145,7 +_,8 @@ - ((ServerPlayer)p_29617_).f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132162_, 0.0F)); + ((ServerPlayer)p_29617_).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F)); } -- p_29617_.m_147207_(new MobEffectInstance(MobEffects.f_19614_, 60 * i, 0), this); +- p_29617_.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this); + p_29617_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ p_29617_.m_147207_(new MobEffectInstance(MobEffects.f_19614_, 60 * i, 0), this); // CraftBukkit ++ p_29617_.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this); // CraftBukkit } } 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 84a8e3e9..7bf05b58 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -2,49 +2,49 @@ +++ b/net/minecraft/world/entity/animal/Rabbit.java @@ -88,8 +_,14 @@ super(p_29656_, p_29657_); - this.f_21343_ = new Rabbit.RabbitJumpControl(this); - this.f_21342_ = new Rabbit.RabbitMoveControl(this); + this.jumpControl = new Rabbit.RabbitJumpControl(this); + this.moveControl = new Rabbit.RabbitMoveControl(this); + this.initializePathFinderGoals(); // CraftBukkit - moved code + } + + // CraftBukkit start - code from constructor + public void initializePathFinderGoals(){ - this.m_29725_(0.0D); + this.setSpeedModifier(0.0D); } + // CraftBukkit end - public void m_8099_() { - this.f_21345_.m_25352_(1, new FloatGoal(this)); + public void registerGoals() { + this.goalSelector.addGoal(1, new FloatGoal(this)); @@ -510,7 +_,7 @@ - public boolean m_8036_() { - if (this.f_25600_ <= 0) { -- if (!this.f_29778_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_29778_.f_19853_, this.f_29778_)) { + 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)) { return false; } @@ -537,9 +_,23 @@ - if (this.f_29780_ && block instanceof CarrotBlock) { - int i = blockstate.m_61143_(CarrotBlock.f_52244_); + if (this.canRaid && block instanceof CarrotBlock) { + int i = blockstate.getValue(CarrotBlock.AGE); if (i == 0) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_29778_, f_25602_, Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockPos, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - level.m_7731_(blockpos, Blocks.f_50016_.m_49966_(), 2); - level.m_46953_(blockpos, true, this.f_29778_); + level.setBlock(blockpos, Blocks.AIR.defaultBlockState(), 2); + level.destroyBlock(blockpos, true, this.rabbit); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent( -+ this.f_29778_, -+ f_25602_, -+ blockstate.m_61124_(CarrotBlock.f_52244_, i - 1) ++ this.rabbit, ++ blockPos, ++ blockstate.setValue(CarrotBlock.AGE, i - 1) + ).isCancelled()) { + return; + } + // CraftBukkit end - level.m_7731_(blockpos, blockstate.m_61124_(CarrotBlock.f_52244_, Integer.valueOf(i - 1)), 2); - level.m_46796_(2001, blockpos, Block.m_49956_(blockstate)); + level.setBlock(blockpos, blockstate.setValue(CarrotBlock.AGE, Integer.valueOf(i - 1)), 2); + level.levelEvent(2001, blockpos, Block.getId(blockstate)); } 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 deeb3c5f..4920e27e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch @@ -6,43 +6,43 @@ -public class Sheep extends Animal implements Shearable { +public class Sheep extends Animal implements Shearable, net.minecraftforge.common.IForgeShearable { - private static final int f_149039_ = 40; - private static final EntityDataAccessor f_29799_ = SynchedEntityData.m_135353_(Sheep.class, EntityDataSerializers.f_135027_); - private static final Map f_29800_ = Util.m_137469_(Maps.newEnumMap(DyeColor.class), (p_29841_) -> { + private static final int EAT_ANIMATION_TICKS = 40; + private static final EntityDataAccessor DATA_WOOL_ID = SynchedEntityData.defineId(Sheep.class, EntityDataSerializers.BYTE); + private static final Map ITEM_BY_DYE = Util.make(Maps.newEnumMap(DyeColor.class), (p_29841_) -> { @@ -212,7 +_,7 @@ - public InteractionResult m_6071_(Player p_29853_, InteractionHand p_29854_) { - ItemStack itemstack = p_29853_.m_21120_(p_29854_); -- if (itemstack.m_150930_(Items.f_42574_)) { -+ if (false && itemstack.m_41720_() == Items.f_42574_) { //Forge: Moved to onSheared - if (!this.f_19853_.f_46443_ && this.m_6220_()) { - this.m_5851_(SoundSource.PLAYERS); - this.m_146852_(GameEvent.f_157781_, p_29853_); + public InteractionResult mobInteract(Player p_29853_, InteractionHand p_29854_) { + ItemStack itemstack = p_29853_.getItemInHand(p_29854_); +- if (itemstack.is(Items.SHEARS)) { ++ if (false && itemstack.getItem() == Items.SHEARS) { //Forge: Moved to onSheared + if (!this.level.isClientSide && this.readyForShearing()) { + this.shear(SoundSource.PLAYERS); + this.gameEvent(GameEvent.SHEAR, p_29853_); @@ -234,7 +_,9 @@ - int i = 1 + this.f_19796_.nextInt(3); + int i = 1 + this.random.nextInt(3); for(int j = 0; j < i; ++j) { + this.forceDrops = true; // CraftBukkit - ItemEntity itementity = this.m_20000_(f_29800_.get(this.m_29874_()), 1); + ItemEntity itementity = this.spawnAtLocation(ITEM_BY_DYE.get(this.getColor()), 1); + this.forceDrops = false; // CraftBukkit if (itementity != null) { - itementity.m_20256_(itementity.m_20184_().m_82520_((double)((this.f_19796_.nextFloat() - this.f_19796_.nextFloat()) * 0.1F), (double)(this.f_19796_.nextFloat() * 0.05F), (double)((this.f_19796_.nextFloat() - this.f_19796_.nextFloat()) * 0.1F))); + itementity.setDeltaMovement(itementity.getDeltaMovement().add((double)((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double)(this.random.nextFloat() * 0.05F), (double)((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); } @@ -320,6 +_,11 @@ } - public void m_8035_() { + public void ate() { + // CraftBukkit start + org.bukkit.event.entity.SheepRegrowWoolEvent event = new org.bukkit.event.entity.SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) return; + // CraftBukkit end - this.m_29878_(false); - if (this.m_6162_()) { - this.m_146758_(60); + this.setSheared(false); + if (this.isBaby()) { + this.ageUp(60); @@ -346,16 +_,47 @@ - private static CraftingContainer m_29831_(DyeColor p_29832_, DyeColor p_29833_) { + private static CraftingContainer makeContainer(DyeColor p_29832_, DyeColor p_29833_) { CraftingContainer craftingcontainer = new CraftingContainer(new AbstractContainerMenu((MenuType)null, -1) { + // CraftBukkit start + @Override @@ -51,37 +51,37 @@ + } + // CraftBukkit end + - public boolean m_6875_(Player p_29888_) { + public boolean stillValid(Player p_29888_) { return false; } }, 2, 1); - craftingcontainer.m_6836_(0, new ItemStack(DyeItem.m_41082_(p_29832_))); - craftingcontainer.m_6836_(1, new ItemStack(DyeItem.m_41082_(p_29833_))); + craftingcontainer.setItem(0, new ItemStack(DyeItem.byColor(p_29832_))); + craftingcontainer.setItem(1, new ItemStack(DyeItem.byColor(p_29833_))); + craftingcontainer.resultInventory = new net.minecraft.world.inventory.ResultContainer(); // CraftBukkit - add result slot for event return craftingcontainer; } - protected float m_6431_(Pose p_29850_, EntityDimensions p_29851_) { - return 0.95F * p_29851_.f_20378_; + protected float getStandingEyeHeight(Pose p_29850_, EntityDimensions p_29851_) { + return 0.95F * p_29851_.height; + } + + @Override + public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) { -+ return m_6220_(); ++ return readyForShearing(); + } + + @javax.annotation.Nonnull + @Override + public java.util.List onSheared(@Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) { -+ world.m_6269_(null, this, SoundEvents.f_12344_, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); -+ this.m_146852_(GameEvent.f_157781_, player); -+ if (!world.f_46443_) { -+ this.m_29878_(true); -+ int i = 1 + this.f_19796_.nextInt(3); ++ world.playSound(null, this, SoundEvents.SHEEP_SHEAR, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); ++ this.gameEvent(GameEvent.SHEAR, player); ++ if (!world.isClientSide) { ++ this.setSheared(true); ++ int i = 1 + this.random.nextInt(3); + + java.util.List items = new java.util.ArrayList<>(); + for (int j = 0; j < i; ++j) { -+ items.add(new ItemStack(f_29800_.get(this.m_29874_()))); ++ items.add(new ItemStack(ITEM_BY_DYE.get(this.getColor()))); + } + return items; + } 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 75ab690f..eb6722e1 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -6,71 +6,71 @@ -public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob { +public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob, net.minecraftforge.common.IForgeShearable { - private static final EntityDataAccessor f_29899_ = SynchedEntityData.m_135353_(SnowGolem.class, EntityDataSerializers.f_135027_); - private static final byte f_149047_ = 16; - private static final float f_149048_ = 1.7F; + private static final EntityDataAccessor DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE); + private static final byte PUMPKIN_FLAG = 16; + private static final float EYE_HEIGHT = 1.7F; @@ -94,10 +_,10 @@ BlockPos blockpos = new BlockPos(i, j, k); - Biome biome = this.f_19853_.m_204166_(blockpos).m_203334_(); - if (biome.m_198910_(blockpos)) { -- this.m_6469_(DamageSource.f_19307_, 1.0F); -+ this.m_6469_(org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.MELTING + Biome biome = this.level.getBiome(blockpos).value(); + if (biome.shouldSnowGolemBurn(blockpos)) { +- this.hurt(DamageSource.ON_FIRE, 1.0F); ++ this.hurt(org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.MELTING } -- if (!this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { +- if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this)) { return; } @@ -108,8 +_,8 @@ - j = Mth.m_14107_(this.m_20186_()); - k = Mth.m_14107_(this.m_20189_() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); + j = Mth.floor(this.getY()); + k = Mth.floor(this.getZ() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); BlockPos blockpos1 = new BlockPos(i, j, k); -- if (this.f_19853_.m_8055_(blockpos1).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos1)) { -- this.f_19853_.m_46597_(blockpos1, blockstate); -+ if (this.f_19853_.m_46859_(blockpos1) && blockstate.m_60710_(this.f_19853_, blockpos1)) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(this.f_19853_, blockpos1, blockstate, this); // CraftBukkit +- if (this.level.getBlockState(blockpos1).isAir() && blockstate.canSurvive(this.level, blockpos1)) { +- this.level.setBlockAndUpdate(blockpos1, blockstate); ++ if (this.level.isEmptyBlock(blockpos1) && blockstate.canSurvive(this.level, blockpos1)) { ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(this.level, blockpos1, blockstate, this); // CraftBukkit } } } @@ -134,7 +_,7 @@ - protected InteractionResult m_6071_(Player p_29920_, InteractionHand p_29921_) { - ItemStack itemstack = p_29920_.m_21120_(p_29921_); -- if (itemstack.m_150930_(Items.f_42574_) && this.m_6220_()) { -+ if (false && itemstack.m_41720_() == Items.f_42574_ && this.m_6220_()) { //Forge: Moved to onSheared - this.m_5851_(SoundSource.PLAYERS); - this.m_146852_(GameEvent.f_157781_, p_29920_); - if (!this.f_19853_.f_46443_) { + 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.getItem() == Items.SHEARS && this.readyForShearing()) { //Forge: Moved to onSheared + this.shear(SoundSource.PLAYERS); + this.gameEvent(GameEvent.SHEAR, p_29920_); + if (!this.level.isClientSide) { @@ -153,7 +_,9 @@ - this.f_19853_.m_6269_((Player)null, this, SoundEvents.f_12480_, p_29907_, 1.0F, 1.0F); - if (!this.f_19853_.m_5776_()) { - this.m_29936_(false); + this.level.playSound((Player)null, this, SoundEvents.SNOW_GOLEM_SHEAR, p_29907_, 1.0F, 1.0F); + if (!this.level.isClientSide()) { + this.setPumpkin(false); + this.forceDrops = true; // CraftBukkit - this.m_5552_(new ItemStack(Items.f_42047_), 1.7F); + this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), 1.7F); + this.forceDrops = false; // CraftBukkit } } @@ -193,5 +_,22 @@ - public Vec3 m_7939_() { - return new Vec3(0.0D, (double)(0.75F * this.m_20192_()), (double)(this.m_20205_() * 0.4F)); + public Vec3 getLeashOffset() { + return new Vec3(0.0D, (double)(0.75F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F)); + } + + @Override + public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) { -+ return m_6220_(); ++ return readyForShearing(); + } + + @javax.annotation.Nonnull + @Override + public java.util.List onSheared(@Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) { -+ world.m_6269_(null, this, SoundEvents.f_12480_, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); -+ this.m_146852_(GameEvent.f_157781_, player); -+ if (!world.m_5776_()) { -+ m_29936_(false); -+ return java.util.Collections.singletonList(new ItemStack(Items.f_42047_)); ++ 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()) { ++ setPumpkin(false); ++ return java.util.Collections.singletonList(new ItemStack(Items.CARVED_PUMPKIN)); + } + return java.util.Collections.emptyList(); } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Turtle.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Turtle.java.patch index 4621476b..a8313d19 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Turtle.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Turtle.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/Turtle.java +++ b/net/minecraft/world/entity/animal/Turtle.java @@ -284,7 +_,9 @@ - protected void m_142669_() { - super.m_142669_(); - if (!this.m_6162_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46135_)) { + protected void ageBoundaryReached() { + super.ageBoundaryReached(); + if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + this.forceDrops = true; // CraftBukkit - this.m_20000_(Items.f_42355_, 1); + this.spawnAtLocation(Items.SCUTE, 1); + this.forceDrops = false; // CraftBukkit } @@ -13,25 +13,25 @@ @@ -308,7 +_,9 @@ } - public void m_8038_(ServerLevel p_30140_, LightningBolt p_30141_) { + public void thunderHit(ServerLevel p_30140_, LightningBolt p_30141_) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = p_30141_; // CraftBukkit - this.m_6469_(DamageSource.f_19306_, Float.MAX_VALUE); + this.hurt(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; // CraftBukkit } static class TurtleBreedGoal extends BreedGoal { @@ -467,8 +_,12 @@ - this.f_30274_.m_30236_(true); - } else if (this.f_30274_.f_30129_ > this.m_183277_(200)) { - Level level = this.f_30274_.f_19853_; -- level.m_5594_((Player)null, blockpos, SoundEvents.f_12486_, SoundSource.BLOCKS, 0.3F, 0.9F + level.f_46441_.nextFloat() * 0.2F); -- level.m_7731_(this.f_25602_.m_7494_(), Blocks.f_50578_.m_49966_().m_61124_(TurtleEggBlock.f_57754_, Integer.valueOf(this.f_30274_.f_19796_.nextInt(4) + 1)), 3); + this.turtle.setLayingEgg(true); + } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { + Level level = this.turtle.level; +- level.playSound((Player)null, blockpos, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + level.random.nextFloat() * 0.2F); +- level.setBlock(this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, Integer.valueOf(this.turtle.random.nextInt(4) + 1)), 3); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_30274_, this.f_25602_.m_7494_(), (BlockState) Blocks.f_50578_.m_49966_().m_61124_(TurtleEggBlock.f_57754_, this.f_30274_.f_19796_.nextInt(4) + 1)).isCancelled()) { -+ level.m_5594_((Player)null, blockpos, SoundEvents.f_12486_, SoundSource.BLOCKS, 0.3F, 0.9F + level.f_46441_.nextFloat() * 0.2F); -+ level.m_7731_(this.f_25602_.m_7494_(), Blocks.f_50578_.m_49966_().m_61124_(TurtleEggBlock.f_57754_, Integer.valueOf(this.f_30274_.f_19796_.nextInt(4) + 1)), 3); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) { ++ level.playSound((Player)null, blockpos, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + level.random.nextFloat() * 0.2F); ++ level.setBlock(this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, Integer.valueOf(this.turtle.random.nextInt(4) + 1)), 3); + } + // CraftBukkit end - this.f_30274_.m_30234_(false); - this.f_30274_.m_30236_(false); - this.f_30274_.m_27601_(600); + this.turtle.setHasEgg(false); + this.turtle.setLayingEgg(false); + this.turtle.setInLoveTime(600); 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 3fbf0068..a5d58169 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/Wolf.java +++ b/net/minecraft/world/entity/animal/Wolf.java @@ -123,6 +_,16 @@ - return Mob.m_21552_().m_22268_(Attributes.f_22279_, (double)0.3F).m_22268_(Attributes.f_22276_, 8.0D).m_22268_(Attributes.f_22281_, 2.0D); + return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, (double)0.3F).add(Attributes.MAX_HEALTH, 8.0D).add(Attributes.ATTACK_DAMAGE, 2.0D); } + // CraftBukkit - add overriden version @@ -10,72 +10,72 @@ + if (!super.setTarget(entityliving, reason, fire)) { + return false; + } -+ entityliving = m_5448_(); ++ entityliving = getTarget(); + return true; + } + // CraftBukkit end - protected void m_8097_() { - super.m_8097_(); - this.f_19804_.m_135372_(f_30358_, false); + protected void defineSynchedData() { + super.defineSynchedData(); + this.entityData.define(DATA_INTERESTED_ID, false); @@ -284,7 +_,7 @@ } else { - Entity entity = p_30386_.m_7639_(); - if (!this.f_19853_.f_46443_) { -- this.m_21839_(false); + Entity entity = p_30386_.getEntity(); + if (!this.level.isClientSide) { +- this.setOrderedToSit(false); + // this.setOrderedToSit(false); // CraftBukkit - moved into LivingEntity.damageEntity(DamageSource, float) } if (entity != null && !(entity instanceof Player) && !(entity instanceof AbstractArrow)) { @@ -308,7 +_,7 @@ - super.m_7105_(p_30443_); + super.setTame(p_30443_); if (p_30443_) { - this.m_21051_(Attributes.f_22276_).m_22100_(20.0D); -- this.m_21153_(20.0F); -+ this.m_21153_(this.m_21233_()); // CraftBukkit - 20.0 -> getMaxHealth() + this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(20.0D); +- this.setHealth(20.0F); ++ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() } else { - this.m_21051_(Attributes.f_22276_).m_22100_(8.0D); + this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0D); } @@ -325,11 +_,12 @@ } else { - if (this.m_21824_()) { - if (this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) { + if (this.isTame()) { + if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); //Magma -+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_()); - if (!p_30412_.m_150110_().f_35937_) { - itemstack.m_41774_(1); ++ this.heal((float)itemstack.getFoodProperties(this).getNutrition()); + if (!p_30412_.getAbilities().instabuild) { + itemstack.shrink(1); } -- this.m_5634_((float)item.m_41473_().m_38744_()); - this.m_146859_(GameEvent.f_157771_, this.m_146901_()); +- this.heal((float)item.getFoodProperties().getNutrition()); + this.gameEvent(GameEvent.MOB_INTERACT, this.eyeBlockPosition()); return InteractionResult.SUCCESS; } @@ -340,7 +_,7 @@ - this.m_21839_(!this.m_21827_()); - this.f_20899_ = false; - this.f_21344_.m_26573_(); -- this.m_6710_((LivingEntity)null); + this.setOrderedToSit(!this.isOrderedToSit()); + this.jumping = false; + this.navigation.stop(); +- this.setTarget((LivingEntity)null); + this.setTarget((LivingEntity)null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason return InteractionResult.SUCCESS; } @@ -360,8 +_,9 @@ - if (!p_30412_.m_150110_().f_35937_) { - itemstack.m_41774_(1); + if (!p_30412_.getAbilities().instabuild) { + itemstack.shrink(1); } - -- if (this.f_19796_.nextInt(3) == 0) { +- if (this.random.nextInt(3) == 0) { + + // CraftBukkit - added event call and isCancelled check. -+ if (this.f_19796_.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_30412_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_30412_).isCancelled()) { - this.m_21828_(p_30412_); - this.f_21344_.m_26573_(); - this.m_6710_((LivingEntity)null); ++ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_30412_) || !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTameEvent(this, p_30412_).isCancelled()) { + this.tame(p_30412_); + this.navigation.stop(); + this.setTarget((LivingEntity)null); @@ -401,7 +_,7 @@ - public boolean m_6898_(ItemStack p_30440_) { - Item item = p_30440_.m_41720_(); -- return item.m_41472_() && item.m_41473_().m_38746_(); -+ return item.m_41472_() && p_30440_.getFoodProperties(this).m_38746_(); + public boolean isFood(ItemStack p_30440_) { + Item item = p_30440_.getItem(); +- return item.isEdible() && item.getFoodProperties().isMeat(); ++ return item.isEdible() && p_30440_.getFoodProperties(this).isMeat(); } - public int m_5792_() { + public int getMaxSpawnClusterSize() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch index f235e669..4a78c27d 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch @@ -8,28 +8,28 @@ + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override + public int getDefaultMaxAirSupply() { -+ return f_149099_; ++ return AXOLOTL_TOTAL_AIR_SUPPLY; + } + // CraftBukkit end - private static final Logger f_212250_ = LogUtils.getLogger(); - public static final int f_149090_ = 200; - protected static final ImmutableList>> f_149091_ = ImmutableList.of(SensorType.f_26811_, SensorType.f_26822_, SensorType.f_26814_, SensorType.f_148315_, SensorType.f_148316_); + private static final Logger LOGGER = LogUtils.getLogger(); + public static final int TOTAL_PLAYDEAD_TIME = 200; + protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS); @@ -174,7 +_,7 @@ } - public int m_6062_() { + public int getMaxAirSupply() { - return 6000; + return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() } - public Axolotl.Variant m_149179_() { + public Axolotl.Variant getVariant() { @@ -378,7 +_,8 @@ - int i = mobeffectinstance != null ? mobeffectinstance.m_19557_() : 0; + int i = mobeffectinstance != null ? mobeffectinstance.getDuration() : 0; if (i < 2400) { i = Math.min(2400, 100 + i); -- p_149174_.m_147207_(new MobEffectInstance(MobEffects.f_19605_, i, 0), this); +- p_149174_.addEffect(new MobEffectInstance(MobEffects.REGENERATION, i, 0), this); + p_149174_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); //Magma -+ p_149174_.m_147207_(new MobEffectInstance(MobEffects.f_19605_, i, 0), this); // CraftBukkit ++ p_149174_.addEffect(new MobEffectInstance(MobEffects.REGENERATION, i, 0), this); // CraftBukkit } - p_149174_.m_21195_(MobEffects.f_19599_); + p_149174_.removeEffect(MobEffects.DIG_SLOWDOWN); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/goat/Goat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/goat/Goat.java.patch index 1337b2b6..ef49f735 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java @@ -151,8 +_,15 @@ - public InteractionResult m_6071_(Player p_149379_, InteractionHand p_149380_) { - ItemStack itemstack = p_149379_.m_21120_(p_149380_); - if (itemstack.m_150930_(Items.f_42446_) && !this.m_6162_()) { + public InteractionResult mobInteract(Player p_149379_, InteractionHand p_149380_) { + ItemStack itemstack = p_149379_.getItemInHand(p_149380_); + if (itemstack.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) p_149379_.f_19853_, p_149379_, this.m_142538_(), this.m_142538_(), null, itemstack, Items.f_42455_); ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) p_149379_.level, p_149379_, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET); + + if (event.isCancelled()) { + return InteractionResult.PASS; + } + // CraftBukkit end - p_149379_.m_5496_(this.m_149403_(), 1.0F, 1.0F); -- ItemStack itemstack1 = ItemUtils.m_41813_(itemstack, p_149379_, Items.f_42455_.m_7968_()); -+ ItemStack itemstack1 = ItemUtils.m_41813_(itemstack, p_149379_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - p_149379_.m_21008_(p_149380_, itemstack1); - return InteractionResult.m_19078_(this.f_19853_.f_46443_); + p_149379_.playSound(this.getMilkingSound(), 1.0F, 1.0F); +- ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, p_149379_, Items.MILK_BUCKET.getDefaultInstance()); ++ ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, p_149379_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + p_149379_.setItemInHand(p_149380_, itemstack1); + return InteractionResult.sidedSuccess(this.level.isClientSide); } else { 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 4b70b6f2..cdc2147f 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,100 +1,100 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java @@ -106,6 +_,7 @@ - private float f_30516_; - protected boolean f_30523_ = true; - protected int f_30524_; + private float mouthAnimO; + protected boolean canGallop = true; + protected int gallopSoundCounter; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected AbstractHorse(EntityType p_30531_, Level p_30532_) { super(p_30531_, p_30532_); @@ -273,7 +_,7 @@ - public void m_30625_() { - SimpleContainer simplecontainer = this.f_30520_; -- this.f_30520_ = new SimpleContainer(this.m_7506_()); -+ this.f_30520_ = new SimpleContainer(this.m_7506_(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit + public void createInventory() { + SimpleContainer simplecontainer = this.inventory; +- this.inventory = new SimpleContainer(this.getInventorySize()); ++ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit if (simplecontainer != null) { - simplecontainer.m_19181_(this); - int i = Math.min(simplecontainer.m_6643_(), this.f_30520_.m_6643_()); + simplecontainer.removeListener(this); + int i = Math.min(simplecontainer.getContainerSize(), this.inventory.getContainerSize()); @@ -288,6 +_,7 @@ - this.f_30520_.m_19164_(this); - this.m_7493_(); -+ this.itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this.f_30520_)); + this.inventory.addListener(this); + this.updateContainerEquipment(); ++ this.itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this.inventory)); } - protected void m_7493_() { + protected void updateContainerEquipment() { @@ -346,9 +_,9 @@ - protected void m_7355_(BlockPos p_30584_, BlockState p_30585_) { - if (!p_30585_.m_60767_().m_76332_()) { - BlockState blockstate = this.f_19853_.m_8055_(p_30584_.m_7494_()); -- SoundType soundtype = p_30585_.m_60827_(); -+ SoundType soundtype = p_30585_.getSoundType(f_19853_, p_30584_, this); - if (blockstate.m_60713_(Blocks.f_50125_)) { -- soundtype = blockstate.m_60827_(); -+ soundtype = blockstate.getSoundType(f_19853_, p_30584_, this); + protected void playStepSound(BlockPos p_30584_, BlockState p_30585_) { + if (!p_30585_.getMaterial().isLiquid()) { + BlockState blockstate = this.level.getBlockState(p_30584_.above()); +- SoundType soundtype = p_30585_.getSoundType(); ++ SoundType soundtype = p_30585_.getSoundType(level, p_30584_, this); + if (blockstate.is(Blocks.SNOW)) { +- soundtype = blockstate.getSoundType(); ++ soundtype = blockstate.getSoundType(level, p_30584_, this); } - if (this.m_20160_() && this.f_30523_) { + if (this.isVehicle() && this.canGallop) { @@ -380,7 +_,7 @@ } - public int m_7555_() { + public int getMaxTemper() { - return 100; + return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 } - protected float m_6121_() { + protected float getSoundVolume() { @@ -450,6 +_,7 @@ } - if (this.m_21223_() < this.m_21233_() && f > 0.0F) { + if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); - this.m_5634_(f); + this.heal(f); flag = true; } @@ -522,6 +_,7 @@ - super.m_8107_(); - if (!this.f_19853_.f_46443_ && this.m_6084_()) { - if (this.f_19796_.nextInt(900) == 0 && this.f_20919_ == 0) { + super.aiStep(); + if (!this.level.isClientSide && this.isAlive()) { + if (this.random.nextInt(900) == 0 && this.deathTime == 0) { + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); - this.m_5634_(1.0F); + this.heal(1.0F); } @@ -700,6 +_,7 @@ - this.m_20334_(vec3.f_82479_, d1, vec3.f_82481_); - this.m_30655_(true); - this.f_19812_ = true; + this.setDeltaMovement(vec3.x, d1, vec3.z); + this.setIsJumping(true); + this.hasImpulse = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); if (f1 > 0.0F) { - float f2 = Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)); - float f3 = Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)); + float f2 = Mth.sin(this.getYRot() * ((float)Math.PI / 180F)); + float f3 = Mth.cos(this.getYRot() * ((float)Math.PI / 180F)); @@ -744,6 +_,7 @@ - if (this.m_30615_() != null) { - p_30589_.m_128362_("Owner", this.m_30615_()); + if (this.getOwnerUUID() != null) { + p_30589_.putUUID("Owner", this.getOwnerUUID()); } -+ p_30589_.m_128405_("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit ++ p_30589_.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit - if (!this.f_30520_.m_8020_(0).m_41619_()) { - p_30589_.m_128365_("SaddleItem", this.f_30520_.m_8020_(0).m_41739_(new CompoundTag())); + if (!this.inventory.getItem(0).isEmpty()) { + p_30589_.put("SaddleItem", this.inventory.getItem(0).save(new CompoundTag())); @@ -769,6 +_,12 @@ - this.m_30586_(uuid); + this.setOwnerUUID(uuid); } + // CraftBukkit start -+ if (p_30565_.m_128441_("Bukkit.MaxDomestication")) { -+ this.maxDomestication = p_30565_.m_128451_("Bukkit.MaxDomestication"); ++ if (p_30565_.contains("Bukkit.MaxDomestication")) { ++ this.maxDomestication = p_30565_.getInt("Bukkit.MaxDomestication"); + } + // CraftBukkit end + - if (p_30565_.m_128425_("SaddleItem", 10)) { - ItemStack itemstack = ItemStack.m_41712_(p_30565_.m_128469_("SaddleItem")); - if (itemstack.m_150930_(Items.f_42450_)) { + if (p_30565_.contains("SaddleItem", 10)) { + ItemStack itemstack = ItemStack.of(p_30565_.getCompound("SaddleItem")); + if (itemstack.is(Items.SADDLE)) { @@ -840,6 +_,18 @@ } - public void m_7199_(int p_30574_) { + public void handleStartJump(int p_30574_) { + // CraftBukkit start + float power; + if (p_30574_ >= 90) { @@ -107,20 +107,20 @@ + return; + } + // CraftBukkit end - this.f_30510_ = true; - this.m_30613_(); - this.m_7486_(); + this.allowStandSliding = true; + this.stand(); + this.playJumpSound(); @@ -1029,6 +_,25 @@ - this.m_7505_(); - return super.m_6518_(p_30555_, p_30556_, p_30557_, p_30558_, p_30559_); + this.randomizeAttributes(); + return super.finalizeSpawn(p_30555_, p_30556_, p_30557_, p_30558_, p_30559_); + } + + private net.minecraftforge.common.util.LazyOptional itemHandler = null; + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.core.Direction facing) { -+ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && itemHandler != null) ++ if (this.isAlive() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && itemHandler != null) + return itemHandler.cast(); + return super.getCapability(capability, facing); + } @@ -135,4 +135,4 @@ + } } - public boolean m_149511_(Container p_149512_) { + public boolean hasInventoryChanged(Container p_149512_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch index d509feb6..da4db096 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/horse/Horse.java +++ b/net/minecraft/world/entity/animal/horse/Horse.java @@ -139,6 +_,8 @@ - this.m_5496_(SoundEvents.f_11974_, p_30709_.m_56773_() * 0.6F, p_30709_.m_56774_()); + this.playSound(SoundEvents.HORSE_BREATHE, p_30709_.getVolume() * 0.6F, p_30709_.getPitch()); } -+ ItemStack stack = this.f_30520_.m_8020_(1); -+ if (m_6010_(stack)) stack.onHorseArmorTick(f_19853_, this); ++ ItemStack stack = this.inventory.getItem(1); ++ if (isArmor(stack)) stack.onHorseArmorTick(level, this); } - protected SoundEvent m_7515_() { + protected SoundEvent getAmbientSound() { 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 2b5d145b..ee736958 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 @@ -6,9 +6,9 @@ + // Magma start - NMS + public void setStrengthPublic(int i) { -+ this.m_30840_(i); ++ this.setStrength(i); + } + // Magma end - public void m_30840_(int p_30841_) { - this.f_19804_.m_135381_(f_30745_, Math.max(1, Math.min(5, p_30841_))); + public void setStrength(int p_30841_) { + this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, p_30841_))); } 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 e6f1123c..d8a35470 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 @@ -2,39 +2,39 @@ +++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java @@ -27,6 +_,10 @@ - public void m_8037_() { - ServerLevel serverlevel = (ServerLevel)this.f_30925_.f_19853_; + public void tick() { + ServerLevel serverlevel = (ServerLevel)this.horse.level; + // Forge: Trigger the trap in a tick task to avoid crashes when mods add goals to skeleton horses + // (MC-206338/Forge PR #7509) -+ serverlevel.m_142572_().m_6937_(new net.minecraft.server.TickTask(serverlevel.m_142572_().m_129921_(), () -> { -+ if (!this.f_30925_.m_6084_()) return; - DifficultyInstance difficultyinstance = serverlevel.m_6436_(this.f_30925_.m_142538_()); - this.f_30925_.m_30923_(false); - this.f_30925_.m_30651_(true); ++ 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); @@ -34,19 +_,22 @@ - LightningBolt lightningbolt = EntityType.f_20465_.m_20615_(serverlevel); - lightningbolt.m_6027_(this.f_30925_.m_20185_(), this.f_30925_.m_20186_(), this.f_30925_.m_20189_()); - lightningbolt.m_20874_(true); -- serverlevel.m_7967_(lightningbolt); + LightningBolt lightningbolt = EntityType.LIGHTNING_BOLT.create(serverlevel); + lightningbolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); + lightningbolt.setVisualOnly(true); +- serverlevel.addFreshEntity(lightningbolt); + serverlevel.strikeLightning(lightningbolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit - Skeleton skeleton = this.m_30931_(difficultyinstance, this.f_30925_); -- skeleton.m_20329_(this.f_30925_); -+ if (skeleton != null) skeleton.m_20329_(this.f_30925_); // CraftBukkit + Skeleton skeleton = this.createSkeleton(difficultyinstance, this.horse); +- skeleton.startRiding(this.horse); ++ if (skeleton != null) skeleton.startRiding(this.horse); // CraftBukkit + serverlevel.prepareEntity(skeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); //Magma - add spawn reason - serverlevel.m_47205_(skeleton); + serverlevel.addFreshEntityWithPassengers(skeleton); for(int i = 0; i < 3; ++i) { - AbstractHorse abstracthorse = this.m_30929_(difficultyinstance); + AbstractHorse abstracthorse = this.createHorse(difficultyinstance); + if (abstracthorse == null) continue; // CraftBukkit - Skeleton skeleton1 = this.m_30931_(difficultyinstance, abstracthorse); -- skeleton1.m_20329_(abstracthorse); -+ if (skeleton1 != null) skeleton1.m_20329_(abstracthorse); // CraftBukkit - abstracthorse.m_5997_(this.f_30925_.m_21187_().nextGaussian() * 0.5D, 0.0D, this.f_30925_.m_21187_().nextGaussian() * 0.5D); + Skeleton skeleton1 = this.createSkeleton(difficultyinstance, abstracthorse); +- skeleton1.startRiding(abstracthorse); ++ if (skeleton1 != null) skeleton1.startRiding(abstracthorse); // CraftBukkit + abstracthorse.push(this.horse.getRandom().nextGaussian() * 0.5D, 0.0D, this.horse.getRandom().nextGaussian() * 0.5D); + serverlevel.prepareEntity(abstracthorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); //Magma - add spawn reason - serverlevel.m_47205_(abstracthorse); + serverlevel.addFreshEntityWithPassengers(abstracthorse); } - + })); } - private AbstractHorse m_30929_(DifficultyInstance p_30930_) { + private AbstractHorse createHorse(DifficultyInstance p_30930_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch index 4591ab0e..74095ab8 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch @@ -3,9 +3,9 @@ @@ -136,7 +_,7 @@ } - public void m_8056_() { -- this.f_26135_.m_6710_(this.f_30963_); -+ this.f_26135_.setTarget(this.f_30963_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - Entity entity = this.f_30962_.m_21524_(); + public void start() { +- this.mob.setTarget(this.ownerLastHurtBy); ++ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit + Entity entity = this.llama.getLeashHolder(); if (entity instanceof WanderingTrader) { - this.f_30964_ = ((WanderingTrader)entity).m_21213_(); + this.timestamp = ((WanderingTrader)entity).getLastHurtByMobTimestamp(); 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 9906520e..e6fb8157 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch @@ -6,13 +6,13 @@ -public class EnderDragonPart extends Entity { +public class EnderDragonPart extends net.minecraftforge.entity.PartEntity { - public final EnderDragon f_31010_; - public final String f_31011_; - private final EntityDimensions f_31012_; + public final EnderDragon parentMob; + public final String name; + private final EntityDimensions size; public EnderDragonPart(EnderDragon p_31014_, String p_31015_, float p_31016_, float p_31017_) { -- super(p_31014_.m_6095_(), p_31014_.f_19853_); +- super(p_31014_.getType(), p_31014_.level); + super(p_31014_); - this.f_31012_ = EntityDimensions.m_20395_(p_31016_, p_31017_); - this.m_6210_(); - this.f_31010_ = p_31014_; + this.size = EntityDimensions.scalable(p_31016_, p_31017_); + this.refreshDimensions(); + this.parentMob = p_31014_; diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch index 678119d4..acd38b9d 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java @@ -51,7 +_,11 @@ - if (this.f_19853_ instanceof ServerLevel) { - BlockPos blockpos = this.m_142538_(); - if (((ServerLevel)this.f_19853_).m_8586_() != null && this.f_19853_.m_8055_(blockpos).m_60795_()) { -- this.f_19853_.m_46597_(blockpos, BaseFireBlock.m_49245_(this.f_19853_, blockpos)); + if (this.level instanceof ServerLevel) { + BlockPos blockpos = this.blockPosition(); + if (((ServerLevel)this.level).dragonFight() != null && this.level.getBlockState(blockpos).isAir()) { +- this.level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level, blockpos)); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(this.f_19853_, blockpos, this).isCancelled()) { -+ this.f_19853_.m_46597_(blockpos, BaseFireBlock.m_49245_(this.f_19853_, blockpos)); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(this.level, blockpos, this).isCancelled()) { ++ this.level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level, blockpos)); + } + // CraftBukkit end } @@ -16,25 +16,25 @@ @@ -87,9 +_,23 @@ return false; } else { - if (!this.m_146910_() && !this.f_19853_.f_46443_) { + if (!this.isRemoved() && !this.level.isClientSide) { + // CraftBukkit start - All non-living entities need this + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_31050_, p_31051_, false)) { + return false; + } + // CraftBukkit end - this.m_142687_(Entity.RemovalReason.KILLED); - if (!p_31050_.m_19372_()) { -- this.f_19853_.m_46511_((Entity)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), 6.0F, Explosion.BlockInteraction.DESTROY); + this.remove(Entity.RemovalReason.KILLED); + if (!p_31050_.isExplosion()) { +- this.level.explode((Entity)null, this.getX(), this.getY(), this.getZ(), 6.0F, Explosion.BlockInteraction.DESTROY); + // CraftBukkit start + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.m_146912_(); ++ this.unsetRemoved(); + return false; + } -+ this.f_19853_.prepareExplosion(event.getFire()); //Magma - fix mixin inject error -+ this.f_19853_.m_46511_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), event.getRadius(), Explosion.BlockInteraction.DESTROY); ++ this.level.prepareExplosion(event.getFire()); //Magma - fix mixin inject error ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), Explosion.BlockInteraction.DESTROY); + // CraftBukkit end } - this.m_31047_(p_31050_); + this.onDestroyedBy(p_31050_); 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 e5dd76fe..516d614c 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,68 +1,68 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java @@ -85,6 +_,7 @@ - private final Node[] f_31077_ = new Node[24]; - private final int[] f_31078_ = new int[24]; - private final BinaryHeap f_31079_ = new BinaryHeap(); + private final Node[] nodes = new Node[24]; + private final int[] nodeAdjacency = new int[24]; + private final BinaryHeap openSet = new BinaryHeap(); + private net.minecraft.world.level.Explosion explosionSource; public EnderDragon(EntityType p_31096_, Level p_31097_) { - super(EntityType.f_20565_, p_31097_); + super(EntityType.ENDER_DRAGON, p_31097_); @@ -107,6 +_,15 @@ } - this.f_31074_ = new EnderDragonPhaseManager(this); -+ this.m_20234_(f_19843_.getAndAdd(this.f_31089_.length + 1) + 1); // Forge: Fix MC-158205: Make sure part ids are successors of parent mob id + 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 + this.explosionSource = new net.minecraft.world.level.Explosion(p_31097_, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, net.minecraft.world.level.Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() //Magma - moved to constructor and added level + } + + @Override -+ public void m_20234_(int p_20235_) { -+ super.m_20234_(p_20235_); -+ for (int i = 0; i < this.f_31089_.length; i++) // Forge: Fix MC-158205: Set part ids to successors of parent mob id -+ this.f_31089_[i].m_20234_(p_20235_ + i + 1); ++ public void setId(int p_20235_) { ++ super.setId(p_20235_); ++ for (int i = 0; i < this.subEntities.length; i++) // Forge: Fix MC-158205: Set part ids to successors of parent mob id ++ this.subEntities[i].setId(p_20235_ + i + 1); } - public static AttributeSupplier.Builder m_31167_() { + public static AttributeSupplier.Builder createAttributes() { @@ -150,7 +_,11 @@ return adouble; } + @javax.annotation.Nullable private Player unlimitedLastHurtByPlayer = null; - public void m_8107_() { + public void aiStep() { + // lastHurtByPlayer is cleared after 100 ticks, capture it indefinitely in unlimitedLastHurtByPlayer for LivingExperienceDropEvent -+ if (this.f_20888_ != null) this.unlimitedLastHurtByPlayer = f_20888_; -+ if (this.unlimitedLastHurtByPlayer != null && this.unlimitedLastHurtByPlayer.m_146910_()) this.unlimitedLastHurtByPlayer = null; - this.m_146874_(); - if (this.f_19853_.f_46443_) { - this.m_21153_(this.m_21223_()); ++ if (this.lastHurtByPlayer != null) this.unlimitedLastHurtByPlayer = lastHurtByPlayer; ++ if (this.unlimitedLastHurtByPlayer != null && this.unlimitedLastHurtByPlayer.isRemoved()) this.unlimitedLastHurtByPlayer = null; + this.processFlappingMovement(); + if (this.level.isClientSide) { + this.setHealth(this.getHealth()); @@ -219,7 +_,7 @@ } - Vec3 vec31 = dragonphaseinstance.m_5535_(); + Vec3 vec31 = dragonphaseinstance.getFlyTargetLocation(); - if (vec31 != null) { -+ if (vec31 != null && dragonphaseinstance.m_7309_() != EnderDragonPhase.f_31387_) { // CraftBukkit - Don't move when hovering - double d7 = vec31.f_82479_ - this.m_20185_(); - double d8 = vec31.f_82480_ - this.m_20186_(); - double d9 = vec31.f_82481_ - this.m_20189_(); ++ if (vec31 != null && dragonphaseinstance.getPhase() != EnderDragonPhase.HOVERING) { // CraftBukkit - Don't move when hovering + double d7 = vec31.x - this.getX(); + double d8 = vec31.y - this.getY(); + double d9 = vec31.z - this.getZ(); @@ -349,7 +_,14 @@ - if (this.f_31086_.m_146910_()) { - this.f_31086_ = null; - } else if (this.f_19797_ % 10 == 0 && this.m_21223_() < this.m_21233_()) { -- this.m_21153_(this.m_21223_() + 1.0F); + if (this.nearestCrystal.isRemoved()) { + this.nearestCrystal = null; + } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { +- this.setHealth(this.getHealth() + 1.0F); + // CraftBukkit start + org.bukkit.event.entity.EntityRegainHealthEvent event = new org.bukkit.event.entity.EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.m_21153_((float) (this.m_21223_() + event.getAmount())); ++ this.setHealth((float) (this.getHealth() + event.getAmount())); + } + // CraftBukkit end } } @@ -413,6 +_,9 @@ - int j1 = Mth.m_14107_(p_31140_.f_82293_); + int j1 = Mth.floor(p_31140_.maxZ); boolean flag = false; boolean flag1 = false; + // CraftBukkit start - Create a list to hold all the destroyed blocks @@ -73,15 +73,15 @@ for(int l1 = j; l1 <= i1; ++l1) { @@ -420,8 +_,12 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); - BlockState blockstate = this.f_19853_.m_8055_(blockpos); - if (!blockstate.m_60795_() && blockstate.m_60767_() != Material.f_76309_) { -- if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && !blockstate.m_204336_(BlockTags.f_13069_)) { -- flag1 = this.f_19853_.m_7471_(blockpos, false) || flag1; -+ if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.f_19853_, blockpos, this) && !blockstate.m_204336_(BlockTags.f_13069_)) { + BlockState blockstate = this.level.getBlockState(blockpos); + if (!blockstate.isAir() && blockstate.getMaterial() != Material.FIRE) { +- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { +- flag1 = this.level.removeBlock(blockpos, false) || flag1; ++ if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.level, blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { + // CraftBukkit start - Add blocks to list rather than destroying them + // flag1 = this.level.removeBlock(blockpos, false) || flag1; + flag1 = true; -+ destroyedBlocks.add(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(f_19853_, blockpos)); ++ destroyedBlocks.add(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, blockpos)); + // CraftBukkit end } else { flag = true; @@ -106,7 +106,7 @@ + } else if (event.getYield() == 0F) { + // Yield zero ==> no drops + for (org.bukkit.block.Block block : event.blockList()) { -+ this.f_19853_.m_7471_(new BlockPos(block.getX(), block.getY(), block.getZ()), false); ++ this.level.removeBlock(new BlockPos(block.getX(), block.getY(), block.getZ()), false); + } + } else { + for (org.bukkit.block.Block block : event.blockList()) { @@ -118,52 +118,52 @@ + org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock craftBlock = ((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) block); + BlockPos blockposition = craftBlock.getPosition(); + -+ net.minecraft.world.level.block.Block nmsBlock = craftBlock.getNMS().m_60734_(); -+ if (nmsBlock.m_6903_(explosionSource)) { -+ net.minecraft.world.level.block.entity.BlockEntity tileentity = craftBlock.getNMS().m_155947_() ? this.f_19853_.m_7702_(blockposition) : null; -+ net.minecraft.world.level.storage.loot.LootContext.Builder loottableinfo_builder = (new net.minecraft.world.level.storage.loot.LootContext.Builder((ServerLevel) this.f_19853_)).m_78977_(this.f_19853_.f_46441_).m_78972_(net.minecraft.world.level.storage.loot.parameters.LootContextParams.f_81460_, Vec3.m_82512_(blockposition)).m_78972_(net.minecraft.world.level.storage.loot.parameters.LootContextParams.f_81463_, net.minecraft.world.item.ItemStack.f_41583_).m_78972_(net.minecraft.world.level.storage.loot.parameters.LootContextParams.f_81464_, 1.0F / event.getYield()).m_78984_(net.minecraft.world.level.storage.loot.parameters.LootContextParams.f_81462_, tileentity); ++ net.minecraft.world.level.block.Block nmsBlock = craftBlock.getNMS().getBlock(); ++ if (nmsBlock.dropFromExplosion(explosionSource)) { ++ net.minecraft.world.level.block.entity.BlockEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null; ++ net.minecraft.world.level.storage.loot.LootContext.Builder loottableinfo_builder = (new net.minecraft.world.level.storage.loot.LootContext.Builder((ServerLevel) this.level)).withRandom(this.level.random).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.ORIGIN, Vec3.atCenterOf(blockposition)).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.TOOL, net.minecraft.world.item.ItemStack.EMPTY).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.BLOCK_ENTITY, tileentity); + -+ craftBlock.getNMS().m_60724_(loottableinfo_builder).forEach((itemstack) -> { -+ net.minecraft.world.level.block.Block.m_49840_(f_19853_, blockposition, itemstack); ++ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> { ++ net.minecraft.world.level.block.Block.popResource(level, blockposition, itemstack); + }); -+ craftBlock.getNMS().m_60612_((ServerLevel) f_19853_, blockposition, net.minecraft.world.item.ItemStack.f_41583_); ++ craftBlock.getNMS().spawnAfterBreak((ServerLevel) level, blockposition, net.minecraft.world.item.ItemStack.EMPTY); + } -+ nmsBlock.m_7592_(f_19853_, blockposition, explosionSource); ++ nmsBlock.wasExploded(level, blockposition, explosionSource); + -+ this.f_19853_.m_7471_(blockposition, false); ++ this.level.removeBlock(blockposition, false); + } + } + // CraftBukkit end + if (flag1) { - BlockPos blockpos1 = new BlockPos(i + this.f_19796_.nextInt(l - i + 1), j + this.f_19796_.nextInt(i1 - j + 1), k + this.f_19796_.nextInt(j1 - k + 1)); - this.f_19853_.m_46796_(2008, blockpos1, 0); + BlockPos blockpos1 = new BlockPos(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1)); + this.level.levelEvent(2008, blockpos1, 0); @@ -514,11 +_,29 @@ - if (this.f_19853_ instanceof ServerLevel) { - if (this.f_31084_ > 150 && this.f_31084_ % 5 == 0 && flag) { -- ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), Mth.m_14143_((float)i * 0.08F)); -+ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.m_14143_((float)i * 0.08F)); -+ ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), award); + 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)); ++ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.08F)); ++ ExperienceOrb.award((ServerLevel)this.level, this.position(), award); } - if (this.f_31084_ == 1 && !this.m_20067_()) { -- this.f_19853_.m_6798_(1028, this.m_142538_(), 0); + if (this.dragonDeathTime == 1 && !this.isSilent()) { +- this.level.globalLevelEvent(1028, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds + // this.level.globalLevelEvent(1028, this.blockPosition(), 0); -+ int viewDistance = ((ServerLevel) this.f_19853_).getCraftServer().getViewDistance() * 16; -+ for (net.minecraft.server.level.ServerPlayer player : this.f_19853_.m_142572_().m_6846_().f_11196_) { -+ double deltaX = this.m_20185_() - player.m_20185_(); -+ double deltaZ = this.m_20189_() - player.m_20189_(); ++ int viewDistance = ((ServerLevel) this.level).getCraftServer().getViewDistance() * 16; ++ for (net.minecraft.server.level.ServerPlayer player : this.level.getServer().getPlayerList().players) { ++ double deltaX = this.getX() - player.getX(); ++ double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; -+ if ( f_19853_.spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > f_19853_.spigotConfig.dragonDeathSoundRadius * f_19853_.spigotConfig.dragonDeathSoundRadius ) continue; // Spigot ++ if ( level.spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > level.spigotConfig.dragonDeathSoundRadius * level.spigotConfig.dragonDeathSoundRadius ) continue; // Spigot + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); -+ double relativeX = player.m_20185_() + (deltaX / deltaLength) * viewDistance; -+ double relativeZ = player.m_20189_() + (deltaZ / deltaLength) * viewDistance; -+ player.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) relativeX, (int) this.m_20186_(), (int) relativeZ), 0, true)); ++ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; ++ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); + } else { -+ player.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) this.m_20185_(), (int) this.m_20186_(), (int) this.m_20189_()), 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) this.getX(), (int) this.getY(), (int) this.getZ()), 0, true)); + } + } + // CraftBukkit end @@ -171,15 +171,15 @@ } @@ -527,7 +_,8 @@ - this.f_20883_ = this.m_146908_(); - if (this.f_31084_ == 200 && this.f_19853_ instanceof ServerLevel) { + this.yBodyRot = this.getYRot(); + if (this.dragonDeathTime == 200 && this.level instanceof ServerLevel) { if (flag) { -- ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), Mth.m_14143_((float)i * 0.2F)); -+ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.m_14143_((float)i * 0.2F)); -+ ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), award); +- ExperienceOrb.award((ServerLevel)this.level, 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); } - if (this.f_31073_ != null) { + if (this.dragonFight != null) { @@ -849,8 +_,19 @@ return false; } @@ -191,12 +191,12 @@ + + @Override + public net.minecraftforge.entity.PartEntity[] getParts() { -+ return this.f_31089_; ++ return this.subEntities; + } + - public void m_142223_(ClientboundAddMobPacket p_149572_) { - super.m_142223_(p_149572_); + public void recreateFromPacket(ClientboundAddMobPacket p_149572_) { + super.recreateFromPacket(p_149572_); + if (true) return; // Forge: Fix MC-158205: Moved into setId() - EnderDragonPart[] aenderdragonpart = this.m_31156_(); + EnderDragonPart[] aenderdragonpart = this.getSubEntities(); for(int i = 0; i < aenderdragonpart.length; ++i) { diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java.patch index cad1d16c..ac14bbea 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java @@ -23,6 +_,26 @@ - this.f_31411_.m_7081_(); + this.currentPhase.end(); } + // CraftBukkit start - Call EnderDragonChangePhaseEvent @@ -10,11 +10,11 @@ + + if (bukkitPhase != org.bukkit.entity.EnderDragon.Phase.UNKNOWN) { + org.bukkit.event.entity.EnderDragonChangePhaseEvent event = new org.bukkit.event.entity.EnderDragonChangePhaseEvent( -+ (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEnderDragon) this.f_31409_.getBukkitEntity(), -+ (this.f_31411_ == null) ? null : org.bukkit.craftbukkit.v1_18_R2.entity.CraftEnderDragon.getBukkitPhase(this.f_31411_.m_7309_()), ++ (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEnderDragon) this.dragon.getBukkitEntity(), ++ (this.currentPhase == null) ? null : org.bukkit.craftbukkit.v1_18_R2.entity.CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()), + bukkitPhase + ); -+ this.f_31409_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.dragon.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } @@ -24,6 +24,6 @@ + + // CraftBukkit end + - this.f_31411_ = this.m_31418_(p_31417_); - if (!this.f_31409_.f_19853_.f_46443_) { - this.f_31409_.m_20088_().m_135381_(EnderDragon.f_31067_, p_31417_.m_31405_()); + this.currentPhase = this.getPhase(p_31417_); + if (!this.dragon.level.isClientSide) { + this.dragon.getEntityData().set(EnderDragon.DATA_PHASE, p_31417_.getId()); 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 ee5010b7..d608b141 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,89 +1,89 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java @@ -219,15 +_,42 @@ - int k1 = this.m_31502_() - 1; - this.f_31430_.m_142711_(1.0F - (float)k1 / 220.0F); + int k1 = this.getInvulnerableTicks() - 1; + this.bossEvent.setProgress(1.0F - (float)k1 / 220.0F); if (k1 <= 0) { -- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; -- this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20188_(), this.m_20189_(), 7.0F, false, explosion$blockinteraction); -+ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; +- Explosion.BlockInteraction explosion$blockinteraction = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; +- this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion$blockinteraction); ++ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + + // CraftBukkit start + // this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion$blockinteraction); + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20188_(), this.m_20189_(), event.getRadius(), event.getFire(), explosion$blockinteraction); ++ this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), explosion$blockinteraction); + } + // CraftBukkit end + - if (!this.m_20067_()) { -- this.f_19853_.m_6798_(1023, this.m_142538_(), 0); + if (!this.isSilent()) { +- this.level.globalLevelEvent(1023, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds + // this.level.globalLevelEvent(1023, this.blockPosition(), 0); -+ int viewDistance = ((net.minecraft.server.level.ServerLevel) this.f_19853_).getCraftServer().getViewDistance() * 16; -+ for (ServerPlayer player : (List) net.minecraft.server.MinecraftServer.getServer().m_6846_().f_11196_) { -+ double deltaX = this.m_20185_() - player.m_20185_(); -+ double deltaZ = this.m_20189_() - player.m_20189_(); ++ int viewDistance = ((net.minecraft.server.level.ServerLevel) this.level).getCraftServer().getViewDistance() * 16; ++ for (ServerPlayer player : (List) net.minecraft.server.MinecraftServer.getServer().getPlayerList().players) { ++ double deltaX = this.getX() - player.getX(); ++ double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; -+ if ( f_19853_.spigotConfig.witherSpawnSoundRadius > 0 && distanceSquared > f_19853_.spigotConfig.witherSpawnSoundRadius * f_19853_.spigotConfig.witherSpawnSoundRadius ) continue; // Spigot ++ if ( level.spigotConfig.witherSpawnSoundRadius > 0 && distanceSquared > level.spigotConfig.witherSpawnSoundRadius * level.spigotConfig.witherSpawnSoundRadius ) continue; // Spigot + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); -+ double relativeX = player.m_20185_() + (deltaX / deltaLength) * viewDistance; -+ double relativeZ = player.m_20189_() + (deltaZ / deltaLength) * viewDistance; -+ player.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1023, new BlockPos((int) relativeX, (int) this.m_20186_(), (int) relativeZ), 0, true)); ++ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; ++ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1023, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); + } else { -+ player.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1023, this.m_142538_(), 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1023, this.blockPosition(), 0, true)); + } + } + // CraftBukkit end } } - this.m_31510_(k1); - if (this.f_19797_ % 10 == 0) { + this.setInvulnerableTicks(k1); + if (this.tickCount % 10 == 0) { + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); - this.m_5634_(10.0F); + this.heal(10.0F); } @@ -266,6 +_,8 @@ - List list = this.f_19853_.m_45971_(LivingEntity.class, f_31432_, this, this.m_142469_().m_82377_(20.0D, 8.0D, 20.0D)); + List list = this.level.getNearbyEntities(LivingEntity.class, TARGETING_CONDITIONS, this, this.getBoundingBox().inflate(20.0D, 8.0D, 20.0D)); if (!list.isEmpty()) { - LivingEntity livingentity1 = list.get(this.f_19796_.nextInt(list.size())); + LivingEntity livingentity1 = list.get(this.random.nextInt(list.size())); + + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTargetLivingEvent(this, livingentity1, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit - this.m_31454_(i, livingentity1.m_142049_()); + this.setAlternativeTarget(i, livingentity1.getId()); } } @@ -280,7 +_,7 @@ - if (this.f_31429_ > 0) { - --this.f_31429_; -- if (this.f_31429_ == 0 && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (this.f_31429_ == 0 && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { - int j1 = Mth.m_14107_(this.m_20186_()); - int i2 = Mth.m_14107_(this.m_20185_()); - int j2 = Mth.m_14107_(this.m_20189_()); + 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)) { + int j1 = Mth.floor(this.getY()); + int i2 = Mth.floor(this.getX()); + int j2 = Mth.floor(this.getZ()); @@ -294,7 +_,12 @@ int i1 = j2 + k2; BlockPos blockpos = new BlockPos(l2, l, i1); - BlockState blockstate = this.f_19853_.m_8055_(blockpos); -- if (m_31491_(blockstate)) { -+ if (blockstate.canEntityDestroy(this.f_19853_, blockpos, this) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this, blockpos, blockstate)) { + BlockState blockstate = this.level.getBlockState(blockpos); +- if (canDestroy(blockstate)) { ++ if (blockstate.canEntityDestroy(this.level, blockpos, this) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this, blockpos, blockstate)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockpos, net.minecraft.world.level.block.Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockpos, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { + continue; + } + // CraftBukkit end - flag = this.f_19853_.m_46953_(blockpos, true, this) || flag; + flag = this.level.destroyBlock(blockpos, true, this) || flag; } } @@ -308,6 +_,7 @@ } - if (this.f_19797_ % 20 == 0) { + if (this.tickCount % 20 == 0) { + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); - this.m_5634_(1.0F); + this.heal(1.0F); } @@ -315,6 +_,7 @@ @@ -91,6 +91,6 @@ } + @Deprecated //Forge: DO NOT USE use BlockState.canEntityDestroy - public static boolean m_31491_(BlockState p_31492_) { - return !p_31492_.m_60795_() && !p_31492_.m_204336_(BlockTags.f_13070_); + public static boolean canDestroy(BlockState p_31492_) { + return !p_31492_.isAir() && !p_31492_.is(BlockTags.WITHER_IMMUNE); } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch index de24be65..db92d46a 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,66 +1,66 @@ --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -71,7 +_,7 @@ - public static final EntityDataAccessor f_31550_ = SynchedEntityData.m_135353_(ArmorStand.class, EntityDataSerializers.f_135037_); - public static final EntityDataAccessor f_31527_ = SynchedEntityData.m_135353_(ArmorStand.class, EntityDataSerializers.f_135037_); - private static final Predicate f_31537_ = (p_31582_) -> { -- return p_31582_ instanceof AbstractMinecart && ((AbstractMinecart)p_31582_).m_6064_() == AbstractMinecart.Type.RIDEABLE; + 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_) -> { +- return p_31582_ instanceof AbstractMinecart && ((AbstractMinecart)p_31582_).getMinecartType() == AbstractMinecart.Type.RIDEABLE; + return p_31582_ instanceof AbstractMinecart && ((AbstractMinecart)p_31582_).canBeRidden(); }; - private final NonNullList f_31538_ = NonNullList.m_122780_(2, ItemStack.f_41583_); - private final NonNullList f_31539_ = NonNullList.m_122780_(4, ItemStack.f_41583_); + private final NonNullList handItems = NonNullList.withSize(2, ItemStack.EMPTY); + private final NonNullList armorItems = NonNullList.withSize(4, ItemStack.EMPTY); @@ -95,6 +_,13 @@ - this.m_6034_(p_31557_, p_31558_, p_31559_); + this.setPos(p_31557_, p_31558_, p_31559_); } + // CraftBukkit start - SPIGOT-3607, SPIGOT-3637 + @Override + public float getBukkitYaw() { -+ return this.m_146908_(); ++ return this.getYRot(); + } + // CraftBukkit end + - public void m_6210_() { - double d0 = this.m_20185_(); - double d1 = this.m_20186_(); + public void refreshDimensions() { + double d0 = this.getX(); + double d1 = this.getY(); @@ -141,18 +_,25 @@ } } + @Override - public void m_8061_(EquipmentSlot p_31584_, ItemStack p_31585_) { - this.m_181122_(p_31585_); -- switch(p_31584_.m_20743_()) { + public void setItemSlot(EquipmentSlot p_31584_, ItemStack p_31585_) { + this.verifyEquippedItem(p_31585_); +- switch(p_31584_.getType()) { - case HAND: -- this.m_147218_(p_31585_); -- this.f_31538_.set(p_31584_.m_20749_(), p_31585_); +- this.equipEventAndSound(p_31585_); +- this.handItems.set(p_31584_.getIndex(), p_31585_); - break; - case ARMOR: -- this.m_147218_(p_31585_); -- this.f_31539_.set(p_31584_.m_20749_(), p_31585_); -+ switch (p_31584_.m_20743_()) { +- this.equipEventAndSound(p_31585_); +- this.armorItems.set(p_31584_.getIndex(), p_31585_); ++ switch (p_31584_.getType()) { + case HAND: -+ this.m_147218_(p_31585_); -+ this.f_31538_.set(p_31584_.m_20749_(), p_31585_); ++ this.equipEventAndSound(p_31585_); ++ this.handItems.set(p_31584_.getIndex(), p_31585_); + break; + case ARMOR: -+ this.m_147218_(p_31585_); -+ this.f_31539_.set(p_31584_.m_20749_(), p_31585_); ++ this.equipEventAndSound(p_31585_); ++ this.armorItems.set(p_31584_.getIndex(), p_31585_); } + } + @Override + public void setItemSlot(EquipmentSlot p_31584_, ItemStack p_31585_, boolean silent) { + silenceEquipSound(silent); -+ this.m_8061_(p_31584_, p_31585_); ++ this.setItemSlot(p_31584_, p_31585_); + silenceEquipSound(false); //reset } - public boolean m_7066_(ItemStack p_31638_) { + public boolean canTakeItem(ItemStack p_31638_) { @@ -355,6 +_,20 @@ - if (!itemstack.m_41619_() && (this.f_31541_ & 1 << p_31590_.m_20750_() + 8) != 0) { + if (!itemstack.isEmpty() && (this.disabledSlots & 1 << p_31590_.getFilterFlag() + 8) != 0) { return false; - } else if (itemstack.m_41619_() && (this.f_31541_ & 1 << p_31590_.m_20750_() + 16) != 0) { + } else if (itemstack.isEmpty() && (this.disabledSlots & 1 << p_31590_.getFilterFlag() + 16) != 0) { + + // CraftBukkit start + org.bukkit.inventory.ItemStack armorStandItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack); @@ -69,91 +69,91 @@ + org.bukkit.entity.ArmorStand self = (org.bukkit.entity.ArmorStand) this.getBukkitEntity(); + org.bukkit.inventory.EquipmentSlot slot = org.bukkit.craftbukkit.v1_18_R2.CraftEquipmentSlot.getSlot(p_31590_); + org.bukkit.event.player.PlayerArmorStandManipulateEvent armorStandManipulateEvent = new org.bukkit.event.player.PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(armorStandManipulateEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(armorStandManipulateEvent); + if (armorStandManipulateEvent.isCancelled()) { + return true; + } + // CraftBukkit end + return false; - } else if (p_31589_.m_150110_().f_35937_ && itemstack.m_41619_() && !p_31591_.m_41619_()) { - ItemStack itemstack2 = p_31591_.m_41777_(); + } else if (p_31589_.getAbilities().instabuild && itemstack.isEmpty() && !p_31591_.isEmpty()) { + ItemStack itemstack2 = p_31591_.copy(); @@ -381,9 +_,19 @@ - public boolean m_6469_(DamageSource p_31579_, float p_31580_) { - if (!this.f_19853_.f_46443_ && !this.m_146910_()) { - if (DamageSource.f_19317_.equals(p_31579_)) { + public boolean hurt(DamageSource p_31579_, float p_31580_) { + if (!this.level.isClientSide && !this.isRemoved()) { + if (DamageSource.OUT_OF_WORLD.equals(p_31579_)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_31579_, p_31580_)) { + return false; + } + // CraftBukkit end - this.m_6074_(); + this.kill(); return false; -- } else if (!this.m_6673_(p_31579_) && !this.f_31540_ && !this.m_31677_()) { -+ } else if (!this.m_6673_(p_31579_) && (true || !this.f_31540_) && !this.m_31677_()) { // CraftBukkit +- } else if (!this.isInvulnerableTo(p_31579_) && !this.invisible && !this.isMarker()) { ++ } else if (!this.isInvulnerableTo(p_31579_) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_31579_, p_31580_, true, this.f_31540_)) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_31579_, p_31580_, true, this.invisible)) { + return false; + } + // CraftBukkit end - if (p_31579_.m_19372_()) { - this.m_31653_(p_31579_); - this.m_6074_(); + if (p_31579_.isExplosion()) { + this.brokenByAnything(p_31579_); + this.kill(); @@ -410,7 +_,7 @@ - } else if (p_31579_.m_19390_()) { - this.m_31566_(); - this.m_31565_(); -- this.m_6074_(); -+ this.m_146870_(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event + } else if (p_31579_.isCreativePlayer()) { + this.playBrokenSound(); + this.showBreakingParticles(); +- this.kill(); ++ this.discard(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event return flag1; } else { - long i = this.f_19853_.m_46467_(); + long i = this.level.getGameTime(); @@ -478,18 +_,18 @@ } - private void m_31646_(DamageSource p_31647_) { -- Block.m_49840_(this.f_19853_, this.m_142538_(), new ItemStack(Items.f_42650_)); -+ drops.add(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.f_42650_))); // CraftBukkit - add to drops - this.m_31653_(p_31647_); + private void brokenByPlayer(DamageSource p_31647_) { +- Block.popResource(this.level, this.blockPosition(), new ItemStack(Items.ARMOR_STAND)); ++ drops.add(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops + this.brokenByAnything(p_31647_); } - private void m_31653_(DamageSource p_31654_) { - this.m_31566_(); -- this.m_6668_(p_31654_); + private void brokenByAnything(DamageSource p_31654_) { + this.playBrokenSound(); +- this.dropAllDeathLoot(p_31654_); + // this.dropAllDeathLoot(p_31654_); // CraftBukkit - moved down - for(int i = 0; i < this.f_31538_.size(); ++i) { - ItemStack itemstack = this.f_31538_.get(i); - if (!itemstack.m_41619_()) { -- Block.m_49840_(this.f_19853_, this.m_142538_().m_7494_(), itemstack); + for(int i = 0; i < this.handItems.size(); ++i) { + ItemStack itemstack = this.handItems.get(i); + if (!itemstack.isEmpty()) { +- Block.popResource(this.level, this.blockPosition().above(), itemstack); + drops.add(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.f_31538_.set(i, ItemStack.f_41583_); + this.handItems.set(i, ItemStack.EMPTY); } } @@ -497,10 +_,11 @@ - for(int j = 0; j < this.f_31539_.size(); ++j) { - ItemStack itemstack1 = this.f_31539_.get(j); - if (!itemstack1.m_41619_()) { -- Block.m_49840_(this.f_19853_, this.m_142538_().m_7494_(), itemstack1); + for(int j = 0; j < this.armorItems.size(); ++j) { + ItemStack itemstack1 = this.armorItems.get(j); + if (!itemstack1.isEmpty()) { +- Block.popResource(this.level, this.blockPosition().above(), itemstack1); + drops.add(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(itemstack1)); // CraftBukkit - add to drops - this.f_31539_.set(j, ItemStack.f_41583_); + this.armorItems.set(j, ItemStack.EMPTY); } } -+ this.m_6668_(p_31654_); // CraftBukkit - moved from above ++ this.dropAllDeathLoot(p_31654_); // CraftBukkit - moved from above } @@ -584,6 +_,13 @@ - public boolean m_6162_() { - return this.m_31666_(); + public boolean isBaby() { + return this.isSmall(); } + + // CraftBukkit start + @Override -+ protected boolean m_6149_() { ++ protected boolean shouldDropExperience() { + return true; // MC-157395, SPIGOT-5193 even baby (small) armor stands should drop + } + // CraftBukkit end - public void m_6074_() { - this.m_142687_(Entity.RemovalReason.KILLED); + public void kill() { + this.remove(Entity.RemovalReason.KILLED); 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 7454dcb6..5517de14 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -2,25 +2,25 @@ +++ b/net/minecraft/world/entity/decoration/HangingEntity.java @@ -55,45 +_,73 @@ - protected void m_7087_() { - if (this.f_31699_ != null) { -- double d0 = (double)this.f_31698_.m_123341_() + 0.5D; -- double d1 = (double)this.f_31698_.m_123342_() + 0.5D; -- double d2 = (double)this.f_31698_.m_123343_() + 0.5D; + protected void recalculateBoundingBox() { + if (this.direction != null) { +- double d0 = (double)this.pos.getX() + 0.5D; +- double d1 = (double)this.pos.getY() + 0.5D; +- double d2 = (double)this.pos.getZ() + 0.5D; - double d3 = 0.46875D; -- double d4 = this.m_31709_(this.m_7076_()); -- double d5 = this.m_31709_(this.m_7068_()); -- d0 -= (double)this.f_31699_.m_122429_() * 0.46875D; -- d2 -= (double)this.f_31699_.m_122431_() * 0.46875D; +- double d4 = this.offs(this.getWidth()); +- double d5 = this.offs(this.getHeight()); +- d0 -= (double)this.direction.getStepX() * 0.46875D; +- d2 -= (double)this.direction.getStepZ() * 0.46875D; - d1 += d5; -- Direction direction = this.f_31699_.m_122428_(); -- d0 += d4 * (double)direction.m_122429_(); -- d2 += d4 * (double)direction.m_122431_(); -- this.m_20343_(d0, d1, d2); -- double d6 = (double)this.m_7076_(); -- double d7 = (double)this.m_7068_(); -- double d8 = (double)this.m_7076_(); -- if (this.f_31699_.m_122434_() == Direction.Axis.Z) { +- Direction direction = this.direction.getCounterClockWise(); +- d0 += d4 * (double)direction.getStepX(); +- d2 += d4 * (double)direction.getStepZ(); +- this.setPosRaw(d0, d1, d2); +- double d6 = (double)this.getWidth(); +- double d7 = (double)this.getHeight(); +- double d8 = (double)this.getWidth(); +- if (this.direction.getAxis() == Direction.Axis.Z) { - d8 = 1.0D; - } else { - d6 = 1.0D; @@ -29,38 +29,38 @@ - d6 /= 32.0D; - d7 /= 32.0D; - d8 /= 32.0D; -- this.m_20011_(new AABB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); +- this.setBoundingBox(new AABB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); - } - } - -- private double m_31709_(int p_31710_) { +- private double offs(int p_31710_) { + // CraftBukkit start code moved in to calculateBoundingBox -+ this.m_20011_(calculateBoundingBox(this, this.f_31698_, this.f_31699_, this.m_7076_(), this.m_7068_())); ++ this.setBoundingBox(calculateBoundingBox(this, this.pos, this.direction, this.getWidth(), this.getHeight())); + // CraftBukkit end + } + } + + // CraftBukkit start - break out BB calc into own method + public static AABB calculateBoundingBox(Entity entity, BlockPos pos, Direction opposite, int width, int height) { -+ double d0 = (double) pos.m_123341_() + 0.5D; -+ double d1 = (double) pos.m_123342_() + 0.5D; -+ double d2 = (double) pos.m_123343_() + 0.5D; ++ double d0 = (double) pos.getX() + 0.5D; ++ double d1 = (double) pos.getY() + 0.5D; ++ double d2 = (double) pos.getZ() + 0.5D; + double d3 = 0.46875D; -+ double d4 = m_31709_(width); -+ double d5 = m_31709_(height); -+ d0 -= (double) opposite.m_122429_() * 0.46875D; -+ d2 -= (double) opposite.m_122431_() * 0.46875D; ++ double d4 = offs(width); ++ double d5 = offs(height); ++ d0 -= (double) opposite.getStepX() * 0.46875D; ++ d2 -= (double) opposite.getStepZ() * 0.46875D; + d1 += d5; -+ Direction direction = opposite.m_122428_(); -+ d0 += d4 * (double) direction.m_122429_(); -+ d2 += d4 * (double) direction.m_122431_(); ++ Direction direction = opposite.getCounterClockWise(); ++ d0 += d4 * (double) direction.getStepX(); ++ d2 += d4 * (double) direction.getStepZ(); + if (entity != null) { -+ entity.m_20343_(d0, d1, d2); ++ entity.setPosRaw(d0, d1, d2); + } + double d6 = (double) width; + double d7 = (double) height; + double d8 = (double) width; -+ if (opposite.m_122434_() == Direction.Axis.Z) { ++ if (opposite.getAxis() == Direction.Axis.Z) { + d8 = 1.0D; + } else { + d6 = 1.0D; @@ -74,94 +74,94 @@ + } + // CraftBukkit end + -+ private static double m_31709_(int p_31710_) { // CraftBukkit - static ++ private static double offs(int p_31710_) { // CraftBukkit - static return p_31710_ % 32 == 0 ? 0.5D : 0.0D; } - public void m_8119_() { - if (!this.f_19853_.f_46443_) { - this.m_146871_(); -- if (this.f_31700_++ == 100) { -+ if (this.f_31700_++ == this.f_19853_.spigotConfig.hangingTickFrequency) { // Spigot - this.f_31700_ = 0; - if (!this.m_146910_() && !this.m_7088_()) { + public void tick() { + if (!this.level.isClientSide) { + this.checkOutOfWorld(); +- if (this.checkInterval++ == 100) { ++ if (this.checkInterval++ == this.level.spigotConfig.hangingTickFrequency) { // Spigot + this.checkInterval = 0; + if (!this.isRemoved() && !this.survives()) { + // CraftBukkit start - fire break events -+ net.minecraft.world.level.material.Material material = this.f_19853_.m_8055_(this.m_142538_()).m_60767_(); ++ net.minecraft.world.level.material.Material material = this.level.getBlockState(this.blockPosition()).getMaterial(); + org.bukkit.event.hanging.HangingBreakEvent.RemoveCause cause; + -+ if (!material.equals(net.minecraft.world.level.material.Material.f_76296_)) { ++ if (!material.equals(net.minecraft.world.level.material.Material.AIR)) { + // TODO: This feels insufficient to catch 100% of suffocation cases + cause = org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.OBSTRUCTION; + } else { + cause = org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.PHYSICS; + } + org.bukkit.event.hanging.HangingBreakEvent event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), cause); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + -+ if (this.m_146910_() || event.isCancelled()) { ++ if (this.isRemoved() || event.isCancelled()) { + return; + } + // CraftBukkit end - this.m_146870_(); - this.m_5553_((Entity)null); + this.discard(); + this.dropItem((Entity)null); } @@ -118,6 +_,8 @@ int j1 = (j - 1) / -2; - blockpos$mutableblockpos.m_122190_(blockpos).m_122175_(direction, k + i1).m_122175_(Direction.UP, l + j1); - BlockState blockstate = this.f_19853_.m_8055_(blockpos$mutableblockpos); -+ if (net.minecraft.world.level.block.Block.m_49863_(this.f_19853_, blockpos$mutableblockpos, this.f_31699_)) + blockpos$mutableblockpos.set(blockpos).move(direction, k + i1).move(Direction.UP, l + j1); + BlockState blockstate = this.level.getBlockState(blockpos$mutableblockpos); ++ if (net.minecraft.world.level.block.Block.canSupportCenter(this.level, blockpos$mutableblockpos, this.direction)) + continue; - if (!blockstate.m_60767_().m_76333_() && !DiodeBlock.m_52586_(blockstate)) { + if (!blockstate.getMaterial().isSolid() && !DiodeBlock.isDiode(blockstate)) { return false; } @@ -150,6 +_,22 @@ return false; } else { - if (!this.m_146910_() && !this.f_19853_.f_46443_) { + if (!this.isRemoved() && !this.level.isClientSide) { + // CraftBukkit start - fire break events -+ Entity damager = (p_31715_ instanceof net.minecraft.world.damagesource.IndirectEntityDamageSource) ? ((net.minecraft.world.damagesource.IndirectEntityDamageSource) p_31715_).getProximateDamageSource() : p_31715_.m_7639_(); ++ Entity damager = (p_31715_ instanceof net.minecraft.world.damagesource.IndirectEntityDamageSource) ? ((net.minecraft.world.damagesource.IndirectEntityDamageSource) p_31715_).getProximateDamageSource() : p_31715_.getEntity(); + org.bukkit.event.hanging.HangingBreakEvent event; + if (damager != null) { -+ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), p_31715_.m_19372_() ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.ENTITY); ++ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), p_31715_.isExplosion() ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.ENTITY); + } else { -+ event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), p_31715_.m_19372_() ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.DEFAULT); ++ event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), p_31715_.isExplosion() ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.DEFAULT); + } + -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + -+ if (this.m_146910_() || event.isCancelled()) { ++ if (this.isRemoved() || event.isCancelled()) { + return true; + } + // CraftBukkit end + - this.m_6074_(); - this.m_5834_(); - this.m_5553_(p_31715_.m_7639_()); + this.kill(); + this.markHurt(); + this.dropItem(p_31715_.getEntity()); @@ -161,6 +_,18 @@ - public void m_6478_(MoverType p_31719_, Vec3 p_31720_) { - if (!this.f_19853_.f_46443_ && !this.m_146910_() && p_31720_.m_82556_() > 0.0D) { -+ if (this.m_146910_()) return; // CraftBukkit + public void move(MoverType p_31719_, Vec3 p_31720_) { + if (!this.level.isClientSide && !this.isRemoved() && p_31720_.lengthSqr() > 0.0D) { ++ if (this.isRemoved()) return; // CraftBukkit + + // CraftBukkit start - fire break events + // TODO - Does this need its own cause? Seems to only be triggered by pistons + org.bukkit.event.hanging.HangingBreakEvent event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.PHYSICS); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + -+ if (this.m_146910_() || event.isCancelled()) { ++ if (this.isRemoved() || event.isCancelled()) { + return; + } + // CraftBukkit end + - this.m_6074_(); - this.m_5553_((Entity)null); + this.kill(); + this.dropItem((Entity)null); } @@ -168,7 +_,7 @@ } - public void m_5997_(double p_31744_, double p_31745_, double p_31746_) { -- if (!this.f_19853_.f_46443_ && !this.m_146910_() && p_31744_ * p_31744_ + p_31745_ * p_31745_ + p_31746_ * p_31746_ > 0.0D) { -+ if (false && !this.f_19853_.f_46443_ && !this.m_146910_() && p_31744_ * p_31744_ + p_31745_ * p_31745_ + p_31746_ * p_31746_ > 0.0D) { // CraftBukkit - not needed - this.m_6074_(); - this.m_5553_((Entity)null); + public void push(double p_31744_, double p_31745_, double p_31746_) { +- if (!this.level.isClientSide && !this.isRemoved() && p_31744_ * p_31744_ + p_31745_ * p_31745_ + p_31746_ * p_31746_ > 0.0D) { ++ if (false && !this.level.isClientSide && !this.isRemoved() && p_31744_ * p_31744_ + p_31745_ * p_31745_ + p_31746_ * p_31746_ > 0.0D) { // CraftBukkit - not needed + this.kill(); + this.dropItem((Entity)null); } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/ItemFrame.java.patch index 32c5424a..c6960bb8 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -2,20 +2,20 @@ +++ b/net/minecraft/world/entity/decoration/ItemFrame.java @@ -84,16 +_,26 @@ - protected void m_7087_() { - if (this.f_31699_ != null) { + protected void recalculateBoundingBox() { + if (this.direction != null) { - double d0 = 0.46875D; -- double d1 = (double)this.f_31698_.m_123341_() + 0.5D - (double)this.f_31699_.m_122429_() * 0.46875D; -- double d2 = (double)this.f_31698_.m_123342_() + 0.5D - (double)this.f_31699_.m_122430_() * 0.46875D; -- double d3 = (double)this.f_31698_.m_123343_() + 0.5D - (double)this.f_31699_.m_122431_() * 0.46875D; -- this.m_20343_(d1, d2, d3); -- double d4 = (double)this.m_7076_(); -- double d5 = (double)this.m_7068_(); -- double d6 = (double)this.m_7076_(); -- Direction.Axis direction$axis = this.f_31699_.m_122434_(); +- double d1 = (double)this.pos.getX() + 0.5D - (double)this.direction.getStepX() * 0.46875D; +- double d2 = (double)this.pos.getY() + 0.5D - (double)this.direction.getStepY() * 0.46875D; +- double d3 = (double)this.pos.getZ() + 0.5D - (double)this.direction.getStepZ() * 0.46875D; +- this.setPosRaw(d1, d2, d3); +- double d4 = (double)this.getWidth(); +- double d5 = (double)this.getHeight(); +- double d6 = (double)this.getWidth(); +- Direction.Axis direction$axis = this.direction.getAxis(); - switch(direction$axis) { + // CraftBukkit start code moved in to calculateBoundingBox -+ this.m_20011_(calculateBoundingBox(this, this.f_31698_, this.f_31699_, this.m_7076_(), this.m_7068_())); ++ this.setBoundingBox(calculateBoundingBox(this, this.pos, this.direction, this.getWidth(), this.getHeight())); + // CraftBukkit end + } + } @@ -23,16 +23,16 @@ + // CraftBukkit start - break out BB calc into own method + public static AABB calculateBoundingBox(@Nullable Entity entity, BlockPos blockPosition, Direction direction, int width, int height) { + double d0 = 0.46875D; -+ double d1 = (double) blockPosition.m_123341_() + 0.5D - (double) direction.m_122429_() * 0.46875D; -+ double d2 = (double) blockPosition.m_123342_() + 0.5D - (double) direction.m_122430_() * 0.46875D; -+ double d3 = (double) blockPosition.m_123343_() + 0.5D - (double) direction.m_122431_() * 0.46875D; ++ double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getStepX() * 0.46875D; ++ double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getStepY() * 0.46875D; ++ double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getStepZ() * 0.46875D; + if (entity != null) { -+ entity.m_20343_(d1, d2, d3); ++ entity.setPosRaw(d1, d2, d3); + } + double d4 = (double) width; + double d5 = (double) height; + double d6 = (double) width; -+ Direction.Axis direction$axis = direction.m_122434_(); ++ Direction.Axis direction$axis = direction.getAxis(); + switch (direction$axis) { case X: d4 = 1.0D; @@ -46,7 +46,7 @@ - d4 /= 32.0D; - d5 /= 32.0D; - d6 /= 32.0D; -- this.m_20011_(new AABB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); +- this.setBoundingBox(new AABB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); } + + d4 /= 32.0D; @@ -56,39 +56,39 @@ } + // CraftBukkit end - public boolean m_7088_() { - if (this.f_31755_) { + public boolean survives() { + if (this.fixed) { @@ -152,6 +_,11 @@ return false; - } else if (!p_31776_.m_19372_() && !this.m_31822_().m_41619_()) { - if (!this.f_19853_.f_46443_) { + } else if (!p_31776_.isExplosion() && !this.getItem().isEmpty()) { + if (!this.level.isClientSide) { + // CraftBukkit start - fire EntityDamageEvent -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_31776_, p_31777_, false) || this.m_146910_()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_31776_, p_31777_, false) || this.isRemoved()) { + return true; + } + // CraftBukkit end - this.m_31802_(p_31776_.m_7639_(), false); - this.m_5496_(this.m_142544_(), 1.0F, 1.0F); + this.dropItem(p_31776_.getEntity(), false); + this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); } @@ -252,6 +_,12 @@ } - public void m_31789_(ItemStack p_31790_, boolean p_31791_) { + public void setItem(ItemStack p_31790_, boolean p_31791_) { + // CraftBukkit start + this.setItem(p_31790_, p_31791_, true); + } + + public void setItem(ItemStack p_31790_, boolean p_31791_, boolean playSound) { + // CraftBukkit end - if (!p_31790_.m_41619_()) { - p_31790_ = p_31790_.m_41777_(); - p_31790_.m_41764_(1); + if (!p_31790_.isEmpty()) { + p_31790_ = p_31790_.copy(); + p_31790_.setCount(1); @@ -259,7 +_,7 @@ } - this.m_20088_().m_135381_(f_31757_, p_31790_); -- if (!p_31790_.m_41619_()) { -+ if (!p_31790_.m_41619_() && playSound) { // CraftBukkit - this.m_5496_(this.m_142546_(), 1.0F, 1.0F); + this.getEntityData().set(DATA_ITEM, p_31790_); +- if (!p_31790_.isEmpty()) { ++ if (!p_31790_.isEmpty() && playSound) { // CraftBukkit + this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch index 4ae64223..7b2cdc9b 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch @@ -3,42 +3,42 @@ @@ -81,20 +_,40 @@ for(Mob mob : list) { - if (mob.m_21524_() == p_31842_) { + if (mob.getLeashHolder() == p_31842_) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerLeashEntityEvent(mob, this, p_31842_).isCancelled()) { -+ ((net.minecraft.server.level.ServerPlayer) p_31842_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(mob, mob.m_21524_())); ++ ((net.minecraft.server.level.ServerPlayer) p_31842_).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(mob, mob.getLeashHolder())); + continue; + } + // CraftBukkit end - mob.m_21463_(this, true); + mob.setLeashedTo(this, true); flag = true; } } if (!flag) { -- this.m_146870_(); -- if (p_31842_.m_150110_().f_35937_) { +- this.discard(); +- if (p_31842_.getAbilities().instabuild) { + // CraftBukkit start - Move below + // this.discard(); + boolean die = true; + // CraftBukkit end -+ if (true || p_31842_.m_150110_().f_35937_) { // CraftBukkit - Process for non-creative as well ++ if (true || p_31842_.getAbilities().instabuild) { // CraftBukkit - Process for non-creative as well for(Mob mob1 : list) { - if (mob1.m_21523_() && mob1.m_21524_() == this) { -- mob1.m_21455_(true, false); + if (mob1.isLeashed() && mob1.getLeashHolder() == this) { +- mob1.dropLeash(true, false); + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerUnleashEntityEvent(mob1, p_31842_).isCancelled()) { + die = false; + continue; + } -+ mob1.m_21455_(true, !p_31842_.m_150110_().f_35937_); // false -> survival mode boolean ++ mob1.dropLeash(true, !p_31842_.getAbilities().instabuild); // false -> survival mode boolean + // CraftBukkit end } } } + // CraftBukkit start + if (die) { -+ this.m_146870_(); ++ this.discard(); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch index c738d9d2..05201260 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/Motive.java.patch @@ -6,6 +6,6 @@ -public class Motive { +public class Motive extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final Motive f_31866_ = m_31897_("kebab", 16, 16); - public static final Motive f_31867_ = m_31897_("aztec", 16, 16); - public static final Motive f_31868_ = m_31897_("alban", 16, 16); + public static final Motive KEBAB = register("kebab", 16, 16); + public static final Motive AZTEC = register("aztec", 16, 16); + public static final Motive ALBAN = register("alban", 16, 16); 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 e8d279f5..29e76376 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -3,58 +3,58 @@ @@ -73,8 +_,16 @@ } - public static FallingBlockEntity m_201971_(Level p_201972_, BlockPos p_201973_, BlockState p_201974_) { + public static FallingBlockEntity fall(Level p_201972_, BlockPos p_201973_, BlockState p_201974_) { + // CraftBukkit start + return fall(p_201972_,p_201973_, p_201974_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + public static FallingBlockEntity fall(Level p_201972_, BlockPos p_201973_, BlockState p_201974_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end - FallingBlockEntity fallingblockentity = new FallingBlockEntity(p_201972_, (double)p_201973_.m_123341_() + 0.5D, (double)p_201973_.m_123342_(), (double)p_201973_.m_123343_() + 0.5D, p_201974_.m_61138_(BlockStateProperties.f_61362_) ? p_201974_.m_61124_(BlockStateProperties.f_61362_, Boolean.valueOf(false)) : p_201974_); -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(fallingblockentity, p_201973_, p_201974_.m_60819_().m_76188_()).isCancelled()) return fallingblockentity; // CraftBukkit - p_201972_.m_7731_(p_201973_, p_201974_.m_60819_().m_76188_(), 3); + FallingBlockEntity fallingblockentity = new FallingBlockEntity(p_201972_, (double)p_201973_.getX() + 0.5D, (double)p_201973_.getY(), (double)p_201973_.getZ() + 0.5D, p_201974_.hasProperty(BlockStateProperties.WATERLOGGED) ? p_201974_.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false)) : p_201974_); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(fallingblockentity, p_201973_, p_201974_.getFluidState().createLegacyBlock()).isCancelled()) return fallingblockentity; // CraftBukkit + p_201972_.setBlock(p_201973_, p_201974_.getFluidState().createLegacyBlock(), 3); + p_201972_.prepareEntity(fallingblockentity, spawnReason); //Magma - add spawn reason - p_201972_.m_7967_(fallingblockentity); + p_201972_.addFreshEntity(fallingblockentity); return fallingblockentity; } @@ -114,6 +_,16 @@ } - this.m_6478_(MoverType.SELF, this.m_20184_()); + this.move(MoverType.SELF, this.getDeltaMovement()); + + // Paper start - Configurable EntityFallingBlock height nerf -+ if (this.f_19853_.paperConfig.fallingBlockHeightNerf != 0 && this.m_20186_() > this.f_19853_.paperConfig.fallingBlockHeightNerf) { -+ if (this.f_31943_ && this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_)) { -+ this.m_19998_(block); ++ if (this.level.paperConfig.fallingBlockHeightNerf != 0 && this.getY() > this.level.paperConfig.fallingBlockHeightNerf) { ++ if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ this.spawnAtLocation(block); + } -+ this.m_146870_(); ++ this.discard(); + return; + } + // Paper end - if (!this.f_19853_.f_46443_) { - BlockPos blockpos = this.m_142538_(); - boolean flag = this.f_31946_.m_60734_() instanceof ConcretePowderBlock; + if (!this.level.isClientSide) { + BlockPos blockpos = this.blockPosition(); + boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; @@ -148,6 +_,13 @@ - this.f_31946_ = this.f_31946_.m_61124_(BlockStateProperties.f_61362_, Boolean.valueOf(true)); + this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(true)); } + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockpos, this.f_31946_).isCancelled()) { -+ this.m_146870_(); // SPIGOT-6586 called before the event in previous versions ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockpos, this.blockState).isCancelled()) { ++ this.discard(); // SPIGOT-6586 called before the event in previous versions + return; + } + // CraftBukkit end + - if (this.f_19853_.m_7731_(blockpos, this.f_31946_, 3)) { - ((ServerLevel)this.f_19853_).m_7726_().f_8325_.m_140201_(this, new ClientboundBlockUpdatePacket(blockpos, this.f_19853_.m_8055_(blockpos))); - this.m_146870_(); + if (this.level.setBlock(blockpos, this.blockState, 3)) { + ((ServerLevel)this.level).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockpos, this.level.getBlockState(blockpos))); + this.discard(); @@ -225,7 +_,9 @@ - float f = (float)Math.min(Mth.m_14143_((float)i * this.f_149641_), this.f_31940_); - this.f_19853_.m_6249_(this, this.m_142469_(), predicate).forEach((p_149649_) -> { + float f = (float)Math.min(Mth.floor((float)i * this.fallDamagePerDistance), this.fallDamageMax); + this.level.getEntities(this, this.getBoundingBox(), predicate).forEach((p_149649_) -> { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = this; // CraftBukkit - p_149649_.m_6469_(damagesource, f); + p_149649_.hurt(damagesource, f); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; // CraftBukkit }); - boolean flag = this.f_31946_.m_204336_(BlockTags.f_13033_); - if (flag && f > 0.0F && this.f_19796_.nextFloat() < 0.05F + (float)i * 0.05F) { + boolean flag = this.blockState.is(BlockTags.ANVIL); + if (flag && f > 0.0F && this.random.nextFloat() < 0.05F + (float)i * 0.05F) { 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 1f0e6362..9b9aaea4 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -2,88 +2,86 @@ +++ b/net/minecraft/world/entity/item/ItemEntity.java @@ -43,6 +_,11 @@ @Nullable - private UUID f_31982_; - public final float f_31983_; + private UUID owner; + public final float bobOffs; + /** + * The maximum age of this EntityItem. The item is expired once this is reached. + */ -+ public int lifespan = ItemEntity.f_149659_; ++ public int lifespan = ItemEntity.LIFETIME; + private int lastTick = net.minecraft.server.MinecraftServer.currentTick - 1; // CraftBukkit public ItemEntity(EntityType p_31991_, Level p_31992_) { super(p_31991_, p_31992_); @@ -59,6 +_,7 @@ - this.m_6034_(p_149664_, p_149665_, p_149666_); - this.m_20334_(p_149668_, p_149669_, p_149670_); - this.m_32045_(p_149667_); -+ this.lifespan = (p_149667_.m_41720_() == null ? (p_149663_ == null ? ItemEntity.f_149659_ : f_19853_.spigotConfig.itemDespawnRate) : p_149667_.getEntityLifespan(p_149663_)); + this.setPos(p_149664_, p_149665_, p_149666_); + this.setDeltaMovement(p_149668_, p_149669_, p_149670_); + this.setItem(p_149667_); ++ this.lifespan = (p_149667_.getItem() == null ? (p_149663_ == null ? ItemEntity.LIFETIME : level.spigotConfig.itemDespawnRate) : p_149667_.getEntityLifespan(p_149663_)); } private ItemEntity(ItemEntity p_31994_) { @@ -82,13 +_,17 @@ } - public void m_8119_() { -+ if (m_32055_().onEntityItemUpdate(this)) return; - if (this.m_32055_().m_41619_()) { - this.m_146870_(); + public void tick() { ++ if (getItem().onEntityItemUpdate(this)) return; + if (this.getItem().isEmpty()) { + this.discard(); } else { - super.m_8119_(); -- if (this.f_31986_ > 0 && this.f_31986_ != 32767) { -- --this.f_31986_; + super.tick(); +- if (this.pickupDelay > 0 && this.pickupDelay != 32767) { +- --this.pickupDelay; - } + // CraftBukkit start - Use wall time for pickup and despawn timers + int elapsedTicks = net.minecraft.server.MinecraftServer.currentTick - this.lastTick; -+ if (this.f_31986_ != 32767) this.f_31986_ -= elapsedTicks; -+ if (this.f_31985_ != -32768) this.f_31985_ += elapsedTicks; ++ if (this.pickupDelay != 32767) this.pickupDelay -= elapsedTicks; ++ if (this.age != -32768) this.age += elapsedTicks; + this.lastTick = net.minecraft.server.MinecraftServer.currentTick; + // CraftBukkit end - this.f_19854_ = this.m_20185_(); - this.f_19855_ = this.m_20186_(); + this.xo = this.getX(); + this.yo = this.getY(); @@ -116,7 +_,7 @@ - this.m_6478_(MoverType.SELF, this.m_20184_()); + this.move(MoverType.SELF, this.getDeltaMovement()); float f1 = 0.98F; - if (this.f_19861_) { -- f1 = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).m_60734_().m_49958_() * 0.98F; -+ f1 = this.f_19853_.m_8055_(new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_())).getFriction(f_19853_, new BlockPos(this.m_20185_(), this.m_20186_() - 1.0D, this.m_20189_()), this) * 0.98F; + if (this.onGround) { +- f1 = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ())).getBlock().getFriction() * 0.98F; ++ f1 = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ())).getFriction(level, new BlockPos(this.getX(), this.getY() - 1.0D, this.getZ()), this) * 0.98F; } - this.m_20256_(this.m_20184_().m_82542_((double)f1, 0.98D, (double)f1)); + this.setDeltaMovement(this.getDeltaMovement().multiply((double)f1, 0.98D, (double)f1)); @@ -134,9 +_,11 @@ - this.m_32069_(); + this.mergeWithNeighbours(); } -- if (this.f_31985_ != -32768) { -- ++this.f_31985_; + /* CraftBukkit start - moved up -+ if (this.age != -32768) { -+ ++this.age; + if (this.age != -32768) { + ++this.age; } + // CraftBukkit end */ - this.f_19812_ |= this.m_20073_(); - if (!this.f_19853_.f_46443_) { + this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); + if (!this.level.isClientSide) { @@ -146,12 +_,46 @@ } } -- if (!this.f_19853_.f_46443_ && this.f_31985_ >= 6000) { -+ ItemStack item = this.m_32055_(); -+ if (!this.f_19853_.f_46443_ && this.f_31985_ >= lifespan) { +- if (!this.level.isClientSide && this.age >= 6000) { ++ ItemStack item = this.getItem(); ++ if (!this.level.isClientSide && this.age >= lifespan) { + int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item); -+ if (hook < 0) this.m_146870_(); ++ if (hook < 0) this.discard(); + else this.lifespan += hook; + } + -+ if (item.m_41619_()) { ++ if (item.isEmpty()) { + // CraftBukkit start - fire ItemDespawnEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { -+ this.f_31985_ = 0; ++ this.age = 0; + return; + } + // CraftBukkit end - this.m_146870_(); + this.discard(); } } @@ -94,74 +92,74 @@ + public void inactiveTick() { + // CraftBukkit start - Use wall time for pickup and despawn timers + int elapsedTicks = net.minecraft.server.MinecraftServer.currentTick - this.lastTick; -+ if (this.f_31986_ != 32767) this.f_31986_ -= elapsedTicks; -+ if (this.f_31985_ != -32768) this.f_31985_ += elapsedTicks; ++ if (this.pickupDelay != 32767) this.pickupDelay -= elapsedTicks; ++ if (this.age != -32768) this.age += elapsedTicks; + this.lastTick = net.minecraft.server.MinecraftServer.currentTick; + // CraftBukkit end -+ if (!this.f_19853_.f_46443_ && this.f_31985_ >= lifespan) { //Magma ++ if (!this.level.isClientSide && this.age >= lifespan) { //Magma + // CraftBukkit start - fire ItemDespawnEvent + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { -+ this.f_31985_ = 0; ++ this.age = 0; + return; + } + // CraftBukkit end -+ this.m_146870_(); ++ this.discard(); + } + } + // Spigot end - private void m_32067_() { - Vec3 vec3 = this.m_20184_(); + private void setUnderwaterMovement() { + Vec3 vec3 = this.getDeltaMovement(); @@ -165,7 +_,7 @@ - private void m_32069_() { - if (this.m_32070_()) { -- for(ItemEntity itementity : this.f_19853_.m_6443_(ItemEntity.class, this.m_142469_().m_82377_(0.5D, 0.0D, 0.5D), (p_186268_) -> { -+ for(ItemEntity itementity : this.f_19853_.m_6443_(ItemEntity.class, this.m_142469_().m_82377_(f_19853_.spigotConfig.itemMerge, f_19853_.spigotConfig.itemMerge - 0.5D, f_19853_.spigotConfig.itemMerge), (p_186268_) -> { - return p_186268_ != this && p_186268_.m_32070_(); + private void mergeWithNeighbours() { + if (this.isMergable()) { +- for(ItemEntity itementity : this.level.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.5D, 0.0D, 0.5D), (p_186268_) -> { ++ for(ItemEntity itementity : this.level.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(level.spigotConfig.itemMerge, level.spigotConfig.itemMerge - 0.5D, level.spigotConfig.itemMerge), (p_186268_) -> { + return p_186268_ != this && p_186268_.isMergable(); })) { - if (itementity.m_32070_()) { + if (itementity.isMergable()) { @@ -188,7 +_,7 @@ - ItemStack itemstack = this.m_32055_(); - ItemStack itemstack1 = p_32016_.m_32055_(); - if (Objects.equals(this.m_32056_(), p_32016_.m_32056_()) && m_32026_(itemstack, itemstack1)) { -- if (itemstack1.m_41613_() < itemstack.m_41613_()) { -+ if (true || itemstack1.m_41613_() < itemstack.m_41613_()) { // Spigot - m_32017_(this, itemstack, p_32016_, itemstack1); + ItemStack itemstack = this.getItem(); + ItemStack itemstack1 = p_32016_.getItem(); + if (Objects.equals(this.getOwner(), p_32016_.getOwner()) && areMergable(itemstack, itemstack1)) { +- if (itemstack1.getCount() < itemstack.getCount()) { ++ if (true || itemstack1.getCount() < itemstack.getCount()) { // Spigot + merge(this, itemstack, p_32016_, itemstack1); } else { - m_32017_(p_32016_, itemstack1, this, itemstack); + merge(p_32016_, itemstack1, this, itemstack); @@ -204,6 +_,8 @@ return false; - } else if (p_32028_.m_41782_() ^ p_32027_.m_41782_()) { + } else if (p_32028_.hasTag() ^ p_32027_.hasTag()) { return false; + } else if (!p_32027_.areCapsCompatible(p_32028_)) { + return false; } else { - return !p_32028_.m_41782_() || p_32028_.m_41783_().equals(p_32027_.m_41783_()); + return !p_32028_.hasTag() || p_32028_.getTag().equals(p_32027_.getTag()); } @@ -219,10 +_,11 @@ - private static void m_32022_(ItemEntity p_32023_, ItemStack p_32024_, ItemStack p_32025_) { - ItemStack itemstack = m_32029_(p_32024_, p_32025_, 64); -- p_32023_.m_32045_(itemstack); -+ if (!itemstack.m_41619_()) p_32023_.m_32045_(itemstack); // CraftBukkit - don't set empty stacks + private static void merge(ItemEntity p_32023_, ItemStack p_32024_, ItemStack p_32025_) { + ItemStack itemstack = merge(p_32024_, p_32025_, 64); +- p_32023_.setItem(itemstack); ++ if (!itemstack.isEmpty()) p_32023_.setItem(itemstack); // CraftBukkit - don't set empty stacks } - private static void m_32017_(ItemEntity p_32018_, ItemStack p_32019_, ItemEntity p_32020_, ItemStack p_32021_) { + private static void merge(ItemEntity p_32018_, ItemStack p_32019_, ItemEntity p_32020_, ItemStack p_32021_) { + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callItemMergeEvent(p_32020_, p_32018_).isCancelled()) return; // CraftBukkit - m_32022_(p_32018_, p_32019_, p_32021_); - p_32018_.f_31986_ = Math.max(p_32018_.f_31986_, p_32020_.f_31986_); - p_32018_.f_31985_ = Math.min(p_32018_.f_31985_, p_32020_.f_31985_); + merge(p_32018_, p_32019_, p_32021_); + p_32018_.pickupDelay = Math.max(p_32018_.pickupDelay, p_32020_.pickupDelay); + p_32018_.age = Math.min(p_32018_.age, p_32020_.age); @@ -237,6 +_,7 @@ } - public boolean m_6469_(DamageSource p_32013_, float p_32014_) { -+ if (this.f_19853_.f_46443_ || this.m_146910_()) return false; //Forge: Fixes MC-53850 - if (this.m_6673_(p_32013_)) { + public boolean hurt(DamageSource p_32013_, float p_32014_) { ++ if (this.level.isClientSide || this.isRemoved()) return false; //Forge: Fixes MC-53850 + if (this.isInvulnerableTo(p_32013_)) { return false; - } else if (!this.m_32055_().m_41619_() && this.m_32055_().m_150930_(Items.f_42686_) && p_32013_.m_19372_()) { + } else if (!this.getItem().isEmpty() && this.getItem().is(Items.NETHER_STAR) && p_32013_.isExplosion()) { @@ -246,11 +_,16 @@ - } else if (this.f_19853_.f_46443_) { + } else if (this.level.isClientSide) { return true; } else { + // CraftBukkit start @@ -169,119 +167,119 @@ + return false; + } + // CraftBukkit end - this.m_5834_(); - this.f_31987_ = (int)((float)this.f_31987_ - p_32014_); - this.m_146852_(GameEvent.f_157808_, p_32013_.m_7639_()); - if (this.f_31987_ <= 0) { -- this.m_32055_().m_150924_(this); -+ this.m_32055_().onDestroyed(this, p_32013_); - this.m_146870_(); + this.markHurt(); + this.health = (int)((float)this.health - p_32014_); + this.gameEvent(GameEvent.ENTITY_DAMAGED, p_32013_.getEntity()); + if (this.health <= 0) { +- this.getItem().onDestroyed(this); ++ this.getItem().onDestroyed(this, p_32013_); + this.discard(); } @@ -262,6 +_,7 @@ - p_32050_.m_128376_("Health", (short)this.f_31987_); - p_32050_.m_128376_("Age", (short)this.f_31985_); - p_32050_.m_128376_("PickupDelay", (short)this.f_31986_); -+ p_32050_.m_128405_("Lifespan", lifespan); - if (this.m_32057_() != null) { - p_32050_.m_128362_("Thrower", this.m_32057_()); + p_32050_.putShort("Health", (short)this.health); + p_32050_.putShort("Age", (short)this.age); + p_32050_.putShort("PickupDelay", (short)this.pickupDelay); ++ p_32050_.putInt("Lifespan", lifespan); + if (this.getThrower() != null) { + p_32050_.putUUID("Thrower", this.getThrower()); } @@ -282,6 +_,7 @@ - if (p_32034_.m_128441_("PickupDelay")) { - this.f_31986_ = p_32034_.m_128448_("PickupDelay"); + if (p_32034_.contains("PickupDelay")) { + this.pickupDelay = p_32034_.getShort("PickupDelay"); } -+ if (p_32034_.m_128441_("Lifespan")) lifespan = p_32034_.m_128451_("Lifespan"); ++ if (p_32034_.contains("Lifespan")) lifespan = p_32034_.getInt("Lifespan"); - if (p_32034_.m_128403_("Owner")) { - this.f_31982_ = p_32034_.m_128342_("Owner"); + if (p_32034_.hasUUID("Owner")) { + this.owner = p_32034_.getUUID("Owner"); @@ -301,10 +_,59 @@ - public void m_6123_(Player p_32040_) { - if (!this.f_19853_.f_46443_) { -+ if (this.f_31986_ > 0) return; - ItemStack itemstack = this.m_32055_(); - Item item = itemstack.m_41720_(); - int i = itemstack.m_41613_(); -- if (this.f_31986_ == 0 && (this.f_31982_ == null || this.f_31982_.equals(p_32040_.m_142081_())) && p_32040_.m_150109_().m_36054_(itemstack)) { + public void playerTouch(Player p_32040_) { + if (!this.level.isClientSide) { ++ if (this.pickupDelay > 0) return; + ItemStack itemstack = this.getItem(); + Item item = itemstack.getItem(); + int i = itemstack.getCount(); +- if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(p_32040_.getUUID())) && p_32040_.getInventory().add(itemstack)) { + + // CraftBukkit start - fire PlayerPickupItemEvent -+ int canHold = p_32040_.m_150109_().canHold(itemstack); ++ int canHold = p_32040_.getInventory().canHold(itemstack); + int remaining = i - canHold; + -+ if (this.f_31986_ <= 0 && canHold > 0) { -+ itemstack.m_41764_(canHold); ++ if (this.pickupDelay <= 0 && canHold > 0) { ++ itemstack.setCount(canHold); + // Call legacy event + org.bukkit.event.player.PlayerPickupItemEvent playerEvent = new org.bukkit.event.player.PlayerPickupItemEvent((org.bukkit.entity.Player) p_32040_.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(playerEvent); + if (playerEvent.isCancelled()) { -+ itemstack.m_41764_(i); // SPIGOT-5294 - restore count ++ itemstack.setCount(i); // SPIGOT-5294 - restore count + return; + } + + // Call newer event afterwards + org.bukkit.event.entity.EntityPickupItemEvent entityEvent = new org.bukkit.event.entity.EntityPickupItemEvent((org.bukkit.entity.Player) p_32040_.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(entityEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(entityEvent); + if (entityEvent.isCancelled()) { -+ itemstack.m_41764_(i); // SPIGOT-5294 - restore count ++ itemstack.setCount(i); // SPIGOT-5294 - restore count + return; + } + + // Update the ItemStack if it was changed in the event -+ ItemStack current = this.m_32055_(); ++ ItemStack current = this.getItem(); + if (!itemstack.equals(current)) { + itemstack = current; + } else { -+ itemstack.m_41764_(canHold + remaining); // = i ++ itemstack.setCount(canHold + remaining); // = i + } + + // Possibly < 0; fix here so we do not have to modify code below -+ this.f_31986_ = 0; -+ } else if (this.f_31986_ == 0) { ++ this.pickupDelay = 0; ++ } else if (this.pickupDelay == 0) { + // ensure that the code below isn't triggered if canHold says we can't pick the items up -+ this.f_31986_ = -1; ++ this.pickupDelay = -1; + } + // CraftBukkit end + + int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, p_32040_); + if (hook < 0) return; + -+ ItemStack copy = itemstack.m_41777_(); ++ ItemStack copy = itemstack.copy(); + -+ if (this.f_31986_ == 0 && (this.f_31982_ == null || lifespan - this.f_31985_ <= 200 || this.f_31982_.equals(p_32040_.m_142081_())) && (hook == 1 || i <= 0 || p_32040_.m_150109_().m_36054_(itemstack))) { -+ copy.m_41764_(copy.m_41613_() - m_32055_().m_41613_()); ++ if (this.pickupDelay == 0 && (this.owner == null || lifespan - this.age <= 200 || this.owner.equals(p_32040_.getUUID())) && (hook == 1 || i <= 0 || p_32040_.getInventory().add(itemstack))) { ++ copy.setCount(copy.getCount() - getItem().getCount()); + net.minecraftforge.event.ForgeEventFactory.firePlayerItemPickupEvent(p_32040_, this, copy); - p_32040_.m_7938_(this, i); - if (itemstack.m_41619_()) { - this.m_146870_(); + p_32040_.take(this, i); + if (itemstack.isEmpty()) { + this.discard(); @@ -328,8 +_,8 @@ } @Nullable -- public Entity m_5489_(ServerLevel p_32042_) { -- Entity entity = super.m_5489_(p_32042_); +- public Entity changeDimension(ServerLevel p_32042_) { +- Entity entity = super.changeDimension(p_32042_); + public Entity changeDimension(ServerLevel p_32042_, net.minecraftforge.common.util.ITeleporter teleporter) { + Entity entity = super.changeDimension(p_32042_, teleporter); - if (!this.f_19853_.f_46443_ && entity instanceof ItemEntity) { - ((ItemEntity)entity).m_32069_(); + if (!this.level.isClientSide && entity instanceof ItemEntity) { + ((ItemEntity)entity).mergeWithNeighbours(); } @@ -342,7 +_,9 @@ } - public void m_32045_(ItemStack p_32046_) { + public void setItem(ItemStack p_32046_) { + //com.google.common.base.Preconditions.checkArgument(!p_32046_.isEmpty(), "Cannot drop air"); // CraftBukkit //Magma - removed - this.m_20088_().m_135381_(f_31984_, p_32046_); -+ this.m_20088_().markDirty(f_31984_); // CraftBukkit - SPIGOT-4591, must mark dirty + this.getEntityData().set(DATA_ITEM, p_32046_); ++ this.getEntityData().markDirty(DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty } - public void m_7350_(EntityDataAccessor p_32036_) { + public void onSyncedDataUpdated(EntityDataAccessor p_32036_) { @@ -405,7 +_,7 @@ - public void m_32065_() { - this.m_32062_(); -- this.f_31985_ = 5999; -+ this.f_31985_ = f_19853_.spigotConfig.itemDespawnRate - 1; // Spigot + public void makeFakeItem() { + this.setNeverPickUp(); +- this.age = 5999; ++ this.age = level.spigotConfig.itemDespawnRate - 1; // Spigot } - public float m_32008_(float p_32009_) { + public float getSpin(float p_32009_) { diff --git a/patches/minecraft/net/minecraft/world/entity/item/PrimedTnt.java.patch b/patches/minecraft/net/minecraft/world/entity/item/PrimedTnt.java.patch index 9b75c8e9..543c3a1c 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -22,6 +_,8 @@ - private static final int f_149679_ = 80; + private static final int DEFAULT_FUSE_TIME = 80; @Nullable - public LivingEntity f_32072_; + public LivingEntity owner; + public float yield = 4; // CraftBukkit - add field + public boolean isIncendiary = false; // CraftBukkit - add field @@ -12,53 +12,53 @@ @@ -53,11 +_,18 @@ } - public void m_8119_() { -+ if (f_19853_.spigotConfig.maxTntTicksPerTick > 0 && ++f_19853_.spigotConfig.currentPrimedTnt > f_19853_.spigotConfig.maxTntTicksPerTick) { return; } // Spigot - if (!this.m_20068_()) { - this.m_20256_(this.m_20184_().m_82520_(0.0D, -0.04D, 0.0D)); + public void tick() { ++ if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot + if (!this.isNoGravity()) { + this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); } - this.m_6478_(MoverType.SELF, this.m_20184_()); + this.move(MoverType.SELF, this.getDeltaMovement()); + // Paper start - Configurable TNT entity height nerf -+ if (this.f_19853_.paperConfig.entityTNTHeightNerf != 0 && this.m_20186_() > this.f_19853_.paperConfig.entityTNTHeightNerf) { -+ this.m_146870_(); ++ if (this.level.paperConfig.entityTNTHeightNerf != 0 && this.getY() > this.level.paperConfig.entityTNTHeightNerf) { ++ this.discard(); + return; + } + // Paper end - this.m_20256_(this.m_20184_().m_82490_(0.98D)); - if (this.f_19861_) { - this.m_20256_(this.m_20184_().m_82542_(0.7D, -0.5D, 0.7D)); + this.setDeltaMovement(this.getDeltaMovement().scale(0.98D)); + if (this.onGround) { + this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D)); @@ -66,10 +_,13 @@ - int i = this.m_32100_() - 1; - this.m_32085_(i); + int i = this.getFuse() - 1; + this.setFuse(i); if (i <= 0) { -- this.m_146870_(); +- this.discard(); + // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event + // this.discard(); - if (!this.f_19853_.f_46443_) { - this.m_32103_(); + if (!this.level.isClientSide) { + this.explode(); } -+ this.m_146870_(); ++ this.discard(); + // CraftBukkit end } else { - this.m_20073_(); - if (this.f_19853_.f_46443_) { + this.updateInWaterStateAndDoFluidPushing(); + if (this.level.isClientSide) { @@ -80,8 +_,16 @@ } - protected void m_32103_() { + protected void explode() { - float f = 4.0F; -- this.f_19853_.m_46511_(this, this.m_20185_(), this.m_20227_(0.0625D), this.m_20189_(), 4.0F, Explosion.BlockInteraction.BREAK); +- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, Explosion.BlockInteraction.BREAK); + // CraftBukkit start + // float f = 4.0F; + + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20227_(0.0625D), this.m_20189_(), event.getRadius(), event.getFire(), Explosion.BlockInteraction.BREAK); ++ this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Explosion.BlockInteraction.BREAK); + } + // CraftBukkit end } - protected void m_7380_(CompoundTag p_32097_) { + protected void addAdditionalSaveData(CompoundTag p_32097_) { 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 4fbe3007..1658122e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,41 +1,41 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java @@ -152,7 +_,7 @@ - if (this.f_19853_ != null && !this.f_19853_.f_46443_) { - this.f_21345_.m_25363_(this.f_32131_); - this.f_21345_.m_25363_(this.f_32130_); -- ItemStack itemstack = this.m_21120_(ProjectileUtil.m_37297_(this, Items.f_42411_)); -+ ItemStack itemstack = this.m_21120_(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem)); - if (itemstack.m_150930_(Items.f_42411_)) { + if (this.level != null && !this.level.isClientSide) { + this.goalSelector.removeGoal(this.meleeGoal); + this.goalSelector.removeGoal(this.bowGoal); +- ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW)); ++ ItemStack itemstack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem)); + if (itemstack.is(Items.BOW)) { int i = 20; - if (this.f_19853_.m_46791_() != Difficulty.HARD) { + if (this.level.getDifficulty() != Difficulty.HARD) { @@ -169,15 +_,27 @@ } - public void m_6504_(LivingEntity p_32141_, float p_32142_) { -- ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.m_37297_(this, Items.f_42411_))); -+ ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem))); - AbstractArrow abstractarrow = this.m_7932_(itemstack, p_32142_); -+ if (this.m_21205_().m_41720_() instanceof net.minecraft.world.item.BowItem) -+ abstractarrow = ((net.minecraft.world.item.BowItem)this.m_21205_().m_41720_()).customArrow(abstractarrow); - double d0 = p_32141_.m_20185_() - this.m_20185_(); - double d1 = p_32141_.m_20227_(0.3333333333333333D) - abstractarrow.m_20186_(); - double d2 = p_32141_.m_20189_() - this.m_20189_(); + public void performRangedAttack(LivingEntity p_32141_, float p_32142_) { +- ItemStack itemstack = this.getProjectile(this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW))); ++ ItemStack itemstack = this.getProjectile(this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem))); + AbstractArrow abstractarrow = this.getArrow(itemstack, p_32142_); ++ if (this.getMainHandItem().getItem() instanceof net.minecraft.world.item.BowItem) ++ abstractarrow = ((net.minecraft.world.item.BowItem)this.getMainHandItem().getItem()).customArrow(abstractarrow); + double d0 = p_32141_.getX() - this.getX(); + double d1 = p_32141_.getY(0.3333333333333333D) - abstractarrow.getY(); + double d2 = p_32141_.getZ() - this.getZ(); double d3 = Math.sqrt(d0 * d0 + d2 * d2); - abstractarrow.m_6686_(d0, d1 + d3 * (double)0.2F, d2, 1.6F, (float)(14 - this.f_19853_.m_46791_().m_19028_() * 4)); + abstractarrow.shoot(d0, d1 + d3 * (double)0.2F, d2, 1.6F, (float)(14 - this.level.getDifficulty().getId() * 4)); + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityShootBowEvent(this, this.m_21205_(), null, abstractarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, abstractarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); + if (event.isCancelled()) { + event.getProjectile().remove(); + return; + } + if (event.getProjectile() == abstractarrow.getBukkitEntity()) { -+ f_19853_.m_7967_(abstractarrow); ++ level.addFreshEntity(abstractarrow); + } + // CraftBukkit end - this.m_5496_(SoundEvents.f_12382_, 1.0F, 1.0F / (this.m_21187_().nextFloat() * 0.4F + 0.8F)); -- this.f_19853_.m_7967_(abstractarrow); + this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); +- this.level.addFreshEntity(abstractarrow); + // this.level.addFreshEntity(abstractarrow); // CraftBukkit - moved to above } - protected AbstractArrow m_7932_(ItemStack p_32156_, float p_32157_) { + protected AbstractArrow getArrow(ItemStack p_32156_, float p_32157_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/CaveSpider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/CaveSpider.java.patch index 3920613a..f35d8804 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/CaveSpider.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/CaveSpider.java.patch @@ -4,9 +4,9 @@ } if (i > 0) { -- ((LivingEntity)p_32257_).m_147207_(new MobEffectInstance(MobEffects.f_19614_, i * 20, 0), this); +- ((LivingEntity)p_32257_).addEffect(new MobEffectInstance(MobEffects.POISON, i * 20, 0), this); + ((LivingEntity)p_32257_).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ ((LivingEntity)p_32257_).m_147207_(new MobEffectInstance(MobEffects.f_19614_, i * 20, 0), this); // CraftBukkit ++ ((LivingEntity)p_32257_).addEffect(new MobEffectInstance(MobEffects.POISON, i * 20, 0), this); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch index aa7b51bc..d8453545 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/world/entity/monster/Creeper.java @@ -198,8 +_,18 @@ - public void m_8038_(ServerLevel p_32286_, LightningBolt p_32287_) { - super.m_8038_(p_32286_, p_32287_); -- this.f_19804_.m_135381_(f_32274_, true); + public void thunderHit(ServerLevel p_32286_, LightningBolt p_32287_) { + super.thunderHit(p_32286_, p_32287_); +- this.entityData.set(DATA_IS_POWERED, true); - } + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callCreeperPowerEvent(this, p_32287_, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { @@ -15,51 +15,51 @@ + } + + public void setPowered(boolean powered) { -+ this.f_19804_.m_135381_(f_32274_, powered); ++ this.entityData.set(DATA_IS_POWERED, powered); + } + // CraftBukkit end - protected InteractionResult m_6071_(Player p_32301_, InteractionHand p_32302_) { - ItemStack itemstack = p_32301_.m_21120_(p_32302_); + protected InteractionResult mobInteract(Player p_32301_, InteractionHand p_32302_) { + ItemStack itemstack = p_32301_.getItemInHand(p_32302_); @@ -220,12 +_,20 @@ - public void m_32315_() { - if (!this.f_19853_.f_46443_) { -- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; -+ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; - float f = this.m_7090_() ? 2.0F : 1.0F; -- this.f_20890_ = true; -- this.f_19853_.m_46511_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_32272_ * f, explosion$blockinteraction); -- this.m_146870_(); -- this.m_32316_(); + public void explodeCreeper() { + if (!this.level.isClientSide) { +- Explosion.BlockInteraction explosion$blockinteraction = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; ++ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + float f = this.isPowered() ? 2.0F : 1.0F; +- this.dead = true; +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float)this.explosionRadius * f, explosion$blockinteraction); +- this.discard(); +- this.spawnLingeringCloud(); + // CraftBukkit start -+ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), this.f_32272_ * f, false); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.f_20890_ = true; -+ this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), event.getRadius(), event.getFire(), explosion$blockinteraction); -+ this.m_146870_(); -+ this.m_32316_(); ++ this.dead = true; ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion$blockinteraction); ++ this.discard(); ++ this.spawnLingeringCloud(); + } else { -+ f_32270_ = 0; ++ swell = 0; + } + // CraftBukkit end } } @@ -234,6 +_,7 @@ - Collection collection = this.m_21220_(); + Collection collection = this.getActiveEffects(); if (!collection.isEmpty()) { - AreaEffectCloud areaeffectcloud = new AreaEffectCloud(this.f_19853_, this.m_20185_(), this.m_20186_(), this.m_20189_()); -+ areaeffectcloud.m_19718_(this); // CraftBukkit - areaeffectcloud.m_19712_(2.5F); - areaeffectcloud.m_19732_(-0.5F); - areaeffectcloud.m_19740_(10); + AreaEffectCloud areaeffectcloud = new AreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ()); ++ areaeffectcloud.setOwner(this); // CraftBukkit + areaeffectcloud.setRadius(2.5F); + areaeffectcloud.setRadiusOnUse(-0.5F); + areaeffectcloud.setWaitTime(10); @@ -244,6 +_,7 @@ - areaeffectcloud.m_19716_(new MobEffectInstance(mobeffectinstance)); + areaeffectcloud.addEffect(new MobEffectInstance(mobeffectinstance)); } -+ this.f_19853_.prepareEntity(areaeffectcloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); //Magma - add spawn reason - this.f_19853_.m_7967_(areaeffectcloud); ++ this.level.prepareEntity(areaeffectcloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); //Magma - add spawn reason + this.level.addFreshEntity(areaeffectcloud); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch index dfa98e8a..629734de 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/CrossbowAttackMob.java +++ b/net/minecraft/world/entity/monster/CrossbowAttackMob.java @@ -24,9 +_,9 @@ - void m_5847_(); + void onCrossbowAttackPerformed(); - default void m_32336_(LivingEntity p_32337_, float p_32338_) { -- InteractionHand interactionhand = ProjectileUtil.m_37297_(p_32337_, Items.f_42717_); + default void performCrossbowAttack(LivingEntity p_32337_, float p_32338_) { +- InteractionHand interactionhand = ProjectileUtil.getWeaponHoldingHand(p_32337_, Items.CROSSBOW); + InteractionHand interactionhand = ProjectileUtil.getWeaponHoldingHand(p_32337_, item -> item instanceof CrossbowItem); - ItemStack itemstack = p_32337_.m_21120_(interactionhand); -- if (p_32337_.m_21055_(Items.f_42717_)) { -+ if (p_32337_.m_21093_(is -> is.m_41720_() instanceof CrossbowItem)) { - CrossbowItem.m_40887_(p_32337_.f_19853_, p_32337_, interactionhand, itemstack, p_32338_, (float)(14 - p_32337_.f_19853_.m_46791_().m_19028_() * 4)); + ItemStack itemstack = p_32337_.getItemInHand(interactionhand); +- if (p_32337_.isHolding(Items.CROSSBOW)) { ++ if (p_32337_.isHolding(is -> is.getItem() instanceof CrossbowItem)) { + CrossbowItem.performShooting(p_32337_.level, p_32337_, interactionhand, itemstack, p_32338_, (float)(14 - p_32337_.level.getDifficulty().getId() * 4)); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Drowned.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Drowned.java.patch index 19b117c6..198380f3 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Drowned.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Drowned.java.patch @@ -3,9 +3,9 @@ @@ -233,7 +_,7 @@ } - public void m_6504_(LivingEntity p_32356_, float p_32357_) { -- ThrownTrident throwntrident = new ThrownTrident(this.f_19853_, this, new ItemStack(Items.f_42713_)); -+ ThrownTrident throwntrident = new ThrownTrident(this.f_19853_, this,this.m_21120_(net.minecraft.world.entity.projectile.ProjectileUtil.m_37297_(this, Items.f_42713_))); // CraftBukkit - Use Trident in hand like skeletons (SPIGOT-7025) - double d0 = p_32356_.m_20185_() - this.m_20185_(); - double d1 = p_32356_.m_20227_(0.3333333333333333D) - throwntrident.m_20186_(); - double d2 = p_32356_.m_20189_() - this.m_20189_(); + public void performRangedAttack(LivingEntity p_32356_, float p_32357_) { +- ThrownTrident throwntrident = new ThrownTrident(this.level, this, new ItemStack(Items.TRIDENT)); ++ ThrownTrident throwntrident = new ThrownTrident(this.level, this,this.getItemInHand(net.minecraft.world.entity.projectile.ProjectileUtil.getWeaponHoldingHand(this, Items.TRIDENT))); // CraftBukkit - Use Trident in hand like skeletons (SPIGOT-7025) + double d0 = p_32356_.getX() - this.getX(); + double d1 = p_32356_.getY(0.3333333333333333D) - throwntrident.getY(); + double d2 = p_32356_.getZ() - this.getZ(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ElderGuardian.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ElderGuardian.java.patch index 8737ebdb..bce51f7b 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ElderGuardian.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ElderGuardian.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/entity/monster/ElderGuardian.java @@ -66,7 +_,8 @@ for(ServerPlayer serverplayer : list) { - if (!serverplayer.m_21023_(mobeffect) || serverplayer.m_21124_(mobeffect).m_19564_() < 2 || serverplayer.m_21124_(mobeffect).m_19557_() < 1200) { - serverplayer.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132163_, this.m_20067_() ? 0.0F : 1.0F)); -- serverplayer.m_147207_(new MobEffectInstance(mobeffect, 6000, 2), this); + if (!serverplayer.hasEffect(mobeffect) || serverplayer.getEffect(mobeffect).getAmplifier() < 2 || serverplayer.getEffect(mobeffect).getDuration() < 1200) { + serverplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)); +- serverplayer.addEffect(new MobEffectInstance(mobeffect, 6000, 2), this); + serverplayer.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ serverplayer.m_147207_(new MobEffectInstance(mobeffect, 6000, 2), this); // CraftBukkit ++ serverplayer.addEffect(new MobEffectInstance(mobeffect, 6000, 2), this); // CraftBukkit } } } 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 1ff5c4ce..adce2750 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -3,8 +3,8 @@ @@ -105,7 +_,17 @@ } - public void m_6710_(@Nullable LivingEntity p_32537_) { -- super.m_6710_(p_32537_); + public void setTarget(@Nullable LivingEntity p_32537_) { +- super.setTarget(p_32537_); + // CraftBukkit start - fire event + setTarget(p_32537_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true); + } @@ -14,11 +14,11 @@ + if (!super.setTarget(p_32537_, reason, fireEvent)) { + return false; + } -+ p_32537_ = m_5448_(); ++ p_32537_ = getTarget(); + // CraftBukkit end - AttributeInstance attributeinstance = this.m_21051_(Attributes.f_22279_); + AttributeInstance attributeinstance = this.getAttribute(Attributes.MOVEMENT_SPEED); if (p_32537_ == null) { - this.f_32477_ = 0; + this.targetChangeTime = 0; @@ -120,6 +_,7 @@ } } @@ -26,50 +26,50 @@ + return true; } - protected void m_8097_() { + protected void defineSynchedData() { @@ -194,7 +_,7 @@ - boolean m_32534_(Player p_32535_) { - ItemStack itemstack = p_32535_.m_150109_().f_35975_.get(3); -- if (itemstack.m_150930_(Blocks.f_50143_.m_5456_())) { + 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_.m_20252_(1.0F).m_82541_(); + Vec3 vec3 = p_32535_.getViewVector(1.0F).normalize(); @@ -273,7 +_,9 @@ - boolean flag = blockstate.m_60767_().m_76334_(); - boolean flag1 = blockstate.m_60819_().m_205070_(FluidTags.f_13131_); + boolean flag = blockstate.getMaterial().blocksMotion(); + boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { -- boolean flag2 = this.m_20984_(p_32544_, p_32545_, p_32546_, true); +- boolean flag2 = this.randomTeleport(p_32544_, p_32545_, p_32546_, true); + net.minecraftforge.event.entity.EntityTeleportEvent.EnderEntity event = net.minecraftforge.event.ForgeEventFactory.onEnderTeleport(this, p_32544_, p_32545_, p_32546_); + if (event.isCanceled()) return false; -+ boolean flag2 = this.m_20984_(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true); - if (flag2 && !this.m_20067_()) { - this.f_19853_.m_6263_((Player)null, this.f_19854_, this.f_19855_, this.f_19856_, SoundEvents.f_11852_, this.m_5720_(), 1.0F, 1.0F); - this.m_5496_(SoundEvents.f_11852_, 1.0F, 1.0F); ++ boolean flag2 = this.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true); + if (flag2 && !this.isSilent()) { + this.level.playSound((Player)null, this.xo, this.yo, this.zo, SoundEvents.ENDERMAN_TELEPORT, this.getSoundSource(), 1.0F, 1.0F); + this.playSound(SoundEvents.ENDERMAN_TELEPORT, 1.0F, 1.0F); @@ -407,7 +_,7 @@ - public boolean m_8036_() { - if (this.f_32554_.m_32530_() == null) { + public boolean canUse() { + if (this.enderman.getCarriedBlock() == null) { return false; -- } else if (!this.f_32554_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_32554_.f_19853_, this.f_32554_)) { +- } else if (!this.enderman.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.enderman.level, this.enderman)) { return false; } else { - return this.f_32554_.m_21187_().nextInt(m_186073_(2000)) == 0; + return this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; @@ -427,17 +_,21 @@ - BlockState blockstate2 = this.f_32554_.m_32530_(); + BlockState blockstate2 = this.enderman.getCarriedBlock(); if (blockstate2 != null) { - blockstate2 = Block.m_49931_(blockstate2, this.f_32554_.f_19853_, blockpos); -- if (this.m_32558_(level, blockpos, blockstate2, blockstate, blockstate1, blockpos1)) { -- level.m_7731_(blockpos, blockstate2, 3); -- level.m_142346_(this.f_32554_, GameEvent.f_157797_, blockpos); -- this.f_32554_.m_32521_((BlockState)null); -+ if (this.m_32558_(level, blockpos, blockstate2, blockstate, blockstate1, blockpos1) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(f_32554_, net.minecraftforge.common.util.BlockSnapshot.create(level.m_46472_(), level, blockpos1), net.minecraft.core.Direction.UP)) { + blockstate2 = Block.updateFromNeighbourShapes(blockstate2, this.enderman.level, blockpos); +- if (this.canPlaceBlock(level, blockpos, blockstate2, blockstate, blockstate1, blockpos1)) { +- level.setBlock(blockpos, blockstate2, 3); +- level.gameEvent(this.enderman, GameEvent.BLOCK_PLACE, blockpos); +- this.enderman.setCarriedBlock((BlockState)null); ++ if (this.canPlaceBlock(level, blockpos, blockstate2, blockstate, blockstate1, blockpos1) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(enderman, net.minecraftforge.common.util.BlockSnapshot.create(level.dimension(), level, blockpos1), net.minecraft.core.Direction.UP)) { + // CraftBukkit start - Place event -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_32554_, blockpos, blockstate2).isCancelled()) { -+ level.m_7731_(blockpos, blockstate2, 3); -+ level.m_142346_(this.f_32554_, GameEvent.f_157797_, blockpos); -+ this.f_32554_.m_32521_((BlockState)null); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockpos, blockstate2).isCancelled()) { ++ level.setBlock(blockpos, blockstate2, 3); ++ level.gameEvent(this.enderman, GameEvent.BLOCK_PLACE, blockpos); ++ this.enderman.setCarriedBlock((BlockState)null); + } + // CraftBukkit end } @@ -77,33 +77,33 @@ } } - private boolean m_32558_(Level p_32559_, BlockPos p_32560_, BlockState p_32561_, BlockState p_32562_, BlockState p_32563_, BlockPos p_32564_) { -- return p_32562_.m_60795_() && !p_32563_.m_60795_() && !p_32563_.m_60713_(Blocks.f_50752_) && p_32563_.m_60838_(p_32559_, p_32564_) && p_32561_.m_60710_(p_32559_, p_32560_) && p_32559_.m_45933_(this.f_32554_, AABB.m_82333_(Vec3.m_82528_(p_32560_))).isEmpty(); -+ return p_32562_.m_60795_() && !p_32563_.m_60795_() && !p_32563_.m_60713_(Blocks.f_50752_) && !p_32563_.m_204336_(net.minecraftforge.common.Tags.Blocks.ENDERMAN_PLACE_ON_BLACKLIST) && p_32563_.m_60838_(p_32559_, p_32564_) && p_32561_.m_60710_(p_32559_, p_32560_) && p_32559_.m_45933_(this.f_32554_, AABB.m_82333_(Vec3.m_82528_(p_32560_))).isEmpty(); + 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(); } } @@ -527,7 +_,7 @@ - public boolean m_8036_() { - if (this.f_32583_.m_32530_() != null) { + public boolean canUse() { + if (this.enderman.getCarriedBlock() != null) { return false; -- } else if (!this.f_32583_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_32583_.f_19853_, this.f_32583_)) { +- } else if (!this.enderman.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.enderman.level, this.enderman)) { return false; } else { - return this.f_32583_.m_21187_().nextInt(m_186073_(20)) == 0; + return this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; @@ -547,9 +_,13 @@ - BlockHitResult blockhitresult = level.m_45547_(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.f_32583_)); - boolean flag = blockhitresult.m_82425_().equals(blockpos); - if (blockstate.m_204336_(BlockTags.f_13046_) && flag) { -- level.m_7471_(blockpos, false); -- level.m_142346_(this.f_32583_, GameEvent.f_157794_, blockpos); -- this.f_32583_.m_32521_(blockstate.m_60734_().m_49966_()); + BlockHitResult blockhitresult = level.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.enderman)); + boolean flag = blockhitresult.getBlockPos().equals(blockpos); + if (blockstate.is(BlockTags.ENDERMAN_HOLDABLE) && flag) { +- level.removeBlock(blockpos, false); +- level.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockpos); +- this.enderman.setCarriedBlock(blockstate.getBlock().defaultBlockState()); + // CraftBukkit start - Pickup event -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_32583_, blockpos, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ level.m_7471_(blockpos, false); -+ level.m_142346_(this.f_32583_, GameEvent.f_157794_, blockpos); -+ this.f_32583_.m_32521_(blockstate.m_60734_().m_49966_()); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockpos, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ level.removeBlock(blockpos, false); ++ level.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockpos); ++ this.enderman.setCarriedBlock(blockstate.getBlock().defaultBlockState()); + } + // CraftBukkit end } 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 8412c038..6f3db26c 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java @@ -247,6 +_,7 @@ - vex.m_33994_(Evoker.this); - vex.m_34033_(blockpos); - vex.m_33987_(20 * (30 + Evoker.this.f_19796_.nextInt(90))); + vex.setOwner(Evoker.this); + vex.setBoundOrigin(blockpos); + vex.setLimitedLife(20 * (30 + Evoker.this.random.nextInt(90))); + serverlevel.prepareEntity(vex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); //Magma - added spawn reason - serverlevel.m_47205_(vex); + serverlevel.addFreshEntityWithPassengers(vex); } @@ -273,7 +_,7 @@ return false; - } else if (Evoker.this.f_19797_ < this.f_33775_) { + } else if (Evoker.this.tickCount < this.nextAttackTickCount) { return false; -- } else if (!Evoker.this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Evoker.this.f_19853_, Evoker.this)) { +- } else if (!Evoker.this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Evoker.this.level, Evoker.this)) { return false; } else { - List list = Evoker.this.f_19853_.m_45971_(Sheep.class, this.f_32705_, Evoker.this, Evoker.this.m_142469_().m_82377_(16.0D, 4.0D, 16.0D)); + List list = Evoker.this.level.getNearbyEntities(Sheep.class, this.wololoTargeting, Evoker.this, Evoker.this.getBoundingBox().inflate(16.0D, 4.0D, 16.0D)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Ghast.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ghast.java.patch index 917b73b4..3427551b 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ghast.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ghast.java.patch @@ -3,9 +3,9 @@ @@ -253,6 +_,8 @@ } - LargeFireball largefireball = new LargeFireball(level, this.f_32774_, d2, d3, d4, this.f_32774_.m_32751_()); + LargeFireball largefireball = new LargeFireball(level, this.ghast, d2, d3, d4, this.ghast.getExplosionPower()); + // CraftBukkit - set bukkitYield when setting explosionpower -+ largefireball.bukkitYield = largefireball.f_37197_ = this.f_32774_.m_32751_(); - largefireball.m_6034_(this.f_32774_.m_20185_() + vec3.f_82479_ * 4.0D, this.f_32774_.m_20227_(0.5D) + 0.5D, largefireball.m_20189_() + vec3.f_82481_ * 4.0D); - level.m_7967_(largefireball); - this.f_32773_ = -40; ++ largefireball.bukkitYield = largefireball.explosionPower = this.ghast.getExplosionPower(); + largefireball.setPos(this.ghast.getX() + vec3.x * 4.0D, this.ghast.getY(0.5D) + 0.5D, largefireball.getZ() + vec3.z * 4.0D); + level.addFreshEntity(largefireball); + this.chargeTime = -40; 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 3243a8c0..b6761039 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java @@ -49,7 +_,8 @@ - boolean flag = super.m_7327_(p_32892_); - if (flag && this.m_21205_().m_41619_() && p_32892_ instanceof LivingEntity) { - float f = this.f_19853_.m_6436_(this.m_142538_()).m_19056_(); -- ((LivingEntity)p_32892_).m_147207_(new MobEffectInstance(MobEffects.f_19612_, 140 * (int)f), this); + boolean flag = super.doHurtTarget(p_32892_); + if (flag && this.getMainHandItem().isEmpty() && p_32892_ instanceof LivingEntity) { + float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); +- ((LivingEntity)p_32892_).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)f), this); + ((LivingEntity)p_32892_).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ ((LivingEntity)p_32892_).m_147207_(new MobEffectInstance(MobEffects.f_19612_, 140 * (int)f), this); // CraftBukkit ++ ((LivingEntity)p_32892_).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)f), this); // CraftBukkit } return flag; 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 8325025e..2d32d168 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch @@ -3,31 +3,31 @@ @@ -178,8 +_,10 @@ } - public void m_6504_(LivingEntity p_32918_, float p_32919_) { -- ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.m_37297_(this, Items.f_42411_))); -+ ItemStack itemstack = this.m_6298_(this.m_21120_(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem))); - AbstractArrow abstractarrow = ProjectileUtil.m_37300_(this, itemstack, p_32919_); -+ if (this.m_21205_().m_41720_() instanceof net.minecraft.world.item.BowItem) -+ abstractarrow = ((net.minecraft.world.item.BowItem)this.m_21205_().m_41720_()).customArrow(abstractarrow); - double d0 = p_32918_.m_20185_() - this.m_20185_(); - double d1 = p_32918_.m_20227_(0.3333333333333333D) - abstractarrow.m_20186_(); - double d2 = p_32918_.m_20189_() - this.m_20189_(); + public void performRangedAttack(LivingEntity p_32918_, float p_32919_) { +- ItemStack itemstack = this.getProjectile(this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW))); ++ ItemStack itemstack = this.getProjectile(this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, item -> item instanceof net.minecraft.world.item.BowItem))); + AbstractArrow abstractarrow = ProjectileUtil.getMobArrow(this, itemstack, p_32919_); ++ if (this.getMainHandItem().getItem() instanceof net.minecraft.world.item.BowItem) ++ abstractarrow = ((net.minecraft.world.item.BowItem)this.getMainHandItem().getItem()).customArrow(abstractarrow); + double d0 = p_32918_.getX() - this.getX(); + double d1 = p_32918_.getY(0.3333333333333333D) - abstractarrow.getY(); + double d2 = p_32918_.getZ() - this.getZ(); @@ -230,7 +_,8 @@ } - protected void m_8130_() { -- Illusioner.this.m_5448_().m_147207_(new MobEffectInstance(MobEffects.f_19610_, 400), Illusioner.this); -+ Illusioner.this.m_5448_().prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ Illusioner.this.m_5448_().m_147207_(new MobEffectInstance(MobEffects.f_19610_, 400), Illusioner.this); // CraftBukkit + protected void performSpellCasting() { +- Illusioner.this.getTarget().addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 400), Illusioner.this); ++ Illusioner.this.getTarget().prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma ++ Illusioner.this.getTarget().addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 400), Illusioner.this); // CraftBukkit } - protected SoundEvent m_7030_() { + protected SoundEvent getSpellPrepareSound() { @@ -260,7 +_,7 @@ } - protected void m_8130_() { -- Illusioner.this.m_7292_(new MobEffectInstance(MobEffects.f_19609_, 1200)); -+ Illusioner.this.addEffect(new MobEffectInstance(MobEffects.f_19609_, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit + protected void performSpellCasting() { +- Illusioner.this.addEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 1200)); ++ Illusioner.this.addEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit } @Nullable diff --git a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch index 9bb81b91..7d928423 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/monster/MagmaCube.java +++ b/net/minecraft/world/entity/monster/MagmaCube.java @@ -72,6 +_,7 @@ - Vec3 vec3 = this.m_20184_(); - this.m_20334_(vec3.f_82479_, (double)(this.m_6118_() + (float)this.m_33632_() * 0.1F), vec3.f_82481_); - this.f_19812_ = true; + Vec3 vec3 = this.getDeltaMovement(); + this.setDeltaMovement(vec3.x, (double)(this.getJumpPower() + (float)this.getSize() * 0.1F), vec3.z); + this.hasImpulse = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } - protected void m_203347_(TagKey p_204065_) { + protected void jumpInLiquid(TagKey p_204065_) { 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 e2276cf9..0d4c55ad 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java @@ -116,9 +_,9 @@ - if (p_33038_.m_41720_() instanceof ProjectileWeaponItem) { - Predicate predicate = ((ProjectileWeaponItem)p_33038_.m_41720_()).m_6442_(); - ItemStack itemstack = ProjectileWeaponItem.m_43010_(this, predicate); -- return itemstack.m_41619_() ? new ItemStack(Items.f_42412_) : itemstack; -+ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_33038_, itemstack.m_41619_() ? new ItemStack(Items.f_42412_) : itemstack); + if (p_33038_.getItem() instanceof ProjectileWeaponItem) { + Predicate predicate = ((ProjectileWeaponItem)p_33038_.getItem()).getSupportedHeldProjectiles(); + ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); +- return itemstack.isEmpty() ? new ItemStack(Items.ARROW) : itemstack; ++ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_33038_, itemstack.isEmpty() ? new ItemStack(Items.ARROW) : itemstack); } else { -- return ItemStack.f_41583_; -+ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_33038_, ItemStack.f_41583_); +- return ItemStack.EMPTY; ++ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_33038_, ItemStack.EMPTY); } } } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Phantom.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Phantom.java.patch index a6116ba3..d6664de1 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Phantom.java.patch @@ -3,8 +3,8 @@ @@ -222,7 +_,7 @@ for(Player player : list) { - if (Phantom.this.m_21040_(player, TargetingConditions.f_26872_)) { -- Phantom.this.m_6710_(player); + if (Phantom.this.canAttack(player, TargetingConditions.DEFAULT)) { +- Phantom.this.setTarget(player); + Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason return true; } 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 8a0d749f..e53f1fad 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Pillager.java +++ b/net/minecraft/world/entity/monster/Pillager.java @@ -119,7 +_,7 @@ - public AbstractIllager.IllagerArmPose m_6768_() { - if (this.m_33309_()) { + public AbstractIllager.IllagerArmPose getArmPose() { + if (this.isChargingCrossbow()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; -- } else if (this.m_21055_(Items.f_42717_)) { -+ } else if (this.m_21093_(is -> is.m_41720_() instanceof net.minecraft.world.item.CrossbowItem)) { +- } else if (this.isHolding(Items.CROSSBOW)) { ++ } else if (this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem)) { return AbstractIllager.IllagerArmPose.CROSSBOW_HOLD; } else { - return this.m_5912_() ? AbstractIllager.IllagerArmPose.ATTACKING : AbstractIllager.IllagerArmPose.NEUTRAL; + return this.isAggressive() ? AbstractIllager.IllagerArmPose.ATTACKING : AbstractIllager.IllagerArmPose.NEUTRAL; 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 13715838..affff228 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java @@ -144,14 +_,14 @@ - this.m_21051_(Attributes.f_22279_).m_22100_(Mth.m_14139_(0.1D, d1, d0)); + this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1D, d1, d0)); } -- if (this.f_19862_ && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (this.f_19862_ && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { +- if (this.horizontalCollision && this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (this.horizontalCollision && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this)) { boolean flag = false; - AABB aabb = this.m_142469_().m_82400_(0.2D); + AABB aabb = this.getBoundingBox().inflate(0.2D); - for(BlockPos blockpos : BlockPos.m_121976_(Mth.m_14107_(aabb.f_82288_), Mth.m_14107_(aabb.f_82289_), Mth.m_14107_(aabb.f_82290_), Mth.m_14107_(aabb.f_82291_), Mth.m_14107_(aabb.f_82292_), Mth.m_14107_(aabb.f_82293_))) { - BlockState blockstate = this.f_19853_.m_8055_(blockpos); - Block block = blockstate.m_60734_(); + for(BlockPos blockpos : BlockPos.betweenClosed(Mth.floor(aabb.minX), Mth.floor(aabb.minY), Mth.floor(aabb.minZ), Mth.floor(aabb.maxX), Mth.floor(aabb.maxY), Mth.floor(aabb.maxZ))) { + BlockState blockstate = this.level.getBlockState(blockpos); + Block block = blockstate.getBlock(); - if (block instanceof LeavesBlock) { -+ if (block instanceof LeavesBlock && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockpos, net.minecraft.world.level.block.Blocks.f_50016_.m_49966_()).isCancelled()) { // CraftBukkit - flag = this.f_19853_.m_46953_(blockpos, true, this) || flag; ++ if (block instanceof LeavesBlock && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockpos, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit + flag = this.level.destroyBlock(blockpos, true, this) || flag; } } 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 a39c515d..bc06ecaf 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java @@ -356,6 +_,22 @@ - if (blockpos1.m_123342_() > this.f_19853_.m_141937_() && this.f_19853_.m_46859_(blockpos1) && this.f_19853_.m_6857_().m_61937_(blockpos1) && this.f_19853_.m_45756_(this, (new AABB(blockpos1)).m_82406_(1.0E-6D))) { - Direction direction = this.m_149810_(blockpos1); + if (blockpos1.getY() > this.level.getMinBuildHeight() && this.level.isEmptyBlock(blockpos1) && this.level.getWorldBorder().isWithinBounds(blockpos1) && this.level.noCollision(this, (new AABB(blockpos1)).deflate(1.0E-6D))) { + Direction direction = this.findAttachableSurface(blockpos1); if (direction != null) { -+ net.minecraftforge.event.entity.EntityTeleportEvent.EnderEntity event = net.minecraftforge.event.ForgeEventFactory.onEnderTeleport(this, blockpos1.m_123341_(), blockpos1.m_123342_(), blockpos1.m_123343_()); ++ net.minecraftforge.event.entity.EntityTeleportEvent.EnderEntity event = net.minecraftforge.event.ForgeEventFactory.onEnderTeleport(this, blockpos1.getX(), blockpos1.getY(), blockpos1.getZ()); + if (event.isCanceled()) direction = null; + blockpos1 = new BlockPos(event.getTargetX(), event.getTargetY(), event.getTargetZ()); + } + + if (direction != null) { + // CraftBukkit start -+ org.bukkit.event.entity.EntityTeleportEvent teleport = new org.bukkit.event.entity.EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new org.bukkit.Location(this.f_19853_.getWorld(), blockpos1.m_123341_(), blockpos1.m_123342_(), blockpos1.m_123343_())); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(teleport); ++ org.bukkit.event.entity.EntityTeleportEvent teleport = new org.bukkit.event.entity.EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new org.bukkit.Location(this.level.getWorld(), blockpos1.getX(), blockpos1.getY(), blockpos1.getZ())); ++ this.level.getCraftServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled()) { + org.bukkit.Location to = teleport.getTo(); + blockpos1 = new BlockPos(to.getX(), to.getY(), to.getZ()); @@ -20,14 +20,14 @@ + return false; + } + // CraftBukkit end - this.m_19877_(); - this.m_149788_(direction); - this.m_5496_(SoundEvents.f_12418_, 1.0F, 1.0F); + this.unRide(); + this.setAttachFace(direction); + this.playSound(SoundEvents.SHULKER_TELEPORT, 1.0F, 1.0F); @@ -421,6 +_,7 @@ } - shulker.m_20219_(vec3); -+ this.f_19853_.prepareEntity(shulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); //Magma - add spawn reason - this.f_19853_.m_7967_(shulker); + shulker.moveTo(vec3); ++ this.level.prepareEntity(shulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); //Magma - add spawn reason + this.level.addFreshEntity(shulker); } } 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 3d717160..d6568741 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -3,35 +3,35 @@ @@ -140,7 +_,7 @@ return false; } else { - Random random = this.f_25725_.m_21187_(); -- if (this.f_25725_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && random.nextInt(m_186073_(10)) == 0) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25725_.f_19853_, this.f_25725_) && random.nextInt(10) == 0) { - this.f_33555_ = Direction.m_122404_(random); - BlockPos blockpos = (new BlockPos(this.f_25725_.m_20185_(), this.f_25725_.m_20186_() + 0.5D, this.f_25725_.m_20189_())).m_142300_(this.f_33555_); - BlockState blockstate = this.f_25725_.f_19853_.m_8055_(blockpos); + Random random = this.mob.getRandom(); +- if (this.mob.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && random.nextInt(reducedTickDelay(10)) == 0) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.mob.level, this.mob) && random.nextInt(10) == 0) { + this.selectedDirection = Direction.getRandom(random); + BlockPos blockpos = (new BlockPos(this.mob.getX(), this.mob.getY() + 0.5D, this.mob.getZ())).relative(this.selectedDirection); + BlockState blockstate = this.mob.level.getBlockState(blockpos); @@ -167,6 +_,11 @@ - BlockPos blockpos = (new BlockPos(this.f_25725_.m_20185_(), this.f_25725_.m_20186_() + 0.5D, this.f_25725_.m_20189_())).m_142300_(this.f_33555_); - BlockState blockstate = levelaccessor.m_8055_(blockpos); - if (InfestedBlock.m_54195_(blockstate)) { + BlockPos blockpos = (new BlockPos(this.mob.getX(), this.mob.getY() + 0.5D, this.mob.getZ())).relative(this.selectedDirection); + BlockState blockstate = levelaccessor.getBlockState(blockpos); + if (InfestedBlock.isCompatibleHostBlock(blockstate)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_25725_, blockpos, InfestedBlock.m_153430_(blockstate)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockpos, InfestedBlock.infestedStateByHost(blockstate)).isCancelled()) { + return; + } + // CraftBukkit end - levelaccessor.m_7731_(blockpos, InfestedBlock.m_153430_(blockstate), 3); - this.f_25725_.m_21373_(); - this.f_25725_.m_146870_(); + levelaccessor.setBlock(blockpos, InfestedBlock.infestedStateByHost(blockstate), 3); + this.mob.spawnAnim(); + this.mob.discard(); @@ -209,7 +_,12 @@ - BlockState blockstate = level.m_8055_(blockpos1); - Block block = blockstate.m_60734_(); + BlockState blockstate = level.getBlockState(blockpos1); + Block block = blockstate.getBlock(); if (block instanceof InfestedBlock) { -- if (level.m_46469_().m_46207_(GameRules.f_46132_)) { +- if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.f_33562_, blockpos1, net.minecraft.world.level.block.Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockpos1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { + continue; + } + // CraftBukkit end -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this.f_33562_)) { - level.m_46953_(blockpos1, true, this.f_33562_); ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this.silverfish)) { + level.destroyBlock(blockpos1, true, this.silverfish); } else { - level.m_7731_(blockpos1, ((InfestedBlock)block).m_153432_(level.m_8055_(blockpos1)), 3); + 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 fd79128d..58b58be2 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -3,9 +3,9 @@ @@ -79,7 +_,7 @@ } - protected void m_149840_() { -- this.m_21406_(EntityType.f_20481_, true); -+ this.convertTo(EntityType.f_20481_, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons - if (!this.m_20067_()) { - this.f_19853_.m_5898_((Player)null, 1048, this.m_142538_(), 0); + protected void doFreezeConversion() { +- this.convertTo(EntityType.STRAY, true); ++ this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons + if (!this.isSilent()) { + this.level.levelEvent((Player)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 44257f08..1d2507f7 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java @@ -123,6 +_,7 @@ - if (this.f_19861_ && !this.f_33583_) { - int i = this.m_33632_(); + if (this.onGround && !this.wasOnGround) { + int i = this.getSize(); + if (spawnCustomParticles()) i = 0; // don't spawn particles if it's handled by the implementation itself for(int j = 0; j < i * 8; ++j) { - float f = this.f_19796_.nextFloat() * ((float)Math.PI * 2F); - float f1 = this.f_19796_.nextFloat() * 0.5F + 0.5F; + float f = this.random.nextFloat() * ((float)Math.PI * 2F); + float f1 = this.random.nextFloat() * 0.5F + 0.5F; @@ -183,6 +_,19 @@ int j = i / 2; - int k = 2 + this.f_19796_.nextInt(3); + int k = 2 + this.random.nextInt(3); + // CraftBukkit start + org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled() && event.getCount() > 0) { + k = event.getCount(); + } else { -+ super.m_142687_(p_149847_); ++ super.remove(p_149847_); + return; + } + java.util.List slimes = new java.util.ArrayList<>(j); @@ -29,38 +29,38 @@ float f1 = ((float)(l % 2) - 0.5F) * f; float f2 = ((float)(l / 2) - 0.5F) * f; @@ -196,8 +_,18 @@ - slime.m_20331_(this.m_20147_()); - slime.m_7839_(j, true); - slime.m_7678_(this.m_20185_() + (double)f1, this.m_20186_() + 0.5D, this.m_20189_() + (double)f2, this.f_19796_.nextFloat() * 360.0F, 0.0F); -- this.f_19853_.m_7967_(slime); + slime.setInvulnerable(this.isInvulnerable()); + slime.setSize(j, true); + slime.moveTo(this.getX() + (double)f1, this.getY() + 0.5D, this.getZ() + (double)f2, this.random.nextFloat() * 360.0F, 0.0F); +- this.level.addFreshEntity(slime); - } + slimes.add(slime); // CraftBukkit + } + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTransformEvent(this, slimes, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { -+ super.m_142687_(p_149847_); ++ super.remove(p_149847_); + return; + } + for (LivingEntity living : slimes) { -+ this.f_19853_.prepareEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); //Magma - add spawn reason -+ this.f_19853_.m_7967_(living); // CraftBukkit - SpawnReason ++ this.level.prepareEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); //Magma - add spawn reason ++ this.level.addFreshEntity(living); // CraftBukkit - SpawnReason + } + // CraftBukkit end } - super.m_142687_(p_149847_); + super.remove(p_149847_); @@ -268,7 +_,7 @@ } ChunkPos chunkpos = new ChunkPos(p_33624_); -- boolean flag = WorldgenRandom.m_64685_(chunkpos.f_45578_, chunkpos.f_45579_, ((WorldGenLevel)p_33622_).m_7328_(), 987234911L).nextInt(10) == 0; -+ boolean flag = WorldgenRandom.m_64685_(chunkpos.f_45578_, chunkpos.f_45579_, ((WorldGenLevel) p_33622_).m_7328_(), p_33622_.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot - if (p_33625_.nextInt(10) == 0 && flag && p_33624_.m_123342_() < 40) { - return m_21400_(p_33621_, p_33622_, p_33623_, p_33624_, p_33625_); +- boolean flag = WorldgenRandom.seedSlimeChunk(chunkpos.x, chunkpos.z, ((WorldGenLevel)p_33622_).getSeed(), 987234911L).nextInt(10) == 0; ++ boolean flag = WorldgenRandom.seedSlimeChunk(chunkpos.x, chunkpos.z, ((WorldGenLevel) p_33622_).getSeed(), p_33622_.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot + if (p_33625_.nextInt(10) == 0 && flag && p_33624_.getY() < 40) { + return checkMobSpawnRules(p_33621_, p_33622_, p_33623_, p_33624_, p_33625_); } @@ -319,6 +_,12 @@ - public EntityDimensions m_6972_(Pose p_33597_) { - return super.m_6972_(p_33597_).m_20388_(0.255F * (float)this.m_33632_()); + public EntityDimensions getDimensions(Pose p_33597_) { + return super.getDimensions(p_33597_).scale(0.255F * (float)this.getSize()); } + + /** @@ -70,4 +70,4 @@ + protected boolean spawnCustomParticles() { return false; } static class SlimeAttackGoal extends Goal { - private final Slime f_33645_; + private final Slime slime; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch index 2efcc9d0..b385523c 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/SpellcasterIllager.java +++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java @@ -184,6 +_,11 @@ - public void m_8037_() { - --this.f_33774_; - if (this.f_33774_ == 0) { + public void tick() { + --this.attackWarmupDelay; + if (this.attackWarmupDelay == 0) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleEntitySpellCastEvent(SpellcasterIllager.this, this.m_7269_())) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleEntitySpellCastEvent(SpellcasterIllager.this, this.getSpell())) { + return; + } + // CraftBukkit end - this.m_8130_(); - SpellcasterIllager.this.m_5496_(SpellcasterIllager.this.m_7894_(), 1.0F, 1.0F); + this.performSpellCasting(); + SpellcasterIllager.this.playSound(SpellcasterIllager.this.getCastingSoundEvent(), 1.0F, 1.0F); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch index 66487780..1a8becfd 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch @@ -3,22 +3,22 @@ @@ -119,7 +_,12 @@ } - public boolean m_7301_(MobEffectInstance p_33809_) { -- return p_33809_.m_19544_() == MobEffects.f_19614_ ? false : super.m_7301_(p_33809_); -+ if (p_33809_.m_19544_() == MobEffects.f_19614_) { + public boolean canBeAffected(MobEffectInstance p_33809_) { +- return p_33809_.getEffect() == MobEffects.POISON ? false : super.canBeAffected(p_33809_); ++ if (p_33809_.getEffect() == MobEffects.POISON) { + net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_33809_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW; + } -+ return super.m_7301_(p_33809_); ++ return super.canBeAffected(p_33809_); } - public boolean m_33816_() { + public boolean isClimbing() { @@ -157,7 +_,7 @@ if (p_33793_ instanceof Spider.SpiderEffectsGroupData) { - MobEffect mobeffect = ((Spider.SpiderEffectsGroupData)p_33793_).f_33827_; + MobEffect mobeffect = ((Spider.SpiderEffectsGroupData)p_33793_).effect; if (mobeffect != null) { -- this.m_7292_(new MobEffectInstance(mobeffect, Integer.MAX_VALUE)); +- this.addEffect(new MobEffectInstance(mobeffect, Integer.MAX_VALUE)); + this.addEffect(new MobEffectInstance(mobeffect, Integer.MAX_VALUE), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Strider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Strider.java.patch index 00f72e2a..7a3dd64d 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Strider.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Strider.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/monster/Strider.java +++ b/net/minecraft/world/entity/monster/Strider.java @@ -277,7 +_,13 @@ - BlockState blockstate = this.f_19853_.m_8055_(this.m_142538_()); - BlockState blockstate1 = this.m_20075_(); - boolean flag = blockstate.m_204336_(BlockTags.f_13086_) || blockstate1.m_204336_(BlockTags.f_13086_) || this.m_204036_(FluidTags.f_13132_) > 0.0D; -- this.m_33951_(!flag); + BlockState blockstate = this.level.getBlockState(this.blockPosition()); + BlockState blockstate1 = this.getBlockStateOn(); + boolean flag = blockstate.is(BlockTags.STRIDER_WARM_BLOCKS) || blockstate1.is(BlockTags.STRIDER_WARM_BLOCKS) || this.getFluidHeight(FluidTags.LAVA) > 0.0D; +- this.setSuffocating(!flag); + // CraftBukkit start -+ if (!flag ^ this.m_33935_()) { ++ if (!flag ^ this.isSuffocating()) { + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, !flag)) { -+ this.m_33951_(!flag); ++ this.setSuffocating(!flag); + } + } + // CraftBukkit end - super.m_8119_(); - this.m_33940_(); - this.m_20101_(); + super.tick(); + this.floatStrider(); + this.checkInsideBlocks(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Vex.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Vex.java.patch index 0b154251..30ba4123 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Vex.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Vex.java.patch @@ -3,9 +3,9 @@ @@ -265,7 +_,7 @@ } - public void m_8056_() { -- Vex.this.m_6710_(Vex.this.f_33980_.m_5448_()); -+ Vex.this.setTarget(Vex.this.f_33980_.m_5448_(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - super.m_8056_(); + public void start() { +- Vex.this.setTarget(Vex.this.owner.getTarget()); ++ Vex.this.setTarget(Vex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit + super.start(); } } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Witch.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Witch.java.patch index 1757f442..36078788 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Witch.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Witch.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/monster/Witch.java +++ b/net/minecraft/world/entity/monster/Witch.java @@ -116,7 +_,7 @@ - List list = PotionUtils.m_43547_(itemstack); + List list = PotionUtils.getMobEffects(itemstack); if (list != null) { for(MobEffectInstance mobeffectinstance : list) { -- this.m_7292_(new MobEffectInstance(mobeffectinstance)); +- this.addEffect(new MobEffectInstance(mobeffectinstance)); + this.addEffect(new MobEffectInstance(mobeffectinstance), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/WitherSkeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/WitherSkeleton.java.patch index 462a574d..9c6506a9 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/WitherSkeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/WitherSkeleton.java.patch @@ -4,9 +4,9 @@ return false; } else { if (p_34169_ instanceof LivingEntity) { -- ((LivingEntity)p_34169_).m_147207_(new MobEffectInstance(MobEffects.f_19615_, 200), this); +- ((LivingEntity)p_34169_).addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this); + ((LivingEntity)p_34169_).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ ((LivingEntity)p_34169_).m_147207_(new MobEffectInstance(MobEffects.f_19615_, 200), this); // CraftBukkit ++ ((LivingEntity)p_34169_).addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this); // CraftBukkit } return true; 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 40e33ea9..ce1964b7 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,61 +1,61 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java @@ -83,6 +_,7 @@ - private boolean f_34264_; - private int f_34265_; - public int f_34266_; + private boolean canBreakDoors; + private int inWaterTime; + public int conversionTime; + private int lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit - add field public Zombie(EntityType p_34271_, Level p_34272_) { super(p_34271_, p_34272_); @@ -105,7 +_,7 @@ - this.f_21345_.m_25352_(7, new WaterAvoidingRandomStrollGoal(this, 1.0D)); - this.f_21346_.m_25352_(1, (new HurtByTargetGoal(this)).m_26044_(ZombifiedPiglin.class)); - this.f_21346_.m_25352_(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); -- this.f_21346_.m_25352_(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); -+ if ( f_19853_.spigotConfig.zombieAggressiveTowardsVillager ) this.f_21346_.m_25352_(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Spigot - this.f_21346_.m_25352_(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); - this.f_21346_.m_25352_(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.f_30122_)); + this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D)); + this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setAlertOthers(ZombifiedPiglin.class)); + this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); +- this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); ++ if ( level.spigotConfig.zombieAggressiveTowardsVillager ) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Spigot + this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); + this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } @@ -190,8 +_,11 @@ - public void m_8119_() { - if (!this.f_19853_.f_46443_ && this.m_6084_() && !this.m_21525_()) { - if (this.m_34329_()) { -- --this.f_34266_; -- if (this.f_34266_ < 0) { + public void tick() { + if (!this.level.isClientSide && this.isAlive() && !this.isNoAi()) { + if (this.isUnderWaterConverting()) { +- --this.conversionTime; +- if (this.conversionTime < 0) { + // CraftBukkit start - Use wall time instead of ticks for conversion + int elapsedTicks = net.minecraft.server.MinecraftServer.currentTick - this.lastTick; -+ this.f_34266_ -= elapsedTicks; ++ this.conversionTime -= elapsedTicks; + // CraftBukkit end -+ if (this.f_34266_ < 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20562_, (timer) -> this.f_34266_ = timer)) { - this.m_7595_(); ++ if (this.conversionTime < 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.DROWNED, (timer) -> this.conversionTime = timer)) { + this.doUnderWaterConversion(); } - } else if (this.m_7593_()) { + } else if (this.convertsInWater()) { @@ -207,6 +_,7 @@ } - super.m_8119_(); + super.tick(); + this.lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit } - public void m_8107_() { + public void aiStep() { @@ -236,6 +_,7 @@ } - public void m_34278_(int p_34279_) { + public void startUnderWaterConversion(int p_34279_) { + this.lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit - this.f_34266_ = p_34279_; - this.m_20088_().m_135381_(f_34261_, true); + this.conversionTime = p_34279_; + this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); } @@ -249,10 +_,15 @@ } - protected void m_34310_(EntityType p_34311_) { -- Zombie zombie = this.m_21406_(p_34311_, true); + protected void convertToZombieType(EntityType p_34311_) { +- Zombie zombie = this.convertTo(p_34311_, true); + Zombie zombie = this.convertTo(p_34311_, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.DROWNED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DROWNED); if (zombie != null) { - zombie.m_34339_(zombie.f_19853_.m_6436_(zombie.m_142538_()).m_19057_()); - zombie.m_34336_(zombie.m_7586_() && this.m_34330_()); + zombie.handleAttributes(zombie.level.getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); + zombie.setCanBreakDoors(zombie.supportsBreakDoorGoal() && this.canBreakDoors()); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombie); + // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam + } else { @@ -65,42 +65,42 @@ } @@ -273,11 +_,14 @@ - livingentity = (LivingEntity)p_34288_.m_7639_(); + livingentity = (LivingEntity)p_34288_.getEntity(); } -- if (livingentity != null && this.f_19853_.m_46791_() == Difficulty.HARD && (double)this.f_19796_.nextFloat() < this.m_21133_(Attributes.f_22287_) && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { - int i = Mth.m_14107_(this.m_20185_()); - int j = Mth.m_14107_(this.m_20186_()); - int k = Mth.m_14107_(this.m_20189_()); -- Zombie zombie = new Zombie(this.f_19853_); -+ net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, f_19853_, i, j, k, livingentity, this.m_21051_(Attributes.f_22287_).m_22135_()); +- if (livingentity != null && this.level.getDifficulty() == Difficulty.HARD && (double)this.random.nextFloat() < this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE) && this.level.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); ++ net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, level, i, j, k, livingentity, this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).getValue()); + if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true; + if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || -+ livingentity != null && this.f_19853_.m_46791_() == Difficulty.HARD && (double)this.f_19796_.nextFloat() < this.m_21051_(Attributes.f_22287_).m_22135_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { -+ Zombie zombie = event.getCustomSummonedAid() != null && event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW ? event.getCustomSummonedAid() : EntityType.f_20501_.m_20615_(this.f_19853_); ++ livingentity != null && this.level.getDifficulty() == Difficulty.HARD && (double)this.random.nextFloat() < this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).getValue() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { ++ Zombie zombie = event.getCustomSummonedAid() != null && event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW ? event.getCustomSummonedAid() : EntityType.ZOMBIE.create(this.level); for(int l = 0; l < 50; ++l) { - int i1 = i + Mth.m_14072_(this.f_19796_, 7, 40) * Mth.m_14072_(this.f_19796_, -1, 1); + int i1 = i + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); @@ -289,8 +_,10 @@ - if (NaturalSpawner.m_47051_(spawnplacements$type, this.f_19853_, blockpos, entitytype) && SpawnPlacements.m_21759_(entitytype, serverlevel, MobSpawnType.REINFORCEMENT, blockpos, this.f_19853_.f_46441_)) { - zombie.m_6034_((double)i1, (double)j1, (double)k1); - if (!this.f_19853_.m_45914_((double)i1, (double)j1, (double)k1, 7.0D) && this.f_19853_.m_45784_(zombie) && this.f_19853_.m_45786_(zombie) && !this.f_19853_.m_46855_(zombie.m_142469_())) { -- zombie.m_6710_(livingentity); + if (NaturalSpawner.isSpawnPositionOk(spawnplacements$type, this.level, blockpos, entitytype) && SpawnPlacements.checkSpawnRules(entitytype, serverlevel, MobSpawnType.REINFORCEMENT, blockpos, this.level.random)) { + zombie.setPos((double)i1, (double)j1, (double)k1); + if (!this.level.hasNearbyAlivePlayer((double)i1, (double)j1, (double)k1, 7.0D) && this.level.isUnobstructed(zombie) && this.level.noCollision(zombie) && !this.level.containsAnyLiquid(zombie.getBoundingBox())) { +- zombie.setTarget(livingentity); + if (livingentity != null) + zombie.setTarget(livingentity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit - zombie.m_6518_(serverlevel, this.f_19853_.m_6436_(zombie.m_142538_()), MobSpawnType.REINFORCEMENT, (SpawnGroupData)null, (CompoundTag)null); + zombie.finalizeSpawn(serverlevel, this.level.getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.REINFORCEMENT, (SpawnGroupData)null, (CompoundTag)null); + serverlevel.prepareEntity(zombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); //Magma - add spawn reason - serverlevel.m_47205_(zombie); - this.m_21051_(Attributes.f_22287_).m_22125_(new AttributeModifier("Zombie reinforcement caller charge", (double)-0.05F, AttributeModifier.Operation.ADDITION)); - zombie.m_21051_(Attributes.f_22287_).m_22125_(new AttributeModifier("Zombie reinforcement callee charge", (double)-0.05F, AttributeModifier.Operation.ADDITION)); + serverlevel.addFreshEntityWithPassengers(zombie); + this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", (double)-0.05F, AttributeModifier.Operation.ADDITION)); + zombie.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", (double)-0.05F, AttributeModifier.Operation.ADDITION)); @@ -309,7 +_,13 @@ if (flag) { - float f = this.f_19853_.m_6436_(this.m_142538_()).m_19056_(); - if (this.m_21205_().m_41619_() && this.m_6060_() && this.f_19796_.nextFloat() < f * 0.3F) { -- p_34276_.m_20254_(2 * (int)f); + float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); + if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { +- p_34276_.setSecondsOnFire(2 * (int)f); + // CraftBukkit start + org.bukkit.event.entity.EntityCombustByEntityEvent event = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), p_34276_.getBukkitEntity(), 2 * (int) f); // PAIL: fixme -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + p_34276_.setSecondsOnFire(event.getDuration(), false); + } @@ -110,71 +110,71 @@ @@ -374,23 +_,33 @@ - public void m_5837_(ServerLevel p_34281_, LivingEntity p_34282_) { - super.m_5837_(p_34281_, p_34282_); -- if ((p_34281_.m_46791_() == Difficulty.NORMAL || p_34281_.m_46791_() == Difficulty.HARD) && p_34282_ instanceof Villager) { -+ if ((p_34281_.m_46791_() == Difficulty.NORMAL || p_34281_.m_46791_() == Difficulty.HARD) && p_34282_ instanceof Villager && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_34282_, EntityType.f_20530_, (timer) -> { + public void killed(ServerLevel p_34281_, LivingEntity p_34282_) { + super.killed(p_34281_, p_34282_); +- if ((p_34281_.getDifficulty() == Difficulty.NORMAL || p_34281_.getDifficulty() == Difficulty.HARD) && p_34282_ instanceof Villager) { ++ if ((p_34281_.getDifficulty() == Difficulty.NORMAL || p_34281_.getDifficulty() == Difficulty.HARD) && p_34282_ instanceof Villager && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_34282_, EntityType.ZOMBIE_VILLAGER, (timer) -> { + })) { - if (p_34281_.m_46791_() != Difficulty.HARD && this.f_19796_.nextBoolean()) { + if (p_34281_.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { return; } - Villager villager = (Villager)p_34282_; -- ZombieVillager zombievillager = villager.m_21406_(EntityType.f_20530_, false); -- zombievillager.m_6518_(p_34281_, p_34281_.m_6436_(zombievillager.m_142538_()), MobSpawnType.CONVERSION, new Zombie.ZombieGroupData(false, true), (CompoundTag)null); -- zombievillager.m_141967_(villager.m_7141_()); -- zombievillager.m_34391_(villager.m_35517_().m_26179_(NbtOps.f_128958_).getValue()); -- zombievillager.m_34411_(villager.m_6616_().m_45388_()); -- zombievillager.m_34373_(villager.m_7809_()); -- if (!this.m_20067_()) { -- p_34281_.m_5898_((Player)null, 1026, this.m_142538_(), 0); +- ZombieVillager zombievillager = villager.convertTo(EntityType.ZOMBIE_VILLAGER, false); +- zombievillager.finalizeSpawn(p_34281_, p_34281_.getCurrentDifficultyAt(zombievillager.blockPosition()), MobSpawnType.CONVERSION, new Zombie.ZombieGroupData(false, true), (CompoundTag)null); +- zombievillager.setVillagerData(villager.getVillagerData()); +- zombievillager.setGossips(villager.getGossips().store(NbtOps.INSTANCE).getValue()); +- zombievillager.setTradeOffers(villager.getOffers().createTag()); +- zombievillager.setVillagerXp(villager.getVillagerXp()); +- if (!this.isSilent()) { +- p_34281_.levelEvent((Player)null, 1026, this.blockPosition(), 0); + Villager villager = (Villager) p_34282_; + // CraftBukkit start -+ zombifyVillager(p_34281_, villager, this.m_142538_(), this.m_20067_(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.INFECTION); ++ zombifyVillager(p_34281_, villager, this.blockPosition(), this.isSilent(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.INFECTION); + } + } + public static ZombieVillager zombifyVillager(ServerLevel p_34281_, Villager villager, net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { -+ ZombieVillager entityzombievillager = (ZombieVillager) villager.convertTo(EntityType.f_20530_, false, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION, spawnReason); ++ ZombieVillager entityzombievillager = (ZombieVillager) villager.convertTo(EntityType.ZOMBIE_VILLAGER, false, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION, spawnReason); + if (entityzombievillager != null) { + // CraftBukkit end -+ entityzombievillager.m_6518_(p_34281_, p_34281_.m_6436_(villager.m_142538_()), MobSpawnType.CONVERSION, new Zombie.ZombieGroupData(false, true), (CompoundTag) null); -+ entityzombievillager.m_141967_(villager.m_7141_()); -+ entityzombievillager.m_34391_(villager.m_35517_().m_26179_(NbtOps.f_128958_).getValue()); -+ entityzombievillager.m_34411_(villager.m_6616_().m_45388_()); -+ entityzombievillager.m_34373_(villager.m_7809_()); ++ entityzombievillager.finalizeSpawn(p_34281_, p_34281_.getCurrentDifficultyAt(villager.blockPosition()), MobSpawnType.CONVERSION, new Zombie.ZombieGroupData(false, true), (CompoundTag) null); ++ entityzombievillager.setVillagerData(villager.getVillagerData()); ++ entityzombievillager.setGossips(villager.getGossips().store(NbtOps.INSTANCE).getValue()); ++ entityzombievillager.setTradeOffers(villager.getOffers().createTag()); ++ entityzombievillager.setVillagerXp(villager.getVillagerXp()); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(entityzombievillager, villager); + if (!silent) { -+ p_34281_.m_5898_((Player) null, 1026, blockPosition, 0); ++ p_34281_.levelEvent((Player) null, 1026, blockPosition, 0); } } + return entityzombievillager; // CraftBukkit } - protected float m_6431_(Pose p_34313_, EntityDimensions p_34314_) { + protected float getStandingEyeHeight(Pose p_34313_, EntityDimensions p_34314_) { @@ -432,6 +_,7 @@ - chicken1.m_6518_(p_34297_, p_34298_, MobSpawnType.JOCKEY, (SpawnGroupData)null, (CompoundTag)null); - chicken1.m_28273_(true); - this.m_20329_(chicken1); + chicken1.finalizeSpawn(p_34297_, p_34298_, MobSpawnType.JOCKEY, (SpawnGroupData)null, (CompoundTag)null); + chicken1.setChickenJockey(true); + this.startRiding(chicken1); + p_34297_.prepareEntity(chicken1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT); //Magma - add spawn reason - p_34297_.m_7967_(chicken1); + p_34297_.addFreshEntity(chicken1); } } @@ -457,7 +_,7 @@ } - public static boolean m_34302_(Random p_34303_) { + public static boolean getSpawnAsBabyOdds(Random p_34303_) { - return p_34303_.nextFloat() < 0.05F; + return p_34303_.nextFloat() < net.minecraftforge.common.ForgeConfig.SERVER.zombieBabyChance.get(); } - protected void m_34339_(float p_34340_) { + protected void handleAttributes(float p_34340_) { @@ -477,7 +_,7 @@ } - protected void m_7572_() { -- this.m_21051_(Attributes.f_22287_).m_22100_(this.f_19796_.nextDouble() * (double)0.1F); -+ this.m_21051_(Attributes.f_22287_).m_22100_(this.f_19796_.nextDouble() * net.minecraftforge.common.ForgeConfig.SERVER.zombieBaseSummonChance.get()); + protected void randomizeReinforcementsChance() { +- this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).setBaseValue(this.random.nextDouble() * (double)0.1F); ++ this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).setBaseValue(this.random.nextDouble() * net.minecraftforge.common.ForgeConfig.SERVER.zombieBaseSummonChance.get()); } - public double m_6049_() { + public double getMyRidingOffset() { 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 bd357b6a..89a9143e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -2,53 +2,53 @@ +++ b/net/minecraft/world/entity/monster/ZombieVillager.java @@ -63,6 +_,7 @@ @Nullable - private CompoundTag f_34362_; - private int f_34363_; + private CompoundTag tradeOffers; + private int villagerXp; + private int lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit - add field public ZombieVillager(EntityType p_34368_, Level p_34369_) { super(p_34368_, p_34369_); @@ -126,13 +_,19 @@ - public void m_8119_() { - if (!this.f_19853_.f_46443_ && this.m_6084_() && this.m_34408_()) { - int i = this.m_34410_(); + public void tick() { + if (!this.level.isClientSide && this.isAlive() && this.isConverting()) { + int i = this.getConversionProgress(); + // CraftBukkit start - Use wall time instead of ticks for villager conversion + int elapsedTicks = net.minecraft.server.MinecraftServer.currentTick - this.lastTick; + i *= elapsedTicks; + // CraftBukkit end + - this.f_34365_ -= i; -- if (this.f_34365_ <= 0) { -+ if (this.f_34365_ <= 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20492_, (timer) -> this.f_34365_ = timer)) { - this.m_34398_((ServerLevel)this.f_19853_); + this.villagerConversionTime -= i; +- if (this.villagerConversionTime <= 0) { ++ if (this.villagerConversionTime <= 0 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.VILLAGER, (timer) -> this.villagerConversionTime = timer)) { + this.finishConversion((ServerLevel)this.level); } } - super.m_8119_(); + super.tick(); + this.lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit } - public InteractionResult m_6071_(Player p_34394_, InteractionHand p_34395_) { + public InteractionResult mobInteract(Player p_34394_, InteractionHand p_34395_) { @@ -173,8 +_,10 @@ - this.f_34360_ = p_34384_; - this.f_34365_ = p_34385_; - this.m_20088_().m_135381_(f_34359_, true); -- this.m_21195_(MobEffects.f_19613_); -- this.m_7292_(new MobEffectInstance(MobEffects.f_19600_, p_34385_, Math.min(this.f_19853_.m_46791_().m_19028_() - 1, 0))); + this.conversionStarter = p_34384_; + this.villagerConversionTime = p_34385_; + this.getEntityData().set(DATA_CONVERTING_ID, true); +- this.removeEffect(MobEffects.WEAKNESS); +- this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, p_34385_, Math.min(this.level.getDifficulty().getId() - 1, 0))); + // CraftBukkit start -+ this.removeEffect(MobEffects.f_19613_, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19600_, p_34385_, Math.min(this.f_19853_.m_46791_().m_19028_() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); ++ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); ++ this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, p_34385_, Math.min(this.level.getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + // CraftBukkit end - this.f_19853_.m_7605_(this, (byte)16); + this.level.broadcastEntityEvent(this, (byte)16); } @@ -190,7 +_,13 @@ } - private void m_34398_(ServerLevel p_34399_) { -- Villager villager = this.m_21406_(EntityType.f_20492_, false); + private void finishConversion(ServerLevel p_34399_) { +- Villager villager = this.convertTo(EntityType.VILLAGER, false); + // CraftBukkit start -+ Villager villager = (Villager) this.convertTo(EntityType.f_20492_, false, org.bukkit.event.entity.EntityTransformEvent.TransformReason.CURED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); ++ Villager villager = (Villager) this.convertTo(EntityType.VILLAGER, false, org.bukkit.event.entity.EntityTransformEvent.TransformReason.CURED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); + if (villager == null) { + ((org.bukkit.entity.ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam + return; @@ -56,13 +56,13 @@ + // CraftBukkit end for(EquipmentSlot equipmentslot : EquipmentSlot.values()) { - ItemStack itemstack = this.m_6844_(equipmentslot); + ItemStack itemstack = this.getItemBySlot(equipmentslot); @@ -200,7 +_,9 @@ } else { - double d0 = (double)this.m_21519_(equipmentslot); + double d0 = (double)this.getEquipmentDropChance(equipmentslot); if (d0 > 1.0D) { + this.forceDrops = true; // CraftBukkit - this.m_19983_(itemstack); + this.spawnAtLocation(itemstack); + this.forceDrops = false; // CraftBukkit } } @@ -71,13 +71,13 @@ } } -- villager.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); -+ villager.addEffect(new MobEffectInstance(MobEffects.f_19604_, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit - if (!this.m_20067_()) { - p_34399_.m_5898_((Player)null, 1027, this.m_142538_(), 0); +- villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit + if (!this.isSilent()) { + p_34399_.levelEvent((Player)null, 1027, this.blockPosition(), 0); } - + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, villager); } - private int m_34410_() { + private int getConversionProgress() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch index 555e14ae..30d2c1d2 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch @@ -2,42 +2,42 @@ +++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java @@ -136,7 +_,7 @@ }).filter((p_34456_) -> { - return !p_34456_.m_7307_(this.m_5448_()); + return !p_34456_.isAlliedTo(this.getTarget()); }).forEach((p_34440_) -> { -- p_34440_.m_6710_(this.m_5448_()); -+ p_34440_.setTarget(this.m_5448_(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit +- p_34440_.setTarget(this.getTarget()); ++ p_34440_.setTarget(this.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit }); } @@ -144,7 +_,7 @@ - this.m_5496_(SoundEvents.f_12611_, this.m_6121_() * 2.0F, this.m_6100_() * 1.8F); + this.playSound(SoundEvents.ZOMBIFIED_PIGLIN_ANGRY, this.getSoundVolume() * 2.0F, this.getVoicePitch() * 1.8F); } -- public void m_6710_(@Nullable LivingEntity p_34478_) { +- public void setTarget(@Nullable LivingEntity p_34478_) { + public boolean setTarget(@Nullable LivingEntity p_34478_, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature - if (this.m_5448_() == null && p_34478_ != null) { - this.f_34417_ = f_34424_.m_142270_(this.f_19796_); - this.f_34422_ = f_34421_.m_142270_(this.f_19796_); + if (this.getTarget() == null && p_34478_ != null) { + this.playFirstAngerSoundIn = FIRST_ANGER_SOUND_DELAY.sample(this.random); + this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random); @@ -154,11 +_,20 @@ - this.m_6598_((Player)p_34478_); + this.setLastHurtByPlayer((Player)p_34478_); } -- super.m_6710_(p_34478_); +- super.setTarget(p_34478_); + return super.setTarget(p_34478_, reason, fireEvent); // CraftBukkit } - public void m_6825_() { -- this.m_7870_(f_34418_.m_142270_(this.f_19796_)); + public void startPersistentAngerTimer() { +- this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random)); + // CraftBukkit start -+ net.minecraft.world.entity.Entity entity = ((ServerLevel) this.f_19853_).m_8791_(m_6120_()); -+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), ZombifiedPiglin.f_34418_.m_142270_(this.f_19796_)); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ net.minecraft.world.entity.Entity entity = ((ServerLevel) this.level).getEntity(getPersistentAngerTarget()); ++ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), ZombifiedPiglin.PERSISTENT_ANGER_TIME.sample(this.random)); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.m_6925_(null); ++ this.setPersistentAngerTarget(null); + return; + } -+ this.m_7870_(event.getNewAnger()); ++ this.setRemainingPersistentAngerTime(event.getNewAnger()); + // CraftBukkit end } - public static boolean m_34449_(EntityType p_34450_, LevelAccessor p_34451_, MobSpawnType p_34452_, BlockPos p_34453_, Random p_34454_) { + public static boolean checkZombifiedPiglinSpawnRules(EntityType p_34450_, LevelAccessor p_34451_, MobSpawnType p_34452_, BlockPos p_34453_, Random p_34454_) { 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 dcda2e19..19c8743f 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,18 +1,18 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java @@ -126,7 +_,7 @@ - HoglinAi.m_34577_(this); - if (this.m_34554_()) { - ++this.f_34484_; -- if (this.f_34484_ > 300) { -+ if (this.f_34484_ > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20500_, (timer) -> this.f_34484_ = timer)) { - this.m_34500_(SoundEvents.f_11959_); - this.m_34531_((ServerLevel)this.f_19853_); + 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.playSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); + this.finishConversion((ServerLevel)this.level); } @@ -219,6 +_,7 @@ - Zoglin zoglin = this.m_21406_(EntityType.f_20500_, true); + Zoglin zoglin = this.convertTo(EntityType.ZOGLIN, true); if (zoglin != null) { - zoglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); + zoglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zoglin); } 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 b4c2f52c..bfe2ba63 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,25 +1,25 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java @@ -80,9 +_,10 @@ - ++this.f_34649_; + ++this.timeInOverworld; } else { - this.f_34649_ = 0; -+ this.f_34649_ = 0; + this.timeInOverworld = 0; ++ this.timeInOverworld = 0; } -- if (this.f_34649_ > 300) { -+ if (this.f_34649_ > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20531_, (timer) -> this.f_34649_ = timer)) { - this.m_7580_(); - this.m_8063_((ServerLevel)this.f_19853_); +- 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,9 +_,10 @@ } - protected void m_8063_(ServerLevel p_34663_) { -- ZombifiedPiglin zombifiedpiglin = this.m_21406_(EntityType.f_20531_, true); -+ ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.f_20531_, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons + protected void finishConversion(ServerLevel p_34663_) { +- ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, true); ++ ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons if (zombifiedpiglin != null) { - zombifiedpiglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); + zombifiedpiglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); } 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 9da441d4..01a3b5be 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,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java @@ -75,6 +_,11 @@ - protected static final ImmutableList>> f_34680_ = ImmutableList.of(SensorType.f_26811_, SensorType.f_26812_, SensorType.f_26810_, SensorType.f_26814_, SensorType.f_26819_); - protected static final ImmutableList> f_34672_ = ImmutableList.of(MemoryModuleType.f_26371_, MemoryModuleType.f_26379_, MemoryModuleType.f_148204_, MemoryModuleType.f_148205_, MemoryModuleType.f_26368_, MemoryModuleType.f_148206_, MemoryModuleType.f_26347_, MemoryModuleType.f_26346_, MemoryModuleType.f_26332_, MemoryModuleType.f_26381_, MemoryModuleType.f_26382_, MemoryModuleType.f_26370_, MemoryModuleType.f_26326_, MemoryModuleType.f_26372_, MemoryModuleType.f_26373_, MemoryModuleType.f_26374_, MemoryModuleType.f_26377_, MemoryModuleType.f_26334_, MemoryModuleType.f_26335_, MemoryModuleType.f_26383_, MemoryModuleType.f_26336_, MemoryModuleType.f_26337_, MemoryModuleType.f_26339_, MemoryModuleType.f_26338_, MemoryModuleType.f_26341_, MemoryModuleType.f_26342_, MemoryModuleType.f_26340_, MemoryModuleType.f_26344_, MemoryModuleType.f_26333_, MemoryModuleType.f_26351_, MemoryModuleType.f_26376_, MemoryModuleType.f_26352_, MemoryModuleType.f_26353_, MemoryModuleType.f_26343_, MemoryModuleType.f_26345_, MemoryModuleType.f_26354_, MemoryModuleType.f_26355_, MemoryModuleType.f_26356_); + protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR); + protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT); + // CraftBukkit start - Custom bartering and interest list + public java.util.Set allowedBarterItems = new java.util.HashSet<>(); @@ -11,68 +11,68 @@ + public Piglin(EntityType p_34683_, Level p_34684_) { super(p_34683_, p_34684_); - this.f_21364_ = 5; + this.xpReward = 5; @@ -91,6 +_,14 @@ } - p_34751_.m_128365_("Inventory", this.f_34678_.m_7927_()); + p_34751_.put("Inventory", this.inventory.createTag()); + // CraftBukkit start + net.minecraft.nbt.ListTag barterList = new net.minecraft.nbt.ListTag(); -+ allowedBarterItems.stream().map(net.minecraft.core.Registry.f_122827_::m_7981_).map(net.minecraft.resources.ResourceLocation::toString).map(net.minecraft.nbt.StringTag::m_129297_).forEach(barterList::add); -+ p_34751_.m_128365_("Bukkit.BarterList", barterList); ++ allowedBarterItems.stream().map(net.minecraft.core.Registry.ITEM::getKey).map(net.minecraft.resources.ResourceLocation::toString).map(net.minecraft.nbt.StringTag::valueOf).forEach(barterList::add); ++ p_34751_.put("Bukkit.BarterList", barterList); + net.minecraft.nbt.ListTag interestList = new net.minecraft.nbt.ListTag(); -+ interestItems.stream().map(net.minecraft.core.Registry.f_122827_::m_7981_).map(net.minecraft.resources.ResourceLocation::toString).map(net.minecraft.nbt.StringTag::m_129297_).forEach(interestList::add); -+ p_34751_.m_128365_("Bukkit.InterestList", interestList); ++ interestItems.stream().map(net.minecraft.core.Registry.ITEM::getKey).map(net.minecraft.resources.ResourceLocation::toString).map(net.minecraft.nbt.StringTag::valueOf).forEach(interestList::add); ++ p_34751_.put("Bukkit.InterestList", interestList); + // CraftBukkit end } - public void m_7378_(CompoundTag p_34725_) { + public void readAdditionalSaveData(CompoundTag p_34725_) { @@ -98,6 +_,10 @@ - this.m_6863_(p_34725_.m_128471_("IsBaby")); - this.m_34791_(p_34725_.m_128471_("CannotHunt")); - this.f_34678_.m_7797_(p_34725_.m_128437_("Inventory", 10)); + this.setBaby(p_34725_.getBoolean("IsBaby")); + this.setCannotHunt(p_34725_.getBoolean("CannotHunt")); + this.inventory.fromTag(p_34725_.getList("Inventory", 10)); + // CraftBukkit start -+ this.allowedBarterItems = p_34725_.m_128437_("Bukkit.BarterList", 8).stream().map(net.minecraft.nbt.Tag::m_7916_).map(net.minecraft.resources.ResourceLocation::m_135820_).map(net.minecraft.core.Registry.f_122827_::m_7745_).collect(java.util.stream.Collectors.toCollection(java.util.HashSet::new)); -+ this.interestItems = p_34725_.m_128437_("Bukkit.InterestList", 8).stream().map(net.minecraft.nbt.Tag::m_7916_).map(net.minecraft.resources.ResourceLocation::m_135820_).map(net.minecraft.core.Registry.f_122827_::m_7745_).collect(java.util.stream.Collectors.toCollection(java.util.HashSet::new)); ++ this.allowedBarterItems = p_34725_.getList("Bukkit.BarterList", 8).stream().map(net.minecraft.nbt.Tag::getAsString).map(net.minecraft.resources.ResourceLocation::tryParse).map(net.minecraft.core.Registry.ITEM::get).collect(java.util.stream.Collectors.toCollection(java.util.HashSet::new)); ++ this.interestItems = p_34725_.getList("Bukkit.InterestList", 8).stream().map(net.minecraft.nbt.Tag::getAsString).map(net.minecraft.resources.ResourceLocation::tryParse).map(net.minecraft.core.Registry.ITEM::get).collect(java.util.stream.Collectors.toCollection(java.util.HashSet::new)); + // CraftBukkit end } @VisibleForDebug @@ -282,7 +_,7 @@ - } else if (this.m_34773_()) { + } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { -- return this.m_5912_() && this.m_21055_(Items.f_42717_) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; -+ return this.m_5912_() && this.m_21093_(is -> is.m_41720_() instanceof net.minecraft.world.item.CrossbowItem) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; +- 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; } } @@ -324,7 +_,7 @@ } - protected void m_34785_(ItemStack p_34786_) { -- if (p_34786_.m_150930_(PiglinAi.f_34794_)) { -+ if (p_34786_.isPiglinCurrency() || allowedBarterItems.contains(p_34786_.m_41720_())) { // CraftBukkit - Changes to accept custom payment items - this.m_8061_(EquipmentSlot.OFFHAND, p_34786_); - this.m_21508_(EquipmentSlot.OFFHAND); + protected void holdInOffHand(ItemStack p_34786_) { +- if (p_34786_.is(PiglinAi.BARTERING_ITEM)) { ++ if (p_34786_.isPiglinCurrency() || allowedBarterItems.contains(p_34786_.getItem())) { // CraftBukkit - Changes to accept custom payment items + this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); + this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { @@ -334,7 +_,7 @@ } - public boolean m_7243_(ItemStack p_34777_) { -- return this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && this.m_21531_() && PiglinAi.m_34857_(this, p_34777_); -+ return net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) && this.m_21531_() && PiglinAi.m_34857_(this, p_34777_); + 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_); } - protected boolean m_34787_(ItemStack p_34788_) { + protected boolean canReplaceCurrentItem(ItemStack p_34788_) { @@ -347,8 +_,8 @@ - if (EnchantmentHelper.m_44920_(p_34713_)) { + if (EnchantmentHelper.hasBindingCurse(p_34713_)) { return false; } else { -- boolean flag = PiglinAi.m_149965_(p_34712_) || p_34712_.m_150930_(Items.f_42717_); -- boolean flag1 = PiglinAi.m_149965_(p_34713_) || p_34713_.m_150930_(Items.f_42717_); -+ boolean flag = PiglinAi.isLovedItem(p_34712_, this) || p_34712_.m_150930_(Items.f_42717_); // CraftBukkit -+ boolean flag1 = PiglinAi.isLovedItem(p_34713_, this) || p_34713_.m_150930_(Items.f_42717_); // CraftBukkit +- boolean flag = PiglinAi.isLovedItem(p_34712_) || p_34712_.is(Items.CROSSBOW); +- boolean flag1 = PiglinAi.isLovedItem(p_34713_) || p_34713_.is(Items.CROSSBOW); ++ boolean flag = PiglinAi.isLovedItem(p_34712_, this) || p_34712_.is(Items.CROSSBOW); // CraftBukkit ++ boolean flag1 = PiglinAi.isLovedItem(p_34713_, this) || p_34713_.is(Items.CROSSBOW); // CraftBukkit if (flag && !flag1) { return true; } else if (!flag && flag1) { 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 035c804c..deab9ce6 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,100 +1,100 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java @@ -211,23 +_,27 @@ - protected static void m_34843_(Piglin p_34844_, ItemEntity p_34845_) { - m_35006_(p_34844_); + protected static void pickUpItem(Piglin p_34844_, ItemEntity p_34845_) { + stopWalking(p_34844_); ItemStack itemstack; -- if (p_34845_.m_32055_().m_150930_(Items.f_42587_)) { +- if (p_34845_.getItem().is(Items.GOLD_NUGGET)) { + // CraftBukkit start -+ if (p_34845_.m_32055_().m_150930_(Items.f_42587_) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(p_34844_, p_34845_, 0, false).isCancelled()) { - p_34844_.m_7938_(p_34845_, p_34845_.m_32055_().m_41613_()); - itemstack = p_34845_.m_32055_(); - p_34845_.m_146870_(); ++ if (p_34845_.getItem().is(Items.GOLD_NUGGET) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(p_34844_, p_34845_, 0, false).isCancelled()) { + p_34844_.take(p_34845_, p_34845_.getItem().getCount()); + itemstack = p_34845_.getItem(); + p_34845_.discard(); - } else { -+ } else if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(p_34844_, p_34845_, p_34845_.m_32055_().m_41613_() - 1, false).isCancelled()) { - p_34844_.m_7938_(p_34845_, 1); - itemstack = m_34822_(p_34845_); ++ } else if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(p_34844_, p_34845_, p_34845_.getItem().getCount() - 1, false).isCancelled()) { + p_34844_.take(p_34845_, 1); + itemstack = removeOneItemFromItemEntity(p_34845_); + } else { + return; } + // CraftBukkit end -- if (m_149965_(itemstack)) { +- if (isLovedItem(itemstack)) { + if (isLovedItem(itemstack, p_34844_)) { // CraftBukkit - Changes to allow for custom payment in bartering - p_34844_.m_6274_().m_21936_(MemoryModuleType.f_26337_); - m_34932_(p_34844_, itemstack); - m_34938_(p_34844_); - } else if (m_149969_(itemstack) && !m_35018_(p_34844_)) { - m_35014_(p_34844_); + p_34844_.getBrain().eraseMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM); + holdInOffhand(p_34844_, itemstack); + admireGoldItem(p_34844_); + } else if (isFood(itemstack) && !hasEatenRecently(p_34844_)) { + eat(p_34844_); } else { -- boolean flag = p_34844_.m_21540_(itemstack); +- boolean flag = p_34844_.equipItemIfPossible(itemstack); + boolean flag = p_34844_.equipItemIfPossible(itemstack, p_34845_); // CraftBukkit if (!flag) { - m_34952_(p_34844_, itemstack); + putInInventory(p_34844_, itemstack); } @@ -258,9 +_,14 @@ - ItemStack itemstack = p_34868_.m_21120_(InteractionHand.OFF_HAND); - p_34868_.m_21008_(InteractionHand.OFF_HAND, ItemStack.f_41583_); - if (p_34868_.m_34667_()) { -- boolean flag = m_149967_(itemstack); + ItemStack itemstack = p_34868_.getItemInHand(InteractionHand.OFF_HAND); + p_34868_.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); + if (p_34868_.isAdult()) { +- boolean flag = isBarterCurrency(itemstack); - if (p_34869_ && flag) { -- m_34860_(p_34868_, m_34996_(p_34868_)); +- throwItems(p_34868_, getBarterResponseItems(p_34868_)); + boolean flag = itemstack.isPiglinCurrency(); + if (p_34869_ && flag || isBarterCurrency(itemstack, p_34868_)) { // Magma + // CraftBukkit start -+ org.bukkit.event.entity.PiglinBarterEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPiglinBarterEvent(p_34868_, m_34996_(p_34868_), itemstack); ++ org.bukkit.event.entity.PiglinBarterEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPiglinBarterEvent(p_34868_, getBarterResponseItems(p_34868_), itemstack); + if (!event.isCancelled()) { -+ m_34860_(p_34868_, event.getOutcome().stream().map(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack::asNMSCopy).collect(java.util.stream.Collectors.toList())); ++ throwItems(p_34868_, event.getOutcome().stream().map(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack::asNMSCopy).collect(java.util.stream.Collectors.toList())); + } + // CraftBukkit end } else if (!flag) { - boolean flag1 = p_34868_.m_21540_(itemstack); + boolean flag1 = p_34868_.equipItemIfPossible(itemstack); if (!flag1) { @@ -271,7 +_,7 @@ - boolean flag2 = p_34868_.m_21540_(itemstack); + boolean flag2 = p_34868_.equipItemIfPossible(itemstack); if (!flag2) { - ItemStack itemstack1 = p_34868_.m_21205_(); -- if (m_149965_(itemstack1)) { + ItemStack itemstack1 = p_34868_.getMainHandItem(); +- if (isLovedItem(itemstack1)) { + if (isLovedItem(itemstack1, p_34868_)) { // CraftBukkit - Changes to allow for custom payment in bartering - m_34952_(p_34868_, itemstack1); + putInInventory(p_34868_, itemstack1); } else { - m_34860_(p_34868_, Collections.singletonList(itemstack1)); + throwItems(p_34868_, Collections.singletonList(itemstack1)); @@ -345,7 +_,7 @@ return false; - } else if (m_35024_(p_34858_) && p_34858_.m_6274_().m_21874_(MemoryModuleType.f_26372_)) { + } else if (isAdmiringDisabled(p_34858_) && p_34858_.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; -- } else if (m_149967_(p_34859_)) { +- } else if (isBarterCurrency(p_34859_)) { + } else if (p_34859_.isPiglinCurrency() || isBarterCurrency(p_34859_, p_34858_)) { - return m_35028_(p_34858_); + return isNotHoldingLovedItemInOffHand(p_34858_); } else { - boolean flag = p_34858_.m_34780_(p_34859_); + boolean flag = p_34858_.canAddToInventory(p_34859_); @@ -361,6 +_,12 @@ } } + // CraftBukkit start - Added method to allow checking for custom payment items + protected static boolean isLovedItem(ItemStack itemstack, Piglin piglin) { -+ return m_149965_(itemstack) || (piglin.interestItems.contains(itemstack.m_41720_()) || piglin.allowedBarterItems.contains(itemstack.m_41720_())); ++ return isLovedItem(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem())); + } + // CraftBukkit end + - protected static boolean m_149965_(ItemStack p_149966_) { - return p_149966_.m_204117_(ItemTags.f_13151_); + protected static boolean isLovedItem(ItemStack p_149966_) { + return p_149966_.is(ItemTags.PIGLIN_LOVED); } @@ -445,7 +_,7 @@ } - protected static boolean m_34909_(Piglin p_34910_, ItemStack p_34911_) { -- return !m_35024_(p_34910_) && !m_35020_(p_34910_) && p_34910_.m_34667_() && m_149967_(p_34911_); -+ return !m_35024_(p_34910_) && !m_35020_(p_34910_) && p_34910_.m_34667_() && p_34911_.isPiglinCurrency() || isBarterCurrency(p_34911_, p_34910_); + protected static boolean canAdmire(Piglin p_34910_, ItemStack p_34911_) { +- return !isAdmiringDisabled(p_34910_) && !isAdmiringItem(p_34910_) && p_34910_.isAdult() && isBarterCurrency(p_34911_); ++ return !isAdmiringDisabled(p_34910_) && !isAdmiringItem(p_34910_) && p_34910_.isAdult() && p_34911_.isPiglinCurrency() || isBarterCurrency(p_34911_, p_34910_); } - protected static void m_34837_(Piglin p_34838_, LivingEntity p_34839_) { + protected static void wasHurtBy(Piglin p_34838_, LivingEntity p_34839_) { @@ -546,7 +_,7 @@ - public static boolean m_34808_(LivingEntity p_34809_) { - for(ItemStack itemstack : p_34809_.m_6168_()) { - Item item = itemstack.m_41720_(); -- if (item instanceof ArmorItem && ((ArmorItem)item).m_40401_() == ArmorMaterials.GOLD) { + public static boolean isWearingGold(LivingEntity p_34809_) { + for(ItemStack itemstack : p_34809_.getArmorSlots()) { + Item item = itemstack.getItem(); +- if (item instanceof ArmorItem && ((ArmorItem)item).getMaterial() == ArmorMaterials.GOLD) { + if (itemstack.makesPiglinsNeutral(p_34809_)) { return true; } @@ -102,31 +102,31 @@ @@ -704,7 +_,7 @@ } - private static boolean m_34918_(LivingEntity p_34919_) { -- return p_34919_.m_21055_(Items.f_42717_); -+ return p_34919_.m_21093_(is -> is.m_41720_() instanceof net.minecraft.world.item.CrossbowItem); + private static boolean hasCrossbow(LivingEntity p_34919_) { +- return p_34919_.isHolding(Items.CROSSBOW); ++ return p_34919_.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem); } - private static void m_34938_(LivingEntity p_34939_) { + private static void admireGoldItem(LivingEntity p_34939_) { @@ -715,6 +_,12 @@ - return p_35021_.m_6274_().m_21874_(MemoryModuleType.f_26336_); + return p_35021_.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } + // CraftBukkit start - Changes to allow custom payment for bartering + private static boolean isBarterCurrency(ItemStack itemstack, Piglin piglin) { -+ return m_149967_(itemstack) || piglin.allowedBarterItems.contains(itemstack.m_41720_()); ++ return isBarterCurrency(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem()); + } + // CraftBukkit end + - private static boolean m_149967_(ItemStack p_149968_) { - return p_149968_.m_150930_(f_34794_); + private static boolean isBarterCurrency(ItemStack p_149968_) { + return p_149968_.is(BARTERING_ITEM); } @@ -752,7 +_,7 @@ } - private static boolean m_35028_(Piglin p_35029_) { -- return p_35029_.m_21206_().m_41619_() || !m_149965_(p_35029_.m_21206_()); -+ return p_35029_.m_21206_().m_41619_() || !isLovedItem(p_35029_.m_21206_(), p_35029_); // CraftBukkit - Changes to allow custom payment for bartering + private static boolean isNotHoldingLovedItemInOffHand(Piglin p_35029_) { +- return p_35029_.getOffhandItem().isEmpty() || !isLovedItem(p_35029_.getOffhandItem()); ++ return p_35029_.getOffhandItem().isEmpty() || !isLovedItem(p_35029_.getOffhandItem(), p_35029_); // CraftBukkit - Changes to allow custom payment for bartering } - public static boolean m_34806_(EntityType p_34807_) { + public static boolean isZombified(EntityType p_34807_) { 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 f2ee3e92..401d417e 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 @@ @@ -13,7 +_,7 @@ } - protected boolean m_6114_(ServerLevel p_35255_, E p_35256_) { -- return !p_35256_.m_21206_().m_41619_() && !p_35256_.m_21206_().m_150930_(Items.f_42740_); -+ return !p_35256_.m_21206_().m_41619_() && !p_35256_.m_21206_().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK); + protected boolean checkExtraStartConditions(ServerLevel p_35255_, E p_35256_) { +- return !p_35256_.getOffhandItem().isEmpty() && !p_35256_.getOffhandItem().is(Items.SHIELD); ++ return !p_35256_.getOffhandItem().isEmpty() && !p_35256_.getOffhandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK); } - protected void m_6735_(ServerLevel p_35258_, E p_35259_, long p_35260_) { + protected void start(ServerLevel p_35258_, E p_35259_, long p_35260_) { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch index d91c374b..6e1d9a7d 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/AbstractVillager.java @@ -43,7 +_,16 @@ - private Player f_35263_; + private Player tradingPlayer; @Nullable - protected MerchantOffers f_35261_; -- private final SimpleContainer f_35264_ = new SimpleContainer(8); -+ private final SimpleContainer f_35264_ = new SimpleContainer(8, (org.bukkit.craftbukkit.v1_18_R2.entity.CraftAbstractVillager) this.getBukkitEntity()); // // CraftBukkit add argument + protected MerchantOffers offers; +- private final SimpleContainer inventory = new SimpleContainer(8); ++ private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.v1_18_R2.entity.CraftAbstractVillager) this.getBukkitEntity()); // // CraftBukkit add argument + + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMerchant craftMerchant; @@ -22,17 +22,17 @@ } @Nullable -- public Entity m_5489_(ServerLevel p_35295_) { +- public Entity changeDimension(ServerLevel p_35295_) { + public Entity changeDimension(ServerLevel p_35295_, net.minecraftforge.common.util.ITeleporter teleporter) { - this.m_7996_(); -- return super.m_5489_(p_35295_); + this.stopTrading(); +- return super.changeDimension(p_35295_); + return super.changeDimension(p_35295_, teleporter); } - protected void m_7996_() { + protected void stopTrading() { @@ -219,7 +_,16 @@ VillagerTrades.ItemListing villagertrades$itemlisting = p_35279_[integer]; - MerchantOffer merchantoffer = villagertrades$itemlisting.m_5670_(this, this.f_19796_); + MerchantOffer merchantoffer = villagertrades$itemlisting.getOffer(this, this.random); if (merchantoffer != null) { - p_35278_.add(merchantoffer); + // CraftBukkit start 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 e9c4bbf4..586d3f0b 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -4,10 +4,10 @@ if (cat == null) { return 0; } else { -+ cat.m_20035_(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(cat, p_35335_, p_35334_.m_123341_(), p_35334_.m_123342_(), p_35334_.m_123343_(), null, MobSpawnType.NATURAL) == -1) return 0; - cat.m_6518_(p_35335_, p_35335_.m_6436_(p_35334_), MobSpawnType.NATURAL, (SpawnGroupData)null, (CompoundTag)null); -- cat.m_20035_(p_35334_, 0.0F, 0.0F); - p_35335_.m_47205_(cat); ++ cat.moveTo(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat ++ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(cat, p_35335_, p_35334_.getX(), p_35334_.getY(), p_35334_.getZ(), null, MobSpawnType.NATURAL) == -1) return 0; + cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), MobSpawnType.NATURAL, (SpawnGroupData)null, (CompoundTag)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/ClientSideMerchant.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/ClientSideMerchant.java.patch index 561db3b2..3163caa8 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/ClientSideMerchant.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/ClientSideMerchant.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/npc/ClientSideMerchant.java +++ b/net/minecraft/world/entity/npc/ClientSideMerchant.java @@ -44,6 +_,11 @@ - return this.f_35340_.m_183503_().f_46443_; + return this.source.getLevel().isClientSide; } + @Override @@ -9,6 +9,6 @@ + return null; + } + - public int m_7809_() { - return this.f_35342_; + public int getVillagerXp() { + return this.xp; } 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 c65b1c93..61bcded8 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,66 +1,66 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java @@ -203,6 +_,17 @@ - return this.f_35366_; + return this.assignProfessionWhenSpawned; } + // Spigot Start + @Override + public void inactiveTick() { + // SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :( -+ if (f_19853_.spigotConfig.tickInactiveVillagers && this.m_6142_()) { -+ this.m_8024_(); ++ if (level.spigotConfig.tickInactiveVillagers && this.isEffectiveAi()) { ++ this.customServerAiStep(); + } + super.inactiveTick(); + } + // Spigot End + - protected void m_8024_() { - this.f_19853_.m_46473_().m_6180_("villagerBrain"); - this.m_6274_().m_21865_((ServerLevel)this.f_19853_, this); + protected void customServerAiStep() { + this.level.getProfiler().push("villagerBrain"); + this.getBrain().tick((ServerLevel)this.level, this); @@ -219,7 +_,7 @@ - this.f_35374_ = false; + this.increaseProfessionLevelOnUpdate = false; } -- this.m_7292_(new MobEffectInstance(MobEffects.f_19605_, 200, 0)); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19605_, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit +- this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 0)); ++ this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit } } @@ -254,7 +_,7 @@ - public InteractionResult m_6071_(Player p_35472_, InteractionHand p_35473_) { - ItemStack itemstack = p_35472_.m_21120_(p_35473_); -- if (!itemstack.m_150930_(Items.f_42601_) && this.m_6084_() && !this.m_35306_() && !this.m_5803_()) { -+ if (itemstack.m_41720_() != Items.f_42601_ && this.m_6084_() && !this.m_35306_() && !this.m_5803_() && !p_35472_.m_36341_()) { - if (this.m_6162_()) { - this.m_35518_(); - return InteractionResult.m_19078_(this.f_19853_.f_46443_); + public InteractionResult mobInteract(Player p_35472_, InteractionHand p_35473_) { + ItemStack itemstack = p_35472_.getItemInHand(p_35473_); +- if (!itemstack.is(Items.VILLAGER_SPAWN_EGG) && this.isAlive() && !this.isTrading() && !this.isSleeping()) { ++ if (itemstack.getItem() != Items.VILLAGER_SPAWN_EGG && this.isAlive() && !this.isTrading() && !this.isSleeping() && !p_35472_.isSecondaryUseActive()) { + if (this.isBaby()) { + this.setUnhappy(); + return InteractionResult.sidedSuccess(this.level.isClientSide); @@ -330,7 +_,13 @@ - this.m_35523_(); + this.updateDemand(); - for(MerchantOffer merchantoffer : this.m_6616_()) { -- merchantoffer.m_45372_(); + for(MerchantOffer merchantoffer : this.getOffers()) { +- merchantoffer.resetUses(); + // CraftBukkit start + org.bukkit.event.entity.VillagerReplenishTradeEvent event = new org.bukkit.event.entity.VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantoffer.asBukkit()); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ merchantoffer.m_45372_(); ++ merchantoffer.resetUses(); + } + // CraftBukkit end } - this.f_35363_ = this.f_19853_.m_46467_(); + this.lastRestockGameTime = this.level.getGameTime(); @@ -375,7 +_,13 @@ - int i = 2 - this.f_35364_; + int i = 2 - this.numberOfRestocksToday; if (i > 0) { - for(MerchantOffer merchantoffer : this.m_6616_()) { -- merchantoffer.m_45372_(); + for(MerchantOffer merchantoffer : this.getOffers()) { +- merchantoffer.resetUses(); + // CraftBukkit start + org.bukkit.event.entity.VillagerReplenishTradeEvent event = new org.bukkit.event.entity.VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantoffer.asBukkit()); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ merchantoffer.m_45372_(); ++ merchantoffer.resetUses(); + } + // CraftBukkit end } @@ -69,65 +69,65 @@ @@ -548,7 +_,7 @@ } - public void m_6667_(DamageSource p_35419_) { -- f_201976_.info("Villager {} died, message: '{}'", this, p_35419_.m_6157_(this).getString()); -+ if (org.spigotmc.SpigotConfig.logVillagerDeaths) f_201976_.info("Villager {} died, message: '{}'", this, p_35419_.m_6157_(this).getString()); // Spigot - Entity entity = p_35419_.m_7639_(); + public void die(DamageSource p_35419_) { +- LOGGER.info("Villager {} died, message: '{}'", this, p_35419_.getLocalizedDeathMessage(this).getString()); ++ if (org.spigotmc.SpigotConfig.logVillagerDeaths) LOGGER.info("Villager {} died, message: '{}'", this, p_35419_.getLocalizedDeathMessage(this).getString()); // Spigot + Entity entity = p_35419_.getEntity(); if (entity != null) { - this.m_35420_(entity); + this.tellWitnessesThatIWasMurdered(entity); @@ -658,7 +_,8 @@ } - protected Component m_5677_() { -- return new TranslatableComponent(this.m_6095_().m_20675_() + "." + Registry.f_122869_.m_7981_(this.m_7141_().m_35571_()).m_135815_()); -+ net.minecraft.resources.ResourceLocation profName = this.m_7141_().m_35571_().getRegistryName(); -+ return new TranslatableComponent(this.m_6095_().m_20675_() + '.' + (!"minecraft".equals(profName.m_135827_()) ? profName.m_135827_() + '.' : "") + profName.m_135815_()); + protected Component getTypeName() { +- return new TranslatableComponent(this.getType().getDescriptionId() + "." + Registry.VILLAGER_PROFESSION.getKey(this.getVillagerData().getProfession()).getPath()); ++ net.minecraft.resources.ResourceLocation profName = this.getVillagerData().getProfession().getRegistryName(); ++ return new TranslatableComponent(this.getType().getDescriptionId() + '.' + (!"minecraft".equals(profName.getNamespace()) ? profName.getNamespace() + '.' : "") + profName.getPath()); } - public void m_7822_(byte p_35391_) { + public void handleEntityEvent(byte p_35391_) { @@ -710,7 +_,7 @@ } - public void m_8038_(ServerLevel p_35409_, LightningBolt p_35410_) { -- if (p_35409_.m_46791_() != Difficulty.PEACEFUL) { -+ if (p_35409_.m_46791_() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20495_, (timer) -> {})) { - f_201976_.info("Villager {} was struck by lightning {}.", this, p_35410_); - Witch witch = EntityType.f_20495_.m_20615_(p_35409_); - witch.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); + 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_); + witch.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); @@ -722,7 +_,14 @@ } - witch.m_21530_(); + witch.setPersistenceRequired(); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, witch); + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityTransformEvent(this, witch, org.bukkit.event.entity.EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { + return; + } + p_35409_.prepareEntity(witch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); //Magma - add spawn reason - p_35409_.m_47205_(witch); + p_35409_.addFreshEntityWithPassengers(witch); + // CraftBukkit end - this.m_35524_(); - this.m_146870_(); + this.releaseAllPois(); + this.discard(); } else { @@ -740,6 +_,13 @@ return; } + // CraftBukkit start -+ ItemStack remaining = new SimpleContainer(simplecontainer).m_19173_(itemstack); -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_35467_, remaining.m_41613_(), false).isCancelled()) { ++ ItemStack remaining = new SimpleContainer(simplecontainer).addItem(itemstack); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, p_35467_, remaining.getCount(), false).isCancelled()) { + return; + } + // CraftBukkit end + - this.m_21053_(p_35467_); - this.m_7938_(p_35467_, itemstack.m_41613_()); - ItemStack itemstack1 = simplecontainer.m_19173_(itemstack); + this.onItemPickup(p_35467_); + this.take(p_35467_, itemstack.getCount()); + ItemStack itemstack1 = simplecontainer.addItem(itemstack); @@ -843,6 +_,7 @@ - IronGolem irongolem = EntityType.f_20460_.m_20655_(p_35491_, (CompoundTag)null, (Component)null, (Player)null, blockpos1, MobSpawnType.MOB_SUMMONED, false, false); + IronGolem irongolem = EntityType.IRON_GOLEM.create(p_35491_, (CompoundTag)null, (Component)null, (Player)null, blockpos1, MobSpawnType.MOB_SUMMONED, false, false); if (irongolem != null) { - if (irongolem.m_5545_(p_35491_, MobSpawnType.MOB_SUMMONED) && irongolem.m_6914_(p_35491_)) { + if (irongolem.checkSpawnRules(p_35491_, MobSpawnType.MOB_SUMMONED) && irongolem.checkSpawnObstruction(p_35491_)) { + p_35491_.prepareEntity(irongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); //Magma - add spawn reason - p_35491_.m_47205_(irongolem); + p_35491_.addFreshEntityWithPassengers(irongolem); return irongolem; } diff --git a/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch index 0346b5d9..804229fa 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/VillagerProfession.java.patch @@ -6,6 +6,6 @@ -public class VillagerProfession { +public class VillagerProfession extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final VillagerProfession f_35585_ = m_35612_("none", PoiType.f_27331_, (SoundEvent)null); - public static final VillagerProfession f_35586_ = m_35612_("armorer", PoiType.f_27332_, SoundEvents.f_12510_); - public static final VillagerProfession f_35587_ = m_35612_("butcher", PoiType.f_27333_, SoundEvents.f_12564_); + public static final VillagerProfession NONE = register("none", PoiType.UNEMPLOYED, (SoundEvent)null); + public static final VillagerProfession ARMORER = register("armorer", PoiType.ARMORER, SoundEvents.VILLAGER_WORK_ARMORER); + public static final VillagerProfession BUTCHER = register("butcher", PoiType.BUTCHER, SoundEvents.VILLAGER_WORK_BUTCHER); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/WanderingTrader.java.patch index 9a8108e8..dd208e0c 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/WanderingTrader.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/WanderingTrader.java.patch @@ -4,13 +4,13 @@ public WanderingTrader(EntityType p_35843_, Level p_35844_) { super(p_35843_, p_35844_); -+ this.m_35891_(48000); // CraftBukkit - set default from MobSpawnerTrader ++ this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader } - protected void m_8099_() { + protected void registerGoals() { @@ -120,7 +_,16 @@ VillagerTrades.ItemListing villagertrades$itemlisting = avillagertrades$itemlisting1[i]; - MerchantOffer merchantoffer = villagertrades$itemlisting.m_5670_(this, this.f_19796_); + MerchantOffer merchantoffer = villagertrades$itemlisting.getOffer(this, this.random); if (merchantoffer != null) { - merchantoffers.add(merchantoffer); + // CraftBukkit start diff --git a/patches/minecraft/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch index 49b89ceb..20e0d124 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch @@ -4,24 +4,24 @@ return false; } -+ EntityType.f_20494_.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); //Magma - WanderingTrader wanderingtrader = EntityType.f_20494_.m_20600_(p_35916_, (CompoundTag)null, (Component)null, (Player)null, blockpos2, MobSpawnType.EVENT, false, false); ++ EntityType.WANDERING_TRADER.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); //Magma + WanderingTrader wanderingtrader = EntityType.WANDERING_TRADER.spawn(p_35916_, (CompoundTag)null, (Component)null, (Player)null, blockpos2, MobSpawnType.EVENT, false, false); if (wanderingtrader != null) { for(int j = 0; j < 2; ++j) { @@ -111,7 +_,7 @@ } - this.f_35909_.m_8115_(wanderingtrader.m_142081_()); -- wanderingtrader.m_35891_(48000); + this.serverLevelData.setWanderingTraderId(wanderingtrader.getUUID()); +- wanderingtrader.setDespawnDelay(48000); + // wanderingtrader.setDespawnDelay(48000); // CraftBukkit - moved to WanderingTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent - wanderingtrader.m_35883_(blockpos1); - wanderingtrader.m_21446_(blockpos1, 16); + wanderingtrader.setWanderTarget(blockpos1); + wanderingtrader.restrictTo(blockpos1, 16); return true; @@ -125,6 +_,7 @@ - private void m_35917_(ServerLevel p_35918_, WanderingTrader p_35919_, int p_35920_) { - BlockPos blockpos = this.m_35928_(p_35918_, p_35919_.m_142538_(), p_35920_); + private void tryToSpawnLlamaFor(ServerLevel p_35918_, WanderingTrader p_35919_, int p_35920_) { + BlockPos blockpos = this.findSpawnPositionNear(p_35918_, p_35919_.blockPosition(), p_35920_); if (blockpos != null) { -+ EntityType.f_20488_.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); //Magma - TraderLlama traderllama = EntityType.f_20488_.m_20600_(p_35918_, (CompoundTag)null, (Component)null, (Player)null, blockpos, MobSpawnType.EVENT, false, false); ++ EntityType.TRADER_LLAMA.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); //Magma + TraderLlama traderllama = EntityType.TRADER_LLAMA.spawn(p_35918_, (CompoundTag)null, (Component)null, (Player)null, blockpos, MobSpawnType.EVENT, false, false); if (traderllama != null) { - traderllama.m_21463_(p_35919_, true); + traderllama.setLeashedTo(p_35919_, true); 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 41a7ab14..1fac2a88 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java @@ -40,6 +_,54 @@ - public final Player f_35978_; - private int f_35981_; + public final Player player; + private int timesChanged; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public List getContents() { -+ List combined = new java.util.ArrayList(f_35974_.size() + f_35975_.size() + f_35976_.size()); -+ for (List sub : this.f_35979_) { ++ List combined = new java.util.ArrayList(items.size() + armor.size() + offhand.size()); ++ for (List sub : this.compartments) { + combined.addAll(sub); + } + @@ -18,7 +18,7 @@ + } + + public List getArmorContents() { -+ return this.f_35975_; ++ return this.armor; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -34,11 +34,11 @@ + } + + public org.bukkit.inventory.InventoryHolder getOwner() { -+ return this.f_35978_.getBukkitEntity(); ++ return this.player.getBukkitEntity(); + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -48,65 +48,65 @@ + + @Override + public org.bukkit.Location getLocation() { -+ return f_35978_.getBukkitEntity().getLocation(); ++ return player.getBukkitEntity().getLocation(); + } + // CraftBukkit end + public Inventory(Player p_35983_) { - this.f_35978_ = p_35983_; + this.player = p_35983_; } @@ -56,6 +_,26 @@ - return !p_36015_.m_41619_() && ItemStack.m_150942_(p_36015_, p_36016_) && p_36015_.m_41753_() && p_36015_.m_41613_() < p_36015_.m_41741_() && p_36015_.m_41613_() < this.m_6893_(); + return !p_36015_.isEmpty() && ItemStack.isSameItemSameTags(p_36015_, p_36016_) && p_36015_.isStackable() && p_36015_.getCount() < p_36015_.getMaxStackSize() && p_36015_.getCount() < this.getMaxStackSize(); } + // CraftBukkit start - Watch method above! :D + public int canHold(ItemStack itemstack) { -+ int remains = itemstack.m_41613_(); -+ for (int i = 0; i < this.f_35974_.size(); ++i) { -+ ItemStack itemstack1 = this.m_8020_(i); -+ if (itemstack1.m_41619_()) return itemstack.m_41613_(); -+ if (this.m_36014_(itemstack1, itemstack)) { -+ remains -= (itemstack1.m_41741_() < this.m_6893_() ? itemstack1.m_41741_() : this.m_6893_()) - itemstack1.m_41613_(); ++ int remains = itemstack.getCount(); ++ for (int i = 0; i < this.items.size(); ++i) { ++ ItemStack itemstack1 = this.getItem(i); ++ if (itemstack1.isEmpty()) return itemstack.getCount(); ++ if (this.hasRemainingSpaceForItem(itemstack1, itemstack)) { ++ remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount(); + } -+ if (remains <= 0) return itemstack.m_41613_(); ++ if (remains <= 0) return itemstack.getCount(); + } -+ ItemStack offhandItemStack = this.m_8020_(this.f_35974_.size() + this.f_35975_.size()); -+ if (this.m_36014_(offhandItemStack, itemstack)) { -+ remains -= (offhandItemStack.m_41741_() < this.m_6893_() ? offhandItemStack.m_41741_() : this.m_6893_()) - offhandItemStack.m_41613_(); ++ ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size()); ++ if (this.hasRemainingSpaceForItem(offhandItemStack, itemstack)) { ++ remains -= (offhandItemStack.getMaxStackSize() < this.getMaxStackSize() ? offhandItemStack.getMaxStackSize() : this.getMaxStackSize()) - offhandItemStack.getCount(); + } -+ if (remains <= 0) return itemstack.m_41613_(); -+ return itemstack.m_41613_() - remains; ++ if (remains <= 0) return itemstack.getCount(); ++ return itemstack.getCount() - remains; + } + // CraftBukkit end + - public int m_36062_() { - for(int i = 0; i < this.f_35974_.size(); ++i) { - if (this.f_35974_.get(i).m_41619_()) { + public int getFreeSlot() { + for(int i = 0; i < this.items.size(); ++i) { + if (this.items.get(i).isEmpty()) { @@ -178,7 +_,8 @@ - int i = p_36049_.m_41613_(); - ItemStack itemstack = this.m_8020_(p_36048_); - if (itemstack.m_41619_()) { + int i = p_36049_.getCount(); + ItemStack itemstack = this.getItem(p_36048_); + if (itemstack.isEmpty()) { - itemstack = new ItemStack(item, 0); -+ itemstack = p_36049_.m_41777_(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up. -+ itemstack.m_41764_(0); - if (p_36049_.m_41782_()) { - itemstack.m_41751_(p_36049_.m_41783_().m_6426_()); ++ itemstack = p_36049_.copy(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up. ++ itemstack.setCount(0); + if (p_36049_.hasTag()) { + itemstack.setTag(p_36049_.getTag().copy()); } @@ -229,7 +_,7 @@ } } } - -+ f_35975_.forEach(e -> e.onArmorTick(f_35978_.f_19853_, f_35978_)); ++ armor.forEach(e -> e.onArmorTick(player.level, player)); } - public boolean m_36054_(ItemStack p_36055_) { + public boolean add(ItemStack p_36055_) { @@ -278,6 +_,8 @@ } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.m_127521_(throwable, "Adding item to inventory"); - CrashReportCategory crashreportcategory = crashreport.m_127514_("Item being added"); -+ crashreportcategory.m_128165_("Registry Name", () -> String.valueOf(p_36042_.m_41720_().getRegistryName())); -+ crashreportcategory.m_128165_("Item Class", () -> p_36042_.m_41720_().getClass().getName()); - crashreportcategory.m_128159_("Item ID", Item.m_41393_(p_36042_.m_41720_())); - crashreportcategory.m_128159_("Item data", p_36042_.m_41773_()); - crashreportcategory.m_128165_("Item name", () -> { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); ++ crashreportcategory.setDetail("Registry Name", () -> String.valueOf(p_36042_.getItem().getRegistryName())); ++ crashreportcategory.setDetail("Item Class", () -> p_36042_.getItem().getClass().getName()); + crashreportcategory.setDetail("Item ID", Item.getId(p_36042_.getItem())); + crashreportcategory.setDetail("Item data", p_36042_.getDamageValue()); + crashreportcategory.setDetail("Item name", () -> { 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 0a5e3289..0b24740f 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -7,26 +7,26 @@ -public abstract class Player extends LivingEntity { +public abstract class Player extends LivingEntity implements net.minecraftforge.common.extensions.IForgePlayer { + public static final String PERSISTED_NBT_TAG = "PlayerPersisted"; - public static final String f_150081_ = "OfflinePlayer:"; - public static final int f_150082_ = 16; - public static final int f_150083_ = 20; + public static final String UUID_PREFIX_OFFLINE_PLAYER = "OfflinePlayer:"; + public static final int MAX_NAME_LENGTH = 16; + public static final int MAX_HEALTH = 20; @@ -133,10 +_,10 @@ - protected static final EntityDataAccessor f_36092_ = SynchedEntityData.m_135353_(Player.class, EntityDataSerializers.f_135042_); - private long f_36109_; - private final Inventory f_36093_ = new Inventory(this); -- protected PlayerEnderChestContainer f_36094_ = new PlayerEnderChestContainer(); -+ protected PlayerEnderChestContainer f_36094_ = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor - public final InventoryMenu f_36095_; - public AbstractContainerMenu f_36096_; -- protected FoodData f_36097_ = new FoodData(); -+ protected FoodData f_36097_ = new FoodData(this); // CraftBukkit - add "this" to constructor - protected int f_36098_; - public float f_36099_; - public float f_36100_; + protected static final EntityDataAccessor DATA_SHOULDER_RIGHT = SynchedEntityData.defineId(Player.class, EntityDataSerializers.COMPOUND_TAG); + private long timeEntitySatOnShoulder; + private final Inventory inventory = new Inventory(this); +- protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(); ++ protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor + public final InventoryMenu inventoryMenu; + public AbstractContainerMenu containerMenu; +- protected FoodData foodData = new FoodData(); ++ protected FoodData foodData = new FoodData(this); // CraftBukkit - add "this" to constructor + protected int jumpTriggerTime; + public float oBob; + public float bob; @@ -162,6 +_,19 @@ - private final ItemCooldowns f_36087_ = this.m_7478_(); + private final ItemCooldowns cooldowns = this.createItemCooldowns(); @Nullable - public FishingHook f_36083_; + public FishingHook fishing; + private final java.util.Collection prefixes = new java.util.LinkedList<>(); + private final java.util.Collection suffixes = new java.util.LinkedList<>(); + @Nullable private Pose forcedPose; @@ -42,104 +42,104 @@ + // CraftBukkit end public Player(Level p_36114_, BlockPos p_36115_, float p_36116_, GameProfile p_36117_) { - super(EntityType.f_20532_, p_36114_); + super(EntityType.PLAYER, p_36114_); @@ -187,7 +_,14 @@ } - public static AttributeSupplier.Builder m_36340_() { -- return LivingEntity.m_21183_().m_22268_(Attributes.f_22281_, 1.0D).m_22268_(Attributes.f_22279_, (double)0.1F).m_22266_(Attributes.f_22283_).m_22266_(Attributes.f_22286_); -+ return LivingEntity.m_21183_() -+ .m_22268_(Attributes.f_22281_, 1.0D) -+ .m_22268_(Attributes.f_22279_, (double) 0.1F) -+ .m_22266_(Attributes.f_22283_) -+ .m_22266_(Attributes.f_22286_) -+ .m_22266_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()) -+ .m_22266_(Attributes.f_22282_) -+ .m_22266_(net.minecraftforge.common.ForgeMod.ATTACK_RANGE.get()); //Magma - add missing ATTACK_RANGE attribute + public static AttributeSupplier.Builder createAttributes() { +- return LivingEntity.createLivingAttributes().add(Attributes.ATTACK_DAMAGE, 1.0D).add(Attributes.MOVEMENT_SPEED, (double)0.1F).add(Attributes.ATTACK_SPEED).add(Attributes.LUCK); ++ return LivingEntity.createLivingAttributes() ++ .add(Attributes.ATTACK_DAMAGE, 1.0D) ++ .add(Attributes.MOVEMENT_SPEED, (double) 0.1F) ++ .add(Attributes.ATTACK_SPEED) ++ .add(Attributes.LUCK) ++ .add(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()) ++ .add(Attributes.ATTACK_KNOCKBACK) ++ .add(net.minecraftforge.common.ForgeMod.ATTACK_RANGE.get()); //Magma - add missing ATTACK_RANGE attribute } - protected void m_8097_() { + protected void defineSynchedData() { @@ -201,6 +_,7 @@ } - public void m_8119_() { + public void tick() { + net.minecraftforge.event.ForgeEventFactory.onPlayerPreTick(this); - this.f_19794_ = this.m_5833_(); - if (this.m_5833_()) { - this.f_19861_ = false; + this.noPhysics = this.isSpectator(); + if (this.isSpectator()) { + this.onGround = false; @@ -216,7 +_,7 @@ - this.f_36110_ = 100; + this.sleepCounter = 100; } -- if (!this.f_19853_.f_46443_ && this.f_19853_.m_46461_()) { -+ if (!this.f_19853_.f_46443_ && !net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, m_21257_())) { - this.m_6145_(false, true); +- if (!this.level.isClientSide && this.level.isDay()) { ++ if (!this.level.isClientSide && !net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, getSleepingPos())) { + this.stopSleepInBed(false, true); } - } else if (this.f_36110_ > 0) { + } else if (this.sleepCounter > 0) { @@ -271,6 +_,7 @@ - this.m_36372_(); - this.f_36087_.m_41518_(); - this.m_7594_(); + this.turtleHelmetTick(); + this.cooldowns.tick(); + this.updatePlayerPose(); + net.minecraftforge.event.ForgeEventFactory.onPlayerPostTick(this); } - public boolean m_36341_() { + public boolean isSecondaryUseActive() { @@ -293,7 +_,7 @@ - private void m_36372_() { - ItemStack itemstack = this.m_6844_(EquipmentSlot.HEAD); - if (itemstack.m_150930_(Items.f_42354_) && !this.m_204029_(FluidTags.f_13131_)) { -- this.m_7292_(new MobEffectInstance(MobEffects.f_19608_, 200, 0, false, false, true)); -+ this.addEffect(new MobEffectInstance(MobEffects.f_19608_, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit + private void turtleHelmetTick() { + ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); + if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(FluidTags.WATER)) { +- this.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 200, 0, false, false, true)); ++ this.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit } } @@ -346,6 +_,10 @@ } - protected void m_7594_() { + protected void updatePlayerPose() { + if(forcedPose != null) { -+ this.m_20124_(forcedPose); ++ this.setPose(forcedPose); + return; + } - if (this.m_20175_(Pose.SWIMMING)) { + if (this.canEnterPose(Pose.SWIMMING)) { Pose pose; - if (this.m_21255_()) { + if (this.isFallFlying()) { @@ -469,6 +_,8 @@ - if (this.f_19853_.m_46791_() == Difficulty.PEACEFUL && this.f_19853_.m_46469_().m_46207_(GameRules.f_46139_)) { - if (this.m_21223_() < this.m_21233_() && this.f_19797_ % 20 == 0) { + if (this.level.getDifficulty() == Difficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { + // CraftBukkit - added regain reason of "REGEN" for filtering purposes. + this.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); - this.m_5634_(1.0F); + this.heal(1.0F); } @@ -569,6 +_,7 @@ } - public void m_6667_(DamageSource p_36152_) { + public void die(DamageSource p_36152_) { + if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_36152_)) return; - super.m_6667_(p_36152_); - this.m_20090_(); - if (!this.m_5833_()) { + super.die(p_36152_); + this.reapplyPosition(); + if (!this.isSpectator()) { @@ -625,11 +_,15 @@ @Nullable - public ItemEntity m_36176_(ItemStack p_36177_, boolean p_36178_) { -- return this.m_7197_(p_36177_, false, p_36178_); + public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { +- return this.drop(p_36177_, false, p_36178_); + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, p_36177_, p_36178_); } + private boolean drop_callEvent = true; @Nullable - public ItemEntity m_7197_(ItemStack p_36179_, boolean p_36180_, boolean p_36181_) { + public ItemEntity drop(ItemStack p_36179_, boolean p_36180_, boolean p_36181_) { + // CraftBukkit start - SPIGOT-2942: Add boolean to call event + //return drop(p_36179_, p_36180_, p_36181_, true); + // CraftBukkit end - if (p_36179_.m_41619_()) { + if (p_36179_.isEmpty()) { return null; } else { @@ -659,11 +_,48 @@ - itementity.m_20334_((double)(-f3 * f2 * 0.3F) + Math.cos((double)f5) * (double)f6, (double)(-f8 * 0.3F + 0.1F + (this.f_19796_.nextFloat() - this.f_19796_.nextFloat()) * 0.1F), (double)(f4 * f2 * 0.3F) + Math.sin((double)f5) * (double)f6); + itementity.setDeltaMovement((double)(-f3 * f2 * 0.3F) + Math.cos((double)f5) * (double)f6, (double)(-f8 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double)(f4 * f2 * 0.3F) + Math.sin((double)f5) * (double)f6); } + // CraftBukkit start - fire PlayerDropItemEvent @@ -150,7 +150,7 @@ + org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.getBukkitEntity(); + org.bukkit.entity.Item drop = (org.bukkit.entity.Item) itementity.getBukkitEntity(); + org.bukkit.event.player.PlayerDropItemEvent event = new org.bukkit.event.player.PlayerDropItemEvent(player, drop); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); + if (p_36180_ && (cur == null || cur.getAmount() == 0)) { @@ -175,18 +175,18 @@ + @Nullable + public ItemEntity drop(ItemStack p_36179_, boolean p_36180_, boolean p_36181_, boolean callEvent) { + drop_callEvent = callEvent; -+ return m_7197_(p_36179_, p_36180_, p_36181_); ++ return drop(p_36179_, p_36180_, p_36181_); + } + + @Deprecated //Use location sensitive version below - public float m_36281_(BlockState p_36282_) { + public float getDestroySpeed(BlockState p_36282_) { + return getDigSpeed(p_36282_, null); + } + + public float getDigSpeed(BlockState p_36282_, @Nullable BlockPos pos) { - float f = this.f_36093_.m_36020_(p_36282_); + float f = this.inventory.getDestroySpeed(p_36282_); if (f > 1.0F) { - int i = EnchantmentHelper.m_44926_(this); + int i = EnchantmentHelper.getBlockEfficiency(this); @@ -705,11 +_,12 @@ f /= 5.0F; } @@ -195,46 +195,46 @@ return f; } - public boolean m_36298_(BlockState p_36299_) { -- return !p_36299_.m_60834_() || this.f_36093_.m_36056_().m_41735_(p_36299_); -+ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_36299_, !p_36299_.m_60834_() || this.f_36093_.m_36056_().m_41735_(p_36299_)); + public boolean hasCorrectToolForDrops(BlockState p_36299_) { +- return !p_36299_.requiresCorrectToolForDrops() || this.inventory.getSelected().isCorrectToolForDrops(p_36299_); ++ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_36299_, !p_36299_.requiresCorrectToolForDrops() || this.inventory.getSelected().isCorrectToolForDrops(p_36299_)); } - public void m_7378_(CompoundTag p_36215_) { + public void readAdditionalSaveData(CompoundTag p_36215_) { @@ -786,6 +_,7 @@ } - public boolean m_6469_(DamageSource p_36154_, float p_36155_) { + public boolean hurt(DamageSource p_36154_, float p_36155_) { + if (!net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_36154_, p_36155_)) return false; - if (this.m_6673_(p_36154_)) { + if (this.isInvulnerableTo(p_36154_)) { return false; - } else if (this.f_36077_.f_35934_ && !p_36154_.m_19378_()) { + } else if (this.abilities.invulnerable && !p_36154_.isBypassInvul()) { @@ -796,7 +_,7 @@ return false; } else { - if (!this.f_19853_.f_46443_) { -- this.m_36328_(); + if (!this.level.isClientSide) { +- this.removeEntitiesOnShoulder(); + // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down } - if (p_36154_.m_7986_()) { + if (p_36154_.scalesWithDifficulty()) { @@ -813,14 +_,28 @@ } } -- return p_36155_ == 0.0F ? false : super.m_6469_(p_36154_, p_36155_); +- return p_36155_ == 0.0F ? false : super.hurt(p_36154_, p_36155_); + // Magma: move check down because of mixins + // CraftBukkit - f = 0.0f -> return false -+ if (p_36154_.m_7986_() && this.f_19853_.m_46791_() == Difficulty.PEACEFUL && p_36155_ == 0.0F) { ++ if (p_36154_.scalesWithDifficulty() && this.level.getDifficulty() == Difficulty.PEACEFUL && p_36155_ == 0.0F) { + return false; + } + // Magma end + + // CraftBukkit start - Don't filter out 0 damage + -+ boolean damaged = super.m_6469_(p_36154_, p_36155_); ++ boolean damaged = super.hurt(p_36154_, p_36155_); + if (damaged) { -+ this.m_36328_(); ++ this.removeEntitiesOnShoulder(); + } + return damaged; + // CraftBukkit end @@ -242,19 +242,19 @@ } } - protected void m_6728_(LivingEntity p_36295_) { - super.m_6728_(p_36295_); -- if (p_36295_.m_21205_().m_41720_() instanceof AxeItem) { -+ if (p_36295_.m_21205_().canDisableShield(this.f_20935_, this, p_36295_)) { - this.m_36384_(true); + protected void blockUsingShield(LivingEntity p_36295_) { + super.blockUsingShield(p_36295_); +- if (p_36295_.getMainHandItem().getItem() instanceof AxeItem) { ++ if (p_36295_.getMainHandItem().canDisableShield(this.useItem, this, p_36295_)) { + this.disableShield(true); } @@ -831,13 +_,31 @@ } - public boolean m_7099_(Player p_36169_) { -- Team team = this.m_5647_(); -- Team team1 = p_36169_.m_5647_(); + public boolean canHarmPlayer(Player p_36169_) { +- Team team = this.getTeam(); +- Team team1 = p_36169_.getTeam(); - if (team == null) { - return true; +// Team team = this.getTeam(); @@ -269,11 +269,11 @@ + return true; + } } else { -- return !team.m_83536_(team1) ? true : team.m_6260_(); +- return !team.isAlliedTo(team1) ? true : team.isAllowFriendlyFire(); - } + // This should never be called, but is implemented anyway -+ org.bukkit.OfflinePlayer thisPlayer = p_36169_.f_19853_.getCraftServer().getOfflinePlayer(p_36169_.m_6302_()); -+ team = p_36169_.f_19853_.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); ++ org.bukkit.OfflinePlayer thisPlayer = p_36169_.level.getCraftServer().getOfflinePlayer(p_36169_.getScoreboardName()); ++ team = p_36169_.level.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); + if (team == null || team.allowFriendlyFire()) { + return true; + } @@ -282,43 +282,43 @@ + if (this instanceof ServerPlayer) { + return !team.hasPlayer(((ServerPlayer) this).getBukkitEntity()); + } -+ return !team.hasPlayer(this.f_19853_.getCraftServer().getOfflinePlayer(this.m_6302_())); ++ return !team.hasPlayer(this.level.getCraftServer().getOfflinePlayer(this.getScoreboardName())); + // CraftBukkit end } - protected void m_6472_(DamageSource p_36251_, float p_36252_) { + protected void hurtArmor(DamageSource p_36251_, float p_36252_) { @@ -849,7 +_,7 @@ } - protected void m_7909_(float p_36383_) { -- if (this.f_20935_.m_150930_(Items.f_42740_)) { -+ if (this.f_20935_.canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { - if (!this.f_19853_.f_46443_) { - this.m_36246_(Stats.f_12982_.m_12902_(this.f_20935_.m_41720_())); + protected void hurtCurrentlyUsedShield(float p_36383_) { +- if (this.useItem.is(Items.SHIELD)) { ++ if (this.useItem.canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { + if (!this.level.isClientSide) { + this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem())); } @@ -859,6 +_,7 @@ - InteractionHand interactionhand = this.m_7655_(); - this.f_20935_.m_41622_(i, this, (p_36149_) -> { - p_36149_.m_21190_(interactionhand); -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.f_20935_, interactionhand); + InteractionHand interactionhand = this.getUsedItemHand(); + this.useItem.hurtAndBreak(i, this, (p_36149_) -> { + p_36149_.broadcastBreakEvent(interactionhand); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.useItem, interactionhand); }); - if (this.f_20935_.m_41619_()) { + if (this.useItem.isEmpty()) { if (interactionhand == InteractionHand.MAIN_HAND) { @@ -877,26 +_,166 @@ - protected void m_6475_(DamageSource p_36312_, float p_36313_) { - if (!this.m_6673_(p_36312_)) { -- p_36313_ = this.m_21161_(p_36312_, p_36313_); -- p_36313_ = this.m_6515_(p_36312_, p_36313_); -- float f2 = Math.max(p_36313_ - this.m_6103_(), 0.0F); -- this.m_7911_(this.m_6103_() - (p_36313_ - f2)); + protected void actuallyHurt(DamageSource p_36312_, float p_36313_) { + if (!this.isInvulnerableTo(p_36312_)) { +- p_36313_ = this.getDamageAfterArmorAbsorb(p_36312_, p_36313_); +- p_36313_ = this.getDamageAfterMagicAbsorb(p_36312_, p_36313_); +- float f2 = Math.max(p_36313_ - this.getAbsorptionAmount(), 0.0F); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - (p_36313_ - f2)); - float f = p_36313_ - f2; - if (f > 0.0F && f < 3.4028235E37F) { -- this.m_36222_(Stats.f_12933_, Math.round(f * 10.0F)); +- this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f * 10.0F)); - } - - if (f2 != 0.0F) { -- this.m_36399_(p_36312_.m_19377_()); +- this.causeFoodExhaustion(p_36312_.getFoodExhaustion()); + // Check if entity is a "human" aka player + final boolean human = this instanceof Player; + final float originalDamage = p_36313_; @@ -337,7 +337,7 @@ + // Cauldron end + + com.google.common.base.Function hardHat = f -> { -+ if (p_36312_.m_146705_() && !Player.this.m_6844_(EquipmentSlot.HEAD).m_41619_()) { ++ if (p_36312_.isDamageHelmet() && !Player.this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { + return -(f - (f * 0.75F)); + } + return -0.0; @@ -345,17 +345,17 @@ + float hardHatModifier = hardHat.apply((double) p_36313_).floatValue(); + p_36313_ += hardHatModifier; + -+ com.google.common.base.Function blocking = f -> -((Player.this.m_21275_(p_36312_)) ? f : 0.0); ++ com.google.common.base.Function blocking = f -> -((Player.this.isDamageSourceBlocked(p_36312_)) ? f : 0.0); + float blockingModifier = blocking.apply((double) p_36313_).floatValue(); + p_36313_ += blockingModifier; + -+ com.google.common.base.Function armor = f -> -(f - Player.this.m_21161_(p_36312_, f.floatValue())); ++ com.google.common.base.Function armor = f -> -(f - Player.this.getDamageAfterArmorAbsorb(p_36312_, f.floatValue())); + float armorModifier = armor.apply((double) p_36313_).floatValue(); + p_36313_ += armorModifier; + + com.google.common.base.Function resistance = f -> { -+ if (!p_36312_.m_19379_() && Player.this.m_21023_(MobEffects.f_19606_) && p_36312_ != DamageSource.f_19317_) { -+ int i = (Player.this.m_21124_(MobEffects.f_19606_).m_19564_() + 1) * 5; ++ if (!p_36312_.isBypassMagic() && Player.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && p_36312_ != DamageSource.OUT_OF_WORLD) { ++ int i = (Player.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; + int j = 25 - i; + float f1 = f.floatValue() * (float) j; + return -(f - (f1 / 25.0F)); @@ -365,16 +365,16 @@ + float resistanceModifier = resistance.apply((double) p_36313_).floatValue(); + p_36313_ += resistanceModifier; + -+ com.google.common.base.Function magic = f -> -(f - Player.this.m_6515_(p_36312_, f.floatValue())); ++ com.google.common.base.Function magic = f -> -(f - Player.this.getDamageAfterMagicAbsorb(p_36312_, f.floatValue())); + float magicModifier = magic.apply((double) p_36313_).floatValue(); + p_36313_ += magicModifier; + -+ com.google.common.base.Function absorption = f -> -(Math.max(f - Math.max(f - Player.this.m_6103_(), 0.0F), 0.0F)); ++ com.google.common.base.Function absorption = f -> -(Math.max(f - Math.max(f - Player.this.getAbsorptionAmount(), 0.0F), 0.0F)); + float absorptionModifier = absorption.apply((double) p_36313_).floatValue(); + + org.bukkit.event.entity.EntityDamageEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleLivingEntityDamageEvent(this, p_36312_, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); -+ if (p_36312_.m_7639_() instanceof Player) { -+ ((Player) p_36312_.m_7639_()).m_36334_(); // Moved from Player in order to make the cooldown reset get called after the damage event is fired ++ if (p_36312_.getEntity() instanceof Player) { ++ ((Player) p_36312_.getEntity()).resetAttackStrengthTicker(); // Moved from Player in order to make the cooldown reset get called after the damage event is fired + } + if (event.isCancelled()) { + cancelDamage = true; @@ -394,43 +394,43 @@ + float f3 = (float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.RESISTANCE); + if (f3 > 0.0F && f3 < 3.4028235E37F) { + if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).m_36222_(Stats.f_12934_, Math.round(f3 * 10.0F)); -+ } else if (p_36312_.m_7639_() instanceof ServerPlayer) { -+ ((ServerPlayer) p_36312_.m_7639_()).m_36222_(Stats.f_12930_, Math.round(f3 * 10.0F)); ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); ++ } else if (p_36312_.getEntity() instanceof ServerPlayer) { ++ ((ServerPlayer) p_36312_.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F)); + } + } + } + + // Apply damage to helmet -+ if (p_36312_.m_146705_() && !this.m_6844_(EquipmentSlot.HEAD).m_41619_()) { -+ this.m_142642_(p_36312_, p_36313_); ++ if (p_36312_.isDamageHelmet() && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { ++ this.hurtHelmet(p_36312_, p_36313_); + } + + // Apply damage to armor -+ if (!p_36312_.m_19376_() && !net.minecraftforge.fml.ModList.get().isLoaded("the_vault")) { //Magma - skip armor damage if the_vault is loaded ++ if (!p_36312_.isBypassArmor() && !net.minecraftforge.fml.ModList.get().isLoaded("the_vault")) { //Magma - skip armor damage if the_vault is loaded + float armorDamage = (float) (event.getDamage() + event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING) + event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.HARD_HAT)); -+ this.m_6472_(p_36312_, armorDamage); ++ this.hurtArmor(p_36312_, armorDamage); + } + + // Apply blocking code // PAIL: steal from above + if (event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING) < 0) { -+ this.f_19853_.m_7605_(this, (byte) 29); // SPIGOT-4635 - shield damage sound -+ this.m_7909_((float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING)); -+ Entity entity = p_36312_.m_7640_(); ++ this.level.broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound ++ this.hurtCurrentlyUsedShield((float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING)); ++ Entity entity = p_36312_.getDirectEntity(); + if (entity instanceof LivingEntity) { -+ this.m_6728_((LivingEntity) entity); ++ this.blockUsingShield((LivingEntity) entity); + } + } + + absorptionModifier = (float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.ABSORPTION); -+ this.m_7911_(Math.max(this.m_6103_() - absorptionModifier, 0.0F)); ++ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; + + if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof Player) { -+ ((Player) this).m_36222_(Stats.f_12933_, Math.round(f2 * 10.0F)); ++ ((Player) this).awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); + } -+ if (f2 > 0.0F && f2 < 3.4028235E37F && p_36312_.m_7639_() instanceof ServerPlayer) { -+ ((ServerPlayer) p_36312_.m_7639_()).m_36222_(Stats.f_12929_, Math.round(f2 * 10.0F)); ++ if (f2 > 0.0F && f2 < 3.4028235E37F && p_36312_.getEntity() instanceof ServerPlayer) { ++ ((ServerPlayer) p_36312_.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); + } + + p_36313_ = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_36312_, p_36313_); @@ -439,24 +439,24 @@ + if (human) { + // PAIL: Be sure to drag all this code from the Player subclass each update. + ((Player) this).setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); -+ ((Player) this).m_36399_(p_36312_.m_19377_()); ++ ((Player) this).causeFoodExhaustion(p_36312_.getFoodExhaustion()); + if (p_36313_ < 3.4028235E37F) { -+ ((Player) this).m_36222_(Stats.f_12931_, Math.round(p_36313_ * 10.0F)); ++ ((Player) this).awardStat(Stats.DAMAGE_TAKEN, Math.round(p_36313_ * 10.0F)); + } + } + // CraftBukkit end - float f1 = this.m_21223_(); -- this.m_21153_(this.m_21223_() - f2); -- this.m_21231_().m_19289_(p_36312_, f1, f2); + float f1 = this.getHealth(); +- this.setHealth(this.getHealth() - f2); +- this.getCombatTracker().recordDamage(p_36312_, f1, f2); - if (f2 < 3.4028235E37F) { -- this.m_36222_(Stats.f_12931_, Math.round(f2 * 10.0F)); -+ this.m_21231_().m_19289_(p_36312_, f1, p_36313_); -+ this.m_21153_(f1 - p_36313_); // Forge: moved to fix MC-121048 +- this.awardStat(Stats.DAMAGE_TAKEN, Math.round(f2 * 10.0F)); ++ this.getCombatTracker().recordDamage(p_36312_, f1, p_36313_); ++ this.setHealth(f1 - p_36313_); // Forge: moved to fix MC-121048 + // CraftBukkit start + if (!human) { -+ this.m_7911_(this.m_6103_() - p_36313_); ++ this.setAbsorptionAmount(this.getAbsorptionAmount() - p_36313_); } -+ this.m_146852_(net.minecraft.world.level.gameevent.GameEvent.f_157808_, p_36312_.m_7639_()); ++ this.gameEvent(net.minecraft.world.level.gameevent.GameEvent.ENTITY_DAMAGED, p_36312_.getEntity()); + damageEntity0 = true; + return; @@ -464,14 +464,14 @@ + // Duplicate triggers if blocking + if (event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING) < 0) { + if (this instanceof ServerPlayer) { -+ CriteriaTriggers.f_10574_.m_35174_((ServerPlayer) this, p_36312_, p_36313_, originalDamage, true); ++ CriteriaTriggers.ENTITY_HURT_PLAYER.trigger((ServerPlayer) this, p_36312_, p_36313_, originalDamage, true); + f2 = (float) -event.getDamage(org.bukkit.event.entity.EntityDamageEvent.DamageModifier.BLOCKING); + if (f2 > 0.0F && f2 < 3.4028235E37F) { -+ ((ServerPlayer) this).m_36222_(Stats.f_12932_, Math.round(originalDamage * 10.0F)); ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F)); + } + } -+ if (p_36312_.m_7639_() instanceof ServerPlayer) { -+ CriteriaTriggers.f_10573_.m_60112_((ServerPlayer) p_36312_.m_7639_(), this, p_36312_, p_36313_, originalDamage, true); ++ if (p_36312_.getEntity() instanceof ServerPlayer) { ++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer) p_36312_.getEntity(), this, p_36312_, p_36313_, originalDamage, true); + } + damageEntity0 = false; + return; @@ -485,73 +485,73 @@ + damageEntity0 = false; } - protected boolean m_6046_() { + protected boolean onSoulSpeedBlock() { @@ -939,6 +_,8 @@ return InteractionResult.PASS; } else { + InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_36158_, p_36159_); + if (cancelResult != null) return cancelResult; - ItemStack itemstack = this.m_21120_(p_36159_); - ItemStack itemstack1 = itemstack.m_41777_(); - InteractionResult interactionresult = p_36158_.m_6096_(this, p_36159_); + ItemStack itemstack = this.getItemInHand(p_36159_); + ItemStack itemstack1 = itemstack.copy(); + InteractionResult interactionresult = p_36158_.interact(this, p_36159_); @@ -947,6 +_,9 @@ - itemstack.m_41764_(itemstack1.m_41613_()); + itemstack.setCount(itemstack1.getCount()); } -+ if (!this.f_36077_.f_35937_ && itemstack.m_41619_()) { ++ if (!this.abilities.instabuild && itemstack.isEmpty()) { + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_36159_); + } return interactionresult; } else { - if (!itemstack.m_41619_() && p_36158_ instanceof LivingEntity) { + if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { @@ -957,6 +_,7 @@ - InteractionResult interactionresult1 = itemstack.m_41647_(this, (LivingEntity)p_36158_, p_36159_); - if (interactionresult1.m_19077_()) { - if (itemstack.m_41619_() && !this.f_36077_.f_35937_) { + InteractionResult interactionresult1 = itemstack.interactLivingEntity(this, (LivingEntity)p_36158_, p_36159_); + if (interactionresult1.consumesAction()) { + if (itemstack.isEmpty() && !this.abilities.instabuild) { + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_36159_); - this.m_21008_(p_36159_, ItemStack.f_41583_); + this.setItemInHand(p_36159_, ItemStack.EMPTY); } @@ -986,6 +_,7 @@ - return !this.f_36077_.f_35935_; + return !this.abilities.flying; } + // Forge: Don't update this method to use IForgeEntity#getStepHeight() - https://github.com/MinecraftForge/MinecraftForge/issues/8922 - protected Vec3 m_5763_(Vec3 p_36201_, MoverType p_36202_) { - if (!this.f_36077_.f_35935_ && (p_36202_ == MoverType.SELF || p_36202_ == MoverType.PLAYER) && this.m_36343_() && this.m_36386_()) { - double d0 = p_36201_.f_82479_; + protected Vec3 maybeBackOffFromEdge(Vec3 p_36201_, MoverType p_36202_) { + if (!this.abilities.flying && (p_36202_ == MoverType.SELF || p_36202_ == MoverType.PLAYER) && this.isStayingOnGroundSurface() && this.isAboveGround()) { + double d0 = p_36201_.x; @@ -1037,10 +_,11 @@ } - private boolean m_36386_() { -- return this.f_19861_ || this.f_19789_ < this.f_19793_ && !this.f_19853_.m_45756_(this, this.m_142469_().m_82386_(0.0D, (double)(this.f_19789_ - this.f_19793_), 0.0D)); -+ return this.f_19861_ || this.f_19789_ < this.getStepHeight() && !this.f_19853_.m_45756_(this, this.m_142469_().m_82386_(0.0D, (double)(this.f_19789_ - this.getStepHeight()), 0.0D)); + private boolean isAboveGround() { +- return this.onGround || this.fallDistance < this.maxUpStep && !this.level.noCollision(this, this.getBoundingBox().move(0.0D, (double)(this.fallDistance - this.maxUpStep), 0.0D)); ++ return this.onGround || this.fallDistance < this.getStepHeight() && !this.level.noCollision(this, this.getBoundingBox().move(0.0D, (double)(this.fallDistance - this.getStepHeight()), 0.0D)); } - public void m_5706_(Entity p_36347_) { + public void attack(Entity p_36347_) { + if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget(this, p_36347_)) return; - if (p_36347_.m_6097_()) { - if (!p_36347_.m_7313_(this)) { - float f = (float)this.m_21133_(Attributes.f_22281_); + if (p_36347_.isAttackable()) { + if (!p_36347_.skipAttackInteraction(this)) { + float f = (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); @@ -1054,11 +_,11 @@ - float f2 = this.m_36403_(0.5F); + float f2 = this.getAttackStrengthScale(0.5F); f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; -- this.m_36334_(); +- this.resetAttackStrengthTicker(); + // this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; - int i = 0; -+ float i = (float)this.m_21133_(Attributes.f_22282_); // Forge: Initialize this value to the attack knockback attribute of the player, which is by default 0 - i += EnchantmentHelper.m_44894_(this); - if (this.m_20142_() && flag) { - this.f_19853_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12314_, this.m_5720_(), 1.0F, 1.0F); ++ float i = (float)this.getAttributeValue(Attributes.ATTACK_KNOCKBACK); // Forge: Initialize this value to the attack knockback attribute of the player, which is by default 0 + i += EnchantmentHelper.getKnockbackBonus(this); + if (this.isSprinting() && flag) { + this.level.playSound((Player)null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); @@ -1068,8 +_,10 @@ - boolean flag2 = flag && this.f_19789_ > 0.0F && !this.f_19861_ && !this.m_6147_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19610_) && !this.m_20159_() && p_36347_ instanceof LivingEntity; - flag2 = flag2 && !this.m_20142_(); + boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && p_36347_ instanceof LivingEntity; + flag2 = flag2 && !this.isSprinting(); + net.minecraftforge.event.entity.player.CriticalHitEvent hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_36347_, flag2, flag2 ? 1.5F : 1.0F); + flag2 = hitResult != null; if (flag2) { @@ -561,10 +561,10 @@ f += f1; @@ -1077,9 +_,7 @@ - double d0 = (double)(this.f_19787_ - this.f_19867_); - if (flag && !flag2 && !flag1 && this.f_19861_ && d0 < (double)this.m_6113_()) { - ItemStack itemstack = this.m_21120_(InteractionHand.MAIN_HAND); -- if (itemstack.m_41720_() instanceof SwordItem) { + double d0 = (double)(this.walkDist - this.walkDistO); + if (flag && !flag2 && !flag1 && this.onGround && d0 < (double)this.getSpeed()) { + ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); +- if (itemstack.getItem() instanceof SwordItem) { - flag3 = true; - } + flag3 = itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP); @@ -572,10 +572,10 @@ float f4 = 0.0F; @@ -1089,7 +_,15 @@ - f4 = ((LivingEntity)p_36347_).m_21223_(); - if (j > 0 && !p_36347_.m_6060_()) { + f4 = ((LivingEntity)p_36347_).getHealth(); + if (j > 0 && !p_36347_.isOnFire()) { flag4 = true; -- p_36347_.m_20254_(1); +- p_36347_.setSecondsOnFire(1); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item + org.bukkit.event.entity.EntityCombustByEntityEvent combustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), p_36347_.getBukkitEntity(), 1); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); @@ -590,17 +590,17 @@ @@ -1110,10 +_,13 @@ if (flag3) { - float f3 = 1.0F + EnchantmentHelper.m_44821_(this) * f; - -- for(LivingEntity livingentity : this.f_19853_.m_45976_(LivingEntity.class, p_36347_.m_142469_().m_82377_(1.0D, 0.25D, 1.0D))) { -- if (livingentity != this && livingentity != p_36347_ && !this.m_7307_(livingentity) && (!(livingentity instanceof ArmorStand) || !((ArmorStand)livingentity).m_31677_()) && this.m_20280_(livingentity) < 9.0D) { -- livingentity.m_147240_((double)0.4F, (double)Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)), (double)(-Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)))); -- livingentity.m_6469_(DamageSource.m_19344_(this), f3); -+ for(LivingEntity livingentity : this.f_19853_.m_45976_(LivingEntity.class, this.m_21120_(InteractionHand.MAIN_HAND).getSweepHitBox(this, p_36347_))) { -+ if (livingentity != this && livingentity != p_36347_ && !this.m_7307_(livingentity) && (!(livingentity instanceof ArmorStand) || !((ArmorStand)livingentity).m_31677_()) && this.canHit(livingentity, 0)) { // Original check was dist < 3, range is 3, so vanilla used padding=0 + float f3 = 1.0F + EnchantmentHelper.getSweepingDamageRatio(this) * f; + +- for(LivingEntity livingentity : this.level.getEntitiesOfClass(LivingEntity.class, p_36347_.getBoundingBox().inflate(1.0D, 0.25D, 1.0D))) { +- if (livingentity != this && livingentity != p_36347_ && !this.isAlliedTo(livingentity) && (!(livingentity instanceof ArmorStand) || !((ArmorStand)livingentity).isMarker()) && this.distanceToSqr(livingentity) < 9.0D) { +- livingentity.knockback((double)0.4F, (double)Mth.sin(this.getYRot() * ((float)Math.PI / 180F)), (double)(-Mth.cos(this.getYRot() * ((float)Math.PI / 180F)))); +- livingentity.hurt(DamageSource.playerAttack(this), f3); ++ for(LivingEntity livingentity : this.level.getEntitiesOfClass(LivingEntity.class, this.getItemInHand(InteractionHand.MAIN_HAND).getSweepHitBox(this, p_36347_))) { ++ if (livingentity != this && livingentity != p_36347_ && !this.isAlliedTo(livingentity) && (!(livingentity instanceof ArmorStand) || !((ArmorStand)livingentity).isMarker()) && this.canHit(livingentity, 0)) { // Original check was dist < 3, range is 3, so vanilla used padding=0 + // CraftBukkit start - Only apply knockback if the damage hits -+ if (livingentity.m_6469_(DamageSource.m_19344_(this).sweep(), f3)) { -+ livingentity.m_147240_((double)0.4F, (double)Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)), (double)(-Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)))); ++ if (livingentity.hurt(DamageSource.playerAttack(this).sweep(), f3)) { ++ livingentity.knockback((double)0.4F, (double)Mth.sin(this.getYRot() * ((float)Math.PI / 180F)), (double)(-Mth.cos(this.getYRot() * ((float)Math.PI / 180F)))); + } + // CraftBukkit end } @@ -609,17 +609,17 @@ @@ -1122,9 +_,26 @@ } - if (p_36347_ instanceof ServerPlayer && p_36347_.f_19864_) { -- ((ServerPlayer)p_36347_).f_8906_.m_141995_(new ClientboundSetEntityMotionPacket(p_36347_)); -- p_36347_.f_19864_ = false; -- p_36347_.m_20256_(vec3); + if (p_36347_ instanceof ServerPlayer && p_36347_.hurtMarked) { +- ((ServerPlayer)p_36347_).connection.send(new ClientboundSetEntityMotionPacket(p_36347_)); +- p_36347_.hurtMarked = false; +- p_36347_.setDeltaMovement(vec3); + // CraftBukkit start - Add Velocity Event + boolean cancelled = false; + org.bukkit.entity.Player player = (org.bukkit.entity.Player) p_36347_.getBukkitEntity(); + org.bukkit.util.Vector velocity = org.bukkit.craftbukkit.v1_18_R2.util.CraftVector.toBukkit(vec3); + + org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity.clone()); -+ f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + cancelled = true; @@ -628,37 +628,37 @@ + } + + if (!cancelled) { -+ ((ServerPlayer) p_36347_).f_8906_.m_141995_(new ClientboundSetEntityMotionPacket(p_36347_)); -+ p_36347_.f_19864_ = false; -+ p_36347_.m_20256_(vec3); ++ ((ServerPlayer) p_36347_).connection.send(new ClientboundSetEntityMotionPacket(p_36347_)); ++ p_36347_.hurtMarked = false; ++ p_36347_.setDeltaMovement(vec3); + } + // CraftBukkit end } if (flag2) { @@ -1152,13 +_,15 @@ - EnchantmentHelper.m_44896_(this, p_36347_); - ItemStack itemstack1 = this.m_21205_(); + EnchantmentHelper.doPostDamageEffects(this, p_36347_); + ItemStack itemstack1 = this.getMainHandItem(); Entity entity = p_36347_; - if (p_36347_ instanceof EnderDragonPart) { -- entity = ((EnderDragonPart)p_36347_).f_31010_; +- entity = ((EnderDragonPart)p_36347_).parentMob; + if (p_36347_ instanceof net.minecraftforge.entity.PartEntity) { + entity = ((net.minecraftforge.entity.PartEntity) p_36347_).getParent(); } - if (!this.f_19853_.f_46443_ && !itemstack1.m_41619_() && entity instanceof LivingEntity) { -+ ItemStack copy = itemstack1.m_41777_(); - itemstack1.m_41640_((LivingEntity)entity, this); - if (itemstack1.m_41619_()) { + if (!this.level.isClientSide && !itemstack1.isEmpty() && entity instanceof LivingEntity) { ++ ItemStack copy = itemstack1.copy(); + itemstack1.hurtEnemy((LivingEntity)entity, this); + if (itemstack1.isEmpty()) { + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, InteractionHand.MAIN_HAND); - this.m_21008_(InteractionHand.MAIN_HAND, ItemStack.f_41583_); + this.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY); } } @@ -1167,7 +_,14 @@ - float f5 = f4 - ((LivingEntity)p_36347_).m_21223_(); - this.m_36222_(Stats.f_12928_, Math.round(f5 * 10.0F)); + float f5 = f4 - ((LivingEntity)p_36347_).getHealth(); + this.awardStat(Stats.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { -- p_36347_.m_20254_(j * 4); +- p_36347_.setSecondsOnFire(j * 4); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item + org.bukkit.event.entity.EntityCombustByEntityEvent combustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); @@ -669,18 +669,18 @@ + // CraftBukkit end } - if (this.f_19853_ instanceof ServerLevel && f5 > 2.0F) { + if (this.level instanceof ServerLevel && f5 > 2.0F) { @@ -1176,12 +_,18 @@ } } -- this.m_36399_(0.1F); +- this.causeFoodExhaustion(0.1F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); -+ this.m_36399_(f_19853_.spigotConfig.combatExhaustion); ++ this.causeFoodExhaustion(level.spigotConfig.combatExhaustion); } else { - this.f_19853_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12315_, this.m_5720_(), 1.0F, 1.0F); + this.level.playSound((Player)null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); if (flag4) { - p_36347_.m_20095_(); + p_36347_.clearFire(); } + // CraftBukkit start - resync on cancelled event + if (this instanceof ServerPlayer) { @@ -693,14 +693,14 @@ @@ -1200,7 +_,7 @@ } - if (this.f_19796_.nextFloat() < f) { -- this.m_36335_().m_41524_(Items.f_42740_, 100); -+ this.m_36335_().m_41524_(this.m_21211_().m_41720_(), 100); - this.m_5810_(); - this.f_19853_.m_7605_(this, (byte)30); + if (this.random.nextFloat() < f) { +- this.getCooldowns().addCooldown(Items.SHIELD, 100); ++ this.getCooldowns().addCooldown(this.getUseItem().getItem(), 100); + this.stopUsingItem(); + this.level.broadcastEntityEvent(this, (byte)30); } @@ -1253,6 +_,14 @@ - public void m_141945_(ItemStack p_150098_, ItemStack p_150099_, ClickAction p_150100_) { + public void updateTutorialInventoryAction(ItemStack p_150098_, ItemStack p_150099_, ClickAction p_150100_) { } + //Magma start - force sleep @@ -711,176 +711,176 @@ + } + //Magma end + - public Either m_7720_(BlockPos p_36203_) { - this.m_5802_(p_36203_); - this.f_36110_ = 0; + public Either startSleepInBed(BlockPos p_36203_) { + this.startSleeping(p_36203_); + this.sleepCounter = 0; @@ -1260,6 +_,7 @@ } - public void m_6145_(boolean p_36226_, boolean p_36227_) { + public void stopSleepInBed(boolean p_36226_, boolean p_36227_) { + net.minecraftforge.event.ForgeEventFactory.onPlayerWakeup(this, p_36226_, p_36227_); - super.m_5796_(); - if (this.f_19853_ instanceof ServerLevel && p_36227_) { - ((ServerLevel)this.f_19853_).m_8878_(); + super.stopSleeping(); + if (this.level instanceof ServerLevel && p_36227_) { + ((ServerLevel)this.level).updateSleepingPlayerList(); @@ -1285,7 +_,7 @@ - } else if (block instanceof BedBlock && BedBlock.m_49488_(p_36131_)) { - return BedBlock.m_49458_(EntityType.f_20532_, p_36131_, p_36132_, p_36133_); + } else if (block instanceof BedBlock && BedBlock.canSetSpawn(p_36131_)) { + return BedBlock.findStandUpPosition(EntityType.PLAYER, p_36131_, p_36132_, p_36133_); } else if (!p_36134_) { - return Optional.empty(); -+ return blockstate.getRespawnPosition(EntityType.f_20532_, p_36131_, p_36132_, p_36133_, null); ++ return blockstate.getRespawnPosition(EntityType.PLAYER, p_36131_, p_36132_, p_36133_, null); } else { - boolean flag = block.m_5568_(); - boolean flag1 = p_36131_.m_8055_(p_36132_.m_7494_()).m_60734_().m_5568_(); + boolean flag = block.isPossibleToRespawnInThis(); + boolean flag1 = p_36131_.getBlockState(p_36132_.above()).getBlock().isPossibleToRespawnInThis(); @@ -1337,9 +_,11 @@ - super.m_6135_(); - this.m_36220_(Stats.f_12926_); - if (this.m_20142_()) { -- this.m_36399_(0.2F); + super.jumpFromGround(); + this.awardStat(Stats.JUMP); + if (this.isSprinting()) { +- this.causeFoodExhaustion(0.2F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); -+ this.m_36399_(f_19853_.spigotConfig.jumpSprintExhaustion); ++ this.causeFoodExhaustion(level.spigotConfig.jumpSprintExhaustion); } else { -- this.m_36399_(0.05F); +- this.causeFoodExhaustion(0.05F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.JUMP); -+ this.m_36399_(f_19853_.spigotConfig.jumpWalkExhaustion); ++ this.causeFoodExhaustion(level.spigotConfig.jumpWalkExhaustion); } } @@ -1366,7 +_,11 @@ - this.m_20334_(vec3.f_82479_, d5 * 0.6D, vec3.f_82481_); - this.f_20887_ = f; - this.m_183634_(); -- this.m_20115_(7, false); + this.setDeltaMovement(vec3.x, d5 * 0.6D, vec3.z); + this.flyingSpeed = f; + this.resetFallDistance(); +- this.setSharedFlag(7, false); + // CraftBukkit start -+ if (m_20291_(7) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { -+ this.m_20115_(7, false); ++ if (getSharedFlag(7) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { ++ this.setSharedFlag(7, false); + } + // CraftBukkit end } else { - super.m_7023_(p_36359_); + super.travel(p_36359_); } @@ -1397,19 +_,22 @@ int i = Math.round((float)Math.sqrt(p_36379_ * p_36379_ + p_36380_ * p_36380_ + p_36381_ * p_36381_) * 100.0F); if (i > 0) { - this.m_36222_(Stats.f_12924_, i); -- this.m_36399_(0.01F * (float)i * 0.01F); + this.awardStat(Stats.SWIM_ONE_CM, i); +- this.causeFoodExhaustion(0.01F * (float)i * 0.01F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.SWIM); -+ this.m_36399_(f_19853_.spigotConfig.swimMultiplier * (float)i * 0.01F); ++ this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float)i * 0.01F); } - } else if (this.m_204029_(FluidTags.f_13131_)) { + } else if (this.isEyeInFluid(FluidTags.WATER)) { int j = Math.round((float)Math.sqrt(p_36379_ * p_36379_ + p_36380_ * p_36380_ + p_36381_ * p_36381_) * 100.0F); if (j > 0) { - this.m_36222_(Stats.f_13001_, j); -- this.m_36399_(0.01F * (float)j * 0.01F); + this.awardStat(Stats.WALK_UNDER_WATER_ONE_CM, j); +- this.causeFoodExhaustion(0.01F * (float)j * 0.01F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); -+ this.m_36399_(f_19853_.spigotConfig.swimMultiplier * (float)j * 0.01F); ++ this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float)j * 0.01F); } - } else if (this.m_20069_()) { + } else if (this.isInWater()) { int k = Math.round((float)Math.sqrt(p_36379_ * p_36379_ + p_36381_ * p_36381_) * 100.0F); if (k > 0) { - this.m_36222_(Stats.f_12997_, k); -- this.m_36399_(0.01F * (float)k * 0.01F); + this.awardStat(Stats.WALK_ON_WATER_ONE_CM, k); +- this.causeFoodExhaustion(0.01F * (float)k * 0.01F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); -+ this.m_36399_(f_19853_.spigotConfig.swimMultiplier * (float)k * 0.01F); ++ this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float)k * 0.01F); } - } else if (this.m_6147_()) { + } else if (this.onClimbable()) { if (p_36380_ > 0.0D) { @@ -1420,13 +_,17 @@ if (l > 0) { - if (this.m_20142_()) { - this.m_36222_(Stats.f_12996_, l); -- this.m_36399_(0.1F * (float)l * 0.01F); + if (this.isSprinting()) { + this.awardStat(Stats.SPRINT_ONE_CM, l); +- this.causeFoodExhaustion(0.1F * (float)l * 0.01F); + float exhaustion = 0.1F; //Magma - let mods overwrite this to prevent a mixin inject error + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.SPRINT); -+ this.m_36399_((exhaustion != 0.1F ? exhaustion : f_19853_.spigotConfig.sprintMultiplier) * (float)l * 0.01F); - } else if (this.m_6047_()) { - this.m_36222_(Stats.f_12995_, l); -- this.m_36399_(0.0F * (float)l * 0.01F); ++ this.causeFoodExhaustion((exhaustion != 0.1F ? exhaustion : level.spigotConfig.sprintMultiplier) * (float)l * 0.01F); + } else if (this.isCrouching()) { + this.awardStat(Stats.CROUCH_ONE_CM, l); +- this.causeFoodExhaustion(0.0F * (float)l * 0.01F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.CROUCH); -+ this.m_36399_(f_19853_.spigotConfig.otherMultiplier * (float)l * 0.01F); ++ this.causeFoodExhaustion(level.spigotConfig.otherMultiplier * (float)l * 0.01F); } else { - this.m_36222_(Stats.f_12994_, l); -- this.m_36399_(0.0F * (float)l * 0.01F); + this.awardStat(Stats.WALK_ONE_CM, l); +- this.causeFoodExhaustion(0.0F * (float)l * 0.01F); + this.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK); -+ this.m_36399_(f_19853_.spigotConfig.otherMultiplier * (float)l * 0.01F); ++ this.causeFoodExhaustion(level.spigotConfig.otherMultiplier * (float)l * 0.01F); } } - } else if (this.m_21255_()) { + } else if (this.isFallFlying()) { @@ -1465,6 +_,7 @@ - public boolean m_142535_(float p_150093_, float p_150094_, DamageSource p_150095_) { - if (this.f_36077_.f_35936_) { + public boolean causeFallDamage(float p_150093_, float p_150094_, DamageSource p_150095_) { + if (this.abilities.mayfly) { + net.minecraftforge.event.ForgeEventFactory.onPlayerFall(this, p_150093_, p_150093_); return false; } else { if (p_150093_ >= 2.0F) { @@ -1478,7 +_,7 @@ - public boolean m_36319_() { - if (!this.f_19861_ && !this.m_21255_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19620_)) { - ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); -- if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { + 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.m_36320_(); + this.startFallFlying(); return true; } @@ -1488,12 +_,24 @@ } - public void m_36320_() { -- this.m_20115_(7, true); + public void startFallFlying() { +- this.setSharedFlag(7, true); + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) { -+ this.m_20115_(7, true); ++ this.setSharedFlag(7, true); + } else { + // SPIGOT-5542: must toggle like below -+ this.m_20115_(7, true); -+ this.m_20115_(7, false); ++ this.setSharedFlag(7, true); ++ this.setSharedFlag(7, false); + } + // CraftBukkit end } - public void m_36321_() { -- this.m_20115_(7, true); -- this.m_20115_(7, false); + public void stopFallFlying() { +- this.setSharedFlag(7, true); +- this.setSharedFlag(7, false); + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { -+ this.m_20115_(7, true); -+ this.m_20115_(7, false); ++ this.setSharedFlag(7, true); ++ this.setSharedFlag(7, false); + } + // CraftBukkit end } - protected void m_5841_() { + protected void doWaterSplashEffect() { @@ -1519,6 +_,10 @@ } - public void m_6756_(int p_36291_) { + public void giveExperiencePoints(int p_36291_) { + net.minecraftforge.event.entity.player.PlayerXpEvent.XpChange event = new net.minecraftforge.event.entity.player.PlayerXpEvent.XpChange(this, p_36291_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; + p_36291_ = event.getAmount(); + - this.m_36401_(p_36291_); - this.f_36080_ += (float)p_36291_ / (float)this.m_36323_(); - this.f_36079_ = Mth.m_14045_(this.f_36079_ + p_36291_, 0, Integer.MAX_VALUE); + this.increaseScore(p_36291_); + this.experienceProgress += (float)p_36291_ / (float)this.getXpNeededForNextLevel(); + this.totalExperience = Mth.clamp(this.totalExperience + p_36291_, 0, Integer.MAX_VALUE); @@ -1547,7 +_,7 @@ } - public void m_7408_(ItemStack p_36172_, int p_36173_) { -- this.f_36078_ -= p_36173_; -+ m_6749_(-p_36173_); - if (this.f_36078_ < 0) { - this.f_36078_ = 0; - this.f_36080_ = 0.0F; + public void onEnchantmentPerformed(ItemStack p_36172_, int p_36173_) { +- this.experienceLevel -= p_36173_; ++ giveExperienceLevels(-p_36173_); + if (this.experienceLevel < 0) { + this.experienceLevel = 0; + this.experienceProgress = 0.0F; @@ -1558,6 +_,10 @@ } - public void m_6749_(int p_36276_) { + public void giveExperienceLevels(int p_36276_) { + net.minecraftforge.event.entity.player.PlayerXpEvent.LevelChange event = new net.minecraftforge.event.entity.player.PlayerXpEvent.LevelChange(this, p_36276_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; + p_36276_ = event.getLevels(); + - this.f_36078_ += p_36276_; - if (this.f_36078_ < 0) { - this.f_36078_ = 0; + this.experienceLevel += p_36276_; + if (this.experienceLevel < 0) { + this.experienceLevel = 0; @@ -1581,14 +_,29 @@ } } @@ -892,50 +892,50 @@ + this.exhaustionReason = exhaustionReason; + } + - public void m_36399_(float p_36400_) { + public void causeFoodExhaustion(float p_36400_) { + this.causeFoodExhaustion(p_36400_, exhaustionReason); + exhaustionReason = org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.UNKNOWN; + } + + public void causeFoodExhaustion(float p_36400_, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason reason) { + // CraftBukkit end - if (!this.f_36077_.f_35934_) { - if (!this.f_19853_.f_46443_) { -+ this.f_36097_.prepareExhaustion(this, reason); //Magma - this.f_36097_.m_38703_(p_36400_); + if (!this.abilities.invulnerable) { + if (!this.level.isClientSide) { ++ this.foodData.prepareExhaustion(this, reason); //Magma + this.foodData.addExhaustion(p_36400_); } } } + //Magma end - public FoodData m_36324_() { - return this.f_36097_; + public FoodData getFoodData() { + return this.foodData; @@ -1670,7 +_,13 @@ - this.m_147218_(p_36162_); - this.f_36093_.f_35975_.set(p_36161_.m_20749_(), p_36162_); + this.equipEventAndSound(p_36162_); + this.inventory.armor.set(p_36161_.getIndex(), p_36162_); } + } + @Override + public void setItemSlot(EquipmentSlot p_36161_, ItemStack p_36162_, boolean silent) { + silenceEquipSound(silent); -+ m_8061_(p_36161_, p_36162_); ++ setItemSlot(p_36161_, p_36162_); + silenceEquipSound(false); //reset } - public boolean m_36356_(ItemStack p_36357_) { + public boolean addItem(ItemStack p_36357_) { @@ -1745,7 +_,11 @@ } - public Component m_5446_() { -- MutableComponent mutablecomponent = PlayerTeam.m_83348_(this.m_5647_(), this.m_7755_()); -+ if (this.displayname == null) this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.m_7755_()); + public Component getDisplayName() { +- MutableComponent mutablecomponent = PlayerTeam.formatNameForTeam(this.getTeam(), this.getName()); ++ if (this.displayname == null) this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.getName()); + MutableComponent mutablecomponent = new TextComponent(""); -+ mutablecomponent = prefixes.stream().reduce(mutablecomponent, MutableComponent::m_7220_); -+ mutablecomponent = mutablecomponent.m_7220_(PlayerTeam.m_83348_(this.m_5647_(), this.displayname)); -+ mutablecomponent = suffixes.stream().reduce(mutablecomponent, MutableComponent::m_7220_); - return this.m_36218_(mutablecomponent); ++ mutablecomponent = prefixes.stream().reduce(mutablecomponent, MutableComponent::append); ++ mutablecomponent = mutablecomponent.append(PlayerTeam.formatNameForTeam(this.getTeam(), this.displayname)); ++ mutablecomponent = suffixes.stream().reduce(mutablecomponent, MutableComponent::append); + return this.decorateDisplayNameComponent(mutablecomponent); } @@ -1778,6 +_,10 @@ @@ -946,41 +946,41 @@ + if (Float.isNaN(p_36396_)) + p_36396_ = 0.0F; + - this.m_20088_().m_135381_(f_36107_, p_36396_); + this.getEntityData().set(DATA_PLAYER_ABSORPTION_ID, p_36396_); } @@ -1895,24 +_,24 @@ - Predicate predicate = ((ProjectileWeaponItem)p_36349_.m_41720_()).m_6442_(); - ItemStack itemstack = ProjectileWeaponItem.m_43010_(this, predicate); - if (!itemstack.m_41619_()) { + Predicate predicate = ((ProjectileWeaponItem)p_36349_.getItem()).getSupportedHeldProjectiles(); + ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); + if (!itemstack.isEmpty()) { - return itemstack; + return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_36349_, itemstack); } else { - predicate = ((ProjectileWeaponItem)p_36349_.m_41720_()).m_6437_(); + predicate = ((ProjectileWeaponItem)p_36349_.getItem()).getAllSupportedProjectiles(); - for(int i = 0; i < this.f_36093_.m_6643_(); ++i) { - ItemStack itemstack1 = this.f_36093_.m_8020_(i); + for(int i = 0; i < this.inventory.getContainerSize(); ++i) { + ItemStack itemstack1 = this.inventory.getItem(i); if (predicate.test(itemstack1)) { - return itemstack1; + return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_36349_, itemstack1); } } -- return this.f_36077_.f_35937_ ? new ItemStack(Items.f_42412_) : ItemStack.f_41583_; -+ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_36349_, this.f_36077_.f_35937_ ? new ItemStack(Items.f_42412_) : ItemStack.f_41583_); +- return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; ++ return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_36349_, this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY); } } } - public ItemStack m_5584_(Level p_36185_, ItemStack p_36186_) { -- this.m_36324_().m_38712_(p_36186_.m_41720_(), p_36186_); -+ this.m_36324_().eat(p_36186_.m_41720_(), p_36186_, this); - this.m_36246_(Stats.f_12982_.m_12902_(p_36186_.m_41720_())); - p_36185_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12321_, SoundSource.PLAYERS, 0.5F, p_36185_.f_46441_.nextFloat() * 0.1F + 0.9F); + public ItemStack eat(Level p_36185_, ItemStack p_36186_) { +- this.getFoodData().eat(p_36186_.getItem(), p_36186_); ++ this.getFoodData().eat(p_36186_.getItem(), p_36186_, this); + this.awardStat(Stats.ITEM_USED.get(p_36186_.getItem())); + p_36185_.playSound((Player)null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, p_36185_.random.nextFloat() * 0.1F + 0.9F); if (this instanceof ServerPlayer) { @@ -1991,5 +_,63 @@ - public Component m_36423_() { - return this.f_36413_; + public Component getMessage() { + return this.message; } + } + @@ -998,29 +998,29 @@ + * Force the displayed name to refresh, by firing {@link net.minecraftforge.event.entity.player.PlayerEvent.NameFormat}, using the real player name as event parameter. + */ + public void refreshDisplayName() { -+ this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.m_7755_()); ++ this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.getName()); + } + + private final net.minecraftforge.common.util.LazyOptional + playerMainHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(f_36093_)); ++ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(inventory)); + + private final net.minecraftforge.common.util.LazyOptional + playerEquipmentHandler = net.minecraftforge.common.util.LazyOptional.of( + () -> new net.minecraftforge.items.wrapper.CombinedInvWrapper( -+ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(f_36093_), -+ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(f_36093_))); ++ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(inventory), ++ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(inventory))); + + private final net.minecraftforge.common.util.LazyOptional + playerJoinedHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.PlayerInvWrapper(f_36093_)); ++ () -> new net.minecraftforge.items.wrapper.PlayerInvWrapper(inventory)); + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (this.isAlive() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (facing == null) return playerJoinedHandler.cast(); -+ else if (facing.m_122434_().m_122478_()) return playerMainHandler.cast(); -+ else if (facing.m_122434_().m_122479_()) return playerEquipmentHandler.cast(); ++ else if (facing.getAxis().isVertical()) return playerMainHandler.cast(); ++ else if (facing.getAxis().isHorizontal()) return playerEquipmentHandler.cast(); + } + return super.getCapability(capability, facing); + } 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 450943c6..75f803d0 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java @@ -64,6 +_,16 @@ @Nullable - private List f_36702_; + private List piercedAndKilledEntities; + // Spigot Start + @Override + public void inactiveTick() { -+ if (this.f_36703_) { -+ this.f_36697_ += 1; ++ if (this.inGround) { ++ this.life += 1; + } + super.inactiveTick(); + } @@ -22,26 +22,26 @@ } - if (hitresult != null && !flag) { -- this.m_6532_(hitresult); -+ if (hitresult != null && hitresult.m_6662_() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { +- this.onHit(hitresult); ++ if (hitresult != null && hitresult.getType() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.preOnHit(hitresult); // CraftBukkit - projectile hit event - this.f_19812_ = true; + this.hasImpulse = true; } @@ -262,7 +_,7 @@ - protected void m_6901_() { - ++this.f_36697_; -- if (this.f_36697_ >= 1200) { -+ if (this.f_36697_ >= ((this instanceof ThrownTrident) ? f_19853_.spigotConfig.tridentDespawnRate : f_19853_.spigotConfig.arrowDespawnRate)) { // Spigot - this.m_146870_(); + protected void tickDespawn() { + ++this.life; +- if (this.life >= 1200) { ++ if (this.life >= ((this instanceof ThrownTrident) ? level.spigotConfig.tridentDespawnRate : level.spigotConfig.arrowDespawnRate)) { // Spigot + this.discard(); } @@ -320,7 +_,13 @@ - boolean flag = entity.m_6095_() == EntityType.f_20566_; - int k = entity.m_20094_(); - if (this.m_6060_() && !flag) { -- entity.m_20254_(5); + boolean flag = entity.getType() == EntityType.ENDERMAN; + int k = entity.getRemainingFireTicks(); + if (this.isOnFire() && !flag) { +- entity.setSecondsOnFire(5); + // CraftBukkit start + org.bukkit.event.entity.EntityCombustByEntityEvent combustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); @@ -51,27 +51,27 @@ + // CraftBukkit end } - if (entity.m_6469_(damagesource, (float)i)) { + if (entity.hurt(damagesource, (float)i)) { @@ -472,7 +_,21 @@ - public void m_6123_(Player p_36766_) { - if (!this.f_19853_.f_46443_ && (this.f_36703_ || this.m_36797_()) && this.f_36706_ <= 0) { -- if (this.m_142470_(p_36766_)) { + public void playerTouch(Player p_36766_) { + if (!this.level.isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { +- if (this.tryPickup(p_36766_)) { + // CraftBukkit start -+ ItemStack itemstack = this.m_7941_(); -+ if (this.f_36705_ == Pickup.ALLOWED && !itemstack.m_41619_() && p_36766_.m_150109_().canHold(itemstack) > 0) { -+ net.minecraft.world.entity.item.ItemEntity item = new net.minecraft.world.entity.item.ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_(), this.m_20189_(), itemstack); -+ org.bukkit.event.player.PlayerPickupArrowEvent event = new org.bukkit.event.player.PlayerPickupArrowEvent((org.bukkit.entity.Player) p_36766_.getBukkitEntity(), new org.bukkit.craftbukkit.v1_18_R2.entity.CraftItem(this.f_19853_.getCraftServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); ++ ItemStack itemstack = this.getPickupItem(); ++ if (this.pickup == Pickup.ALLOWED && !itemstack.isEmpty() && p_36766_.getInventory().canHold(itemstack) > 0) { ++ net.minecraft.world.entity.item.ItemEntity item = new net.minecraft.world.entity.item.ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), itemstack); ++ org.bukkit.event.player.PlayerPickupArrowEvent event = new org.bukkit.event.player.PlayerPickupArrowEvent((org.bukkit.entity.Player) p_36766_.getBukkitEntity(), new org.bukkit.craftbukkit.v1_18_R2.entity.CraftItem(this.level.getCraftServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); + // event.setCancelled(!p_36766_.canPickUpLoot); TODO -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } -+ itemstack = item.m_32055_(); ++ itemstack = item.getItem(); + } -+ if ((this.f_36705_ == AbstractArrow.Pickup.ALLOWED && p_36766_.m_150109_().m_36054_(itemstack)) || (this.f_36705_ == AbstractArrow.Pickup.CREATIVE_ONLY && p_36766_.m_150110_().f_35937_)) { ++ if ((this.pickup == AbstractArrow.Pickup.ALLOWED && p_36766_.getInventory().add(itemstack)) || (this.pickup == AbstractArrow.Pickup.CREATIVE_ONLY && p_36766_.getAbilities().instabuild)) { + // CraftBukkit end - p_36766_.m_7938_(this, 1); - this.m_146870_(); + p_36766_.take(this, 1); + this.discard(); } 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 9dafd7cf..f6edfe3e 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java @@ -18,6 +_,8 @@ - public double f_36813_; - public double f_36814_; - public double f_36815_; + public double xPower; + public double yPower; + public double zPower; + public float bukkitYield = 1; // CraftBukkit + public boolean isIncendiary = true; // CraftBukkit @@ -11,8 +11,8 @@ super(p_36833_, p_36834_); @@ -27,6 +_,12 @@ this(p_36817_, p_36824_); - this.m_7678_(p_36818_, p_36819_, p_36820_, this.m_146908_(), this.m_146909_()); - this.m_20090_(); + this.moveTo(p_36818_, p_36819_, p_36820_, this.getYRot(), this.getXRot()); + this.reapplyPosition(); + // CraftBukkit start - Added setDirection method + this.setDirection(p_36821_, p_36822_, p_36823_); + } @@ -21,33 +21,33 @@ + // CraftBukkit end double d0 = Math.sqrt(p_36821_ * p_36821_ + p_36822_ * p_36822_ + p_36823_ * p_36823_); if (d0 != 0.0D) { - this.f_36813_ = p_36821_ / d0 * 0.1D; + this.xPower = p_36821_ / d0 * 0.1D; @@ -64,8 +_,14 @@ } - HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); -- if (hitresult.m_6662_() != HitResult.Type.MISS) { -- this.m_6532_(hitresult); -+ if (hitresult.m_6662_() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); +- if (hitresult.getType() != HitResult.Type.MISS) { +- this.onHit(hitresult); ++ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.preOnHit(hitresult); // CraftBukkit - projectile hit event + + // CraftBukkit start - Fire ProjectileHitEvent -+ if (this.m_146910_()) { ++ if (this.isRemoved()) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callProjectileHitEvent(this, hitresult); + } + // CraftBukkit end } - this.m_20101_(); + this.checkInsideBlocks(); @@ -142,6 +_,11 @@ - Entity entity = p_36839_.m_7639_(); + Entity entity = p_36839_.getEntity(); if (entity != null) { - if (!this.f_19853_.f_46443_) { + if (!this.level.isClientSide) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_36839_, p_36840_, false)) { + return false; + } + // CraftBukkit end - Vec3 vec3 = entity.m_20154_(); - this.m_20256_(vec3); - this.f_36813_ = vec3.f_82479_ * 0.1D; + Vec3 vec3 = entity.getLookAngle(); + this.setDeltaMovement(vec3); + this.xPower = vec3.x * 0.1D; diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch index 26acb0b9..674c799a 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch @@ -6,40 +6,40 @@ + // CraftBukkit start accessor methods + public void refreshEffects() { -+ this.m_20088_().m_135381_(Arrow.f_36854_, PotionUtils.m_43564_((Collection) PotionUtils.m_43561_(this.f_36855_, (Collection) this.f_36852_))); ++ this.getEntityData().set(Arrow.ID_EFFECT_COLOR, PotionUtils.getColor((Collection) PotionUtils.getAllEffects(this.potion, (Collection) this.effects))); + } + + public String getPotionType() { -+ return Registry.f_122828_.m_7981_(this.f_36855_).toString(); ++ return Registry.POTION.getKey(this.potion).toString(); + } + + public void setPotionType(String string) { -+ this.f_36855_ = Registry.f_122828_.m_7745_(new net.minecraft.resources.ResourceLocation(string)); -+ this.m_20088_().m_135381_(Arrow.f_36854_, PotionUtils.m_43564_((Collection) PotionUtils.m_43561_(this.f_36855_, (Collection) this.f_36852_))); ++ this.potion = Registry.POTION.get(new net.minecraft.resources.ResourceLocation(string)); ++ this.getEntityData().set(Arrow.ID_EFFECT_COLOR, PotionUtils.getColor((Collection) PotionUtils.getAllEffects(this.potion, (Collection) this.effects))); + } + + public boolean isTipped() { -+ return !(this.f_36852_.isEmpty() && this.f_36855_ == Potions.f_43598_); ++ return !(this.effects.isEmpty() && this.potion == Potions.EMPTY); + } + // CraftBukkit end + - public int m_36889_() { - return this.f_19804_.m_135370_(f_36854_); + public int getColor() { + return this.entityData.get(ID_EFFECT_COLOR); } @@ -178,12 +_,14 @@ - Entity entity = this.m_150173_(); + Entity entity = this.getEffectSource(); - for(MobEffectInstance mobeffectinstance : this.f_36855_.m_43488_()) { -- p_36873_.m_147207_(new MobEffectInstance(mobeffectinstance.m_19544_(), Math.max(mobeffectinstance.m_19557_() / 8, 1), mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()), entity); + for(MobEffectInstance mobeffectinstance : this.potion.getEffects()) { +- p_36873_.addEffect(new MobEffectInstance(mobeffectinstance.getEffect(), Math.max(mobeffectinstance.getDuration() / 8, 1), mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible()), entity); + p_36873_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); -+ p_36873_.m_147207_(new MobEffectInstance(mobeffectinstance.m_19544_(), Math.max(mobeffectinstance.m_19557_() / 8, 1), mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()), entity); // CraftBukkit ++ p_36873_.addEffect(new MobEffectInstance(mobeffectinstance.getEffect(), Math.max(mobeffectinstance.getDuration() / 8, 1), mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible()), entity); // CraftBukkit } - if (!this.f_36852_.isEmpty()) { - for(MobEffectInstance mobeffectinstance1 : this.f_36852_) { -- p_36873_.m_147207_(mobeffectinstance1, entity); + if (!this.effects.isEmpty()) { + for(MobEffectInstance mobeffectinstance1 : this.effects) { +- p_36873_.addEffect(mobeffectinstance1, entity); + p_36873_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); -+ p_36873_.m_147207_(mobeffectinstance1, entity); // CraftBukkit ++ p_36873_.addEffect(mobeffectinstance1, entity); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/EvokerFangs.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/EvokerFangs.java.patch index 0ef29ce5..62d13ed1 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/EvokerFangs.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/EvokerFangs.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EvokerFangs.java @@ -115,7 +_,9 @@ - LivingEntity livingentity = this.m_36947_(); - if (p_36945_.m_6084_() && !p_36945_.m_20147_() && p_36945_ != livingentity) { + LivingEntity livingentity = this.getOwner(); + if (p_36945_.isAlive() && !p_36945_.isInvulnerable() && p_36945_ != livingentity) { if (livingentity == null) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = this; // CraftBukkit - p_36945_.m_6469_(DamageSource.f_19319_, 6.0F); + p_36945_.hurt(DamageSource.MAGIC, 6.0F); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; // CraftBukkit } else { - if (livingentity.m_7307_(p_36945_)) { + if (livingentity.isAlliedTo(p_36945_)) { return; diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch index 79fa96e8..1dcebf80 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch @@ -3,18 +3,18 @@ @@ -37,7 +_,7 @@ } - public void m_36972_(ItemStack p_36973_) { -- if (!p_36973_.m_150930_(Items.f_42545_) || p_36973_.m_41782_()) { -+ if (true || !p_36973_.m_150930_(Items.f_42545_) || p_36973_.m_41782_()) { // CraftBukkit - always allow item changing - this.m_20088_().m_135381_(f_36949_, Util.m_137469_(p_36973_.m_41777_(), (p_36978_) -> { - p_36978_.m_41764_(1); + public void setItem(ItemStack p_36973_) { +- if (!p_36973_.is(Items.ENDER_EYE) || p_36973_.hasTag()) { ++ if (true || !p_36973_.is(Items.ENDER_EYE) || p_36973_.hasTag()) { // CraftBukkit - always allow item changing + this.getEntityData().set(DATA_ITEM_STACK, Util.make(p_36973_.copy(), (p_36978_) -> { + p_36978_.setCount(1); })); @@ -164,7 +_,7 @@ - public void m_7378_(CompoundTag p_36970_) { - ItemStack itemstack = ItemStack.m_41712_(p_36970_.m_128469_("Item")); -- this.m_36972_(itemstack); -+ if (!itemstack.m_41619_()) this.m_36972_(itemstack); // CraftBukkit - SPIGOT-6103 summon, see also SPIGOT-5474 + public void readAdditionalSaveData(CompoundTag p_36970_) { + ItemStack itemstack = ItemStack.of(p_36970_.getCompound("Item")); +- this.setItem(itemstack); ++ if (!itemstack.isEmpty()) this.setItem(itemstack); // CraftBukkit - SPIGOT-6103 summon, see also SPIGOT-5474 } - public float m_6073_() { + public float getBrightness() { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Fireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Fireball.java.patch index 5401e1eb..f4478f95 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Fireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Fireball.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/projectile/Fireball.java +++ b/net/minecraft/world/entity/projectile/Fireball.java @@ -60,6 +_,6 @@ - public void m_7378_(CompoundTag p_37009_) { - super.m_7378_(p_37009_); - ItemStack itemstack = ItemStack.m_41712_(p_37009_.m_128469_("Item")); -- this.m_37010_(itemstack); -+ if (!itemstack.m_41619_()) this.m_37010_(itemstack); // CraftBukkit - SPIGOT-5474 probably came from bugged earlier versions + public void readAdditionalSaveData(CompoundTag p_37009_) { + super.readAdditionalSaveData(p_37009_); + ItemStack itemstack = ItemStack.of(p_37009_.getCompound("Item")); +- this.setItem(itemstack); ++ if (!itemstack.isEmpty()) this.setItem(itemstack); // CraftBukkit - SPIGOT-5474 probably came from bugged earlier versions } } 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 66d39dc1..df4f2223 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java @@ -75,6 +_,21 @@ - this.m_5602_(p_37052_); + this.setOwner(p_37052_); } + // Spigot Start - copied from tick + @Override + public void inactiveTick() { -+ this.f_37022_ += 1; -+ if (!this.f_19853_.f_46443_ && this.f_37022_ > this.f_37023_) { ++ this.life += 1; ++ if (!this.level.isClientSide && this.life > this.lifetime) { + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.m_37080_(); ++ this.explode(); + } + // CraftBukkit end + } @@ -19,28 +19,28 @@ + } + // Spigot End + - protected void m_8097_() { - this.f_19804_.m_135372_(f_37019_, ItemStack.f_41583_); - this.f_19804_.m_135372_(f_37020_, OptionalInt.empty()); + protected void defineSynchedData() { + this.entityData.define(DATA_ID_FIREWORKS_ITEM, ItemStack.EMPTY); + this.entityData.define(DATA_ATTACHED_TO_TARGET, OptionalInt.empty()); @@ -131,7 +_,7 @@ - HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); - if (!this.f_19794_) { -- this.m_6532_(hitresult); + HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); + if (!this.noPhysics) { +- this.onHit(hitresult); + this.preOnHit(hitresult); // CraftBukkit - projectile hit event - this.f_19812_ = true; + this.hasImpulse = true; } @@ -146,9 +_,20 @@ } - if (!this.f_19853_.f_46443_ && this.f_37022_ > this.f_37023_) { -- this.m_37080_(); + if (!this.level.isClientSide && this.life > this.lifetime) { +- this.explode(); - } - + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.m_37080_(); ++ this.explode(); + } + // CraftBukkit end + } @@ -48,45 +48,45 @@ + } + + @Override -+ protected void m_6532_(HitResult result) { -+ if (result.m_6662_() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, result)) { -+ super.m_6532_(result); ++ protected void onHit(HitResult result) { ++ if (result.getType() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, result)) { ++ super.onHit(result); + } } - private void m_37080_() { + private void explode() { @@ -161,7 +_,11 @@ - protected void m_5790_(EntityHitResult p_37071_) { - super.m_5790_(p_37071_); - if (!this.f_19853_.f_46443_) { -- this.m_37080_(); + protected void onHitEntity(EntityHitResult p_37071_) { + super.onHitEntity(p_37071_); + if (!this.level.isClientSide) { +- this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.m_37080_(); ++ this.explode(); + } + // CraftBukkit end } } @@ -169,7 +_,11 @@ - BlockPos blockpos = new BlockPos(p_37069_.m_82425_()); - this.f_19853_.m_8055_(blockpos).m_60682_(this.f_19853_, blockpos, this); - if (!this.f_19853_.m_5776_() && this.m_37086_()) { -- this.m_37080_(); + BlockPos blockpos = new BlockPos(p_37069_.getBlockPos()); + this.level.getBlockState(blockpos).entityInside(this.level, blockpos, this); + if (!this.level.isClientSide() && this.hasExplosion()) { +- this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.m_37080_(); ++ this.explode(); + } + // CraftBukkit end } - super.m_8060_(p_37069_); + super.onHitBlock(p_37069_); @@ -193,7 +_,9 @@ if (f > 0.0F) { - if (this.f_37024_ != null) { + if (this.attachedToEntity != null) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = this; // CraftBukkit - this.f_37024_.m_6469_(DamageSource.m_19352_(this, this.m_37282_()), 5.0F + (float)(listtag.size() * 2)); + this.attachedToEntity.hurt(DamageSource.fireworks(this, this.getOwner()), 5.0F + (float)(listtag.size() * 2)); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; // CraftBukkit } @@ -94,9 +94,9 @@ @@ -214,7 +_,9 @@ if (flag) { - float f1 = f * (float)Math.sqrt((5.0D - (double)this.m_20270_(livingentity)) / 5.0D); + float f1 = f * (float)Math.sqrt((5.0D - (double)this.distanceTo(livingentity)) / 5.0D); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = this; // CraftBukkit - livingentity.m_6469_(DamageSource.m_19352_(this, this.m_37282_()), f1); + livingentity.hurt(DamageSource.fireworks(this, this.getOwner()), f1); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; // CraftBukkit } } 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 f4874cb9..155bb01a 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java @@ -64,11 +_,21 @@ - private final int f_37096_; - private final int f_37097_; + private final int luck; + private final int lureSpeed; + // CraftBukkit start - Extra variables to enable modification of fishing wait time, values are minecraft defaults + public int minWaitTime = 100; @@ -12,9 +12,9 @@ + private FishingHook(EntityType p_150141_, Level p_150142_, int p_150143_, int p_150144_) { super(p_150141_, p_150142_); - this.f_19811_ = true; - this.f_37096_ = Math.max(0, p_150143_); - this.f_37097_ = Math.max(0, p_150144_); + this.noCulling = true; + this.luck = Math.max(0, p_150143_); + this.lureSpeed = Math.max(0, p_150144_); + // Paper start + minWaitTime = p_150142_.paperConfig.fishingMinTicks; + maxWaitTime = p_150142_.paperConfig.fishingMaxTicks; @@ -24,139 +24,139 @@ public FishingHook(EntityType p_150138_, Level p_150139_) { @@ -240,7 +_,7 @@ - private void m_37171_() { - HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); -- this.m_6532_(hitresult); -+ if (hitresult.m_6662_() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) this.preOnHit(hitresult); // CraftBukkit - projectile hit event + private void checkCollision() { + HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); +- this.onHit(hitresult); ++ if (hitresult.getType() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) this.preOnHit(hitresult); // CraftBukkit - projectile hit event } - protected boolean m_5603_(Entity p_37135_) { + protected boolean canHitEntity(Entity p_37135_) { @@ -283,6 +_,13 @@ - this.f_37090_ = 0; - this.f_37091_ = 0; - this.m_20088_().m_135381_(f_37102_, false); + this.timeUntilLured = 0; + this.timeUntilHooked = 0; + this.getEntityData().set(DATA_BITING, false); + // CraftBukkit start -+ Player playerOwner = this.m_37168_(); ++ Player playerOwner = this.getPlayerOwner(); + if (playerOwner != null) { + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) playerOwner.getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.FAILED_ATTEMPT); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + } + // CraftBukkit end } - } else if (this.f_37091_ > 0) { - this.f_37091_ -= i; + } else if (this.timeUntilHooked > 0) { + this.timeUntilHooked -= i; @@ -295,7 +_,7 @@ - double d1 = (double)((float)Mth.m_14107_(this.m_20186_()) + 1.0F); - double d2 = this.m_20189_() + (double)(f2 * (float)this.f_37091_ * 0.1F); - BlockState blockstate = serverlevel.m_8055_(new BlockPos(d0, d1 - 1.0D, d2)); -- if (blockstate.m_60713_(Blocks.f_49990_)) { -+ if (serverlevel.m_8055_(new BlockPos((int)d0, (int)d1 - 1, (int)d2)).m_60767_() == net.minecraft.world.level.material.Material.f_76305_) { - if (this.f_19796_.nextFloat() < 0.15F) { - serverlevel.m_8767_(ParticleTypes.f_123795_, d0, d1 - (double)0.1F, d2, 1, (double)f1, 0.1D, (double)f2, 0.0D); + double d1 = (double)((float)Mth.floor(this.getY()) + 1.0F); + double d2 = this.getZ() + (double)(f2 * (float)this.timeUntilHooked * 0.1F); + BlockState blockstate = serverlevel.getBlockState(new BlockPos(d0, d1 - 1.0D, d2)); +- if (blockstate.is(Blocks.WATER)) { ++ if (serverlevel.getBlockState(new BlockPos((int)d0, (int)d1 - 1, (int)d2)).getMaterial() == net.minecraft.world.level.material.Material.WATER) { + if (this.random.nextFloat() < 0.15F) { + serverlevel.sendParticles(ParticleTypes.BUBBLE, d0, d1 - (double)0.1F, d2, 1, (double)f1, 0.1D, (double)f2, 0.0D); } @@ -306,6 +_,16 @@ - serverlevel.m_8767_(ParticleTypes.f_123816_, d0, d1, d2, 0, (double)(-f4), 0.01D, (double)f3, 1.0D); + serverlevel.sendParticles(ParticleTypes.FISHING, d0, d1, d2, 0, (double)(-f4), 0.01D, (double)f3, 1.0D); } } else { + // CraftBukkit start -+ Player playerOwner = this.m_37168_(); ++ Player playerOwner = this.getPlayerOwner(); + if (playerOwner != null) { + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) playerOwner.getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.BITE); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return; + } + } + // CraftBukkit end - this.m_5496_(SoundEvents.f_11940_, 0.25F, 1.0F + (this.f_19796_.nextFloat() - this.f_19796_.nextFloat()) * 0.4F); - double d3 = this.m_20186_() + 0.5D; - serverlevel.m_8767_(ParticleTypes.f_123795_, this.m_20185_(), d3, this.m_20189_(), (int)(1.0F + this.m_20205_() * 20.0F), (double)this.m_20205_(), 0.0D, (double)this.m_20205_(), (double)0.2F); + this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + double d3 = this.getY() + 0.5D; + serverlevel.sendParticles(ParticleTypes.BUBBLE, this.getX(), d3, this.getZ(), (int)(1.0F + this.getBbWidth() * 20.0F), (double)this.getBbWidth(), 0.0D, (double)this.getBbWidth(), (double)0.2F); @@ -331,7 +_,7 @@ - double d5 = (double)((float)Mth.m_14107_(this.m_20186_()) + 1.0F); - double d6 = this.m_20189_() + (double)(Mth.m_14089_(f6) * f7) * 0.1D; - BlockState blockstate1 = serverlevel.m_8055_(new BlockPos(d4, d5 - 1.0D, d6)); -- if (blockstate1.m_60713_(Blocks.f_49990_)) { -+ if (serverlevel.m_8055_(new BlockPos(d4, d5 - 1.0D, d6)).m_60767_() == net.minecraft.world.level.material.Material.f_76305_) { - serverlevel.m_8767_(ParticleTypes.f_123769_, d4, d5, d6, 2 + this.f_19796_.nextInt(2), (double)0.1F, 0.0D, (double)0.1F, 0.0D); + double d5 = (double)((float)Mth.floor(this.getY()) + 1.0F); + double d6 = this.getZ() + (double)(Mth.cos(f6) * f7) * 0.1D; + BlockState blockstate1 = serverlevel.getBlockState(new BlockPos(d4, d5 - 1.0D, d6)); +- if (blockstate1.is(Blocks.WATER)) { ++ if (serverlevel.getBlockState(new BlockPos(d4, d5 - 1.0D, d6)).getMaterial() == net.minecraft.world.level.material.Material.WATER) { + serverlevel.sendParticles(ParticleTypes.SPLASH, d4, d5, d6, 2 + this.random.nextInt(2), (double)0.1F, 0.0D, (double)0.1F, 0.0D); } } @@ -341,8 +_,10 @@ - this.f_37091_ = Mth.m_14072_(this.f_19796_, 20, 80); + this.timeUntilHooked = Mth.nextInt(this.random, 20, 80); } } else { -- this.f_37090_ = Mth.m_14072_(this.f_19796_, 100, 600); -- this.f_37090_ -= this.f_37097_ * 20 * 5; +- this.timeUntilLured = Mth.nextInt(this.random, 100, 600); +- this.timeUntilLured -= this.lureSpeed * 20 * 5; + // CraftBukkit start - logic to modify fishing wait time -+ this.f_37090_ = Mth.m_14072_(this.f_19796_, this.minWaitTime, this.maxWaitTime); -+ this.f_37090_ -= (this.applyLure) ? (this.f_37097_ * 20 * 5 >= this.maxWaitTime ? this.f_37090_ - 1 : this.f_37097_ * 20 * 5) : 0; // Paper - Fix Lure infinite loop ++ this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime); ++ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed * 20 * 5 >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed * 20 * 5) : 0; // Paper - Fix Lure infinite loop + // CraftBukkit end } } @@ -402,26 +_,55 @@ - Player player = this.m_37168_(); - if (!this.f_19853_.f_46443_ && player != null && !this.m_37136_(player)) { + Player player = this.getPlayerOwner(); + if (!this.level.isClientSide && player != null && !this.shouldStopFishing(player)) { int i = 0; + net.minecraftforge.event.entity.player.ItemFishedEvent event = null; - if (this.f_37094_ != null) { + if (this.hookedIn != null) { + // CraftBukkit start -+ org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.f_37094_.getBukkitEntity(), (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.CAUGHT_ENTITY); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.CAUGHT_ENTITY); ++ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; + } + // CraftBukkit end - this.m_150155_(this.f_37094_); - CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, Collections.emptyList()); - this.f_19853_.m_7605_(this, (byte)31); - i = this.f_37094_ instanceof ItemEntity ? 3 : 5; - } else if (this.f_37089_ > 0) { - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_19853_)).m_78972_(LootContextParams.f_81460_, this.m_20182_()).m_78972_(LootContextParams.f_81463_, p_37157_).m_78972_(LootContextParams.f_81455_, this).m_78977_(this.f_19796_).m_78963_((float)this.f_37096_ + player.m_36336_()); -+ lootcontext$builder.m_78972_(LootContextParams.f_81458_, this.m_37282_()).m_78972_(LootContextParams.f_81455_, this); - LootTable loottable = this.f_19853_.m_142572_().m_129898_().m_79217_(BuiltInLootTables.f_78720_); - List list = loottable.m_79129_(lootcontext$builder.m_78975_(LootContextParamSets.f_81414_)); -+ event = new net.minecraftforge.event.entity.player.ItemFishedEvent(list, this.f_19861_ ? 2 : 1, this); + this.pullEntity(this.hookedIn); + CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); + this.level.broadcastEntityEvent(this, (byte)31); + i = this.hookedIn instanceof ItemEntity ? 3 : 5; + } else if (this.nibble > 0) { + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, p_37157_).withParameter(LootContextParams.THIS_ENTITY, this).withRandom(this.random).withLuck((float)this.luck + player.getLuck()); ++ lootcontext$builder.withParameter(LootContextParams.KILLER_ENTITY, this.getOwner()).withParameter(LootContextParams.THIS_ENTITY, this); + LootTable loottable = this.level.getServer().getLootTables().get(BuiltInLootTables.FISHING); + List list = loottable.getRandomItems(lootcontext$builder.create(LootContextParamSets.FISHING)); ++ event = new net.minecraftforge.event.entity.player.ItemFishedEvent(list, this.onGround ? 2 : 1, this); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) { -+ this.m_146870_(); ++ this.discard(); + return event.getRodDamage(); + } - CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, list); + CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, list); for(ItemStack itemstack : list) { - ItemEntity itementity = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_(), this.m_20189_(), itemstack); + ItemEntity itementity = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), itemstack); + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), player.getBukkitEntity(), (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.CAUGHT_FISH); -+ playerFishEvent.setExpToDrop(this.f_19796_.nextInt(6) + 1); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); ++ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; + } + // CraftBukkit end - double d0 = player.m_20185_() - this.m_20185_(); - double d1 = player.m_20186_() - this.m_20186_(); - double d2 = player.m_20189_() - this.m_20189_(); + double d0 = player.getX() - this.getX(); + double d1 = player.getY() - this.getY(); + double d2 = player.getZ() - this.getZ(); double d3 = 0.1D; - itementity.m_20334_(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); - this.f_19853_.m_7967_(itementity); -- player.f_19853_.m_7967_(new ExperienceOrb(player.f_19853_, player.m_20185_(), player.m_20186_() + 0.5D, player.m_20189_() + 0.5D, this.f_19796_.nextInt(6) + 1)); + itementity.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); + this.level.addFreshEntity(itementity); +- player.level.addFreshEntity(new ExperienceOrb(player.level, player.getX(), player.getY() + 0.5D, player.getZ() + 0.5D, this.random.nextInt(6) + 1)); + // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop() + if (playerFishEvent.getExpToDrop() > 0) { -+ player.f_19853_.m_7967_(new ExperienceOrb(player.f_19853_, player.m_20185_(), player.m_20186_() + 0.5D, player.m_20189_() + 0.5D, playerFishEvent.getExpToDrop())); ++ player.level.addFreshEntity(new ExperienceOrb(player.level, player.getX(), player.getY() + 0.5D, player.getZ() + 0.5D, playerFishEvent.getExpToDrop())); + } + // CraftBukkit end - if (itemstack.m_204117_(ItemTags.f_13156_)) { - player.m_36222_(Stats.f_12939_, 1); + if (itemstack.is(ItemTags.FISHES)) { + player.awardStat(Stats.FISH_CAUGHT, 1); } @@ -431,11 +_,29 @@ } - if (this.f_19861_) { + if (this.onGround) { + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.IN_GROUND); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; @@ -168,14 +168,14 @@ + // CraftBukkit start + if (i == 0) { + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.REEL_IN); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return 0; + } + } + // CraftBukkit end + - this.m_146870_(); + this.discard(); - return i; + return event == null ? i : event.getRodDamage(); } else { 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 d1ac6e27..8774efc7 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -4,40 +4,40 @@ public LargeFireball(EntityType p_37199_, Level p_37200_) { super(p_37199_, p_37200_); -+ isIncendiary = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); // CraftBukkit ++ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } public LargeFireball(Level p_181151_, LivingEntity p_181152_, double p_181153_, double p_181154_, double p_181155_, int p_181156_) { - super(EntityType.f_20463_, p_181152_, p_181153_, p_181154_, p_181155_, p_181151_); - this.f_37197_ = p_181156_; -+ isIncendiary = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); // CraftBukkit + super(EntityType.FIREBALL, p_181152_, p_181153_, p_181154_, p_181155_, p_181151_); + this.explosionPower = p_181156_; ++ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } - protected void m_6532_(HitResult p_37218_) { - super.m_6532_(p_37218_); - if (!this.f_19853_.f_46443_) { -- boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); -- this.f_19853_.m_46518_((Entity)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_37197_, flag, flag ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE); -+ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this.m_37282_()); + protected void onHit(HitResult p_37218_) { + super.onHit(p_37218_); + if (!this.level.isClientSide) { +- boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); +- this.level.explode((Entity)null, this.getX(), this.getY(), this.getZ(), (float)this.explosionPower, flag, flag ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE); ++ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this.getOwner()); + // CraftBukkit start - fire ExplosionPrimeEvent + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage -+ this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), event.getRadius(), event.getFire(), flag ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), flag ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE); + } + // CraftBukkit end - this.m_146870_(); + this.discard(); } @@ -54,7 +_,8 @@ - public void m_7378_(CompoundTag p_37220_) { - super.m_7378_(p_37220_); - if (p_37220_.m_128425_("ExplosionPower", 99)) { -- this.f_37197_ = p_37220_.m_128445_("ExplosionPower"); + public void readAdditionalSaveData(CompoundTag p_37220_) { + super.readAdditionalSaveData(p_37220_); + if (p_37220_.contains("ExplosionPower", 99)) { +- this.explosionPower = p_37220_.getByte("ExplosionPower"); + // CraftBukkit - set bukkitYield when setting explosionpower -+ bukkitYield = this.f_37197_ = p_37220_.m_128445_("ExplosionPower"); ++ bukkitYield = this.explosionPower = p_37220_.getByte("ExplosionPower"); } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch index 34fa319c..48f3c861 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LlamaSpit.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/projectile/LlamaSpit.java +++ b/net/minecraft/world/entity/projectile/LlamaSpit.java @@ -30,7 +_,8 @@ - super.m_8119_(); - Vec3 vec3 = this.m_20184_(); - HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); -- this.m_6532_(hitresult); -+ if (hitresult.m_6662_() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) + super.tick(); + Vec3 vec3 = this.getDeltaMovement(); + HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); +- this.onHit(hitresult); ++ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) + this.preOnHit(hitresult); // CraftBukkit - projectile hit event - double d0 = this.m_20185_() + vec3.f_82479_; - double d1 = this.m_20186_() + vec3.f_82480_; - double d2 = this.m_20189_() + vec3.f_82481_; + double d0 = this.getX() + vec3.x; + double d1 = this.getY() + vec3.y; + double d2 = this.getZ() + vec3.z; 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 80dfcb96..6711ce06 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java @@ -29,6 +_,10 @@ - private boolean f_37246_; - private boolean f_150164_; + private boolean leftOwner; + private boolean hasBeenShot; + // CraftBukkit start + private boolean hitCancelled = false; @@ -12,47 +12,47 @@ super(p_37248_, p_37249_); } @@ -38,6 +_,7 @@ - this.f_37244_ = p_37263_.m_142081_(); - this.f_150163_ = p_37263_; + this.ownerUUID = p_37263_.getUUID(); + this.cachedOwner = p_37263_; } + this.projectileSource = (p_37263_ != null && p_37263_.getBukkitEntity() instanceof org.bukkit.projectiles.ProjectileSource) ? (org.bukkit.projectiles.ProjectileSource) p_37263_.getBukkitEntity() : null; // CraftBukkit } @@ -129,6 +_,16 @@ - this.m_20256_(this.m_20184_().m_82520_(vec3.f_82479_, p_37252_.m_20096_() ? 0.0D : vec3.f_82480_, vec3.f_82481_)); + this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, p_37252_.isOnGround() ? 0.0D : vec3.y, vec3.z)); } + // CraftBukkit start - call projectile hit event + protected void preOnHit(HitResult movingobjectposition) { + org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); + this.hitCancelled = event != null && event.isCancelled(); -+ if (movingobjectposition.m_6662_() == HitResult.Type.BLOCK || !this.hitCancelled) { -+ this.m_6532_(movingobjectposition); ++ if (movingobjectposition.getType() == HitResult.Type.BLOCK || !this.hitCancelled) { ++ this.onHit(movingobjectposition); + } + } + // CraftBukkit end + - protected void m_6532_(HitResult p_37260_) { - HitResult.Type hitresult$type = p_37260_.m_6662_(); + protected void onHit(HitResult p_37260_) { + HitResult.Type hitresult$type = p_37260_.getType(); if (hitresult$type == HitResult.Type.ENTITY) { @@ -152,6 +_,11 @@ } - public void m_6001_(double p_37279_, double p_37280_, double p_37281_) { + public void lerpMotion(double p_37279_, double p_37280_, double p_37281_) { + // CraftBukkit start - cancellable hit event + if (hitCancelled) { + return; + } + // CraftBukkit end - this.m_20334_(p_37279_, p_37280_, p_37281_); - if (this.f_19860_ == 0.0F && this.f_19859_ == 0.0F) { + this.setDeltaMovement(p_37279_, p_37280_, p_37281_); + if (this.xRotO == 0.0F && this.yRotO == 0.0F) { double d0 = Math.sqrt(p_37279_ * p_37279_ + p_37281_ * p_37281_); @@ -211,7 +_,7 @@ if (entity instanceof Player) { - return entity.m_142265_(p_150167_, p_150168_); + return entity.mayInteract(p_150167_, p_150168_); } else { -- return entity == null || p_150167_.m_46469_().m_46207_(GameRules.f_46132_); +- return entity == null || p_150167_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + return entity == null || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_150167_, entity); } } 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 ce834c7c..8e0c915b 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/projectile/ProjectileUtil.java @@ -57,7 +_,7 @@ Vec3 vec31 = optional.get(); - double d1 = p_37289_.m_82557_(vec31); + double d1 = p_37289_.distanceToSqr(vec31); if (d1 < d0 || d0 == 0.0D) { -- if (entity1.m_20201_() == p_37288_.m_20201_()) { -+ if (entity1.m_20201_() == p_37288_.m_20201_() && !entity1.canRiderInteract()) { +- if (entity1.getRootVehicle() == p_37288_.getRootVehicle()) { ++ if (entity1.getRootVehicle() == p_37288_.getRootVehicle() && !entity1.canRiderInteract()) { if (d0 == 0.0D) { entity = entity1; vec3 = vec31; @@ -14,12 +14,12 @@ } + @Deprecated // Forge: Use the version below that takes in a Predicate instead of an Item - public static InteractionHand m_37297_(LivingEntity p_37298_, Item p_37299_) { - return p_37298_.m_21205_().m_150930_(p_37299_) ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; + public static InteractionHand getWeaponHoldingHand(LivingEntity p_37298_, Item p_37299_) { + return p_37298_.getMainHandItem().is(p_37299_) ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; + } + + public static InteractionHand getWeaponHoldingHand(LivingEntity livingEntity, Predicate itemPredicate) { -+ return itemPredicate.test(livingEntity.m_21205_().m_41720_()) ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; ++ return itemPredicate.test(livingEntity.getMainHandItem().getItem()) ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; } - public static AbstractArrow m_37300_(LivingEntity p_37301_, ItemStack p_37302_, float p_37303_) { + public static AbstractArrow getMobArrow(LivingEntity p_37301_, ItemStack p_37302_, float p_37303_) { 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 bb6710d9..8e3e7215 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,57 +1,57 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java @@ -57,7 +_,20 @@ - this.f_37312_ = p_37332_; - this.f_37313_ = Direction.UP; - this.m_37348_(p_37333_); + this.finalTarget = p_37332_; + this.currentMoveDirection = Direction.UP; + this.selectNextMoveDirection(p_37333_); - } + projectileSource = (org.bukkit.entity.LivingEntity) p_37331_.getBukkitEntity(); // CraftBukkit + } + + // CraftBukkit start + public Entity getTarget() { -+ return this.f_37312_; ++ return this.finalTarget; + } + + public void setTarget(Entity e) { -+ this.f_37312_ = e; -+ this.f_37313_ = Direction.UP; -+ this.m_37348_(Direction.Axis.X); ++ this.finalTarget = e; ++ this.currentMoveDirection = Direction.UP; ++ this.selectNextMoveDirection(Direction.Axis.X); + } + // CraftBukkit end - public SoundSource m_5720_() { + public SoundSource getSoundSource() { return SoundSource.HOSTILE; @@ -211,8 +_,8 @@ } - HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); -- if (hitresult.m_6662_() != HitResult.Type.MISS) { -- this.m_6532_(hitresult); -+ if (hitresult.m_6662_() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); +- if (hitresult.getType() != HitResult.Type.MISS) { +- this.onHit(hitresult); ++ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.preOnHit(hitresult); // CraftBukkit - projectile hit event } } @@ -271,7 +_,8 @@ if (flag) { - this.m_19970_(livingentity, entity); + this.doEnchantDamageEffects(livingentity, entity); if (entity instanceof LivingEntity) { -- ((LivingEntity)entity).m_147207_(new MobEffectInstance(MobEffects.f_19620_, 200), MoreObjects.firstNonNull(entity1, this)); +- ((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), MoreObjects.firstNonNull(entity1, this)); + ((LivingEntity)entity).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ ((LivingEntity)entity).m_147207_(new MobEffectInstance(MobEffects.f_19620_, 200), MoreObjects.firstNonNull(entity1, this)); // CraftBukkit ++ ((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), MoreObjects.firstNonNull(entity1, this)); // CraftBukkit } } @@ -293,6 +_,11 @@ } - public boolean m_6469_(DamageSource p_37338_, float p_37339_) { + public boolean hurt(DamageSource p_37338_, float p_37339_) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_37338_, p_37339_, false)) { + return false; + } + // CraftBukkit end - if (!this.f_19853_.f_46443_) { - this.m_5496_(SoundEvents.f_12411_, 1.0F, 1.0F); - ((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123797_, this.m_20185_(), this.m_20186_(), this.m_20189_(), 15, 0.2D, 0.2D, 0.2D, 0.0D); + if (!this.level.isClientSide) { + this.playSound(SoundEvents.SHULKER_BULLET_HURT, 1.0F, 1.0F); + ((ServerLevel)this.level).sendParticles(ParticleTypes.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); 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 0fe458a1..9ec39d15 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch @@ -3,40 +3,40 @@ @@ -24,6 +_,11 @@ public SmallFireball(Level p_37367_, double p_37368_, double p_37369_, double p_37370_, double p_37371_, double p_37372_, double p_37373_) { - super(EntityType.f_20527_, p_37368_, p_37369_, p_37370_, p_37371_, p_37372_, p_37373_, p_37367_); + super(EntityType.SMALL_FIREBALL, p_37368_, p_37369_, p_37370_, p_37371_, p_37372_, p_37373_, p_37367_); + // CraftBukkit start -+ if (this.m_37282_() != null && this.m_37282_() instanceof Mob) { -+ isIncendiary = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); ++ if (this.getOwner() != null && this.getOwner() instanceof Mob) { ++ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + } + // CraftBukkit end } - protected void m_5790_(EntityHitResult p_37386_) { + protected void onHitEntity(EntityHitResult p_37386_) { @@ -33,7 +_,14 @@ - if (!entity.m_5825_()) { - Entity entity1 = this.m_37282_(); - int i = entity.m_20094_(); -- entity.m_20254_(5); + if (!entity.fireImmune()) { + Entity entity1 = this.getOwner(); + int i = entity.getRemainingFireTicks(); +- entity.setSecondsOnFire(5); + // CraftBukkit start - Entity damage by entity event + combust event + org.bukkit.event.entity.EntityCombustByEntityEvent event = new org.bukkit.event.entity.EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); -+ entity.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ entity.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.setSecondsOnFire(event.getDuration(), false); + } + // CraftBukkit end - boolean flag = entity.m_6469_(DamageSource.m_19349_(this, entity1), 5.0F); + boolean flag = entity.hurt(DamageSource.fireball(this, entity1), 5.0F); if (!flag) { - entity.m_7311_(i); + entity.setRemainingFireTicks(i); @@ -49,9 +_,9 @@ - super.m_8060_(p_37384_); - if (!this.f_19853_.f_46443_) { - Entity entity = this.m_37282_(); -- if (!(entity instanceof Mob) || this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this)) { - BlockPos blockpos = p_37384_.m_82425_().m_142300_(p_37384_.m_82434_()); -- if (this.f_19853_.m_46859_(blockpos)) { -+ if (this.f_19853_.m_46859_(blockpos) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(f_19853_, blockpos, this).isCancelled()) { // CraftBukkit - this.f_19853_.m_46597_(blockpos, BaseFireBlock.m_49245_(this.f_19853_, blockpos)); + super.onHitBlock(p_37384_); + if (!this.level.isClientSide) { + 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, this)) { + BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection()); +- if (this.level.isEmptyBlock(blockpos)) { ++ if (this.level.isEmptyBlock(blockpos) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, this).isCancelled()) { // CraftBukkit + this.level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level, blockpos)); } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/SpectralArrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/SpectralArrow.java.patch index f87c16d0..63926e6b 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/SpectralArrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/SpectralArrow.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/projectile/SpectralArrow.java +++ b/net/minecraft/world/entity/projectile/SpectralArrow.java @@ -40,7 +_,8 @@ - protected void m_7761_(LivingEntity p_37422_) { - super.m_7761_(p_37422_); - MobEffectInstance mobeffectinstance = new MobEffectInstance(MobEffects.f_19619_, this.f_37409_, 0); -- p_37422_.m_147207_(mobeffectinstance, this.m_150173_()); + protected void doPostHurtEffects(LivingEntity p_37422_) { + super.doPostHurtEffects(p_37422_); + MobEffectInstance mobeffectinstance = new MobEffectInstance(MobEffects.GLOWING, this.duration, 0); +- p_37422_.addEffect(mobeffectinstance, this.getEffectSource()); + p_37422_.prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); //Magma -+ p_37422_.m_147207_(mobeffectinstance, this.m_150173_()); // CraftBukkit ++ p_37422_.addEffect(mobeffectinstance, this.getEffectSource()); // CraftBukkit } - public void m_7378_(CompoundTag p_37424_) { + public void readAdditionalSaveData(CompoundTag p_37424_) { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch index baf7d0ac..d6217145 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java @@ -29,13 +_,19 @@ - public void m_37446_(ItemStack p_37447_) { - if (!p_37447_.m_150930_(this.m_7881_()) || p_37447_.m_41782_()) { - this.m_20088_().m_135381_(f_37429_, Util.m_137469_(p_37447_.m_41777_(), (p_37451_) -> { -- p_37451_.m_41764_(1); -+ if (!p_37447_.m_41619_()) p_37447_.m_41764_(1); // CraftBukkit + public void setItem(ItemStack p_37447_) { + if (!p_37447_.is(this.getDefaultItem()) || p_37447_.hasTag()) { + this.getEntityData().set(DATA_ITEM_STACK, Util.make(p_37447_.copy(), (p_37451_) -> { +- p_37451_.setCount(1); ++ if (!p_37447_.isEmpty()) p_37447_.setCount(1); // CraftBukkit })); } } - protected abstract Item m_7881_(); + protected abstract Item getDefaultItem(); + + // CraftBukkit start + public Item getDefaultItemPublic() { -+ return m_7881_(); ++ return getDefaultItem(); + } + // CraftBukkit end - public ItemStack m_37454_() { - return this.m_20088_().m_135370_(f_37429_); + public ItemStack getItemRaw() { + return this.getEntityData().get(DATA_ITEM_STACK); 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 6f405de2..05827915 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -4,10 +4,10 @@ } } -- if (hitresult.m_6662_() != HitResult.Type.MISS && !flag) { -- this.m_6532_(hitresult); -+ if (hitresult.m_6662_() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { +- if (hitresult.getType() != HitResult.Type.MISS && !flag) { +- this.onHit(hitresult); ++ if (hitresult.getType() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.preOnHit(hitresult); // CraftBukkit - projectile hit event } - this.m_20101_(); + this.checkInsideBlocks(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEgg.java.patch index b09545cd..d580da12 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEgg.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEgg.java.patch @@ -1,43 +1,43 @@ --- a/net/minecraft/world/entity/projectile/ThrownEgg.java +++ b/net/minecraft/world/entity/projectile/ThrownEgg.java @@ -41,21 +_,31 @@ - p_37486_.m_82443_().m_6469_(DamageSource.m_19361_(this, this.m_37282_()), 0.0F); + p_37486_.getEntity().hurt(DamageSource.thrown(this, this.getOwner()), 0.0F); } + //Magma start - fix mixin inject error - protected void m_6532_(HitResult p_37488_) { - super.m_6532_(p_37488_); - if (!this.f_19853_.f_46443_) { -- if (this.f_19796_.nextInt(8) == 0) { + protected void onHit(HitResult p_37488_) { + super.onHit(p_37488_); + if (!this.level.isClientSide) { +- if (this.random.nextInt(8) == 0) { + newHatch(); + if (true) { int i = 1; - if (this.f_19796_.nextInt(32) == 0) { + if (this.random.nextInt(32) == 0) { i = 4; } - for(int j = 0; j < i; ++j) { -- Chicken chicken = EntityType.f_20555_.m_20615_(this.f_19853_); -- chicken.m_146762_(-24000); -- chicken.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), 0.0F); -- this.f_19853_.m_7967_(chicken); +- Chicken chicken = EntityType.CHICKEN.create(this.level); +- chicken.setAge(-24000); +- chicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- this.level.addFreshEntity(chicken); + i = doBukkitEvent(i); + + if (hatching) { + for (int j = 0; j < i; ++j) { -+ Chicken entity = (Chicken) f_19853_.getWorld().createEntity(new org.bukkit.Location(f_19853_.getWorld(), this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), 0.0F), hatchingType.getEntityClass()); ++ Chicken entity = (Chicken) level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); + if (entity.getBukkitEntity() instanceof org.bukkit.entity.Ageable) { + ((org.bukkit.entity.Ageable) entity.getBukkitEntity()).setBaby(); + } + -+ this.f_19853_.prepareEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); -+ this.f_19853_.m_7967_(entity); ++ this.level.prepareEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); ++ this.level.addFreshEntity(entity); + } } + // CraftBukkit end } - this.f_19853_.m_7605_(this, (byte)3); + this.level.broadcastEntityEvent(this, (byte)3); @@ -63,6 +_,30 @@ } @@ -45,7 +45,7 @@ + + private boolean hatching; + private void newHatch() { -+ this.hatching = this.f_19796_.nextInt(8) == 0; ++ this.hatching = this.random.nextInt(8) == 0; + } + + private org.bukkit.entity.EntityType hatchingType; @@ -55,10 +55,10 @@ + i = 0; + } + hatchingType = org.bukkit.entity.EntityType.CHICKEN; -+ net.minecraft.world.entity.Entity shooter = this.m_37282_(); ++ net.minecraft.world.entity.Entity shooter = this.getOwner(); + if (shooter instanceof net.minecraft.server.level.ServerPlayer) { + org.bukkit.event.player.PlayerEggThrowEvent event = new org.bukkit.event.player.PlayerEggThrowEvent((org.bukkit.entity.Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) i, hatchingType); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + i = event.getNumHatches(); + hatching = event.isHatching(); + hatchingType = event.getHatchingType(); @@ -67,5 +67,5 @@ + } + //Magma end - protected Item m_7881_() { - return Items.f_42521_; + protected Item getDefaultItem() { + return Items.EGG; 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 584ca28c..633a6e8a 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -3,22 +3,22 @@ @@ -47,20 +_,33 @@ if (entity instanceof ServerPlayer) { ServerPlayer serverplayer = (ServerPlayer)entity; - if (serverplayer.f_8906_.m_6198_().m_129536_() && serverplayer.f_19853_ == this.f_19853_ && !serverplayer.m_5803_()) { -- if (this.f_19796_.nextFloat() < 0.05F && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { -- Endermite endermite = EntityType.f_20567_.m_20615_(this.f_19853_); -- endermite.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_()); -- this.f_19853_.m_7967_(endermite); + if (serverplayer.connection.getConnection().isConnected() && serverplayer.level == this.level && !serverplayer.isSleeping()) { +- if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { +- Endermite endermite = EntityType.ENDERMITE.create(this.level); +- endermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); +- this.level.addFreshEntity(endermite); - } - -- if (entity.m_20159_()) { -- serverplayer.m_142098_(this.m_20185_(), this.m_20186_(), this.m_20189_()); +- if (entity.isPassenger()) { +- serverplayer.dismountTo(this.getX(), this.getY(), this.getZ()); - } else { -- entity.m_6021_(this.m_20185_(), this.m_20186_(), this.m_20189_()); +- entity.teleportTo(this.getX(), this.getY(), this.getZ()); - } - -- entity.m_183634_(); -- entity.m_6469_(DamageSource.f_19315_, 5.0F); -+ net.minecraftforge.event.entity.EntityTeleportEvent.EnderPearl event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayer, this.m_20185_(), this.m_20186_(), this.m_20189_(), this, 5.0F); +- entity.resetFallDistance(); +- entity.hurt(DamageSource.FALL, 5.0F); ++ net.minecraftforge.event.entity.EntityTeleportEvent.EnderPearl event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayer, this.getX(), this.getY(), this.getZ(), this, 5.0F); + if (!event.isCanceled()) { // Don't indent to lower patch size + // CraftBukkit start - Fire PlayerTeleportEvent + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer player = serverplayer.getBukkitEntity(); @@ -27,40 +27,40 @@ + location.setYaw(player.getLocation().getYaw()); + org.bukkit.event.player.PlayerTeleportEvent teleEvent = new org.bukkit.event.player.PlayerTeleportEvent(player, player.getLocation(), location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL); + org.bukkit.Bukkit.getPluginManager().callEvent(teleEvent); -+ if (!teleEvent.isCancelled() && !serverplayer.f_8906_.isDisconnected()) { -+ if (this.f_19796_.nextFloat() < 0.05F && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { -+ Endermite entityendermite = (Endermite) EntityType.f_20567_.m_20615_(this.f_19853_); -+ entityendermite.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_()); -+ this.f_19853_.prepareEntity(entityendermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); //Magma - add spawn reason -+ this.f_19853_.m_7967_(entityendermite); ++ if (!teleEvent.isCancelled() && !serverplayer.connection.isDisconnected()) { ++ if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { ++ Endermite entityendermite = (Endermite) EntityType.ENDERMITE.create(this.level); ++ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); ++ this.level.prepareEntity(entityendermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); //Magma - add spawn reason ++ this.level.addFreshEntity(entityendermite); + } -+ if (entity.m_20159_()) { -+ entity.m_8127_(); ++ if (entity.isPassenger()) { ++ entity.stopRiding(); + } -+ serverplayer.f_8906_.teleport(teleEvent.getTo()); -+ entity.m_183634_(); ++ serverplayer.connection.teleport(teleEvent.getTo()); ++ entity.resetFallDistance(); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = this; -+ entity.m_6469_(DamageSource.f_19315_, 5.0F); ++ entity.hurt(DamageSource.FALL, 5.0F); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; + } + // CraftBukkit end + } //Forge: End } } else if (entity != null) { - entity.m_6021_(this.m_20185_(), this.m_20186_(), this.m_20189_()); + entity.teleportTo(this.getX(), this.getY(), this.getZ()); @@ -83,12 +_,12 @@ } @Nullable -- public Entity m_5489_(ServerLevel p_37506_) { +- public Entity changeDimension(ServerLevel p_37506_) { + public Entity changeDimension(ServerLevel p_37506_, net.minecraftforge.common.util.ITeleporter teleporter) { - Entity entity = this.m_37282_(); -- if (entity != null && entity.f_19853_.m_46472_() != p_37506_.m_46472_()) { -+ if (entity != null && p_37506_ != null && entity.f_19853_.m_46472_() != p_37506_.m_46472_()) { // CraftBukkit - SPIGOT-6113 - this.m_5602_((Entity)null); + Entity entity = this.getOwner(); +- if (entity != null && entity.level.dimension() != p_37506_.dimension()) { ++ if (entity != null && p_37506_ != null && entity.level.dimension() != p_37506_.dimension()) { // CraftBukkit - SPIGOT-6113 + this.setOwner((Entity)null); } -- return super.m_5489_(p_37506_); +- return super.changeDimension(p_37506_); + return super.changeDimension(p_37506_, teleporter); } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch index da671a37..4f7491dc 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java +++ b/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java @@ -35,8 +_,18 @@ - protected void m_6532_(HitResult p_37521_) { - super.m_6532_(p_37521_); - if (this.f_19853_ instanceof ServerLevel) { -- this.f_19853_.m_46796_(2002, this.m_142538_(), PotionUtils.m_43559_(Potions.f_43599_)); + protected void onHit(HitResult p_37521_) { + super.onHit(p_37521_); + if (this.level instanceof ServerLevel) { +- this.level.levelEvent(2002, this.blockPosition(), PotionUtils.getColor(Potions.WATER)); + // CraftBukkit - moved to after event + // this.level.levelEvent(2002, this.blockPosition(), PotionUtils.getColor(Potions.WATER)); - int i = 3 + this.f_19853_.f_46441_.nextInt(5) + this.f_19853_.f_46441_.nextInt(5); + int i = 3 + this.level.random.nextInt(5) + this.level.random.nextInt(5); + + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callExpBottleEvent(this, i); + i = event.getExperience(); + if (event.getShowEffect()) { -+ this.f_19853_.m_46796_(2002, this.m_142538_(), PotionUtils.m_43559_(Potions.f_43599_)); ++ this.level.levelEvent(2002, this.blockPosition(), PotionUtils.getColor(Potions.WATER)); + } + // CraftBukkit end + - ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), i); - this.m_146870_(); + ExperienceOrb.award((ServerLevel)this.level, this.position(), i); + this.discard(); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch index 9c0f3344..039dbcf7 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch @@ -1,39 +1,39 @@ --- a/net/minecraft/world/entity/projectile/ThrownPotion.java +++ b/net/minecraft/world/entity/projectile/ThrownPotion.java @@ -87,7 +_,7 @@ - boolean flag = potion == Potions.f_43599_ && list.isEmpty(); + boolean flag = potion == Potions.WATER && list.isEmpty(); if (flag) { - this.m_37552_(); + this.applyWater(); - } else if (!list.isEmpty()) { + } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply - if (this.m_37553_()) { - this.m_37537_(itemstack, potion); + if (this.isLingering()) { + this.makeAreaOfEffectCloud(itemstack, potion); } else { @@ -122,10 +_,11 @@ - private void m_37547_(List p_37548_, @Nullable Entity p_37549_) { - AABB aabb = this.m_142469_().m_82377_(4.0D, 2.0D, 4.0D); - List list = this.f_19853_.m_45976_(LivingEntity.class, aabb); + private void applySplash(List p_37548_, @Nullable Entity p_37549_) { + AABB aabb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); + List list = this.level.getEntitiesOfClass(LivingEntity.class, aabb); + java.util.Map affected = new java.util.HashMap(); // CraftBukkit if (!list.isEmpty()) { - Entity entity = this.m_150173_(); + Entity entity = this.getEffectSource(); - for(LivingEntity livingentity : list) { + for (LivingEntity livingentity : list) { - if (livingentity.m_5801_()) { - double d0 = this.m_20280_(livingentity); + if (livingentity.isAffectedByPotions()) { + double d0 = this.distanceToSqr(livingentity); if (d0 < 16.0D) { @@ -134,22 +_,47 @@ d1 = 1.0D; } - for(MobEffectInstance mobeffectinstance : p_37548_) { -- MobEffect mobeffect = mobeffectinstance.m_19544_(); -- if (mobeffect.m_8093_()) { -- mobeffect.m_19461_(this, this.m_37282_(), livingentity, mobeffectinstance.m_19564_(), d1); +- MobEffect mobeffect = mobeffectinstance.getEffect(); +- if (mobeffect.isInstantenous()) { +- mobeffect.applyInstantenousEffect(this, this.getOwner(), livingentity, mobeffectinstance.getAmplifier(), d1); - } else { -- int i = (int)(d1 * (double)mobeffectinstance.m_19557_() + 0.5D); +- int i = (int)(d1 * (double)mobeffectinstance.getDuration() + 0.5D); - if (i > 20) { -- livingentity.m_147207_(new MobEffectInstance(mobeffect, i, mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()), entity); +- livingentity.addEffect(new MobEffectInstance(mobeffect, i, mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible()), entity); - } - } - } @@ -61,10 +61,10 @@ + // CraftBukkit end + + for (MobEffectInstance effectinstance : p_37548_) { -+ MobEffect effect = effectinstance.m_19544_(); ++ MobEffect effect = effectinstance.getEffect(); + // CraftBukkit start - Abide by PVP settings - for players only! -+ if (!this.f_19853_.pvpMode && this.m_37282_() instanceof net.minecraft.server.level.ServerPlayer && livingentity instanceof net.minecraft.server.level.ServerPlayer && livingentity != this.m_37282_()) { -+ int i = MobEffect.m_19459_(effect); ++ if (!this.level.pvpMode && this.getOwner() instanceof net.minecraft.server.level.ServerPlayer && livingentity instanceof net.minecraft.server.level.ServerPlayer && livingentity != this.getOwner()) { ++ int i = MobEffect.getId(effect); + // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions + if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) { + continue; @@ -72,12 +72,12 @@ + } + // CraftBukkit end + -+ if (effect.m_8093_()) { -+ effect.m_19461_(this, this.m_37282_(), livingentity, effectinstance.m_19564_(), intensity); ++ if (effect.isInstantenous()) { ++ effect.applyInstantenousEffect(this, this.getOwner(), livingentity, effectinstance.getAmplifier(), intensity); + } else { -+ int i = (int) (intensity * (double) effectinstance.m_19557_() + 0.5D); ++ int i = (int) (intensity * (double) effectinstance.getDuration() + 0.5D); + if (i > 20) { -+ livingentity.addEffect(new MobEffectInstance(effect, i, effectinstance.m_19564_(), effectinstance.m_19571_(), effectinstance.m_19572_()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit ++ livingentity.addEffect(new MobEffectInstance(effect, i, effectinstance.getAmplifier(), effectinstance.isAmbient(), effectinstance.isVisible()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit + } + } + } @@ -85,49 +85,49 @@ + } } - private void m_37537_(ItemStack p_37538_, Potion p_37539_) { + private void makeAreaOfEffectCloud(ItemStack p_37538_, Potion p_37539_) { @@ -174,7 +_,14 @@ - areaeffectcloud.m_19714_(compoundtag.m_128451_("CustomPotionColor")); + areaeffectcloud.setFixedColor(compoundtag.getInt("CustomPotionColor")); } -- this.f_19853_.m_7967_(areaeffectcloud); +- this.level.addFreshEntity(areaeffectcloud); + // CraftBukkit start + org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callLingeringPotionSplashEvent(this, areaeffectcloud); -+ if (!(event.isCancelled() || areaeffectcloud.m_146910_())) { -+ this.f_19853_.m_7967_(areaeffectcloud); ++ if (!(event.isCancelled() || areaeffectcloud.isRemoved())) { ++ this.level.addFreshEntity(areaeffectcloud); + } else { -+ areaeffectcloud.m_146870_(); ++ areaeffectcloud.discard(); + } + // CraftBukkit end } - private boolean m_37553_() { + private boolean isLingering() { @@ -184,13 +_,25 @@ - private void m_150192_(BlockPos p_150193_) { - BlockState blockstate = this.f_19853_.m_8055_(p_150193_); - if (blockstate.m_204336_(BlockTags.f_13076_)) { -- this.f_19853_.m_7471_(p_150193_, false); + private void dowseFire(BlockPos p_150193_) { + BlockState blockstate = this.level.getBlockState(p_150193_); + if (blockstate.is(BlockTags.FIRE)) { +- this.level.removeBlock(p_150193_, false); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, p_150193_, net.minecraft.world.level.block.Blocks.f_50016_.m_49966_()).isCancelled()) { -+ this.f_19853_.m_7471_(p_150193_, false); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, p_150193_, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { ++ this.level.removeBlock(p_150193_, false); + } + // CraftBukkit end - } else if (AbstractCandleBlock.m_151933_(blockstate)) { -- AbstractCandleBlock.m_151899_((Player)null, blockstate, this.f_19853_, p_150193_); + } else if (AbstractCandleBlock.isLit(blockstate)) { +- AbstractCandleBlock.extinguish((Player)null, blockstate, this.level, p_150193_); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, p_150193_, blockstate.m_61124_(AbstractCandleBlock.f_151895_, false)).isCancelled()) { -+ AbstractCandleBlock.m_151899_((Player) null, blockstate, this.f_19853_, p_150193_); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, p_150193_, blockstate.setValue(AbstractCandleBlock.LIT, false)).isCancelled()) { ++ AbstractCandleBlock.extinguish((Player) null, blockstate, this.level, p_150193_); + } + // CraftBukkit end - } else if (CampfireBlock.m_51319_(blockstate)) { -- this.f_19853_.m_5898_((Player)null, 1009, p_150193_, 0); -- CampfireBlock.m_152749_(this.m_37282_(), this.f_19853_, p_150193_, blockstate); -- this.f_19853_.m_46597_(p_150193_, blockstate.m_61124_(CampfireBlock.f_51227_, Boolean.valueOf(false))); + } else if (CampfireBlock.isLitCampfire(blockstate)) { +- this.level.levelEvent((Player)null, 1009, p_150193_, 0); +- CampfireBlock.dowse(this.getOwner(), this.level, p_150193_, blockstate); +- this.level.setBlockAndUpdate(p_150193_, blockstate.setValue(CampfireBlock.LIT, Boolean.valueOf(false))); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, p_150193_, blockstate.m_61124_(CampfireBlock.f_51227_, false)).isCancelled()) { -+ this.f_19853_.m_5898_((Player) null, 1009, p_150193_, 0); -+ CampfireBlock.m_152749_(this.m_37282_(), this.f_19853_, p_150193_, blockstate); -+ this.f_19853_.m_46597_(p_150193_, blockstate.m_61124_(CampfireBlock.f_51227_, false)); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(this, p_150193_, blockstate.setValue(CampfireBlock.LIT, false)).isCancelled()) { ++ this.level.levelEvent((Player) null, 1009, p_150193_, 0); ++ CampfireBlock.dowse(this.getOwner(), this.level, p_150193_, blockstate); ++ this.level.setBlockAndUpdate(p_150193_, blockstate.setValue(CampfireBlock.LIT, false)); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownTrident.java.patch index 3d066e7b..13898b6a 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownTrident.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownTrident.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ThrownTrident.java +++ b/net/minecraft/world/entity/projectile/ThrownTrident.java @@ -140,7 +_,7 @@ - LightningBolt lightningbolt = EntityType.f_20465_.m_20615_(this.f_19853_); - lightningbolt.m_20219_(Vec3.m_82539_(blockpos)); - lightningbolt.m_20879_(entity1 instanceof ServerPlayer ? (ServerPlayer)entity1 : null); -- this.f_19853_.m_7967_(lightningbolt); -+ ((ServerLevel) this.f_19853_).strikeLightning(lightningbolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit - soundevent = SoundEvents.f_12521_; + LightningBolt lightningbolt = EntityType.LIGHTNING_BOLT.create(this.level); + lightningbolt.moveTo(Vec3.atBottomCenterOf(blockpos)); + lightningbolt.setCause(entity1 instanceof ServerPlayer ? (ServerPlayer)entity1 : null); +- this.level.addFreshEntity(lightningbolt); ++ ((ServerLevel) this.level).strikeLightning(lightningbolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit + soundevent = SoundEvents.TRIDENT_THUNDER; f1 = 5.0F; } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch index b4ad66fb..afc147d1 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch @@ -3,44 +3,44 @@ @@ -41,7 +_,7 @@ } - public float m_7077_(Explosion p_37619_, BlockGetter p_37620_, BlockPos p_37621_, BlockState p_37622_, FluidState p_37623_, float p_37624_) { -- return this.m_37635_() && WitherBoss.m_31491_(p_37622_) ? Math.min(0.8F, p_37624_) : p_37624_; -+ return this.m_37635_() && p_37622_.canEntityDestroy(p_37620_, p_37621_, this) ? Math.min(0.8F, p_37624_) : p_37624_; + public float getBlockExplosionResistance(Explosion p_37619_, BlockGetter p_37620_, BlockPos p_37621_, BlockState p_37622_, FluidState p_37623_, float p_37624_) { +- return this.isDangerous() && WitherBoss.canDestroy(p_37622_) ? Math.min(0.8F, p_37624_) : p_37624_; ++ return this.isDangerous() && p_37622_.canEntityDestroy(p_37620_, p_37621_, this) ? Math.min(0.8F, p_37624_) : p_37624_; } - protected void m_5790_(EntityHitResult p_37626_) { + protected void onHitEntity(EntityHitResult p_37626_) { @@ -57,6 +_,7 @@ - if (entity.m_6084_()) { - this.m_19970_(livingentity, entity); + if (entity.isAlive()) { + this.doEnchantDamageEffects(livingentity, entity); } else { + livingentity.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); - livingentity.m_5634_(5.0F); + livingentity.heal(5.0F); } } @@ -73,7 +_,8 @@ } if (i > 0) { -- ((LivingEntity)entity).m_147207_(new MobEffectInstance(MobEffects.f_19615_, 20 * i, 1), this.m_150173_()); +- ((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.WITHER, 20 * i, 1), this.getEffectSource()); + ((LivingEntity)entity).prepare(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); //Magma -+ ((LivingEntity)entity).m_147207_(new MobEffectInstance(MobEffects.f_19615_, 20 * i, 1), this.m_150173_()); // CraftBukkit ++ ((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.WITHER, 20 * i, 1), this.getEffectSource()); // CraftBukkit } } @@ -83,8 +_,14 @@ - protected void m_6532_(HitResult p_37628_) { - super.m_6532_(p_37628_); - if (!this.f_19853_.f_46443_) { -- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; -- this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), 1.0F, false, explosion$blockinteraction); -+ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this.m_37282_()) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + protected void onHit(HitResult p_37628_) { + super.onHit(p_37628_); + if (!this.level.isClientSide) { +- Explosion.BlockInteraction explosion$blockinteraction = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, explosion$blockinteraction); ++ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this.getOwner()) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; + // CraftBukkit start + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), event.getRadius(), event.getFire(), explosion$blockinteraction); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion$blockinteraction); + } + // CraftBukkit end - this.m_146870_(); + this.discard(); } 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 d502676d..6d4c16d4 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,41 +1,41 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java @@ -165,6 +_,12 @@ - return this.f_37687_ == Raid.RaidStatus.LOSS; + return this.status == Raid.RaidStatus.LOSS; } + // CraftBukkit start + public boolean isInProgress() { -+ return this.f_37687_ == Raid.RaidStatus.ONGOING; ++ return this.status == Raid.RaidStatus.ONGOING; + } + // CraftBukkit end + - public float m_150220_() { - return this.f_37678_; + public float getTotalHealth() { + return this.totalHealth; } @@ -249,6 +_,7 @@ - boolean flag = this.f_37680_; - this.f_37680_ = this.f_37675_.m_46805_(this.f_37674_); - if (this.f_37675_.m_46791_() == Difficulty.PEACEFUL) { + boolean flag = this.active; + this.active = this.level.hasChunkAt(this.center); + if (this.level.getDifficulty() == Difficulty.PEACEFUL) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit - this.m_37774_(); + this.stop(); return; } @@ -268,13 +_,16 @@ - if (!this.f_37675_.m_8802_(this.f_37674_)) { - if (this.f_37681_ > 0) { - this.f_37687_ = Raid.RaidStatus.LOSS; + if (!this.level.isVillage(this.center)) { + if (this.groupsSpawned > 0) { + this.status = Raid.RaidStatus.LOSS; + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit } else { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.NOT_IN_VILLAGE); // CraftBukkit - this.m_37774_(); + this.stop(); } } - ++this.f_37673_; - if (this.f_37673_ >= 48000L) { + ++this.ticksActive; + if (this.ticksActive >= 48000L) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit - this.m_37774_(); + this.stop(); return; } @@ -345,6 +_,7 @@ @@ -43,21 +43,21 @@ if (k > 3) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit - this.m_37774_(); + this.stop(); break; } @@ -356,6 +_,7 @@ } else { - this.f_37687_ = Raid.RaidStatus.VICTORY; + this.status = Raid.RaidStatus.VICTORY; + List winners = new java.util.ArrayList<>(); // CraftBukkit - for(UUID uuid : this.f_37672_) { - Entity entity = this.f_37675_.m_8791_(uuid); - if (entity instanceof LivingEntity && !entity.m_5833_()) { + for(UUID uuid : this.heroesOfTheVillage) { + Entity entity = this.level.getEntity(uuid); + if (entity instanceof LivingEntity && !entity.isSpectator()) { @@ -365,9 +_,11 @@ ServerPlayer serverplayer = (ServerPlayer)livingentity; - serverplayer.m_36220_(Stats.f_12950_); - CriteriaTriggers.f_10557_.m_53645_(serverplayer); + serverplayer.awardStat(Stats.RAID_WIN); + CriteriaTriggers.RAID_WIN.trigger(serverplayer); + winners.add(serverplayer.getBukkitEntity()); // CraftBukkit } } @@ -67,67 +67,67 @@ } @@ -375,6 +_,7 @@ - } else if (this.m_37706_()) { - ++this.f_37688_; - if (this.f_37688_ >= 600) { + } else if (this.isOver()) { + ++this.celebrationTicks; + if (this.celebrationTicks >= 600) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit - this.m_37774_(); + this.stop(); return; } @@ -496,6 +_,10 @@ - DifficultyInstance difficultyinstance = this.f_37675_.m_6436_(p_37756_); - boolean flag1 = this.m_37702_(); + DifficultyInstance difficultyinstance = this.level.getCurrentDifficultyAt(p_37756_); + boolean flag1 = this.shouldSpawnBonusGroup(); + // CraftBukkit start + Raider leader = null; + List raiders = new java.util.ArrayList<>(); + // CraftBukkit end - for(Raid.RaiderType raid$raidertype : Raid.RaiderType.f_37813_) { - int j = this.m_37730_(raid$raidertype, i, flag1) + this.m_37734_(raid$raidertype, this.f_37685_, i, difficultyinstance, flag1); + for(Raid.RaiderType raid$raidertype : Raid.RaiderType.VALUES) { + int j = this.getDefaultNumSpawns(raid$raidertype, i, flag1) + this.getPotentialBonusSpawns(raid$raidertype, this.random, i, difficultyinstance, flag1); int k = 0; @@ -506,9 +_,11 @@ - raider.m_33075_(true); - this.m_37710_(i, raider); + raider.setPatrolLeader(true); + this.setLeader(i, raider); flag = true; + leader = raider; // CraftBukkit } - this.m_37713_(i, raider, p_37756_, false); + this.joinRaid(i, raider, p_37756_, false); + raiders.add(raider); // CraftBukkit - if (raid$raidertype.f_37814_ == EntityType.f_20518_) { + if (raid$raidertype.entityType == EntityType.RAVAGER) { Raider raider1 = null; - if (i == this.m_37724_(Difficulty.NORMAL)) { + if (i == this.getNumGroups(Difficulty.NORMAL)) { @@ -526,6 +_,7 @@ - this.m_37713_(i, raider1, p_37756_, false); - raider1.m_20035_(p_37756_, 0.0F, 0.0F); - raider1.m_20329_(raider); + this.joinRaid(i, raider1, p_37756_, false); + raider1.moveTo(p_37756_, 0.0F, 0.0F); + raider1.startRiding(raider); + raiders.add(raider); // CraftBukkit } } } @@ -535,6 +_,7 @@ - ++this.f_37681_; - this.m_37776_(); - this.m_37705_(); + ++this.groupsSpawned; + this.updateBossbar(); + this.setDirty(); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit } - public void m_37713_(int p_37714_, Raider p_37715_, @Nullable BlockPos p_37716_, boolean p_37717_) { + public void joinRaid(int p_37714_, Raider p_37715_, @Nullable BlockPos p_37716_, boolean p_37717_) { @@ -549,6 +_,7 @@ - p_37715_.m_6518_(this.f_37675_, this.f_37675_.m_6436_(p_37716_), MobSpawnType.EVENT, (SpawnGroupData)null, (CompoundTag)null); - p_37715_.m_7895_(p_37714_, false); - p_37715_.m_6853_(true); -+ this.f_37675_.prepareEntity(p_37715_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); //Magma - add spawn reason - this.f_37675_.m_47205_(p_37715_); + p_37715_.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(p_37716_), MobSpawnType.EVENT, (SpawnGroupData)null, (CompoundTag)null); + p_37715_.applyRaidBuffs(p_37714_, false); + p_37715_.setOnGround(true); ++ this.level.prepareEntity(p_37715_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); //Magma - add spawn reason + this.level.addFreshEntityWithPassengers(p_37715_); } } @@ -789,6 +_,12 @@ - this.f_37672_.add(p_37727_.m_142081_()); + this.heroesOfTheVillage.add(p_37727_.getUUID()); } + // CraftBukkit start - a method to get all raiders + public java.util.Collection getRaiders() { -+ return this.f_37671_.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); ++ return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); + } + // CraftBukkit end + @@ -140,13 +140,13 @@ - static enum RaiderType { + public static enum RaiderType implements net.minecraftforge.common.IExtensibleEnum { - VINDICATOR(EntityType.f_20493_, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), - EVOKER(EntityType.f_20568_, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), - PILLAGER(EntityType.f_20513_, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), + 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}), @@ -826,6 +_,20 @@ private RaiderType(EntityType p_37821_, int[] p_37822_) { - this.f_37814_ = p_37821_; - this.f_37815_ = p_37822_; + this.entityType = p_37821_; + this.spawnsPerWaveBeforeBonus = p_37822_; + } + + /** @@ -160,7 +160,7 @@ + @Override + @Deprecated + public void init() { -+ f_37813_ = values(); ++ VALUES = values(); } } } diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raider.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raider.java.patch index 67e36c1e..2165d6e3 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raider.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raider.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/world/entity/raid/Raider.java +++ b/net/minecraft/world/entity/raid/Raider.java @@ -149,7 +_,7 @@ - i = Mth.m_14045_(i, 0, 4); - MobEffectInstance mobeffectinstance = new MobEffectInstance(MobEffects.f_19594_, 120000, i, false, false, true); - if (!this.f_19853_.m_46469_().m_46207_(GameRules.f_46154_)) { -- player.m_7292_(mobeffectinstance); + i = Mth.clamp(i, 0, 4); + MobEffectInstance mobeffectinstance = new MobEffectInstance(MobEffects.BAD_OMEN, 120000, i, false, false, true); + if (!this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { +- player.addEffect(mobeffectinstance); + player.addEffect(mobeffectinstance, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit } } } @@ -296,7 +_,7 @@ - this.f_37903_.m_21573_().m_26573_(); + this.mob.getNavigation().stop(); - for(Raider raider : this.f_37903_.f_19853_.m_45971_(Raider.class, this.f_37901_, this.f_37903_, this.f_37903_.m_142469_().m_82377_(8.0D, 8.0D, 8.0D))) { -- raider.m_6710_(this.f_37903_.m_5448_()); -+ raider.setTarget(this.f_37903_.m_5448_(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit + for(Raider raider : this.mob.level.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D))) { +- raider.setTarget(this.mob.getTarget()); ++ raider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit } } @@ -306,7 +_,7 @@ - LivingEntity livingentity = this.f_37903_.m_5448_(); + LivingEntity livingentity = this.mob.getTarget(); if (livingentity != null) { - for(Raider raider : this.f_37903_.f_19853_.m_45971_(Raider.class, this.f_37901_, this.f_37903_, this.f_37903_.m_142469_().m_82377_(8.0D, 8.0D, 8.0D))) { -- raider.m_6710_(livingentity); + for(Raider raider : this.mob.level.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D))) { +- raider.setTarget(livingentity); + raider.setTarget(livingentity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit - raider.m_21561_(true); + raider.setAggressive(true); } diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raids.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raids.java.patch index 1e0942d3..80b5ecb1 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raids.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raids.java.patch @@ -1,39 +1,37 @@ --- a/net/minecraft/world/entity/raid/Raids.java +++ b/net/minecraft/world/entity/raid/Raids.java @@ -108,19 +_,33 @@ - Raid raid = this.m_37960_(p_37964_.m_183503_(), blockpos1); + Raid raid = this.getOrCreateRaid(p_37964_.getLevel(), blockpos1); boolean flag = false; - if (!raid.m_37770_()) { -- if (!this.f_37951_.containsKey(raid.m_37781_())) { -- this.f_37951_.put(raid.m_37781_(), raid); + if (!raid.isStarted()) { + /* CraftBukkit - moved down -+ if (!this.raidMap.containsKey(raid.getId())) { -+ this.raidMap.put(raid.getId(), raid); + if (!this.raidMap.containsKey(raid.getId())) { + this.raidMap.put(raid.getId(), raid); } + */ flag = true; -- } else if (raid.m_37773_() < raid.m_37772_()) { +- } else if (raid.getBadOmenLevel() < raid.getMaxBadOmenLevel()) { + // CraftBukkit start - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished -+ } else if (raid.isInProgress() && raid.m_37773_() < raid.m_37772_()) { ++ } else if (raid.isInProgress() && raid.getBadOmenLevel() < raid.getMaxBadOmenLevel()) { flag = true; + // CraftBukkit end } else { - p_37964_.m_21195_(MobEffects.f_19594_); - p_37964_.f_8906_.m_141995_(new ClientboundEntityEventPacket(p_37964_, (byte)43)); + p_37964_.removeEffect(MobEffects.BAD_OMEN); + p_37964_.connection.send(new ClientboundEntityEventPacket(p_37964_, (byte)43)); } if (flag) { + // CraftBukkit start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRaidTriggerEvent(raid, p_37964_)) { -+ p_37964_.m_21195_(MobEffects.f_19594_); ++ p_37964_.removeEffect(MobEffects.BAD_OMEN); + return null; + } + -+ if (!this.f_37951_.containsKey(raid.m_37781_())) { -+ this.f_37951_.put(raid.m_37781_(), raid); ++ if (!this.raidMap.containsKey(raid.getId())) { ++ this.raidMap.put(raid.getId(), raid); + } + // CraftBukkit end - raid.m_37728_(p_37964_); - p_37964_.f_8906_.m_141995_(new ClientboundEntityEventPacket(p_37964_, (byte)43)); - if (!raid.m_37757_()) { + raid.absorbBadOmen(p_37964_); + p_37964_.connection.send(new ClientboundEntityEventPacket(p_37964_, (byte)43)); + if (!raid.hasFirstWaveSpawned()) { diff --git a/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch b/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch index 7b674664..7adf7180 100644 --- a/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/schedule/Activity.java.patch @@ -6,6 +6,6 @@ -public class Activity { +public class Activity extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final Activity f_37978_ = m_37999_("core"); - public static final Activity f_37979_ = m_37999_("idle"); - public static final Activity f_37980_ = m_37999_("work"); + public static final Activity CORE = register("core"); + public static final Activity IDLE = register("idle"); + public static final Activity WORK = register("work"); diff --git a/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch b/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch index e7e7f927..10bfaf97 100644 --- a/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/schedule/Schedule.java.patch @@ -6,6 +6,6 @@ -public class Schedule { +public class Schedule extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final int f_150241_ = 2000; - public static final int f_150242_ = 7000; - public static final Schedule f_38012_ = m_38029_("empty").m_38040_(0, Activity.f_37979_).m_38039_(); + public static final int WORK_START_TIME = 2000; + public static final int TOTAL_WORK_TIME = 7000; + public static final Schedule EMPTY = register("empty").changeActivityAt(0, Activity.IDLE).build(); 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 6293ed80..e425020d 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -6,21 +6,21 @@ -public abstract class AbstractMinecart extends Entity { +public abstract class AbstractMinecart extends Entity implements net.minecraftforge.common.extensions.IForgeAbstractMinecart { - private static final EntityDataAccessor f_38079_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135028_); - private static final EntityDataAccessor f_38080_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135028_); - private static final EntityDataAccessor f_38081_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135029_); + private static final EntityDataAccessor DATA_ID_HURT = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); + private static final EntityDataAccessor DATA_ID_HURTDIR = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); + private static final EntityDataAccessor DATA_ID_DAMAGE = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.FLOAT); @@ -76,6 +_,7 @@ p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); }); + private static net.minecraftforge.common.IMinecartCollisionHandler COLLISIONS = null; - private int f_38070_; - private double f_38071_; - private double f_38072_; + private int lSteps; + private double lx; + private double ly; @@ -85,6 +_,18 @@ - private double f_38076_; - private double f_38077_; - private double f_38078_; + private double lxd; + private double lyd; + private double lzd; + private boolean canBePushed = true; + + // CraftBukkit start @@ -37,8 +37,8 @@ protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { super(p_38087_, p_38088_); @@ -98,6 +_,14 @@ - this.f_19855_ = p_38093_; - this.f_19856_ = p_38094_; + this.yo = p_38093_; + this.zo = p_38094_; } + + public net.minecraftforge.common.IMinecartCollisionHandler getCollisionHandler() { @@ -49,27 +49,27 @@ + COLLISIONS = handler; + } - public static AbstractMinecart m_38119_(Level p_38120_, double p_38121_, double p_38122_, double p_38123_, AbstractMinecart.Type p_38124_) { + public static AbstractMinecart createMinecart(Level p_38120_, double p_38121_, double p_38122_, double p_38123_, AbstractMinecart.Type p_38124_) { if (p_38124_ == AbstractMinecart.Type.CHEST) { @@ -133,7 +_,7 @@ } - public boolean m_6094_() { + public boolean isPushable() { - return true; + return canBePushed; } - protected Vec3 m_7643_(Direction.Axis p_38132_, BlockUtil.FoundRectangle p_38133_) { + protected Vec3 getRelativePortalPosition(Direction.Axis p_38132_, BlockUtil.FoundRectangle p_38133_) { @@ -200,6 +_,19 @@ - if (this.m_6673_(p_38117_)) { + if (this.isInvulnerableTo(p_38117_)) { return false; } else { + // CraftBukkit start - fire VehicleDamageEvent + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); -+ org.bukkit.entity.Entity passenger = (p_38117_.m_7639_() == null) ? null : p_38117_.m_7639_().getBukkitEntity(); ++ org.bukkit.entity.Entity passenger = (p_38117_.getEntity() == null) ? null : p_38117_.getEntity().getBukkitEntity(); + + org.bukkit.event.vehicle.VehicleDamageEvent event = new org.bukkit.event.vehicle.VehicleDamageEvent(vehicle, passenger, p_38118_); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; @@ -77,203 +77,203 @@ + + p_38118_ = (float) event.getDamage(); + // CraftBukkit end - this.m_38160_(-this.m_38177_()); - this.m_38154_(10); - this.m_5834_(); + this.setHurtDir(-this.getHurtDir()); + this.setHurtTime(10); + this.markHurt(); @@ -207,6 +_,15 @@ - this.m_146852_(GameEvent.f_157808_, p_38117_.m_7639_()); - boolean flag = p_38117_.m_7639_() instanceof Player && ((Player)p_38117_.m_7639_()).m_150110_().f_35937_; - if (flag || this.m_38169_() > 40.0F) { + this.gameEvent(GameEvent.ENTITY_DAMAGED, p_38117_.getEntity()); + boolean flag = p_38117_.getEntity() instanceof Player && ((Player)p_38117_.getEntity()).getAbilities().instabuild; + if (flag || this.getDamage() > 40.0F) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, passenger); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(destroyEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(destroyEvent); + + if (destroyEvent.isCancelled()) { -+ this.m_38109_(40); // Maximize damage so this doesn't get triggered again right away ++ this.setDamage(40); // Maximize damage so this doesn't get triggered again right away + return true; + } + // CraftBukkit end - this.m_20153_(); - if (flag && !this.m_8077_()) { - this.m_146870_(); + this.ejectPassengers(); + if (flag && !this.hasCustomName()) { + this.discard(); @@ -259,6 +_,14 @@ } - public void m_8119_() { + public void tick() { + // CraftBukkit start -+ double prevX = this.m_20185_(); -+ double prevY = this.m_20186_(); -+ double prevZ = this.m_20189_(); -+ float prevYaw = this.m_146908_(); -+ float prevPitch = this.m_146909_(); ++ double prevX = this.getX(); ++ double prevY = this.getY(); ++ double prevZ = this.getZ(); ++ float prevYaw = this.getYRot(); ++ float prevPitch = this.getXRot(); + // CraftBukkit end + - if (this.m_38176_() > 0) { - this.m_38154_(this.m_38176_() - 1); + if (this.getHurtTime() > 0) { + this.setHurtTime(this.getHurtTime() - 1); } @@ -268,7 +_,7 @@ } - this.m_146871_(); -- this.m_20157_(); + this.checkOutOfWorld(); +- this.handleNetherPortal(); + // this.handleNetherPortal(); // CraftBukkit - handled in postTick - if (this.f_19853_.f_46443_) { - if (this.f_38070_ > 0) { - double d5 = this.m_20185_() + (this.f_38071_ - this.m_20185_()) / (double)this.f_38070_; + if (this.level.isClientSide) { + if (this.lSteps > 0) { + double d5 = this.getX() + (this.lx - this.getX()) / (double)this.lSteps; @@ -300,9 +_,9 @@ BlockPos blockpos = new BlockPos(k, i, j); - BlockState blockstate = this.f_19853_.m_8055_(blockpos); -- if (BaseRailBlock.m_49416_(blockstate)) { -+ if (canUseRail() && BaseRailBlock.m_49416_(blockstate)) { - this.m_6401_(blockpos, blockstate); -- if (blockstate.m_60713_(Blocks.f_50285_)) { -+ if (blockstate.m_60734_() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.m_60734_()).isActivatorRail()) { - this.m_6025_(k, i, j, blockstate.m_61143_(PoweredRailBlock.f_55215_)); + BlockState blockstate = this.level.getBlockState(blockpos); +- if (BaseRailBlock.isRail(blockstate)) { ++ if (canUseRail() && BaseRailBlock.isRail(blockstate)) { + this.moveAlongTrack(blockpos, blockstate); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.getBlock()).isActivatorRail()) { + this.activateMinecart(k, i, j, blockstate.getValue(PoweredRailBlock.POWERED)); } } else { @@ -327,21 +_,64 @@ } - this.m_19915_(this.m_146908_(), this.m_146909_()); -- if (this.m_6064_() == AbstractMinecart.Type.RIDEABLE && this.m_20184_().m_165925_() > 0.01D) { -- List list = this.f_19853_.m_6249_(this, this.m_142469_().m_82377_((double)0.2F, 0.0D, (double)0.2F), EntitySelector.m_20421_(this)); + this.setRot(this.getYRot(), this.getXRot()); +- if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { +- List list = this.level.getEntities(this, this.getBoundingBox().inflate((double)0.2F, 0.0D, (double)0.2F), EntitySelector.pushableBy(this)); + + // CraftBukkit start -+ org.bukkit.World bworld = this.f_19853_.getWorld(); ++ org.bukkit.World bworld = this.level.getWorld(); + org.bukkit.Location from = new org.bukkit.Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); -+ org.bukkit.Location to = new org.bukkit.Location(bworld, this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); ++ org.bukkit.Location to = new org.bukkit.Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); + -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); + + if (!from.equals(to)) { -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); + } + // CraftBukkit end + + AABB box; + if (getCollisionHandler() != null) box = getCollisionHandler().getMinecartCollisionBox(this); -+ else box = this.m_142469_().m_82377_(0.2F, 0.0D, 0.2F); -+ if (canBeRidden() && this.m_20184_().m_165925_() > 0.01D) { -+ List list = this.f_19853_.m_6249_(this, box, EntitySelector.m_20421_(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(int l = 0; l < list.size(); ++l) { Entity entity1 = list.get(l); - if (!(entity1 instanceof Player) && !(entity1 instanceof IronGolem) && !(entity1 instanceof AbstractMinecart) && !this.m_20160_() && !entity1.m_20159_()) { + if (!(entity1 instanceof Player) && !(entity1 instanceof IronGolem) && !(entity1 instanceof AbstractMinecart) && !this.isVehicle() && !entity1.isPassenger()) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + continue; + } + // CraftBukkit end - entity1.m_20329_(this); + entity1.startRiding(this); } else { + // CraftBukkit start -+ if (!this.m_20365_(entity1)) { ++ if (!this.isPassengerOfSameVehicle(entity1)) { + org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + continue; + } + } + // CraftBukkit end - entity1.m_7334_(this); + entity1.push(this); } } } } else { -- for(Entity entity : this.f_19853_.m_45933_(this, this.m_142469_().m_82377_((double)0.2F, 0.0D, (double)0.2F))) { -+ for(Entity entity : this.f_19853_.m_45933_(this, box)) { - if (!this.m_20363_(entity) && entity.m_6094_() && entity instanceof AbstractMinecart) { +- for(Entity entity : this.level.getEntities(this, this.getBoundingBox().inflate((double)0.2F, 0.0D, (double)0.2F))) { ++ for(Entity entity : this.level.getEntities(this, box)) { + if (!this.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + continue; + } + // CraftBukkit end - entity.m_7334_(this); + entity.push(this); } } @@ -358,23 +_,34 @@ } - protected double m_7097_() { -- return (this.m_20069_() ? 4.0D : 8.0D) / 20.0D; -+ return (this.m_20069_() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit + protected double getMaxSpeed() { +- return (this.isInWater() ? 4.0D : 8.0D) / 20.0D; ++ return (this.isInWater() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit } - public void m_6025_(int p_38111_, int p_38112_, int p_38113_, boolean p_38114_) { + public void activateMinecart(int p_38111_, int p_38112_, int p_38113_, boolean p_38114_) { } - protected void m_38163_() { -- double d0 = this.m_7097_(); -+ double d0 = f_19861_ ? this.m_7097_() : getMaxSpeedAirLateral(); - Vec3 vec3 = this.m_20184_(); - this.m_20334_(Mth.m_14008_(vec3.f_82479_, -d0, d0), vec3.f_82480_, Mth.m_14008_(vec3.f_82481_, -d0, d0)); - if (this.f_19861_) { -- this.m_20256_(this.m_20184_().m_82490_(0.5D)); + protected void comeOffTrack() { +- double d0 = this.getMaxSpeed(); ++ double d0 = onGround ? this.getMaxSpeed() : getMaxSpeedAirLateral(); + Vec3 vec3 = this.getDeltaMovement(); + this.setDeltaMovement(Mth.clamp(vec3.x, -d0, d0), vec3.y, Mth.clamp(vec3.z, -d0, d0)); + if (this.onGround) { +- this.setDeltaMovement(this.getDeltaMovement().scale(0.5D)); + // CraftBukkit start - replace magic numbers with our variables -+ this.m_20256_(new Vec3(this.m_20184_().f_82479_ * this.derailedX, this.m_20184_().f_82480_ * this.derailedY, this.m_20184_().f_82481_ * this.derailedZ)); ++ this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.derailedX, this.getDeltaMovement().y * this.derailedY, this.getDeltaMovement().z * this.derailedZ)); + // CraftBukkit end + } + -+ if (getMaxSpeedAirVertical() > 0 && m_20184_().f_82480_ > getMaxSpeedAirVertical()) { -+ if(Math.abs(m_20184_().f_82479_) < 0.3f && Math.abs(m_20184_().f_82481_) < 0.3f) -+ m_20256_(new Vec3(m_20184_().f_82479_, 0.15f, m_20184_().f_82481_)); ++ if (getMaxSpeedAirVertical() > 0 && getDeltaMovement().y > getMaxSpeedAirVertical()) { ++ if(Math.abs(getDeltaMovement().x) < 0.3f && Math.abs(getDeltaMovement().z) < 0.3f) ++ setDeltaMovement(new Vec3(getDeltaMovement().x, 0.15f, getDeltaMovement().z)); + else -+ m_20256_(new Vec3(m_20184_().f_82479_, getMaxSpeedAirVertical(), m_20184_().f_82481_)); ++ setDeltaMovement(new Vec3(getDeltaMovement().x, getMaxSpeedAirVertical(), getDeltaMovement().z)); } - this.m_6478_(MoverType.SELF, this.m_20184_()); - if (!this.f_19861_) { -- this.m_20256_(this.m_20184_().m_82490_(0.95D)); + this.move(MoverType.SELF, this.getDeltaMovement()); + if (!this.onGround) { +- this.setDeltaMovement(this.getDeltaMovement().scale(0.95D)); + // CraftBukkit start - replace magic numbers with our variables -+ this.m_20256_(new Vec3(this.m_20184_().f_82479_ * this.flyingX, this.m_20184_().f_82480_ * this.flyingY, this.m_20184_().f_82481_ * this.flyingZ)); ++ this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.flyingX, this.getDeltaMovement().y * this.flyingY, this.getDeltaMovement().z * this.flyingZ)); + // CraftBukkit end } } @@ -388,7 +_,8 @@ - d1 = (double)p_38156_.m_123342_(); + d1 = (double)p_38156_.getY(); boolean flag = false; boolean flag1 = false; -- if (p_38157_.m_60713_(Blocks.f_50030_)) { -+ BaseRailBlock baserailblock = (BaseRailBlock) p_38157_.m_60734_(); +- if (p_38157_.is(Blocks.POWERED_RAIL)) { ++ BaseRailBlock baserailblock = (BaseRailBlock) p_38157_.getBlock(); + if (baserailblock instanceof PoweredRailBlock && !((PoweredRailBlock) baserailblock).isActivatorRail()) { - flag = p_38157_.m_61143_(PoweredRailBlock.f_55215_); + flag = p_38157_.getValue(PoweredRailBlock.POWERED); flag1 = !flag; } @@ -399,22 +_,22 @@ } - Vec3 vec31 = this.m_20184_(); -- RailShape railshape = p_38157_.m_61143_(((BaseRailBlock)p_38157_.m_60734_()).m_7978_()); -+ RailShape railshape = ((BaseRailBlock)p_38157_.m_60734_()).getRailDirection(p_38157_, this.f_19853_, p_38156_, this); + Vec3 vec31 = this.getDeltaMovement(); +- RailShape railshape = p_38157_.getValue(((BaseRailBlock)p_38157_.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_38157_.getBlock()).getRailDirection(p_38157_, this.level, p_38156_, this); switch(railshape) { case ASCENDING_EAST: -- this.m_20256_(vec31.m_82520_(-d3, 0.0D, 0.0D)); -+ this.m_20256_(vec31.m_82520_(-1 * getSlopeAdjustment(), 0.0D, 0.0D)); +- this.setDeltaMovement(vec31.add(-d3, 0.0D, 0.0D)); ++ this.setDeltaMovement(vec31.add(-1 * getSlopeAdjustment(), 0.0D, 0.0D)); ++d1; break; case ASCENDING_WEST: -- this.m_20256_(vec31.m_82520_(d3, 0.0D, 0.0D)); -+ this.m_20256_(vec31.m_82520_(getSlopeAdjustment(), 0.0D, 0.0D)); +- this.setDeltaMovement(vec31.add(d3, 0.0D, 0.0D)); ++ this.setDeltaMovement(vec31.add(getSlopeAdjustment(), 0.0D, 0.0D)); ++d1; break; case ASCENDING_NORTH: -- this.m_20256_(vec31.m_82520_(0.0D, 0.0D, d3)); -+ this.m_20256_(vec31.m_82520_(0.0D, 0.0D, getSlopeAdjustment())); +- this.setDeltaMovement(vec31.add(0.0D, 0.0D, d3)); ++ this.setDeltaMovement(vec31.add(0.0D, 0.0D, getSlopeAdjustment())); ++d1; break; case ASCENDING_SOUTH: -- this.m_20256_(vec31.m_82520_(0.0D, 0.0D, -d3)); -+ this.m_20256_(vec31.m_82520_(0.0D, 0.0D, -1 * getSlopeAdjustment())); +- this.setDeltaMovement(vec31.add(0.0D, 0.0D, -d3)); ++ this.setDeltaMovement(vec31.add(0.0D, 0.0D, -1 * getSlopeAdjustment())); ++d1; } @@ -283,96 +283,96 @@ - if (flag1) { + if (flag1 && shouldDoRailFunctions()) { - double d22 = this.m_20184_().m_165924_(); + double d22 = this.getDeltaMovement().horizontalDistance(); if (d22 < 0.03D) { - this.m_20256_(Vec3.f_82478_); + this.setDeltaMovement(Vec3.ZERO); @@ -474,10 +_,7 @@ d0 = d23 + d4 * d14; d2 = d10 + d5 * d14; - this.m_6034_(d0, d1, d2); -- double d24 = this.m_20160_() ? 0.75D : 1.0D; -- double d25 = this.m_7097_(); -- vec31 = this.m_20184_(); -- this.m_6478_(MoverType.SELF, new Vec3(Mth.m_14008_(d24 * vec31.f_82479_, -d25, d25), 0.0D, Mth.m_14008_(d24 * vec31.f_82481_, -d25, d25))); + this.setPos(d0, d1, d2); +- double d24 = this.isVehicle() ? 0.75D : 1.0D; +- double d25 = this.getMaxSpeed(); +- vec31 = this.getDeltaMovement(); +- this.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec31.x, -d25, d25), 0.0D, Mth.clamp(d24 * vec31.z, -d25, d25))); + this.moveMinecartOnRail(p_38156_); - if (vec3i.m_123342_() != 0 && Mth.m_14107_(this.m_20185_()) - p_38156_.m_123341_() == vec3i.m_123341_() && Mth.m_14107_(this.m_20189_()) - p_38156_.m_123343_() == vec3i.m_123343_()) { - this.m_6034_(this.m_20185_(), this.m_20186_() + (double)vec3i.m_123342_(), this.m_20189_()); - } else if (vec3i1.m_123342_() != 0 && Mth.m_14107_(this.m_20185_()) - p_38156_.m_123341_() == vec3i1.m_123341_() && Mth.m_14107_(this.m_20189_()) - p_38156_.m_123343_() == vec3i1.m_123343_()) { + if (vec3i.getY() != 0 && Mth.floor(this.getX()) - p_38156_.getX() == vec3i.getX() && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i.getZ()) { + this.setPos(this.getX(), this.getY() + (double)vec3i.getY(), this.getZ()); + } else if (vec3i1.getY() != 0 && Mth.floor(this.getX()) - p_38156_.getX() == vec3i1.getX() && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i1.getZ()) { @@ -505,7 +_,10 @@ - this.m_20334_(d26 * (double)(j - p_38156_.m_123341_()), vec35.f_82480_, d26 * (double)(i - p_38156_.m_123343_())); + this.setDeltaMovement(d26 * (double)(j - p_38156_.getX()), vec35.y, d26 * (double)(i - p_38156_.getZ())); } - if (flag) { + if (shouldDoRailFunctions()) -+ baserailblock.onMinecartPass(p_38157_, f_19853_, p_38156_, this); ++ baserailblock.onMinecartPass(p_38157_, level, p_38156_, this); + + if (flag && shouldDoRailFunctions()) { - Vec3 vec36 = this.m_20184_(); - double d27 = vec36.m_165924_(); + Vec3 vec36 = this.getDeltaMovement(); + double d27 = vec36.horizontalDistance(); if (d27 > 0.01D) { @@ -544,7 +_,7 @@ } - protected void m_7114_() { -- double d0 = this.m_20160_() ? 0.997D : 0.96D; -+ double d0 = this.m_20160_() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty - Vec3 vec3 = this.m_20184_(); - vec3 = vec3.m_82542_(d0, 0.0D, d0); - if (this.m_20069_()) { + protected void applyNaturalSlowdown() { +- double d0 = this.isVehicle() ? 0.997D : 0.96D; ++ double d0 = this.isVehicle() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty + Vec3 vec3 = this.getDeltaMovement(); + vec3 = vec3.multiply(d0, 0.0D, d0); + if (this.isInWater()) { @@ -565,7 +_,7 @@ - BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); - if (BaseRailBlock.m_49416_(blockstate)) { -- RailShape railshape = blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()); -+ RailShape railshape = ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, this.f_19853_, new BlockPos(i, j, k), this); + 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); p_38098_ = (double)j; - if (railshape.m_61745_()) { + if (railshape.isAscending()) { p_38098_ = (double)(j + 1); @@ -604,7 +_,7 @@ - BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); - if (BaseRailBlock.m_49416_(blockstate)) { -- RailShape railshape = blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()); -+ RailShape railshape = ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, this.f_19853_, new BlockPos(i, j, k), this); - Pair pair = m_38125_(railshape); + 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(); @@ -666,9 +_,21 @@ } - public void m_7334_(Entity p_38165_) { + public void push(Entity p_38165_) { + if (getCollisionHandler() != null) { + getCollisionHandler().onEntityCollision(this, p_38165_); + return; + } - if (!this.f_19853_.f_46443_) { - if (!p_38165_.f_19794_ && !this.f_19794_) { - if (!this.m_20363_(p_38165_)) { + if (!this.level.isClientSide) { + if (!p_38165_.noPhysics && !this.noPhysics) { + if (!this.hasPassenger(p_38165_)) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) this.getBukkitEntity(), p_38165_.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + return; + } + // CraftBukkit end - double d0 = p_38165_.m_20185_() - this.m_20185_(); - double d1 = p_38165_.m_20189_() - this.m_20189_(); + double d0 = p_38165_.getX() - this.getX(); + double d1 = p_38165_.getZ() - this.getZ(); double d2 = d0 * d0 + d1 * d1; @@ -699,11 +_,11 @@ - Vec3 vec32 = this.m_20184_(); - Vec3 vec33 = p_38165_.m_20184_(); -- if (((AbstractMinecart)p_38165_).m_6064_() == AbstractMinecart.Type.FURNACE && this.m_6064_() != AbstractMinecart.Type.FURNACE) { + Vec3 vec32 = this.getDeltaMovement(); + Vec3 vec33 = p_38165_.getDeltaMovement(); +- if (((AbstractMinecart)p_38165_).getMinecartType() == AbstractMinecart.Type.FURNACE && this.getMinecartType() != AbstractMinecart.Type.FURNACE) { + if (((AbstractMinecart)p_38165_).isPoweredCart() && !this.isPoweredCart()) { - this.m_20256_(vec32.m_82542_(0.2D, 1.0D, 0.2D)); - this.m_5997_(vec33.f_82479_ - d0, 0.0D, vec33.f_82481_ - d1); - p_38165_.m_20256_(vec33.m_82542_(0.95D, 1.0D, 0.95D)); -- } else if (((AbstractMinecart)p_38165_).m_6064_() != AbstractMinecart.Type.FURNACE && this.m_6064_() == AbstractMinecart.Type.FURNACE) { + this.setDeltaMovement(vec32.multiply(0.2D, 1.0D, 0.2D)); + this.push(vec33.x - d0, 0.0D, vec33.z - d1); + p_38165_.setDeltaMovement(vec33.multiply(0.95D, 1.0D, 0.95D)); +- } else if (((AbstractMinecart)p_38165_).getMinecartType() != AbstractMinecart.Type.FURNACE && this.getMinecartType() == AbstractMinecart.Type.FURNACE) { + } else if (!((AbstractMinecart)p_38165_).isPoweredCart() && this.isPoweredCart()) { - p_38165_.m_20256_(vec33.m_82542_(0.2D, 1.0D, 0.2D)); - p_38165_.m_5997_(vec32.f_82479_ + d0, 0.0D, vec32.f_82481_ + d1); - this.m_20256_(vec32.m_82542_(0.95D, 1.0D, 0.95D)); + p_38165_.setDeltaMovement(vec33.multiply(0.2D, 1.0D, 0.2D)); + p_38165_.push(vec32.x + d0, 0.0D, vec32.z + d1); + this.setDeltaMovement(vec32.multiply(0.95D, 1.0D, 0.95D)); @@ -807,6 +_,42 @@ return new ClientboundAddEntityPacket(this); } @@ -395,30 +395,30 @@ + @Override public void setDragAir(double value) { dragAir = value; } + @Override + public double getMaxSpeedWithRail() { //Non-default because getMaximumSpeed is protected -+ if (!canUseRail()) return m_7097_(); ++ if (!canUseRail()) return getMaxSpeed(); + BlockPos pos = this.getCurrentRailPosition(); -+ BlockState state = this.f_19853_.m_8055_(pos); -+ if (!state.m_204336_(BlockTags.f_13034_)) return m_7097_(); ++ BlockState state = this.level.getBlockState(pos); ++ if (!state.is(BlockTags.RAILS)) return getMaxSpeed(); + -+ float railMaxSpeed = ((BaseRailBlock)state.m_60734_()).getRailMaxSpeed(state, this.f_19853_, pos, this); ++ 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.m_20160_() ? 0.75D : 1.0D; ++ double d24 = mc.isVehicle() ? 0.75D : 1.0D; + double d25 = mc.getMaxSpeedWithRail(); -+ Vec3 vec3d1 = mc.m_20184_(); -+ mc.m_6478_(MoverType.SELF, new Vec3(Mth.m_14008_(d24 * vec3d1.f_82479_, -d25, d25), 0.0D, Mth.m_14008_(d24 * vec3d1.f_82481_, -d25, d25))); ++ 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))); + } + // Forge end + - public ItemStack m_142340_() { + public ItemStack getPickResult() { Item item; - switch(this.m_6064_()) { + switch(this.getMinecartType()) { @@ -828,7 +_,8 @@ default: - item = Items.f_42449_; + item = Items.MINECART; } - + // TODO, should this be above? 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 eaf80052..5c1a1f17 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -4,18 +4,18 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; public abstract class AbstractMinecartContainer extends AbstractMinecart implements Container, MenuProvider { -- private NonNullList f_38202_ = NonNullList.m_122780_(36, ItemStack.f_41583_); -+ private NonNullList f_38202_ = NonNullList.m_122780_(this.m_6643_(), ItemStack.f_41583_); // CraftBukkit - SPIGOT-3513 +- private NonNullList itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); ++ private NonNullList itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 @Nullable - public ResourceLocation f_38204_; - public long f_38205_; + public ResourceLocation lootTable; + public long lootTableSeed; + // CraftBukkit start + public java.util.List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.f_38202_; ++ return this.itemStacks; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -37,7 +37,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -57,32 +57,32 @@ @@ -156,6 +_,8 @@ } - public InteractionResult m_6096_(Player p_38232_, InteractionHand p_38233_) { -+ InteractionResult ret = super.m_6096_(p_38232_, p_38233_); -+ if (ret.m_19077_()) return ret; - p_38232_.m_5893_(this); - if (!p_38232_.f_19853_.f_46443_) { - this.m_146852_(GameEvent.f_157803_, p_38232_); + public InteractionResult interact(Player p_38232_, InteractionHand p_38233_) { ++ InteractionResult ret = super.interact(p_38232_, p_38233_); ++ if (ret.consumesAction()) return ret; + p_38232_.openMenu(this); + if (!p_38232_.level.isClientSide) { + this.gameEvent(GameEvent.CONTAINER_OPEN, p_38232_); @@ -189,6 +_,8 @@ - this.f_38204_ = null; - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_19853_)).m_78972_(LootContextParams.f_81460_, this.m_20182_()).m_78965_(this.f_38205_); + this.lootTable = null; + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, this.position()).withOptionalRandomSeed(this.lootTableSeed); + // Forge: add this entity to loot context, however, currently Vanilla uses 'this' for the player creating the chests. So we take over 'killer_entity' for this. -+ lootcontext$builder.m_78972_(LootContextParams.f_81458_, this); ++ lootcontext$builder.withParameter(LootContextParams.KILLER_ENTITY, this); if (p_38255_ != null) { - lootcontext$builder.m_78963_(p_38255_.m_36336_()).m_78972_(LootContextParams.f_81455_, p_38255_); + lootcontext$builder.withLuck(p_38255_.getLuck()).withParameter(LootContextParams.THIS_ENTITY, p_38255_); } @@ -219,4 +_,26 @@ } - protected abstract AbstractContainerMenu m_7402_(int p_38222_, Inventory p_38223_); + protected abstract AbstractContainerMenu createMenu(int p_38222_, Inventory p_38223_); + + // Forge Start + 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) { -+ if (this.m_6084_() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) ++ if (this.isAlive() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + return itemHandler.cast(); + return super.getCapability(capability, facing); + } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch index 5dc02034..dddd5f21 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/Boat.java +++ b/net/minecraft/world/entity/vehicle/Boat.java @@ -87,6 +_,14 @@ - private float f_38260_; - private float f_38261_; + private float bubbleAngle; + private float bubbleAngleO; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -14,17 +14,17 @@ + public Boat(EntityType p_38290_, Level p_38291_) { super(p_38290_, p_38291_); - this.f_19850_ = true; + this.blocksBuilding = true; @@ -146,6 +_,19 @@ - if (this.m_6673_(p_38319_)) { + if (this.isInvulnerableTo(p_38319_)) { return false; - } else if (!this.f_19853_.f_46443_ && !this.m_146910_()) { + } else if (!this.level.isClientSide && !this.isRemoved()) { + // CraftBukkit start + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); -+ org.bukkit.entity.Entity attacker = (p_38319_.m_7639_() == null) ? null : p_38319_.m_7639_().getBukkitEntity(); ++ org.bukkit.entity.Entity attacker = (p_38319_.getEntity() == null) ? null : p_38319_.getEntity().getBukkitEntity(); + + org.bukkit.event.vehicle.VehicleDamageEvent event = new org.bukkit.event.vehicle.VehicleDamageEvent(vehicle, attacker, (double) p_38320_); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; @@ -32,105 +32,105 @@ + // f = event.getDamage(); // TODO Why don't we do this? + // CraftBukkit end + - this.m_38362_(-this.m_38386_()); - this.m_38354_(10); - this.m_38311_(this.m_38384_() + p_38320_ * 10.0F); + this.setHurtDir(-this.getHurtDir()); + this.setHurtTime(10); + this.setDamage(this.getDamage() + p_38320_ * 10.0F); @@ -153,6 +_,15 @@ - this.m_146852_(GameEvent.f_157808_, p_38319_.m_7639_()); - boolean flag = p_38319_.m_7639_() instanceof Player && ((Player)p_38319_.m_7639_()).m_150110_().f_35937_; - if (flag || this.m_38384_() > 40.0F) { + this.gameEvent(GameEvent.ENTITY_DAMAGED, p_38319_.getEntity()); + boolean flag = p_38319_.getEntity() instanceof Player && ((Player)p_38319_.getEntity()).getAbilities().instabuild; + if (flag || this.getDamage() > 40.0F) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, attacker); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(destroyEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(destroyEvent); + + if (destroyEvent.isCancelled()) { -+ this.m_38311_(40F); // Maximize damage so this doesn't get triggered again right away ++ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away + return true; + } + // CraftBukkit end - if (!flag && this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_)) { - this.m_19998_(this.m_38369_()); + if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + this.spawnAtLocation(this.getDropItem()); } @@ -186,9 +_,29 @@ - public void m_7334_(Entity p_38373_) { + public void push(Entity p_38373_) { if (p_38373_ instanceof Boat) { - if (p_38373_.m_142469_().f_82289_ < this.m_142469_().f_82292_) { + if (p_38373_.getBoundingBox().minY < this.getBoundingBox().maxY) { + // CraftBukkit start -+ if (!this.m_20365_(p_38373_)) { ++ if (!this.isPassengerOfSameVehicle(p_38373_)) { + org.bukkit.event.vehicle.VehicleEntityCollisionEvent event = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) this.getBukkitEntity(), p_38373_.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + } + // CraftBukkit end - super.m_7334_(p_38373_); + super.push(p_38373_); } - } else if (p_38373_.m_142469_().f_82289_ <= this.m_142469_().f_82289_) { + } else if (p_38373_.getBoundingBox().minY <= this.getBoundingBox().minY) { + // CraftBukkit start -+ if (!this.m_20365_(p_38373_)) { ++ if (!this.isPassengerOfSameVehicle(p_38373_)) { + org.bukkit.event.vehicle.VehicleEntityCollisionEvent event = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) this.getBukkitEntity(), p_38373_.getBukkitEntity()); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + } + // CraftBukkit end - super.m_7334_(p_38373_); + super.push(p_38373_); } @@ -196,19 +_,19 @@ - public Item m_38369_() { - switch(this.m_38387_()) { + public Item getDropItem() { + switch(this.getBoatType()) { - case OAK: - default: -- return Items.f_42453_; +- return Items.OAK_BOAT; - case SPRUCE: -- return Items.f_42742_; +- return Items.SPRUCE_BOAT; - case BIRCH: -- return Items.f_42743_; +- return Items.BIRCH_BOAT; - case JUNGLE: -- return Items.f_42744_; +- return Items.JUNGLE_BOAT; - case ACACIA: -- return Items.f_42745_; +- return Items.ACACIA_BOAT; - case DARK_OAK: -- return Items.f_42746_; +- return Items.DARK_OAK_BOAT; + case OAK: + default: -+ return Items.f_42453_; ++ return Items.OAK_BOAT; + case SPRUCE: -+ return Items.f_42742_; ++ return Items.SPRUCE_BOAT; + case BIRCH: -+ return Items.f_42743_; ++ return Items.BIRCH_BOAT; + case JUNGLE: -+ return Items.f_42744_; ++ return Items.JUNGLE_BOAT; + case ACACIA: -+ return Items.f_42745_; ++ return Items.ACACIA_BOAT; + case DARK_OAK: -+ return Items.f_42746_; ++ return Items.DARK_OAK_BOAT; } } @@ -235,6 +_,7 @@ - return this.m_6350_().m_122427_(); + return this.getDirection().getClockWise(); } + private org.bukkit.Location lastLocation; // CraftBukkit - public void m_8119_() { - this.f_38280_ = this.f_38279_; - this.f_38279_ = this.m_38392_(); + public void tick() { + this.oldStatus = this.status; + this.status = this.getStatus(); @@ -274,6 +_,22 @@ - this.m_20256_(Vec3.f_82478_); + this.setDeltaMovement(Vec3.ZERO); } + // CraftBukkit start -+ org.bukkit.Server server = this.f_19853_.getCraftServer(); -+ org.bukkit.World bworld = this.f_19853_.getWorld(); ++ org.bukkit.Server server = this.level.getCraftServer(); ++ org.bukkit.World bworld = this.level.getWorld(); + -+ org.bukkit.Location to = new org.bukkit.Location(bworld, this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); ++ org.bukkit.Location to = new org.bukkit.Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); + + server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); @@ -142,28 +142,28 @@ + lastLocation = vehicle.getLocation(); + // CraftBukkit end + - this.m_38388_(); + this.tickBubbleColumn(); for(int i = 0; i <= 1; ++i) { @@ -358,15 +_,15 @@ @Nullable - protected SoundEvent m_38370_() { - switch(this.m_38392_()) { + protected SoundEvent getPaddleSound() { + switch(this.getStatus()) { - case IN_WATER: - case UNDER_WATER: - case UNDER_FLOWING_WATER: -- return SoundEvents.f_11707_; +- return SoundEvents.BOAT_PADDLE_WATER; - case ON_LAND: -- return SoundEvents.f_11706_; +- return SoundEvents.BOAT_PADDLE_LAND; - case IN_AIR: - default: - return null; + case IN_WATER: + case UNDER_WATER: + case UNDER_FLOWING_WATER: -+ return SoundEvents.f_11707_; ++ return SoundEvents.BOAT_PADDLE_WATER; + case ON_LAND: -+ return SoundEvents.f_11706_; ++ return SoundEvents.BOAT_PADDLE_LAND; + case IN_AIR: + default: + return null; @@ -171,38 +171,38 @@ } @@ -475,7 +_,7 @@ - blockpos$mutableblockpos.m_122178_(l1, k2, i2); - BlockState blockstate = this.f_19853_.m_8055_(blockpos$mutableblockpos); - if (!(blockstate.m_60734_() instanceof WaterlilyBlock) && Shapes.m_83157_(blockstate.m_60812_(this.f_19853_, blockpos$mutableblockpos).m_83216_((double)l1, (double)k2, (double)i2), voxelshape, BooleanOp.f_82689_)) { -- f += blockstate.m_60734_().m_49958_(); -+ f += blockstate.getFriction(this.f_19853_, blockpos$mutableblockpos, this); + blockpos$mutableblockpos.set(l1, k2, i2); + BlockState blockstate = this.level.getBlockState(blockpos$mutableblockpos); + if (!(blockstate.getBlock() instanceof WaterlilyBlock) && Shapes.joinIsNotEmpty(blockstate.getCollisionShape(this.level, blockpos$mutableblockpos).move((double)l1, (double)k2, (double)i2), voxelshape, BooleanOp.AND)) { +- f += blockstate.getBlock().getFriction(); ++ f += blockstate.getFriction(this.level, blockpos$mutableblockpos, this); ++k1; } } @@ -730,17 +_,23 @@ - this.m_142535_(this.f_19789_, 1.0F, DamageSource.f_19315_); - if (!this.f_19853_.f_46443_ && !this.m_146910_()) { -- this.m_6074_(); -- if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_)) { + this.causeFallDamage(this.fallDistance, 1.0F, DamageSource.FALL); + if (!this.level.isClientSide && !this.isRemoved()) { +- this.kill(); +- if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { - for(int i = 0; i < 3; ++i) { -- this.m_19998_(this.m_38387_().m_38434_()); +- this.spawnAtLocation(this.getBoatType().getPlanks()); - } + // CraftBukkit start + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); + org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, null); -+ this.f_19853_.getCraftServer().getPluginManager().callEvent(destroyEvent); ++ this.level.getCraftServer().getPluginManager().callEvent(destroyEvent); + if (!destroyEvent.isCancelled()) { -+ this.m_6074_(); -+ if (this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_)) { ++ this.kill(); ++ if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + for (int i = 0; i < 3; ++i) { -+ this.m_19998_(this.m_38387_().m_38434_()); ++ this.spawnAtLocation(this.getBoatType().getPlanks()); + } - for(int j = 0; j < 2; ++j) { -- this.m_19998_(Items.f_42398_); +- this.spawnAtLocation(Items.STICK); + for (int j = 0; j < 2; ++j) { -+ this.m_19998_(Items.f_42398_); ++ this.spawnAtLocation(Items.STICK); + } } } @@ -210,23 +210,23 @@ + } // CraftBukkit end } - this.m_183634_(); + this.resetFallDistance(); @@ -821,6 +_,18 @@ - public boolean m_5842_() { - return this.f_38279_ == Boat.Status.UNDER_WATER || this.f_38279_ == Boat.Status.UNDER_FLOWING_WATER; + public boolean isUnderWater() { + return this.status == Boat.Status.UNDER_WATER || this.status == Boat.Status.UNDER_FLOWING_WATER; + } + + // Forge: Fix MC-119811 by instantly completing lerp on board + @Override + protected boolean addPassenger(Entity passenger) { + //super.addPassenger(passenger); Magma - moved to return -+ if (this.m_6109_() && this.f_38267_ > 0) { -+ this.f_38267_ = 0; -+ this.m_19890_(this.f_38268_, this.f_38269_, this.f_38270_, (float)this.f_38271_, (float)this.f_38272_); ++ if (this.isControlledByLocalInstance() && this.lerpSteps > 0) { ++ this.lerpSteps = 0; ++ this.absMoveTo(this.lerpX, this.lerpY, this.lerpZ, (float)this.lerpYRot, (float)this.lerpXRot); + } + + return super.addPassenger(passenger); // TODO: 10/05/2022 - Magma // Magma 11/07/2022 - don't set this to false, it breaks boats } - public ItemStack m_142340_() { + public ItemStack getPickResult() { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch index 39a97c93..66b9a701 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch @@ -3,9 +3,9 @@ @@ -16,6 +_,8 @@ } - public InteractionResult m_6096_(Player p_38483_, InteractionHand p_38484_) { -+ InteractionResult ret = super.m_6096_(p_38483_, p_38484_); -+ if (ret.m_19077_()) return ret; - if (p_38483_.m_36341_()) { + 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.m_20160_()) { + } 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 0d5c04bd..b429c98b 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -3,15 +3,15 @@ @@ -72,6 +_,8 @@ } - public InteractionResult m_6096_(Player p_38522_, InteractionHand p_38523_) { -+ InteractionResult ret = super.m_6096_(p_38522_, p_38523_); -+ if (ret.m_19077_()) return ret; - return this.f_38505_.m_45412_(p_38522_); + public InteractionResult interact(Player p_38522_, InteractionHand p_38523_) { ++ InteractionResult ret = super.interact(p_38522_, p_38523_); ++ if (ret.consumesAction()) return ret; + return this.commandBlock.usedBy(p_38522_); } @@ -113,5 +_,12 @@ - public CommandSourceStack m_6712_() { - return new CommandSourceStack(this, MinecartCommandBlock.this.m_20182_(), MinecartCommandBlock.this.m_20155_(), this.m_5991_(), 2, this.m_45439_().getString(), MinecartCommandBlock.this.m_5446_(), this.m_5991_().m_142572_(), MinecartCommandBlock.this); + public CommandSourceStack createCommandSourceStack() { + return new CommandSourceStack(this, MinecartCommandBlock.this.position(), MinecartCommandBlock.this.getRotationVector(), this.getLevel(), 2, this.getName().getString(), MinecartCommandBlock.this.getDisplayName(), this.getLevel().getServer(), MinecartCommandBlock.this); } + + // CraftBukkit start 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 ff3e8975..42e5eca7 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java +++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java @@ -71,6 +_,11 @@ - return (this.m_20069_() ? 3.0D : 4.0D) / 20.0D; + return (this.isInWater() ? 3.0D : 4.0D) / 20.0D; } + @Override @@ -9,15 +9,15 @@ + return 0.2f; + } + - public void m_7617_(DamageSource p_38560_) { - super.m_7617_(p_38560_); - if (!p_38560_.m_19372_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_)) { + public void destroy(DamageSource p_38560_) { + super.destroy(p_38560_); + if (!p_38560_.isExplosion() && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { @@ -115,6 +_,8 @@ } - public InteractionResult m_6096_(Player p_38562_, InteractionHand p_38563_) { -+ InteractionResult ret = super.m_6096_(p_38562_, p_38563_); -+ if (ret.m_19077_()) return ret; - ItemStack itemstack = p_38562_.m_21120_(p_38563_); - if (f_38549_.test(itemstack) && this.f_38548_ + 3600 <= 32000) { - if (!p_38562_.m_150110_().f_35937_) { + public InteractionResult interact(Player p_38562_, InteractionHand p_38563_) { ++ InteractionResult 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) { + if (!p_38562_.getAbilities().instabuild) { 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 ed257982..94a7aa92 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/MinecartSpawner.java +++ b/net/minecraft/world/entity/vehicle/MinecartSpawner.java @@ -14,6 +_,12 @@ - public void m_142523_(Level p_150342_, BlockPos p_150343_, int p_150344_) { - p_150342_.m_7605_(MinecartSpawner.this, (byte)p_150344_); + public void broadcastEvent(Level p_150342_, BlockPos p_150343_, int p_150344_) { + p_150342_.broadcastEntityEvent(MinecartSpawner.this, (byte)p_150344_); } + + @Override @@ -11,5 +11,5 @@ + return MinecartSpawner.this; + } }; - private final Runnable f_150333_; + private final Runnable ticker; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch index d49a98c0..03fdf884 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/vehicle/MinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java @@ -42,6 +_,12 @@ - public void m_8119_() { - super.m_8119_(); - if (this.f_38647_ > 0) { + public void tick() { + super.tick(); + if (this.fuse > 0) { + // Paper start - Configurable TNT entity height nerf -+ if (this.f_19853_.paperConfig.entityTNTHeightNerf != 0 && this.m_20186_() > this.f_19853_.paperConfig.entityTNTHeightNerf) { -+ this.m_146870_(); ++ if (this.level.paperConfig.entityTNTHeightNerf != 0 && this.getY() > this.level.paperConfig.entityTNTHeightNerf) { ++ this.discard(); + return; + } + // Paper end - --this.f_38647_; - this.f_19853_.m_7106_(ParticleTypes.f_123762_, this.m_20185_(), this.m_20186_() + 0.5D, this.m_20189_(), 0.0D, 0.0D, 0.0D); - } else if (this.f_38647_ == 0) { + --this.fuse; + this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D); + } else if (this.fuse == 0) { diff --git a/patches/minecraft/net/minecraft/world/food/FoodData.java.patch b/patches/minecraft/net/minecraft/world/food/FoodData.java.patch index ca4e9c3d..4a3590c7 100644 --- a/patches/minecraft/net/minecraft/world/food/FoodData.java.patch +++ b/patches/minecraft/net/minecraft/world/food/FoodData.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/food/FoodData.java +++ b/net/minecraft/world/food/FoodData.java @@ -15,19 +_,60 @@ - private int f_38699_; - private int f_38700_ = 20; + private int tickTimer; + private int lastFoodLevel = 20; + // CraftBukkit start + private @org.jetbrains.annotations.Nullable Player entityhuman; //Magma - add @Nullable @@ -15,7 +15,7 @@ + // CraftBukkit end + public FoodData() { -- this.f_38697_ = 5.0F; +- this.saturationLevel = 5.0F; - } + this(null); //Magma - instead of throwing an error we just set it to null + } @@ -23,40 +23,40 @@ + // CraftBukkit start - added Player constructor + public FoodData(Player player) { + this.entityhuman = player; -+ this.f_38697_ = 5.0F; ++ this.saturationLevel = 5.0F; + } + // CraftBukkit end - public void m_38707_(int p_38708_, float p_38709_) { - this.f_38696_ = Math.min(p_38708_ + this.f_38696_, 20); - this.f_38697_ = Math.min(this.f_38697_ + (float)p_38708_ * p_38709_ * 2.0F, (float)this.f_38696_); + public void eat(int p_38708_, float p_38709_) { + this.foodLevel = Math.min(p_38708_ + this.foodLevel, 20); + this.saturationLevel = Math.min(this.saturationLevel + (float)p_38708_ * p_38709_ * 2.0F, (float)this.foodLevel); } + // Use the LivingEntity sensitive version in favour of this. + @Deprecated - public void m_38712_(Item p_38713_, ItemStack p_38714_) { + public void eat(Item p_38713_, ItemStack p_38714_) { + this.eat(p_38713_, p_38714_, null); + } + + public void eat(Item p_38713_, ItemStack p_38714_, @javax.annotation.Nullable net.minecraft.world.entity.LivingEntity entity) { - if (p_38713_.m_41472_()) { -- FoodProperties foodproperties = p_38713_.m_41473_(); -- this.m_38707_(foodproperties.m_38744_(), foodproperties.m_38745_()); + if (p_38713_.isEdible()) { +- FoodProperties foodproperties = p_38713_.getFoodProperties(); +- this.eat(foodproperties.getNutrition(), foodproperties.getSaturationModifier()); + FoodProperties foodproperties = p_38714_.getFoodProperties(entity); + + //Magma start - null check + if (entityhuman == null) { -+ this.m_38707_(foodproperties.m_38744_(), foodproperties.m_38745_()); ++ this.eat(foodproperties.getNutrition(), foodproperties.getSaturationModifier()); + return; + } + //Magma end + + // CraftBukkit start -+ int oldFoodLevel = f_38696_; -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodproperties.m_38744_() + oldFoodLevel, p_38714_); ++ int oldFoodLevel = foodLevel; ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodproperties.getNutrition() + oldFoodLevel, p_38714_); + + if (!event.isCancelled()) { -+ this.m_38707_(event.getFoodLevel() - oldFoodLevel, foodproperties.m_38745_()); ++ this.eat(event.getFoodLevel() - oldFoodLevel, foodproperties.getSaturationModifier()); + } + + ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); @@ -66,21 +66,21 @@ } @@ -41,28 +_,48 @@ - this.f_38697_ = Math.max(this.f_38697_ - 1.0F, 0.0F); + this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (difficulty != Difficulty.PEACEFUL) { - this.f_38696_ = Math.max(this.f_38696_ - 1, 0); + this.foodLevel = Math.max(this.foodLevel - 1, 0); + + //Magma start - null check + if (entityhuman != null) { + + // CraftBukkit start -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.max(this.f_38696_ - 1, 0)); ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.max(this.foodLevel - 1, 0)); + + if (!event.isCancelled()) { -+ this.f_38696_ = event.getFoodLevel(); ++ this.foodLevel = event.getFoodLevel(); + } + -+ ((net.minecraft.server.level.ServerPlayer) entityhuman).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundSetHealthPacket(((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.f_38696_, this.f_38697_)); ++ ((net.minecraft.server.level.ServerPlayer) entityhuman).connection.send(new net.minecraft.network.protocol.game.ClientboundSetHealthPacket(((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); + // CraftBukkit end + } + //Magma end @@ -88,39 +88,39 @@ } } - boolean flag = p_38711_.f_19853_.m_46469_().m_46207_(GameRules.f_46139_); - if (flag && this.f_38697_ > 0.0F && p_38711_.m_36325_() && this.f_38696_ >= 20) { - ++this.f_38699_; -- if (this.f_38699_ >= 10) { -+ if (this.f_38699_ >= (saturatedRegenRateModified ? saturatedRegenRate : 10)) { // CraftBukkit - add saturatedRegenRate //Magma - mixin inject - float f = Math.min(this.f_38697_, 6.0F); -- p_38711_.m_5634_(f / 6.0F); + boolean flag = p_38711_.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); + if (flag && this.saturationLevel > 0.0F && p_38711_.isHurt() && this.foodLevel >= 20) { + ++this.tickTimer; +- if (this.tickTimer >= 10) { ++ if (this.tickTimer >= (saturatedRegenRateModified ? saturatedRegenRate : 10)) { // CraftBukkit - add saturatedRegenRate //Magma - mixin inject + float f = Math.min(this.saturationLevel, 6.0F); +- p_38711_.heal(f / 6.0F); + p_38711_.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // Magma - fix mixin inject -+ p_38711_.m_5634_(f / 6.0F); // CraftBukkit - add RegainReason ++ p_38711_.heal(f / 6.0F); // CraftBukkit - add RegainReason + this.prepareExhaustion(p_38711_, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); //Magma - this.m_38703_(f); - this.f_38699_ = 0; + this.addExhaustion(f); + this.tickTimer = 0; } - } else if (flag && this.f_38696_ >= 18 && p_38711_.m_36325_()) { - ++this.f_38699_; -- if (this.f_38699_ >= 80) { -+ if (this.f_38699_ >= (unsaturatedRegenRateModified ? this.unsaturatedRegenRate : 80)) { // CraftBukkit - add unsaturatedRegenRate //Magma - mixin inject + } else if (flag && this.foodLevel >= 18 && p_38711_.isHurt()) { + ++this.tickTimer; +- if (this.tickTimer >= 80) { ++ if (this.tickTimer >= (unsaturatedRegenRateModified ? this.unsaturatedRegenRate : 80)) { // CraftBukkit - add unsaturatedRegenRate //Magma - mixin inject + p_38711_.setRegainReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // Magma - fix mixin inject - p_38711_.m_5634_(1.0F); -- this.m_38703_(6.0F); + p_38711_.heal(1.0F); +- this.addExhaustion(6.0F); + this.prepareExhaustion(p_38711_, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); //Magma -+ this.m_38703_(entityhuman == null ? 6.0F : entityhuman.f_19853_.spigotConfig.regenExhaustion); //Magma - add null check - this.f_38699_ = 0; ++ this.addExhaustion(entityhuman == null ? 6.0F : entityhuman.level.spigotConfig.regenExhaustion); //Magma - add null check + this.tickTimer = 0; } - } else if (this.f_38696_ <= 0) { - ++this.f_38699_; -- if (this.f_38699_ >= 80) { -+ if (this.f_38699_ >= (starvationRateModified ? starvationRate : 80)) { // CraftBukkit - add starvationRate //Magma - mixin inject - if (p_38711_.m_21223_() > 10.0F || difficulty == Difficulty.HARD || p_38711_.m_21223_() > 1.0F && difficulty == Difficulty.NORMAL) { - p_38711_.m_6469_(DamageSource.f_19313_, 1.0F); + } else if (this.foodLevel <= 0) { + ++this.tickTimer; +- if (this.tickTimer >= 80) { ++ if (this.tickTimer >= (starvationRateModified ? starvationRate : 80)) { // CraftBukkit - add starvationRate //Magma - mixin inject + if (p_38711_.getHealth() > 10.0F || difficulty == Difficulty.HARD || p_38711_.getHealth() > 1.0F && difficulty == Difficulty.NORMAL) { + p_38711_.hurt(DamageSource.STARVE, 1.0F); } @@ -104,9 +_,29 @@ - return this.f_38696_ < 20; + return this.foodLevel < 20; } + //Magma start - mixin inject @@ -131,22 +131,22 @@ + this.addExhaustion_reason = reason; + } + - public void m_38703_(float p_38704_) { -- this.f_38698_ = Math.min(this.f_38698_ + p_38704_, 40.0F); + public void addExhaustion(float p_38704_) { +- this.exhaustionLevel = Math.min(this.exhaustionLevel + p_38704_, 40.0F); + + if (addExhaustion_player != null) { + // CraftBukkit start + org.bukkit.event.entity.EntityExhaustionEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerExhaustionEvent(addExhaustion_player, addExhaustion_reason, p_38704_); + if (!event.isCancelled()) { -+ this.f_38698_ = Math.min(this.f_38698_ + event.getExhaustion(), 40.0F); ++ this.exhaustionLevel = Math.min(this.exhaustionLevel + event.getExhaustion(), 40.0F); + } + // CraftBukkit end -+ } else this.f_38698_ = Math.min(this.f_38698_ + p_38704_, 40.0F); ++ } else this.exhaustionLevel = Math.min(this.exhaustionLevel + p_38704_, 40.0F); + + this.addExhaustion_player = null; + this.addExhaustion_reason = null; } + //Magma end - public float m_150380_() { - return this.f_38698_; + public float getExhaustionLevel() { + return this.exhaustionLevel; diff --git a/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch b/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch index aae2b25e..12bf1ac7 100644 --- a/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch +++ b/patches/minecraft/net/minecraft/world/food/FoodProperties.java.patch @@ -1,72 +1,72 @@ --- a/net/minecraft/world/food/FoodProperties.java +++ b/net/minecraft/world/food/FoodProperties.java @@ -11,15 +_,26 @@ - private final boolean f_38725_; - private final boolean f_38726_; - private final boolean f_38727_; -- private final List> f_38728_; + private final boolean isMeat; + private final boolean canAlwaysEat; + private final boolean fastFood; +- private final List> effects; - -+ private final List, Float>> f_38728_; ++ private final List, Float>> effects; + + private FoodProperties(FoodProperties.Builder builder) { -+ this.f_38723_ = builder.f_38750_; -+ this.f_38724_ = builder.f_38751_; -+ this.f_38725_ = builder.f_38752_; -+ this.f_38726_ = builder.f_38753_; -+ this.f_38727_ = builder.f_38754_; -+ this.f_38728_ = builder.f_38755_; ++ this.nutrition = builder.nutrition; ++ this.saturationModifier = builder.saturationModifier; ++ this.isMeat = builder.isMeat; ++ this.canAlwaysEat = builder.canAlwaysEat; ++ this.fastFood = builder.fastFood; ++ this.effects = builder.effects; + } + + // Forge: Use builder method instead + @Deprecated FoodProperties(int p_38730_, float p_38731_, boolean p_38732_, boolean p_38733_, boolean p_38734_, List> p_38735_) { - this.f_38723_ = p_38730_; - this.f_38724_ = p_38731_; - this.f_38725_ = p_38732_; - this.f_38726_ = p_38733_; - this.f_38727_ = p_38734_; -- this.f_38728_ = p_38735_; -+ this.f_38728_ = p_38735_.stream().map(pair -> Pair., Float>of(pair::getFirst, pair.getSecond())).collect(java.util.stream.Collectors.toList()); + this.nutrition = p_38730_; + this.saturationModifier = p_38731_; + this.isMeat = p_38732_; + this.canAlwaysEat = p_38733_; + this.fastFood = p_38734_; +- this.effects = p_38735_; ++ this.effects = p_38735_.stream().map(pair -> Pair., Float>of(pair::getFirst, pair.getSecond())).collect(java.util.stream.Collectors.toList()); } - public int m_38744_() { + public int getNutrition() { @@ -43,7 +_,7 @@ } - public List> m_38749_() { -- return this.f_38728_; -+ return this.f_38728_.stream().map(pair -> Pair.of(pair.getFirst() != null ? pair.getFirst().get() : null, pair.getSecond())).collect(java.util.stream.Collectors.toList()); + public List> getEffects() { +- return this.effects; ++ return this.effects.stream().map(pair -> Pair.of(pair.getFirst() != null ? pair.getFirst().get() : null, pair.getSecond())).collect(java.util.stream.Collectors.toList()); } public static class Builder { @@ -52,7 +_,7 @@ - private boolean f_38752_; - private boolean f_38753_; - private boolean f_38754_; -- private final List> f_38755_ = Lists.newArrayList(); -+ private final List, Float>> f_38755_ = Lists.newArrayList(); + private boolean isMeat; + private boolean canAlwaysEat; + private boolean fastFood; +- private final List> effects = Lists.newArrayList(); ++ private final List, Float>> effects = Lists.newArrayList(); - public FoodProperties.Builder m_38760_(int p_38761_) { - this.f_38750_ = p_38761_; + public FoodProperties.Builder nutrition(int p_38761_) { + this.nutrition = p_38761_; @@ -79,13 +_,20 @@ return this; } + public FoodProperties.Builder effect(java.util.function.Supplier effectIn, float probability) { -+ this.f_38755_.add(Pair.of(effectIn, probability)); ++ this.effects.add(Pair.of(effectIn, probability)); + return this; + } + + // Forge: Use supplier method instead + @Deprecated - public FoodProperties.Builder m_38762_(MobEffectInstance p_38763_, float p_38764_) { -- this.f_38755_.add(Pair.of(p_38763_, p_38764_)); -+ this.f_38755_.add(Pair.of(() -> p_38763_, p_38764_)); + public FoodProperties.Builder effect(MobEffectInstance p_38763_, float p_38764_) { +- this.effects.add(Pair.of(p_38763_, p_38764_)); ++ this.effects.add(Pair.of(() -> p_38763_, p_38764_)); return this; } - public FoodProperties m_38767_() { -- return new FoodProperties(this.f_38750_, this.f_38751_, this.f_38752_, this.f_38753_, this.f_38754_, this.f_38755_); + public FoodProperties build() { +- return new FoodProperties(this.nutrition, this.saturationModifier, this.isMeat, this.canAlwaysEat, this.fastFood, this.effects); + return new FoodProperties(this); } } diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 404c2bc9..a8f6da5a 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -59,6 +_,46 @@ - private ContainerSynchronizer f_150397_; - private boolean f_150398_; + private ContainerSynchronizer synchronizer; + private boolean suppressRemoteUpdates; + // CraftBukkit star + //Magma - change this from org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView to InventoryView @@ -35,7 +35,7 @@ + private net.minecraft.network.chat.Component title; + + public final net.minecraft.network.chat.Component getTitle() { -+ return this.title == null ? net.minecraft.network.chat.TextComponent.f_131282_ : this.title; //Magma - allow null titles ++ return this.title == null ? net.minecraft.network.chat.TextComponent.EMPTY : this.title; //Magma - allow null titles + } + + public final void setTitle(net.minecraft.network.chat.Component title) { @@ -45,58 +45,58 @@ + // CraftBukkit end + protected AbstractContainerMenu(@Nullable MenuType p_38851_, int p_38852_) { - this.f_38843_ = p_38851_; - this.f_38840_ = p_38852_; + this.menuType = p_38851_; + this.containerId = p_38852_; @@ -211,9 +_,11 @@ - private void m_150407_(int p_150408_, ItemStack p_150409_, Supplier p_150410_) { - ItemStack itemstack = this.f_38841_.get(p_150408_); - if (!ItemStack.m_41728_(itemstack, p_150409_)) { + private void triggerSlotListeners(int p_150408_, ItemStack p_150409_, Supplier p_150410_) { + ItemStack itemstack = this.lastSlots.get(p_150408_); + if (!ItemStack.matches(itemstack, p_150409_)) { + boolean clientStackChanged = !p_150409_.equals(itemstack, true); ItemStack itemstack1 = p_150410_.get(); - this.f_38841_.set(p_150408_, itemstack1); + this.lastSlots.set(p_150408_, itemstack1); + if(clientStackChanged) - for(ContainerListener containerlistener : this.f_38848_) { - containerlistener.m_7934_(this, p_150408_, itemstack1); + for(ContainerListener containerlistener : this.containerListeners) { + containerlistener.slotChanged(this, p_150408_, itemstack1); } @@ -285,7 +_,7 @@ } - public ItemStack m_7648_(Player p_38941_, int p_38942_) { -- return this.f_38839_.get(p_38942_).m_7993_(); -+ return ItemStack.f_41583_; // CraftBukkit - previous implementation was useless and broken + public ItemStack quickMoveStack(Player p_38941_, int p_38942_) { +- return this.slots.get(p_38942_).getItem(); ++ return ItemStack.EMPTY; // CraftBukkit - previous implementation was useless and broken } - public void m_150399_(int p_150400_, int p_150401_, ClickType p_150402_, Player p_150403_) { + public void clicked(int p_150400_, int p_150401_, ClickType p_150402_, Player p_150403_) { @@ -333,7 +_,7 @@ } - } else if (this.f_38846_ == 2) { - if (!this.f_38847_.isEmpty()) { -- if (this.f_38847_.size() == 1) { -+ if (false && this.f_38847_.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead - int l = (this.f_38847_.iterator().next()).f_40219_; - this.m_38951_(); - this.m_150430_(l, this.f_38845_, ClickType.PICKUP, p_150434_); + } else if (this.quickcraftStatus == 2) { + if (!this.quickcraftSlots.isEmpty()) { +- if (this.quickcraftSlots.size() == 1) { ++ if (false && this.quickcraftSlots.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead + int l = (this.quickcraftSlots.iterator().next()).index; + this.resetQuickCraft(); + this.doClick(l, this.quickcraftType, ClickType.PICKUP, p_150434_); @@ -342,6 +_,7 @@ - ItemStack itemstack3 = this.m_142621_().m_41777_(); - int j1 = this.m_142621_().m_41613_(); + ItemStack itemstack3 = this.getCarried().copy(); + int j1 = this.getCarried().getCount(); + java.util.Map draggedSlots = new java.util.HashMap(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack) - for(Slot slot1 : this.f_38847_) { - ItemStack itemstack1 = this.m_142621_(); + for(Slot slot1 : this.quickcraftSlots) { + ItemStack itemstack1 = this.getCarried(); @@ -355,12 +_,46 @@ } - j1 -= itemstack2.m_41613_() - j; -- slot1.m_5852_(itemstack2); + j1 -= itemstack2.getCount() - j; +- slot1.set(itemstack2); - } - } - -- itemstack3.m_41764_(j1); -- this.m_142503_(itemstack3); +- itemstack3.setCount(j1); +- this.setCarried(itemstack3); + // slot1.set(itemstack2); -+ draggedSlots.put(slot1.f_40219_, itemstack2); // CraftBukkit - Put in map instead of setting ++ draggedSlots.put(slot1.index, itemstack2); // CraftBukkit - Put in map instead of setting + } + } + @@ -110,11 +110,11 @@ + } + + // It's essential that we set the cursor to the new value here to prevent item duplication if a plugin closes the inventory. -+ ItemStack oldCursor = this.m_142621_(); -+ this.m_142503_(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(newcursor)); ++ ItemStack oldCursor = this.getCarried(); ++ this.setCarried(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(newcursor)); + -+ org.bukkit.event.inventory.InventoryDragEvent event = new org.bukkit.event.inventory.InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(oldCursor), this.f_38845_ == 1, eventmap); -+ p_150434_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.inventory.InventoryDragEvent event = new org.bukkit.event.inventory.InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(oldCursor), this.quickcraftType == 1, eventmap); ++ p_150434_.level.getCraftServer().getPluginManager().callEvent(event); + // Whether or not a change was made to the inventory that requires an update. + boolean needsUpdate = event.getResult() != org.bukkit.event.Event.Result.DEFAULT; + @@ -124,121 +124,121 @@ + } + // The only time the carried item will be set to null is if the inventory is closed by the server. + // If the inventory is closed by the server, then the cursor items are dropped. This is why we change the cursor early. -+ if (this.m_142621_() != null) { -+ this.m_142503_(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getCursor())); ++ if (this.getCarried() != null) { ++ this.setCarried(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getCursor())); + needsUpdate = true; + } + } else { -+ this.m_142503_(oldCursor); ++ this.setCarried(oldCursor); + } + if (needsUpdate && p_150434_ instanceof ServerPlayer) { -+ this.m_150429_(); ++ this.sendAllDataToRemote(); + } + // CraftBukkit end } - this.m_38951_(); + this.resetQuickCraft(); @@ -374,8 +_,11 @@ if (p_150431_ == -999) { - if (!this.m_142621_().m_41619_()) { + if (!this.getCarried().isEmpty()) { if (clickaction == ClickAction.PRIMARY) { -- p_150434_.m_36176_(this.m_142621_(), true); +- p_150434_.drop(this.getCarried(), true); + // CraftBukkit start -+ ItemStack carried = this.m_142621_(); - this.m_142503_(ItemStack.f_41583_); -+ p_150434_.m_36176_(carried, true); ++ ItemStack carried = this.getCarried(); + this.setCarried(ItemStack.EMPTY); ++ p_150434_.drop(carried, true); + // CraftBukkit start } else { - p_150434_.m_36176_(this.m_142621_().m_41620_(1), true); + p_150434_.drop(this.getCarried().split(1), true); } @@ -434,6 +_,20 @@ } - slot7.m_6654_(); + slot7.setChanged(); + // CraftBukkit start - Make sure the client has the right slot contents -+ if (p_150434_ instanceof ServerPlayer && slot7.m_6641_() != 64) { -+ ((ServerPlayer) p_150434_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.f_38840_, this.m_182425_(), slot7.f_40219_, slot7.m_7993_())); ++ if (p_150434_ instanceof ServerPlayer && slot7.getMaxStackSize() != 64) { ++ ((ServerPlayer) p_150434_).connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot7.index, slot7.getItem())); + // Updating a crafting inventory makes the client reset the result slot, have to send it again + try { + if (this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.WORKBENCH || this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.CRAFTING) { -+ ((ServerPlayer) p_150434_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.f_38840_, this.m_182425_(), 0, this.m_38853_(0).m_7993_())); ++ ((ServerPlayer) p_150434_).connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); + } + } catch ( AbstractMethodError error ){ -+ f_207773_.error(error.getMessage()); -+ ((ServerPlayer) p_150434_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.f_38840_, this.m_182425_(), 0, this.m_38853_(0).m_7993_())); ++ LOGGER.error(error.getMessage()); ++ ((ServerPlayer) p_150434_).connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); + } + } + // CraftBukkit end } } else if (p_150433_ == ClickType.SWAP) { - Slot slot2 = this.f_38839_.get(p_150431_); + Slot slot2 = this.slots.get(p_150431_); @@ -529,13 +_,14 @@ if (p_38940_ instanceof ServerPlayer) { - ItemStack itemstack = this.m_142621_(); - if (!itemstack.m_41619_()) { -+ this.m_142503_(ItemStack.f_41583_); // CraftBukkit - SPIGOT-4556 - from below - if (p_38940_.m_6084_() && !((ServerPlayer)p_38940_).m_9232_()) { - p_38940_.m_150109_().m_150079_(itemstack); + ItemStack itemstack = this.getCarried(); + if (!itemstack.isEmpty()) { ++ this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below + if (p_38940_.isAlive() && !((ServerPlayer)p_38940_).hasDisconnected()) { + p_38940_.getInventory().placeItemBackInInventory(itemstack); } else { - p_38940_.m_36176_(itemstack, false); + p_38940_.drop(itemstack, false); } -- this.m_142503_(ItemStack.f_41583_); +- this.setCarried(ItemStack.EMPTY); + //this.setCarried(ItemStack.EMPTY); // CraftBukkit - moved up } } @@ -603,14 +_,15 @@ - ItemStack itemstack = slot.m_7993_(); - if (!itemstack.m_41619_() && ItemStack.m_150942_(p_38904_, itemstack)) { - int j = itemstack.m_41613_() + p_38904_.m_41613_(); -- if (j <= p_38904_.m_41741_()) { -+ int maxSize = Math.min(slot.m_6641_(), p_38904_.m_41741_()); + ItemStack itemstack = slot.getItem(); + if (!itemstack.isEmpty() && ItemStack.isSameItemSameTags(p_38904_, itemstack)) { + int j = itemstack.getCount() + p_38904_.getCount(); +- if (j <= p_38904_.getMaxStackSize()) { ++ int maxSize = Math.min(slot.getMaxStackSize(), p_38904_.getMaxStackSize()); + if (j <= maxSize) { - p_38904_.m_41764_(0); - itemstack.m_41764_(j); - slot.m_6654_(); + p_38904_.setCount(0); + itemstack.setCount(j); + slot.setChanged(); flag = true; -- } else if (itemstack.m_41613_() < p_38904_.m_41741_()) { -- p_38904_.m_41774_(p_38904_.m_41741_() - itemstack.m_41613_()); -- itemstack.m_41764_(p_38904_.m_41741_()); -+ } else if (itemstack.m_41613_() < maxSize) { -+ p_38904_.m_41774_(maxSize - itemstack.m_41613_()); -+ itemstack.m_41764_(maxSize); - slot.m_6654_(); +- } else if (itemstack.getCount() < p_38904_.getMaxStackSize()) { +- p_38904_.shrink(p_38904_.getMaxStackSize() - itemstack.getCount()); +- itemstack.setCount(p_38904_.getMaxStackSize()); ++ } else if (itemstack.getCount() < maxSize) { ++ p_38904_.shrink(maxSize - itemstack.getCount()); ++ itemstack.setCount(maxSize); + slot.setChanged(); flag = true; } @@ -710,7 +_,7 @@ - p_38925_.m_41764_(1); + p_38925_.setCount(1); break; case 2: -- p_38925_.m_41764_(p_38925_.m_41720_().m_41459_()); -+ p_38925_.m_41764_(p_38925_.m_41741_()); +- p_38925_.setCount(p_38925_.getItem().getMaxStackSize()); ++ p_38925_.setCount(p_38925_.getMaxStackSize()); } - p_38925_.m_41769_(p_38926_); + p_38925_.grow(p_38926_); @@ -749,6 +_,11 @@ } - public ItemStack m_142621_() { + public ItemStack getCarried() { + // CraftBukkit start -+ if (this.f_150393_.m_41619_()) { -+ this.m_142503_(ItemStack.f_41583_); ++ if (this.carried.isEmpty()) { ++ this.setCarried(ItemStack.EMPTY); + } + // CraftBukkit end - return this.f_150393_; + return this.carried; } @@ -798,4 +_,13 @@ - this.f_182405_ = this.f_182405_ + 1 & 32767; - return this.f_182405_; + this.stateId = this.stateId + 1 & 32767; + return this.stateId; } + + // CraftBukkit start + public void broadcastCarriedItem() { -+ this.f_150396_ = this.m_142621_().m_41777_(); -+ if (this.f_150397_ != null) { -+ this.f_150397_.m_142529_(this, this.f_150396_); ++ this.remoteCarried = this.getCarried().copy(); ++ if (this.synchronizer != null) { ++ this.synchronizer.sendCarriedChange(this, this.remoteCarried); + } + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch index 6335b634..346cec03 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java @@ -28,6 +_,22 @@ - private final RecipeType f_38957_; - private final RecipeBookType f_38958_; + private final RecipeType recipeType; + private final RecipeBookType recipeBookType; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -14,8 +14,8 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryFurnace inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryFurnace((AbstractFurnaceBlockEntity) this.f_38955_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryFurnace inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryFurnace((AbstractFurnaceBlockEntity) this.container); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end @@ -24,9 +24,9 @@ this(p_38960_, p_38961_, p_38962_, p_38963_, p_38964_, new SimpleContainer(3), new SimpleContainerData(4)); } @@ -44,6 +_,7 @@ - this.m_38897_(new Slot(p_38971_, 0, 56, 17)); - this.m_38897_(new FurnaceFuelSlot(this, p_38971_, 1, 56, 53)); - this.m_38897_(new FurnaceResultSlot(p_38970_.f_35978_, p_38971_, 2, 116, 35)); + this.addSlot(new Slot(p_38971_, 0, 56, 17)); + this.addSlot(new FurnaceFuelSlot(this, p_38971_, 1, 56, 53)); + this.addSlot(new FurnaceResultSlot(p_38970_.player, p_38971_, 2, 116, 35)); + this.player = p_38970_; // CraftBukkit - save player for(int i = 0; i < 3; ++i) { @@ -34,17 +34,17 @@ @@ -91,6 +_,7 @@ } - public boolean m_6875_(Player p_38974_) { + public boolean stillValid(Player p_38974_) { + if (!this.checkReachable) return true; // CraftBukkit - return this.f_38955_.m_6542_(p_38974_); + return this.container.stillValid(p_38974_); } @@ -147,7 +_,7 @@ } - protected boolean m_38988_(ItemStack p_38989_) { -- return AbstractFurnaceBlockEntity.m_58399_(p_38989_); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_38989_, this.f_38957_) > 0; + protected boolean isFuel(ItemStack p_38989_) { +- return AbstractFurnaceBlockEntity.isFuel(p_38989_); ++ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_38989_, this.recipeType) > 0; } - public int m_38995_() { + public int getBurnProgress() { diff --git a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch index 1c0f981c..5da323a0 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/AnvilMenu.java +++ b/net/minecraft/world/inventory/AnvilMenu.java @@ -31,6 +_,25 @@ - private static final int f_150466_ = 1; - private static final int f_150467_ = 1; + private static final int COST_INCOMPATIBLE_PENALTY = 1; + private static final int COST_RENAME = 1; + // CraftBukkit start + public static final int DEFAULT_DENIED_COST = -1; @@ -14,8 +14,8 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryAnvil(f_39770_.getLocation(), this.f_39769_, this.f_39768_, this); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.f_39771_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryAnvil(access.getLocation(), this.inputSlots, this.resultSlots, this); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end @@ -24,77 +24,77 @@ + public org.magmafoundation.magma.helpers.AnvilHelper anvilHelper = new org.magmafoundation.magma.helpers.AnvilHelper(); + public AnvilMenu(int p_39005_, Inventory p_39006_) { - this(p_39005_, p_39006_, ContainerLevelAccess.f_39287_); + this(p_39005_, p_39006_, ContainerLevelAccess.NULL); } @@ -45,7 +_,7 @@ } - protected boolean m_6560_(Player p_39023_, boolean p_39024_) { -- return (p_39023_.m_150110_().f_35937_ || p_39023_.f_36078_ >= this.f_39002_.m_6501_()) && this.f_39002_.m_6501_() > 0; -+ return (p_39023_.m_150110_().f_35937_ || p_39023_.f_36078_ >= this.f_39002_.m_6501_()) && this.f_39002_.m_6501_() > AnvilMenu.DEFAULT_DENIED_COST && p_39024_; // CraftBukkit - allow cost 0 like a free item + protected boolean mayPickup(Player p_39023_, boolean p_39024_) { +- return (p_39023_.getAbilities().instabuild || p_39023_.experienceLevel >= this.cost.get()) && this.cost.get() > 0; ++ return (p_39023_.getAbilities().instabuild || p_39023_.experienceLevel >= this.cost.get()) && this.cost.get() > AnvilMenu.DEFAULT_DENIED_COST && p_39024_; // CraftBukkit - allow cost 0 like a free item } - protected void m_142365_(Player p_150474_, ItemStack p_150475_) { + protected void onTake(Player p_150474_, ItemStack p_150475_) { @@ -53,6 +_,8 @@ - p_150474_.m_6749_(-this.f_39002_.m_6501_()); + p_150474_.giveExperienceLevels(-this.cost.get()); } -+ float breakChance = net.minecraftforge.common.ForgeHooks.onAnvilRepair(p_150474_, p_150475_, AnvilMenu.this.f_39769_.m_8020_(0), AnvilMenu.this.f_39769_.m_8020_(1)); ++ float breakChance = net.minecraftforge.common.ForgeHooks.onAnvilRepair(p_150474_, p_150475_, AnvilMenu.this.inputSlots.getItem(0), AnvilMenu.this.inputSlots.getItem(1)); + - this.f_39769_.m_6836_(0, ItemStack.f_41583_); - if (this.f_39000_ > 0) { - ItemStack itemstack = this.f_39769_.m_8020_(1); + this.inputSlots.setItem(0, ItemStack.EMPTY); + if (this.repairItemCountCost > 0) { + ItemStack itemstack = this.inputSlots.getItem(1); @@ -66,10 +_,10 @@ - this.f_39769_.m_6836_(1, ItemStack.f_41583_); + this.inputSlots.setItem(1, ItemStack.EMPTY); } -- this.f_39002_.m_6422_(0); -+ this.f_39002_.m_6422_(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item - this.f_39770_.m_39292_((p_150479_, p_150480_) -> { - BlockState blockstate = p_150479_.m_8055_(p_150480_); -- if (!p_150474_.m_150110_().f_35937_ && blockstate.m_204336_(BlockTags.f_13033_) && p_150474_.m_21187_().nextFloat() < 0.12F) { -+ if (!p_150474_.m_150110_().f_35937_ && blockstate.m_204336_(BlockTags.f_13033_) && p_150474_.m_21187_().nextFloat() < breakChance) { - BlockState blockstate1 = AnvilBlock.m_48824_(blockstate); +- this.cost.set(0); ++ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item + this.access.execute((p_150479_, p_150480_) -> { + BlockState blockstate = p_150479_.getBlockState(p_150480_); +- if (!p_150474_.getAbilities().instabuild && blockstate.is(BlockTags.ANVIL) && p_150474_.getRandom().nextFloat() < 0.12F) { ++ if (!p_150474_.getAbilities().instabuild && blockstate.is(BlockTags.ANVIL) && p_150474_.getRandom().nextFloat() < breakChance) { + BlockState blockstate1 = AnvilBlock.damage(blockstate); if (blockstate1 == null) { - p_150479_.m_7471_(p_150480_, false); + p_150479_.removeBlock(p_150480_, false); @@ -92,21 +_,24 @@ int j = 0; int k = 0; - if (itemstack.m_41619_()) { -- this.f_39768_.m_6836_(0, ItemStack.f_41583_); -- this.f_39002_.m_6422_(0); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.f_41583_); // CraftBukkit -+ this.f_39002_.m_6422_(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item + if (itemstack.isEmpty()) { +- this.resultSlots.setItem(0, ItemStack.EMPTY); +- this.cost.set(0); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit ++ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item } else { - ItemStack itemstack1 = itemstack.m_41777_(); - ItemStack itemstack2 = this.f_39769_.m_8020_(1); - Map map = EnchantmentHelper.m_44831_(itemstack1); - j += itemstack.m_41610_() + (itemstack2.m_41619_() ? 0 : itemstack2.m_41610_()); - this.f_39000_ = 0; + ItemStack itemstack1 = itemstack.copy(); + ItemStack itemstack2 = this.inputSlots.getItem(1); + Map map = EnchantmentHelper.getEnchantments(itemstack1); + j += itemstack.getBaseRepairCost() + (itemstack2.isEmpty() ? 0 : itemstack2.getBaseRepairCost()); + this.repairItemCountCost = 0; + boolean flag = false; + - if (!itemstack2.m_41619_()) { -- boolean flag = itemstack2.m_150930_(Items.f_42690_) && !EnchantedBookItem.m_41163_(itemstack2).isEmpty(); -+ if (!net.minecraftforge.common.ForgeHooks.onAnvilChange(this, itemstack, itemstack2, f_39768_, f_39001_, j, this.f_39771_)) return; -+ flag = itemstack2.m_41720_() == Items.f_42690_ && !EnchantedBookItem.m_41163_(itemstack2).isEmpty(); - if (itemstack1.m_41763_() && itemstack1.m_41720_().m_6832_(itemstack, itemstack2)) { - int l2 = Math.min(itemstack1.m_41773_(), itemstack1.m_41776_() / 4); + if (!itemstack2.isEmpty()) { +- boolean flag = itemstack2.is(Items.ENCHANTED_BOOK) && !EnchantedBookItem.getEnchantments(itemstack2).isEmpty(); ++ if (!net.minecraftforge.common.ForgeHooks.onAnvilChange(this, itemstack, itemstack2, resultSlots, itemName, j, this.player)) return; ++ flag = itemstack2.getItem() == Items.ENCHANTED_BOOK && !EnchantedBookItem.getEnchantments(itemstack2).isEmpty(); + if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { + int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (l2 <= 0) { -- this.f_39768_.m_6836_(0, ItemStack.f_41583_); -- this.f_39002_.m_6422_(0); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.f_41583_); // CraftBukkit -+ this.f_39002_.m_6422_(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item +- this.resultSlots.setItem(0, ItemStack.EMPTY); +- this.cost.set(0); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit ++ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item return; } @@ -121,8 +_,8 @@ - this.f_39000_ = i3; + this.repairItemCountCost = i3; } else { - if (!flag && (!itemstack1.m_150930_(itemstack2.m_41720_()) || !itemstack1.m_41763_())) { -- this.f_39768_.m_6836_(0, ItemStack.f_41583_); -- this.f_39002_.m_6422_(0); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.f_41583_); // CraftBukkit -+ this.f_39002_.m_6422_(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item + if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) { +- this.resultSlots.setItem(0, ItemStack.EMPTY); +- this.cost.set(0); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit ++ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item return; } @@ -102,54 +102,54 @@ } if (flag3 && !flag2) { -- this.f_39768_.m_6836_(0, ItemStack.f_41583_); -- this.f_39002_.m_6422_(0); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.f_41583_); // CraftBukkit -+ this.f_39002_.m_6422_(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item +- this.resultSlots.setItem(0, ItemStack.EMPTY); +- this.cost.set(0); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit ++ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item return; } } @@ -218,14 +_,21 @@ i += k; - itemstack1.m_41714_(new TextComponent(this.f_39001_)); + itemstack1.setHoverName(new TextComponent(this.itemName)); } -+ if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.f_41583_; ++ if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.EMPTY; - this.f_39002_.m_6422_(j + i); + this.cost.set(j + i); if (i <= 0) { - itemstack1 = ItemStack.f_41583_; + itemstack1 = ItemStack.EMPTY; } -- if (k == i && k > 0 && this.f_39002_.m_6501_() >= 40) { -- this.f_39002_.m_6422_(39); +- if (k == i && k > 0 && this.cost.get() >= 40) { +- this.cost.set(39); + if (anvilHelper.isDefaultValue()) { -+ if (k == i && k > 0 && this.f_39002_.m_6501_() >= 40) { -+ this.f_39002_.m_6422_(39); ++ if (k == i && k > 0 && this.cost.get() >= 40) { ++ this.cost.set(39); + } + } else { -+ if (k == i && k > 0 && this.f_39002_.m_6501_() >= anvilHelper.getMaxRepairCost()) { // Craftbukkit -+ this.f_39002_.m_6422_(anvilHelper.getMaxRepairCost() - 1); // Craftbukkit ++ if (k == i && k > 0 && this.cost.get() >= anvilHelper.getMaxRepairCost()) { // Craftbukkit ++ this.cost.set(anvilHelper.getMaxRepairCost() - 1); // Craftbukkit + } } - if (this.f_39002_.m_6501_() >= 40 && !this.f_39771_.m_150110_().f_35937_) { + if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) { @@ -246,7 +_,8 @@ - EnchantmentHelper.m_44865_(map, itemstack1); + EnchantmentHelper.setEnchantments(map, itemstack1); } -- this.f_39768_.m_6836_(0, itemstack1); +- this.resultSlots.setItem(0, itemstack1); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit -+ m_150429_(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client - this.m_38946_(); ++ sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client + this.broadcastChanges(); } } @@ -271,5 +_,9 @@ - public int m_39028_() { - return this.f_39002_.m_6501_(); + public int getCost() { + return this.cost.get(); + } + + public void setMaximumCost(int value) { -+ this.f_39002_.m_6422_(value); ++ this.cost.set(value); } } diff --git a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch index 5d47b54c..662528ed 100644 --- a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java @@ -31,12 +_,29 @@ - private final ContainerLevelAccess f_39033_; - private final ContainerData f_39034_; + private final ContainerLevelAccess access; + private final ContainerData beaconData; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -14,49 +14,49 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryBeacon(this.f_39031_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryBeacon(this.beacon); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end + public BeaconMenu(int p_39036_, Container p_39037_) { - this(p_39036_, p_39037_, new SimpleContainerData(3), ContainerLevelAccess.f_39287_); + this(p_39036_, p_39037_, new SimpleContainerData(3), ContainerLevelAccess.NULL); } public BeaconMenu(int p_39039_, Container p_39040_, ContainerData p_39041_, ContainerLevelAccess p_39042_) { - super(MenuType.f_39965_, p_39039_); + super(MenuType.BEACON, p_39039_); + player = (net.minecraft.world.entity.player.Inventory) p_39040_; // CraftBukkit - TODO: check this - m_38886_(p_39041_, 3); - this.f_39034_ = p_39041_; - this.f_39033_ = p_39042_; + checkContainerDataCount(p_39041_, 3); + this.beaconData = p_39041_; + this.access = p_39042_; @@ -70,6 +_,7 @@ } - public boolean m_6875_(Player p_39047_) { + public boolean stillValid(Player p_39047_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_39033_, p_39047_, Blocks.f_50273_); + return stillValid(this.access, p_39047_, Blocks.BEACON); } @@ -90,10 +_,8 @@ } - slot.m_40234_(itemstack1, itemstack); -- } else if (!this.f_39032_.m_6657_() && this.f_39032_.m_5857_(itemstack1) && itemstack1.m_41613_() == 1) { -- if (!this.m_38903_(itemstack1, 0, 1, false)) { -- return ItemStack.f_41583_; + slot.onQuickCraft(itemstack1, itemstack); +- } else if (!this.paymentSlot.hasItem() && this.paymentSlot.mayPlace(itemstack1) && itemstack1.getCount() == 1) { +- if (!this.moveItemStackTo(itemstack1, 0, 1, false)) { +- return ItemStack.EMPTY; - } -+ } else if (this.m_38903_(itemstack1, 0, 1, false)) { //Forge Fix Shift Clicking in beacons with stacks larger then 1. -+ return ItemStack.f_41583_; ++ } else if (this.moveItemStackTo(itemstack1, 0, 1, false)) { //Forge Fix Shift Clicking in beacons with stacks larger then 1. ++ return ItemStack.EMPTY; } else if (p_39052_ >= 1 && p_39052_ < 28) { - if (!this.m_38903_(itemstack1, 28, 37, false)) { - return ItemStack.f_41583_; + if (!this.moveItemStackTo(itemstack1, 28, 37, false)) { + return ItemStack.EMPTY; @@ -141,7 +_,7 @@ - this.f_39034_.m_8050_(1, p_39054_); - this.f_39034_.m_8050_(2, p_39055_); - this.f_39032_.m_6201_(1); -- this.f_39033_.m_39292_(Level::m_151543_); -+ this.f_39033_.m_39292_(Level::blockEntityChangedWithoutNeighborUpdates); + this.beaconData.set(1, p_39054_); + this.beaconData.set(2, p_39055_); + this.paymentSlot.remove(1); +- this.access.execute(Level::blockEntityChanged); ++ this.access.execute(Level::blockEntityChangedWithoutNeighborUpdates); } } diff --git a/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch index 4c6184b1..b9d2102d 100644 --- a/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/BrewingStandMenu.java +++ b/net/minecraft/world/inventory/BrewingStandMenu.java @@ -27,12 +_,29 @@ - private final ContainerData f_39087_; - private final Slot f_39088_; + private final ContainerData brewingStandData; + private final Slot ingredientSlot; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -14,8 +14,8 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryBrewer inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryBrewer(this.f_39086_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryBrewer inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryBrewer(this.brewingStand); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end @@ -25,50 +25,50 @@ } public BrewingStandMenu(int p_39093_, Inventory p_39094_, Container p_39095_, ContainerData p_39096_) { - super(MenuType.f_39967_, p_39093_); + super(MenuType.BREWING_STAND, p_39093_); + player = p_39094_; // CraftBukkit - m_38869_(p_39095_, 5); - m_38886_(p_39096_, 2); - this.f_39086_ = p_39095_; + checkContainerSize(p_39095_, 5); + checkContainerDataCount(p_39096_, 2); + this.brewingStand = p_39095_; @@ -57,6 +_,7 @@ } - public boolean m_6875_(Player p_39098_) { + public boolean stillValid(Player p_39098_) { + if (!this.checkReachable) return true; // CraftBukkit - return this.f_39086_.m_6542_(p_39098_); + return this.brewingStand.stillValid(p_39098_); } @@ -75,7 +_,7 @@ - if (!this.m_38903_(itemstack1, 3, 4, false)) { - return ItemStack.f_41583_; + if (!this.moveItemStackTo(itemstack1, 3, 4, false)) { + return ItemStack.EMPTY; } -- } else if (BrewingStandMenu.PotionSlot.m_39133_(itemstack) && itemstack.m_41613_() == 1) { -+ } else if (BrewingStandMenu.PotionSlot.m_39133_(itemstack)) { - if (!this.m_38903_(itemstack1, 0, 3, false)) { - return ItemStack.f_41583_; +- } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemstack) && itemstack.getCount() == 1) { ++ } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemstack)) { + if (!this.moveItemStackTo(itemstack1, 0, 3, false)) { + return ItemStack.EMPTY; } @@ -146,7 +_,7 @@ } - public boolean m_5857_(ItemStack p_39121_) { -- return PotionBrewing.m_43506_(p_39121_); + public boolean mayPlace(ItemStack p_39121_) { +- return PotionBrewing.isIngredient(p_39121_); + return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_39121_); } - public int m_6641_() { + public int getMaxStackSize() { @@ -170,6 +_,7 @@ - public void m_142406_(Player p_150499_, ItemStack p_150500_) { - Potion potion = PotionUtils.m_43579_(p_150500_); + public void onTake(Player p_150499_, ItemStack p_150500_) { + Potion potion = PotionUtils.getPotion(p_150500_); if (p_150499_ instanceof ServerPlayer) { + net.minecraftforge.event.ForgeEventFactory.onPlayerBrewedPotion(p_150499_, p_150500_); - CriteriaTriggers.f_10577_.m_19120_((ServerPlayer)p_150499_, potion); + CriteriaTriggers.BREWED_POTION.trigger((ServerPlayer)p_150499_, potion); } @@ -177,7 +_,7 @@ } - public static boolean m_39133_(ItemStack p_39134_) { -- return p_39134_.m_150930_(Items.f_42589_) || p_39134_.m_150930_(Items.f_42736_) || p_39134_.m_150930_(Items.f_42739_) || p_39134_.m_150930_(Items.f_42590_); + public static boolean mayPlaceItem(ItemStack p_39134_) { +- return p_39134_.is(Items.POTION) || p_39134_.is(Items.SPLASH_POTION) || p_39134_.is(Items.LINGERING_POTION) || p_39134_.is(Items.GLASS_BOTTLE); + return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_39134_); } } diff --git a/patches/minecraft/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/CartographyTableMenu.java.patch index 33ceb590..9ddd43b2 100644 --- a/patches/minecraft/net/minecraft/world/inventory/CartographyTableMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/CartographyTableMenu.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/inventory/CartographyTableMenu.java +++ b/net/minecraft/world/inventory/CartographyTableMenu.java @@ -22,18 +_,24 @@ - private static final int f_150507_ = 39; - private final ContainerLevelAccess f_39136_; - long f_39137_; -- public final Container f_39135_ = new SimpleContainer(2) { -- public void m_6596_() { -- CartographyTableMenu.this.m_6199_(this); -- super.m_6596_(); + private static final int USE_ROW_SLOT_END = 39; + private final ContainerLevelAccess access; + long lastSoundTime; +- public final Container container = new SimpleContainer(2) { +- public void setChanged() { +- CartographyTableMenu.this.slotsChanged(this); +- super.setChanged(); - } - }; -- private final ResultContainer f_39138_ = new ResultContainer() { -- public void m_6596_() { -- CartographyTableMenu.this.m_6199_(this); -- super.m_6596_(); +- private final ResultContainer resultContainer = new ResultContainer() { +- public void setChanged() { +- CartographyTableMenu.this.slotsChanged(this); +- super.setChanged(); - } - }; -+ public final Container f_39135_; -+ private final ResultContainer f_39138_; ++ public final Container container; ++ private final ResultContainer resultContainer; + + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -29,23 +29,23 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCartography inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCartography(this.f_39135_, this.f_39138_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCartography inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCartography(this.container, this.resultContainer); + bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end public CartographyTableMenu(int p_39140_, Inventory p_39141_) { - this(p_39140_, p_39141_, ContainerLevelAccess.f_39287_); + this(p_39140_, p_39141_, ContainerLevelAccess.NULL); @@ -41,6 +_,34 @@ public CartographyTableMenu(int p_39143_, Inventory p_39144_, final ContainerLevelAccess p_39145_) { - super(MenuType.f_39979_, p_39143_); + super(MenuType.CARTOGRAPHY_TABLE, p_39143_); + //Magma start - add location -+ this.f_39135_ = new SimpleContainer(2) { -+ public void m_6596_() { -+ CartographyTableMenu.this.m_6199_(this); -+ super.m_6596_(); ++ this.container = new SimpleContainer(2) { ++ public void setChanged() { ++ CartographyTableMenu.this.slotsChanged(this); ++ super.setChanged(); + } + + // CraftBukkit start @@ -55,10 +55,10 @@ + } + // CraftBukkit end + }; -+ this.f_39138_ = new ResultContainer() { -+ public void m_6596_() { -+ CartographyTableMenu.this.m_6199_(this); -+ super.m_6596_(); ++ this.resultContainer = new ResultContainer() { ++ public void setChanged() { ++ CartographyTableMenu.this.slotsChanged(this); ++ super.setChanged(); + } + + // CraftBukkit start @@ -69,18 +69,18 @@ + // CraftBukkit end + }; + //Magma end - this.f_39136_ = p_39145_; - this.m_38897_(new Slot(this.f_39135_, 0, 15, 15) { - public boolean m_5857_(ItemStack p_39194_) { + this.access = p_39145_; + this.addSlot(new Slot(this.container, 0, 15, 15) { + public boolean mayPlace(ItemStack p_39194_) { @@ -83,9 +_,11 @@ - this.m_38897_(new Slot(p_39144_, k, 8 + k * 18, 142)); + this.addSlot(new Slot(p_39144_, k, 8 + k * 18, 142)); } -+ player = (org.bukkit.entity.Player) p_39144_.f_35978_.getBukkitEntity(); // CraftBukkit ++ player = (org.bukkit.entity.Player) p_39144_.player.getBukkitEntity(); // CraftBukkit } - public boolean m_6875_(Player p_39149_) { + public boolean stillValid(Player p_39149_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_39136_, p_39149_, Blocks.f_50621_); + return stillValid(this.access, p_39149_, Blocks.CARTOGRAPHY_TABLE); } diff --git a/patches/minecraft/net/minecraft/world/inventory/ChestMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/ChestMenu.java.patch index e61df3eb..279ce7bc 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ChestMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ChestMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ChestMenu.java +++ b/net/minecraft/world/inventory/ChestMenu.java @@ -11,6 +_,30 @@ - private final Container f_39221_; - private final int f_39222_; + private final Container container; + private final int containerRows; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -15,15 +15,15 @@ + } + + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory; -+ if (this.f_39221_ instanceof Inventory) { -+ inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryPlayer((Inventory) this.f_39221_); -+ } else if (this.f_39221_ instanceof net.minecraft.world.CompoundContainer) { -+ inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryDoubleChest((net.minecraft.world.CompoundContainer) this.f_39221_); ++ if (this.container instanceof Inventory) { ++ inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryPlayer((Inventory) this.container); ++ } else if (this.container instanceof net.minecraft.world.CompoundContainer) { ++ inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryDoubleChest((net.minecraft.world.CompoundContainer) this.container); + } else { -+ inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.f_39221_); ++ inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.container); + } + -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end @@ -32,21 +32,21 @@ this(p_39224_, p_39225_, p_39226_, new SimpleContainer(9 * p_39227_), p_39227_); } @@ -55,6 +_,10 @@ - p_39232_.m_5856_(p_39231_.f_35978_); - int i = (this.f_39222_ - 4) * 18; + p_39232_.startOpen(p_39231_.player); + int i = (this.containerRows - 4) * 18; + // CraftBukkit start - Save player + this.player = p_39231_; + // CraftBukkit end + - for(int j = 0; j < this.f_39222_; ++j) { + for(int j = 0; j < this.containerRows; ++j) { for(int k = 0; k < 9; ++k) { - this.m_38897_(new Slot(p_39232_, k + j * 9, 8 + k * 18, 18 + j * 18)); + this.addSlot(new Slot(p_39232_, k + j * 9, 8 + k * 18, 18 + j * 18)); @@ -74,6 +_,7 @@ } - public boolean m_6875_(Player p_39242_) { + public boolean stillValid(Player p_39242_) { + if (!this.checkReachable) return true; // CraftBukkit - return this.f_39221_.m_6542_(p_39242_); + return this.container.stillValid(p_39242_); } diff --git a/patches/minecraft/net/minecraft/world/inventory/ContainerLevelAccess.java.patch b/patches/minecraft/net/minecraft/world/inventory/ContainerLevelAccess.java.patch index b9c27b98..ad8c6f83 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ContainerLevelAccess.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ContainerLevelAccess.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/ContainerLevelAccess.java +++ b/net/minecraft/world/inventory/ContainerLevelAccess.java @@ -18,6 +_,18 @@ - public Optional m_6721_(BiFunction p_39311_) { + public Optional evaluate(BiFunction p_39311_) { return Optional.of(p_39311_.apply(p_39290_, p_39291_)); } + @@ -34,7 +34,7 @@ + } + + default org.bukkit.Location getLocation() { -+ return new org.bukkit.Location(getWorld().getWorld(), getPosition().m_123341_(), getPosition().m_123342_(), getPosition().m_123343_()); ++ return new org.bukkit.Location(getWorld().getWorld(), getPosition().getX(), getPosition().getY(), getPosition().getZ()); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/inventory/CraftingContainer.java.patch b/patches/minecraft/net/minecraft/world/inventory/CraftingContainer.java.patch index 573d81a8..b8641567 100644 --- a/patches/minecraft/net/minecraft/world/inventory/CraftingContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/CraftingContainer.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/CraftingContainer.java +++ b/net/minecraft/world/inventory/CraftingContainer.java @@ -13,6 +_,73 @@ - private final int f_39322_; - private final AbstractContainerMenu f_39323_; + private final int height; + private final AbstractContainerMenu menu; + // CraftBukkit start - add fields + public java.util.List transaction = new java.util.ArrayList(); @@ -12,7 +12,7 @@ + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.f_39320_; ++ return this.items; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -20,7 +20,7 @@ + } + + public org.bukkit.event.inventory.InventoryType getInvType() { -+ return f_39320_.size() == 4 ? org.bukkit.event.inventory.InventoryType.CRAFTING : org.bukkit.event.inventory.InventoryType.WORKBENCH; ++ return items.size() == 4 ? org.bukkit.event.inventory.InventoryType.CRAFTING : org.bukkit.event.inventory.InventoryType.WORKBENCH; + } + + public void onClose(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -41,7 +41,7 @@ + + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -52,7 +52,7 @@ + + @Override + public org.bukkit.Location getLocation() { -+ return f_39323_ instanceof CraftingMenu ? ((CraftingMenu) f_39323_).f_39350_.getLocation() : owner.getBukkitEntity().getLocation(); ++ return menu instanceof CraftingMenu ? ((CraftingMenu) menu).access.getLocation() : owner.getBukkitEntity().getLocation(); + } + + @Override @@ -72,5 +72,5 @@ + // CraftBukkit end + public CraftingContainer(AbstractContainerMenu p_39325_, int p_39326_, int p_39327_) { - this.f_39320_ = NonNullList.m_122780_(p_39326_ * p_39327_, ItemStack.f_41583_); - this.f_39323_ = p_39325_; + this.items = NonNullList.withSize(p_39326_ * p_39327_, ItemStack.EMPTY); + this.menu = p_39325_; diff --git a/patches/minecraft/net/minecraft/world/inventory/CraftingMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/CraftingMenu.java.patch index 661b50c1..8ecb941f 100644 --- a/patches/minecraft/net/minecraft/world/inventory/CraftingMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/CraftingMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/CraftingMenu.java +++ b/net/minecraft/world/inventory/CraftingMenu.java @@ -27,6 +_,21 @@ - public final ContainerLevelAccess f_39350_; - private final Player f_39351_; + public final ContainerLevelAccess access; + private final Player player; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -13,40 +13,40 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting(this.f_39348_, this.f_39349_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.f_39351_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting(this.craftSlots, this.resultSlots); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end + public CraftingMenu(int p_39353_, Inventory p_39354_) { - this(p_39353_, p_39354_, ContainerLevelAccess.f_39287_); + this(p_39353_, p_39354_, ContainerLevelAccess.NULL); } @@ -35,6 +_,10 @@ - super(MenuType.f_39968_, p_39356_); - this.f_39350_ = p_39358_; - this.f_39351_ = p_39357_.f_35978_; + super(MenuType.CRAFTING, p_39356_); + this.access = p_39358_; + this.player = p_39357_.player; + // CraftBukkit start - Switched order of IInventory construction and stored player -+ this.f_39348_.setOwner(this.f_39351_); -+ this.f_39348_.resultInventory = this.f_39349_; ++ this.craftSlots.setOwner(this.player); ++ this.craftSlots.resultInventory = this.resultSlots; + // CraftBukkit end - this.m_38897_(new ResultSlot(p_39357_.f_35978_, this.f_39348_, this.f_39349_, 0, 124, 35)); + this.addSlot(new ResultSlot(p_39357_.player, this.craftSlots, this.resultSlots, 0, 124, 35)); for(int i = 0; i < 3; ++i) { @@ -66,7 +_,7 @@ - itemstack = craftingrecipe.m_5874_(p_150550_); + itemstack = craftingrecipe.assemble(p_150550_); } } - + itemstack = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPreCraftEvent(p_150550_, p_150551_, itemstack, p_150547_.getBukkitView(), optional.orElse(null) instanceof net.minecraft.world.item.crafting.RepairItemRecipe); // CraftBukkit - p_150551_.m_6836_(0, itemstack); - p_150547_.m_150404_(0, itemstack); - serverplayer.f_8906_.m_141995_(new ClientboundContainerSetSlotPacket(p_150547_.f_38840_, p_150547_.m_182425_(), 0, itemstack)); + p_150551_.setItem(0, itemstack); + p_150547_.setRemoteSlot(0, itemstack); + serverplayer.connection.send(new ClientboundContainerSetSlotPacket(p_150547_.containerId, p_150547_.incrementStateId(), 0, itemstack)); @@ -100,6 +_,7 @@ } - public boolean m_6875_(Player p_39368_) { + public boolean stillValid(Player p_39368_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_39350_, p_39368_, Blocks.f_50091_); + return stillValid(this.access, p_39368_, Blocks.CRAFTING_TABLE); } diff --git a/patches/minecraft/net/minecraft/world/inventory/DispenserMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/DispenserMenu.java.patch index 21259c66..902f158a 100644 --- a/patches/minecraft/net/minecraft/world/inventory/DispenserMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/DispenserMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/DispenserMenu.java +++ b/net/minecraft/world/inventory/DispenserMenu.java @@ -14,12 +_,31 @@ - private static final int f_150561_ = 45; - private final Container f_39431_; + private static final int USE_ROW_SLOT_END = 45; + private final Container dispenser; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -14,8 +14,8 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.f_39431_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.dispenser); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end @@ -25,18 +25,18 @@ } public DispenserMenu(int p_39436_, Inventory p_39437_, Container p_39438_) { - super(MenuType.f_39963_, p_39436_); + super(MenuType.GENERIC_3x3, p_39436_); + // CraftBukkit start - Save player + this.player = p_39437_; + // CraftBukkit end - m_38869_(p_39438_, 9); - this.f_39431_ = p_39438_; - p_39438_.m_5856_(p_39437_.f_35978_); + checkContainerSize(p_39438_, 9); + this.dispenser = p_39438_; + p_39438_.startOpen(p_39437_.player); @@ -43,6 +_,7 @@ } - public boolean m_6875_(Player p_39440_) { + public boolean stillValid(Player p_39440_) { + if (!this.checkReachable) return true; // CraftBukkit - return this.f_39431_.m_6542_(p_39440_); + return this.dispenser.stillValid(p_39440_); } diff --git a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch index ea4d8520..30822354 100644 --- a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -4,19 +4,19 @@ import net.minecraft.world.level.block.EnchantmentTableBlock; public class EnchantmentMenu extends AbstractContainerMenu { -- private final Container f_39449_ = new SimpleContainer(2) { -- public void m_6596_() { -- super.m_6596_(); -- EnchantmentMenu.this.m_6199_(this); +- private final Container enchantSlots = new SimpleContainer(2) { +- public void setChanged() { +- super.setChanged(); +- EnchantmentMenu.this.slotsChanged(this); - } - }; -+ private final Container f_39449_; - private final ContainerLevelAccess f_39450_; - private final Random f_39451_ = new Random(); - private final DataSlot f_39452_ = DataSlot.m_39401_(); ++ private final Container enchantSlots; + private final ContainerLevelAccess access; + private final Random random = new Random(); + private final DataSlot enchantmentSeed = DataSlot.standalone(); @@ -37,12 +_,43 @@ - public final int[] f_39447_ = new int[]{-1, -1, -1}; - public final int[] f_39448_ = new int[]{-1, -1, -1}; + public final int[] enchantClue = new int[]{-1, -1, -1}; + public final int[] levelClue = new int[]{-1, -1, -1}; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -28,23 +28,23 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryEnchanting inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryEnchanting(this.f_39449_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryEnchanting inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryEnchanting(this.enchantSlots); + bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end + public EnchantmentMenu(int p_39454_, Inventory p_39455_) { - this(p_39454_, p_39455_, ContainerLevelAccess.f_39287_); + this(p_39454_, p_39455_, ContainerLevelAccess.NULL); } public EnchantmentMenu(int p_39457_, Inventory p_39458_, ContainerLevelAccess p_39459_) { - super(MenuType.f_39969_, p_39457_); + super(MenuType.ENCHANTMENT, p_39457_); + //Magma start - add location -+ this.f_39449_ = new SimpleContainer(2) { -+ public void m_6596_() { -+ super.m_6596_(); -+ EnchantmentMenu.this.m_6199_(this); ++ this.enchantSlots = new SimpleContainer(2) { ++ public void setChanged() { ++ super.setChanged(); ++ EnchantmentMenu.this.slotsChanged(this); + } + + // CraftBukkit start @@ -55,54 +55,54 @@ + // CraftBukkit end + }; + //Magma end - this.f_39450_ = p_39459_; - this.m_38897_(new Slot(this.f_39449_, 0, 15, 47) { - public boolean m_5857_(ItemStack p_39508_) { + this.access = p_39459_; + this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { + public boolean mayPlace(ItemStack p_39508_) { @@ -55,7 +_,7 @@ }); - this.m_38897_(new Slot(this.f_39449_, 1, 35, 47) { - public boolean m_5857_(ItemStack p_39517_) { -- return p_39517_.m_150930_(Items.f_42534_); -+ return p_39517_.m_204117_(net.minecraftforge.common.Tags.Items.ENCHANTING_FUELS); + this.addSlot(new Slot(this.enchantSlots, 1, 35, 47) { + public boolean mayPlace(ItemStack p_39517_) { +- return p_39517_.is(Items.LAPIS_LAZULI); ++ return p_39517_.is(net.minecraftforge.common.Tags.Items.ENCHANTING_FUELS); } }); @@ -79,30 +_,35 @@ - this.m_38895_(DataSlot.m_39406_(this.f_39448_, 0)); - this.m_38895_(DataSlot.m_39406_(this.f_39448_, 1)); - this.m_38895_(DataSlot.m_39406_(this.f_39448_, 2)); + this.addDataSlot(DataSlot.shared(this.levelClue, 0)); + this.addDataSlot(DataSlot.shared(this.levelClue, 1)); + this.addDataSlot(DataSlot.shared(this.levelClue, 2)); + // CraftBukkit start -+ player = (org.bukkit.entity.Player) p_39458_.f_35978_.getBukkitEntity(); ++ player = (org.bukkit.entity.Player) p_39458_.player.getBukkitEntity(); + // CraftBukkit end } - public void m_6199_(Container p_39461_) { - if (p_39461_ == this.f_39449_) { - ItemStack itemstack = p_39461_.m_8020_(0); -- if (!itemstack.m_41619_() && itemstack.m_41792_()) { -+ if (!itemstack.m_41619_()) { // CraftBukkit - relax condition -+ itemstack.m_41792_(); //Magma - check if item is enchantable, because mixins - this.f_39450_.m_39292_((p_39485_, p_39486_) -> { + public void slotsChanged(Container p_39461_) { + if (p_39461_ == this.enchantSlots) { + ItemStack itemstack = p_39461_.getItem(0); +- if (!itemstack.isEmpty() && itemstack.isEnchantable()) { ++ if (!itemstack.isEmpty()) { // CraftBukkit - relax condition ++ itemstack.isEnchantable(); //Magma - check if item is enchantable, because mixins + this.access.execute((p_39485_, p_39486_) -> { int j = 0; - for(BlockPos blockpos : EnchantmentTableBlock.f_207902_) { - if (EnchantmentTableBlock.m_207909_(p_39485_, p_39486_, blockpos)) { + for(BlockPos blockpos : EnchantmentTableBlock.BOOKSHELF_OFFSETS) { + if (EnchantmentTableBlock.isValidBookShelf(p_39485_, p_39486_, blockpos)) { - ++j; -+ j += p_39485_.m_8055_(p_39486_.m_141952_(blockpos)).getEnchantPowerBonus(p_39485_, p_39486_.m_141952_(blockpos)); ++ j += p_39485_.getBlockState(p_39486_.offset(blockpos)).getEnchantPowerBonus(p_39485_, p_39486_.offset(blockpos)); } } - this.f_39451_.setSeed((long)this.f_39452_.m_6501_()); + this.random.setSeed((long)this.enchantmentSeed.get()); for(int k = 0; k < 3; ++k) { -- this.f_39446_[k] = EnchantmentHelper.m_44872_(this.f_39451_, k, j, itemstack); -+ this.f_39446_[k] = EnchantmentHelper.m_44872_(this.f_39451_, k, (int)j, itemstack); - this.f_39447_[k] = -1; - this.f_39448_[k] = -1; - if (this.f_39446_[k] < k + 1) { - this.f_39446_[k] = 0; +- this.costs[k] = EnchantmentHelper.getEnchantmentCost(this.random, k, j, itemstack); ++ this.costs[k] = EnchantmentHelper.getEnchantmentCost(this.random, k, (int)j, itemstack); + this.enchantClue[k] = -1; + this.levelClue[k] = -1; + if (this.costs[k] < k + 1) { + this.costs[k] = 0; } -+ this.f_39446_[k] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_39485_, p_39486_, k, (int)j, itemstack, f_39446_[k]); ++ this.costs[k] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_39485_, p_39486_, k, (int)j, itemstack, costs[k]); } for(int l = 0; l < 3; ++l) { @@ -114,65 +114,65 @@ + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack item = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new org.bukkit.enchantments.EnchantmentOffer[3]; + for (int k = 0; k < 3; ++k) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.f_39447_[k] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(Registry.f_122825_.m_7981_(Registry.f_122825_.m_7942_(this.f_39447_[k])))) : null; -+ offers[k] = (enchantment != null) ? new org.bukkit.enchantments.EnchantmentOffer(enchantment, this.f_39448_[k], this.f_39446_[k]) : null; ++ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[k] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(Registry.ENCHANTMENT.getKey(Registry.ENCHANTMENT.byId(this.enchantClue[k])))) : null; ++ offers[k] = (enchantment != null) ? new org.bukkit.enchantments.EnchantmentOffer(enchantment, this.levelClue[k], this.costs[k]) : null; + } -+ org.bukkit.event.enchantment.PrepareItemEnchantEvent event = new org.bukkit.event.enchantment.PrepareItemEnchantEvent(player, this.getBukkitView(), f_39450_.getLocation().getBlock(), item, offers, j); -+ event.setCancelled(!itemstack.m_41792_()); ++ org.bukkit.event.enchantment.PrepareItemEnchantEvent event = new org.bukkit.event.enchantment.PrepareItemEnchantEvent(player, this.getBukkitView(), access.getLocation().getBlock(), item, offers, j); ++ event.setCancelled(!itemstack.isEnchantable()); + p_39485_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + for (j = 0; j < 3; ++j) { -+ this.f_39446_[j] = 0; -+ this.f_39447_[j] = -1; -+ this.f_39448_[j] = -1; ++ this.costs[j] = 0; ++ this.enchantClue[j] = -1; ++ this.levelClue[j] = -1; + } + return; + } + for (int k = 0; k < 3; k++) { + org.bukkit.enchantments.EnchantmentOffer offer = event.getOffers()[k]; + if (offer != null) { -+ this.f_39446_[k] = offer.getCost(); -+ this.f_39447_[k] = Registry.f_122825_.m_7447_(Registry.f_122825_.m_7745_(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); -+ this.f_39448_[k] = offer.getEnchantmentLevel(); ++ this.costs[k] = offer.getCost(); ++ this.enchantClue[k] = Registry.ENCHANTMENT.getId(Registry.ENCHANTMENT.get(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); ++ this.levelClue[k] = offer.getEnchantmentLevel(); + } else { -+ this.f_39446_[k] = 0; -+ this.f_39447_[k] = -1; -+ this.f_39448_[k] = -1; ++ this.costs[k] = 0; ++ this.enchantClue[k] = -1; ++ this.levelClue[k] = -1; + } + } + // CraftBukkit end + - this.m_38946_(); + this.broadcastChanges(); }); } else { @@ -142,9 +_,15 @@ - this.f_39450_.m_39292_((p_39481_, p_39482_) -> { + this.access.execute((p_39481_, p_39482_) -> { ItemStack itemstack2 = itemstack; - List list = this.m_39471_(itemstack, p_39466_, this.f_39446_[p_39466_]); + List list = this.getEnchantmentList(itemstack, p_39466_, this.costs[p_39466_]); - if (!list.isEmpty()) { -- p_39465_.m_7408_(itemstack, i); +- p_39465_.onEnchantmentPerformed(itemstack, i); + // CraftBukkit start + if (true || !list.isEmpty()) { + //p_39465_.onEnchantmentPerformed(itemstack, i); // Move down - boolean flag = itemstack.m_150930_(Items.f_42517_); + boolean flag = itemstack.is(Items.BOOK); + + //Magma start - mixin inject + if (!bukkitEnchant(p_39465_, p_39466_, p_39481_, list, itemstack2)) + return; + if (flag) { - itemstack2 = new ItemStack(Items.f_42690_); - CompoundTag compoundtag = itemstack.m_41783_(); + itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); + CompoundTag compoundtag = itemstack.getTag(); @@ -155,15 +_,29 @@ - this.f_39449_.m_6836_(0, itemstack2); + this.enchantSlots.setItem(0, itemstack2); } - for(int j = 0; j < list.size(); ++j) { - EnchantmentInstance enchantmentinstance = list.get(j); - if (flag) { -- EnchantedBookItem.m_41153_(itemstack2, enchantmentinstance); +- EnchantedBookItem.addEnchantment(itemstack2, enchantmentinstance); - } else { -- itemstack2.m_41663_(enchantmentinstance.f_44947_, enchantmentinstance.f_44948_); +- itemstack2.enchant(enchantmentinstance.enchantment, enchantmentinstance.level); - } + //Magma - this is just a mess, but it has to be done this way to prevent a mixin injection error + for (int j = 0; j < bukkitEnchant_event.getEnchantsToAdd().entrySet().size(); ++j) { @@ -185,21 +185,21 @@ + + try { + if (flag) -+ EnchantedBookItem.m_41153_(itemstack2, enchantmentinstance); ++ EnchantedBookItem.addEnchantment(itemstack2, enchantmentinstance); + else -+ itemstack2.m_41663_(enchant_nms, bukkitEnchant_event.getEnchantsToAdd().get(((org.bukkit.enchantments.Enchantment) bukkitEnchant_event.getEnchantsToAdd().keySet().toArray()[j]))); ++ itemstack2.enchant(enchant_nms, bukkitEnchant_event.getEnchantsToAdd().get(((org.bukkit.enchantments.Enchantment) bukkitEnchant_event.getEnchantsToAdd().keySet().toArray()[j]))); + } catch (IllegalArgumentException ignored) {} + + enchant_nms = null; } -+ p_39465_.m_7408_(itemstack, i); ++ p_39465_.onEnchantmentPerformed(itemstack, i); + // CraftBukkit end + + // CraftBukkit - TODO: let plugins change this - if (!p_39465_.m_150110_().f_35937_) { - itemstack1.m_41774_(i); - if (itemstack1.m_41619_()) { + if (!p_39465_.getAbilities().instabuild) { + itemstack1.shrink(i); + if (itemstack1.isEmpty()) { @@ -191,6 +_,30 @@ } } @@ -210,13 +210,13 @@ + java.util.Map enchants = new java.util.HashMap(); + for (Object obj : list) { + EnchantmentInstance instance = (EnchantmentInstance) obj; -+ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(Registry.f_122825_.m_7981_(instance.f_44947_))), instance.f_44948_); ++ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(Registry.ENCHANTMENT.getKey(instance.enchantment))), instance.level); + } + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack item = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack2); -+ bukkitEnchant_event = new org.bukkit.event.enchantment.EnchantItemEvent((org.bukkit.entity.Player) p_39465_.getBukkitEntity(), this.getBukkitView(), f_39450_.getLocation().getBlock(), item, this.f_39446_[p_39466_], enchants, p_39466_); ++ bukkitEnchant_event = new org.bukkit.event.enchantment.EnchantItemEvent((org.bukkit.entity.Player) p_39465_.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[p_39466_], enchants, p_39466_); + p_39481_.getCraftServer().getPluginManager().callEvent(bukkitEnchant_event); + int level = bukkitEnchant_event.getExpLevelCost(); -+ if (bukkitEnchant_event.isCancelled() || (level > p_39465_.f_36078_ && !p_39465_.m_150110_().f_35937_) || bukkitEnchant_event.getEnchantsToAdd().isEmpty()) { ++ if (bukkitEnchant_event.isCancelled() || (level > p_39465_.experienceLevel && !p_39465_.getAbilities().instabuild) || bukkitEnchant_event.getEnchantsToAdd().isEmpty()) { + return false; + } + return true; @@ -224,27 +224,27 @@ + + private @org.jetbrains.annotations.Nullable net.minecraft.world.item.enchantment.Enchantment enchant_nms; + private void getNms(org.bukkit.NamespacedKey enchantId) { -+ enchant_nms = Registry.f_122825_.m_7745_(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.toMinecraft(enchantId)); ++ enchant_nms = Registry.ENCHANTMENT.get(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.toMinecraft(enchantId)); + } + //Magma end + - private List m_39471_(ItemStack p_39472_, int p_39473_, int p_39474_) { - this.f_39451_.setSeed((long)(this.f_39452_.m_6501_() + p_39473_)); - List list = EnchantmentHelper.m_44909_(this.f_39451_, p_39472_, p_39474_, false); + private List getEnchantmentList(ItemStack p_39472_, int p_39473_, int p_39474_) { + this.random.setSeed((long)(this.enchantmentSeed.get() + p_39473_)); + List list = EnchantmentHelper.selectEnchantment(this.random, p_39472_, p_39474_, false); @@ -218,6 +_,7 @@ } - public boolean m_6875_(Player p_39463_) { + public boolean stillValid(Player p_39463_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_39450_, p_39463_, Blocks.f_50201_); + return stillValid(this.access, p_39463_, Blocks.ENCHANTING_TABLE); } @@ -235,7 +_,7 @@ - if (!this.m_38903_(itemstack1, 2, 38, true)) { - return ItemStack.f_41583_; + if (!this.moveItemStackTo(itemstack1, 2, 38, true)) { + return ItemStack.EMPTY; } -- } else if (itemstack1.m_150930_(Items.f_42534_)) { -+ } else if (itemstack1.m_204117_(net.minecraftforge.common.Tags.Items.ENCHANTING_FUELS)) { - if (!this.m_38903_(itemstack1, 1, 2, true)) { - return ItemStack.f_41583_; +- } else if (itemstack1.is(Items.LAPIS_LAZULI)) { ++ } else if (itemstack1.is(net.minecraftforge.common.Tags.Items.ENCHANTING_FUELS)) { + if (!this.moveItemStackTo(itemstack1, 1, 2, true)) { + return ItemStack.EMPTY; } diff --git a/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch index 49f7ef00..7a718233 100644 --- a/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/inventory/FurnaceResultSlot.java +++ b/net/minecraft/world/inventory/FurnaceResultSlot.java @@ -40,9 +_,10 @@ - protected void m_5845_(ItemStack p_39558_) { - p_39558_.m_41678_(this.f_39539_.f_19853_, this.f_39539_, this.f_39540_); - if (this.f_39539_ instanceof ServerPlayer && this.f_40218_ instanceof AbstractFurnaceBlockEntity) { -- ((AbstractFurnaceBlockEntity)this.f_40218_).m_155003_((ServerPlayer)this.f_39539_); -+ ((AbstractFurnaceBlockEntity)this.f_40218_).awardUsedRecipesAndPopExperience((ServerPlayer)this.f_39539_, p_39558_, this.f_39540_); // CraftBukkit + protected void checkTakeAchievements(ItemStack p_39558_) { + p_39558_.onCraftedBy(this.player.level, this.player, this.removeCount); + if (this.player instanceof ServerPlayer && this.container instanceof AbstractFurnaceBlockEntity) { +- ((AbstractFurnaceBlockEntity)this.container).awardUsedRecipesAndPopExperience((ServerPlayer)this.player); ++ ((AbstractFurnaceBlockEntity)this.container).awardUsedRecipesAndPopExperience((ServerPlayer)this.player, p_39558_, this.removeCount); // CraftBukkit } - this.f_39540_ = 0; -+ net.minecraftforge.event.ForgeEventFactory.firePlayerSmeltedEvent(this.f_39539_, p_39558_); + this.removeCount = 0; ++ net.minecraftforge.event.ForgeEventFactory.firePlayerSmeltedEvent(this.player, p_39558_); } } diff --git a/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 26b5698b..c2ad4fb9 100644 --- a/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/inventory/GrindstoneMenu.java +++ b/net/minecraft/world/inventory/GrindstoneMenu.java @@ -27,14 +_,26 @@ - private static final int f_150570_ = 30; - private static final int f_150571_ = 30; - private static final int f_150572_ = 39; -- private final Container f_39559_ = new ResultContainer(); -- final Container f_39560_ = new SimpleContainer(2) { -- public void m_6596_() { -- super.m_6596_(); -- GrindstoneMenu.this.m_6199_(this); + private static final int INV_SLOT_END = 30; + private static final int USE_ROW_SLOT_START = 30; + private static final int USE_ROW_SLOT_END = 39; +- private final Container resultSlots = new ResultContainer(); +- final Container repairSlots = new SimpleContainer(2) { +- public void setChanged() { +- super.setChanged(); +- GrindstoneMenu.this.slotsChanged(this); - } - }; -+ private final Container f_39559_; -+ final Container f_39560_; - private final ContainerLevelAccess f_39561_; ++ private final Container resultSlots; ++ final Container repairSlots; + private final ContainerLevelAccess access; + private int xp = -1; + + // CraftBukkit start @@ -26,24 +26,24 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryGrindstone inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryGrindstone(this.f_39560_, this.f_39559_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryGrindstone inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryGrindstone(this.repairSlots, this.resultSlots); + bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end public GrindstoneMenu(int p_39563_, Inventory p_39564_) { - this(p_39563_, p_39564_, ContainerLevelAccess.f_39287_); + this(p_39563_, p_39564_, ContainerLevelAccess.NULL); @@ -42,15 +_,31 @@ public GrindstoneMenu(int p_39566_, Inventory p_39567_, final ContainerLevelAccess p_39568_) { - super(MenuType.f_39971_, p_39566_); + super(MenuType.GRINDSTONE, p_39566_); + //Magma start - add location -+ this.f_39559_ = new ResultContainer(); -+ this.f_39560_ = new SimpleContainer(2) { -+ public void m_6596_() { -+ super.m_6596_(); -+ GrindstoneMenu.this.m_6199_(this); ++ this.resultSlots = new ResultContainer(); ++ this.repairSlots = new SimpleContainer(2) { ++ public void setChanged() { ++ super.setChanged(); ++ GrindstoneMenu.this.slotsChanged(this); + } + + // CraftBukkit start @@ -54,88 +54,88 @@ + // CraftBukkit end + }; + //Magma end - this.f_39561_ = p_39568_; - this.m_38897_(new Slot(this.f_39560_, 0, 49, 19) { - public boolean m_5857_(ItemStack p_39607_) { -- return p_39607_.m_41763_() || p_39607_.m_150930_(Items.f_42690_) || p_39607_.m_41793_(); + this.access = p_39568_; + this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { + public boolean mayPlace(ItemStack p_39607_) { +- return p_39607_.isDamageableItem() || p_39607_.is(Items.ENCHANTED_BOOK) || p_39607_.isEnchanted(); + return true; //Allow all items in the slot, not just repairable } }); - this.m_38897_(new Slot(this.f_39560_, 1, 49, 40) { - public boolean m_5857_(ItemStack p_39616_) { -- return p_39616_.m_41763_() || p_39616_.m_150930_(Items.f_42690_) || p_39616_.m_41793_(); + this.addSlot(new Slot(this.repairSlots, 1, 49, 40) { + public boolean mayPlace(ItemStack p_39616_) { +- return p_39616_.isDamageableItem() || p_39616_.is(Items.ENCHANTED_BOOK) || p_39616_.isEnchanted(); + return true; //Allow all items in the slot, not just repairable } }); - this.m_38897_(new Slot(this.f_39559_, 2, 129, 34) { + this.addSlot(new Slot(this.resultSlots, 2, 129, 34) { @@ -59,6 +_,7 @@ } - public void m_142406_(Player p_150574_, ItemStack p_150575_) { -+ if (net.minecraftforge.common.ForgeHooks.onGrindstoneTake(GrindstoneMenu.this.f_39560_, p_39568_, this::m_39631_)) return; - p_39568_.m_39292_((p_39634_, p_39635_) -> { + public void onTake(Player p_150574_, ItemStack p_150575_) { ++ if (net.minecraftforge.common.ForgeHooks.onGrindstoneTake(GrindstoneMenu.this.repairSlots, p_39568_, this::getExperienceAmount)) return; + p_39568_.execute((p_39634_, p_39635_) -> { if (p_39634_ instanceof ServerLevel) { - ExperienceOrb.m_147082_((ServerLevel)p_39634_, Vec3.m_82512_(p_39635_), this.m_39631_(p_39634_)); + ExperienceOrb.award((ServerLevel)p_39634_, Vec3.atCenterOf(p_39635_), this.getExperienceAmount(p_39634_)); @@ -71,6 +_,7 @@ } - private int m_39631_(Level p_39632_) { + private int getExperienceAmount(Level p_39632_) { + if (xp > -1) return xp; int l = 0; - l += this.m_39636_(GrindstoneMenu.this.f_39560_.m_8020_(0)); - l += this.m_39636_(GrindstoneMenu.this.f_39560_.m_8020_(1)); + l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); + l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); @@ -108,6 +_,7 @@ - this.m_38897_(new Slot(p_39567_, k, 8 + k * 18, 142)); + this.addSlot(new Slot(p_39567_, k, 8 + k * 18, 142)); } -+ player = (org.bukkit.entity.Player) p_39567_.f_35978_.getBukkitEntity(); // CraftBukkit ++ player = (org.bukkit.entity.Player) p_39567_.player.getBukkitEntity(); // CraftBukkit } - public void m_6199_(Container p_39570_) { + public void slotsChanged(Container p_39570_) { @@ -123,6 +_,8 @@ - ItemStack itemstack1 = this.f_39560_.m_8020_(1); - boolean flag = !itemstack.m_41619_() || !itemstack1.m_41619_(); - boolean flag1 = !itemstack.m_41619_() && !itemstack1.m_41619_(); -+ this.xp = net.minecraftforge.common.ForgeHooks.onGrindstoneChange(itemstack, itemstack1, this.f_39559_, -1); + ItemStack itemstack1 = this.repairSlots.getItem(1); + boolean flag = !itemstack.isEmpty() || !itemstack1.isEmpty(); + boolean flag1 = !itemstack.isEmpty() && !itemstack1.isEmpty(); ++ this.xp = net.minecraftforge.common.ForgeHooks.onGrindstoneChange(itemstack, itemstack1, this.resultSlots, -1); + if (this.xp == Integer.MIN_VALUE) if (!flag) { - this.f_39559_.m_6836_(0, ItemStack.f_41583_); + this.resultSlots.setItem(0, ItemStack.EMPTY); } else { @@ -144,12 +_,13 @@ } - Item item = itemstack.m_41720_(); -- int k = item.m_41462_() - itemstack.m_41773_(); -- int l = item.m_41462_() - itemstack1.m_41773_(); -- int i1 = k + l + item.m_41462_() * 5 / 100; -- i = Math.max(item.m_41462_() - i1, 0); -+ int k = itemstack.m_41776_() - itemstack.m_41773_(); -+ int l = itemstack.m_41776_() - itemstack1.m_41773_(); -+ int i1 = k + l + itemstack.m_41776_() * 5 / 100; -+ i = Math.max(itemstack.m_41776_() - i1, 0); - itemstack2 = this.m_39590_(itemstack, itemstack1); -- if (!itemstack2.m_41763_()) { -+ if (!itemstack2.isRepairable()) i = itemstack.m_41773_(); -+ if (!itemstack2.m_41763_() || !itemstack2.isRepairable()) { - if (!ItemStack.m_41728_(itemstack, itemstack1)) { - this.f_39559_.m_6836_(0, ItemStack.f_41583_); - this.m_38946_(); + Item item = itemstack.getItem(); +- int k = item.getMaxDamage() - itemstack.getDamageValue(); +- int l = item.getMaxDamage() - itemstack1.getDamageValue(); +- int i1 = k + l + item.getMaxDamage() * 5 / 100; +- i = Math.max(item.getMaxDamage() - i1, 0); ++ int k = itemstack.getMaxDamage() - itemstack.getDamageValue(); ++ int l = itemstack.getMaxDamage() - itemstack1.getDamageValue(); ++ int i1 = k + l + itemstack.getMaxDamage() * 5 / 100; ++ i = Math.max(itemstack.getMaxDamage() - i1, 0); + itemstack2 = this.mergeEnchants(itemstack, itemstack1); +- if (!itemstack2.isDamageableItem()) { ++ if (!itemstack2.isRepairable()) i = itemstack.getDamageValue(); ++ if (!itemstack2.isDamageableItem() || !itemstack2.isRepairable()) { + if (!ItemStack.matches(itemstack, itemstack1)) { + this.resultSlots.setItem(0, ItemStack.EMPTY); + this.broadcastChanges(); @@ -164,6 +_,10 @@ itemstack2 = flag3 ? itemstack : itemstack1; } + // Forge: Skip the repair if the result would give an item stack with a count not normally obtainable -+ if (j > itemstack2.m_41741_()) -+ this.f_39559_.m_6836_(0, ItemStack.f_41583_); ++ if (j > itemstack2.getMaxStackSize()) ++ this.resultSlots.setItem(0, ItemStack.EMPTY); + else - this.f_39559_.m_6836_(0, this.m_39579_(itemstack2, i, j)); + this.resultSlots.setItem(0, this.removeNonCurses(itemstack2, i, j)); } @@ -222,6 +_,7 @@ } - public boolean m_6875_(Player p_39572_) { + public boolean stillValid(Player p_39572_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_39561_, p_39572_, Blocks.f_50623_); + return stillValid(this.access, p_39572_, Blocks.GRINDSTONE); } diff --git a/patches/minecraft/net/minecraft/world/inventory/HopperMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/HopperMenu.java.patch index 1e7c8005..a008d86d 100644 --- a/patches/minecraft/net/minecraft/world/inventory/HopperMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/HopperMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/HopperMenu.java +++ b/net/minecraft/world/inventory/HopperMenu.java @@ -10,6 +_,22 @@ - public static final int f_150576_ = 5; - private final Container f_39638_; + public static final int CONTAINER_SIZE = 5; + private final Container hopper; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -14,8 +14,8 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.f_39638_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.hopper); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end @@ -25,17 +25,17 @@ } @@ -17,6 +_,7 @@ public HopperMenu(int p_39643_, Inventory p_39644_, Container p_39645_) { - super(MenuType.f_39972_, p_39643_); - this.f_39638_ = p_39645_; + super(MenuType.HOPPER, p_39643_); + this.hopper = p_39645_; + this.player = p_39644_; // CraftBukkit - save player - m_38869_(p_39645_, 5); - p_39645_.m_5856_(p_39644_.f_35978_); + checkContainerSize(p_39645_, 5); + p_39645_.startOpen(p_39644_.player); int i = 51; @@ -38,6 +_,7 @@ } - public boolean m_6875_(Player p_39647_) { + public boolean stillValid(Player p_39647_) { + if (!this.checkReachable) return true; // CraftBukkit - return this.f_39638_.m_6542_(p_39647_); + return this.hopper.stillValid(p_39647_); } diff --git a/patches/minecraft/net/minecraft/world/inventory/HorseInventoryMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/HorseInventoryMenu.java.patch index 814134b9..5e9119c3 100644 --- a/patches/minecraft/net/minecraft/world/inventory/HorseInventoryMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/HorseInventoryMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/HorseInventoryMenu.java +++ b/net/minecraft/world/inventory/HorseInventoryMenu.java @@ -12,8 +_,22 @@ - private final Container f_39653_; - private final AbstractHorse f_39654_; + private final Container horseContainer; + private final AbstractHorse horse; + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity; @@ -14,12 +14,12 @@ + return bukkitEntity; + } + -+ return bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(player.f_35978_.getBukkitEntity(), f_39653_.getOwner().getInventory(), this); ++ return bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(player.player.getBukkitEntity(), horseContainer.getOwner().getInventory(), this); + } + public HorseInventoryMenu(int p_39656_, Inventory p_39657_, Container p_39658_, final AbstractHorse p_39659_) { super((MenuType)null, p_39656_); + player = p_39657_; // CraftBukkit - this.f_39653_ = p_39658_; - this.f_39654_ = p_39659_; + this.horseContainer = p_39658_; + this.horse = p_39659_; int i = 3; diff --git a/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch index 309c2bcc..295de5c9 100644 --- a/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/InventoryMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/InventoryMenu.java +++ b/net/minecraft/world/inventory/InventoryMenu.java @@ -37,10 +_,31 @@ - public final boolean f_39698_; - private final Player f_39703_; + public final boolean active; + private final Player owner; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -13,31 +13,31 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting(this.f_39701_, this.f_39702_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryCrafting(this.craftSlots, this.resultSlots); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end + public InventoryMenu(Inventory p_39706_, boolean p_39707_, Player p_39708_) { super((MenuType)null, 0); - this.f_39698_ = p_39707_; - this.f_39703_ = p_39708_; + this.active = p_39707_; + this.owner = p_39708_; + // CraftBukkit start -+ this.f_39701_.setOwner(p_39706_.f_35978_); // CraftBukkit - pass player -+ this.f_39701_.resultInventory = this.f_39702_; // CraftBukkit - let InventoryCrafting know about its result slot ++ this.craftSlots.setOwner(p_39706_.player); // CraftBukkit - pass player ++ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot + this.player = p_39706_; // CraftBukkit - save player + setTitle(new net.minecraft.network.chat.TranslatableComponent("container.crafting")); // SPIGOT-4722: Allocate title for player inventory + // CraftBukkit end - this.m_38897_(new ResultSlot(p_39706_.f_35978_, this.f_39701_, this.f_39702_, 0, 154, 28)); + this.addSlot(new ResultSlot(p_39706_.player, this.craftSlots, this.resultSlots, 0, 154, 28)); for(int i = 0; i < 2; ++i) { @@ -57,7 +_,7 @@ } - public boolean m_5857_(ItemStack p_39746_) { -- return equipmentslot == Mob.m_147233_(p_39746_); -+ return p_39746_.canEquip(equipmentslot, f_39703_); + public boolean mayPlace(ItemStack p_39746_) { +- return equipmentslot == Mob.getEquipmentSlotForItem(p_39746_); ++ return p_39746_.canEquip(equipmentslot, owner); } - public boolean m_8010_(Player p_39744_) { + public boolean mayPickup(Player p_39744_) { diff --git a/patches/minecraft/net/minecraft/world/inventory/ItemCombinerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/ItemCombinerMenu.java.patch index 1f9e68e1..25295f7c 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ItemCombinerMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ItemCombinerMenu.java.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/world/inventory/ItemCombinerMenu.java +++ b/net/minecraft/world/inventory/ItemCombinerMenu.java @@ -16,13 +_,8 @@ - private static final int f_150598_ = 30; - private static final int f_150599_ = 30; - private static final int f_150600_ = 39; -- protected final ResultContainer f_39768_ = new ResultContainer(); -- protected final Container f_39769_ = new SimpleContainer(2) { -- public void m_6596_() { -- super.m_6596_(); -- ItemCombinerMenu.this.m_6199_(this); + private static final int INV_SLOT_END = 30; + private static final int USE_ROW_SLOT_START = 30; + private static final int USE_ROW_SLOT_END = 39; +- protected final ResultContainer resultSlots = new ResultContainer(); +- protected final Container inputSlots = new SimpleContainer(2) { +- public void setChanged() { +- super.setChanged(); +- ItemCombinerMenu.this.slotsChanged(this); - } - }; -+ protected final ResultContainer f_39768_; -+ protected final Container f_39769_; - protected final ContainerLevelAccess f_39770_; - protected final Player f_39771_; ++ protected final ResultContainer resultSlots; ++ protected final Container inputSlots; + protected final ContainerLevelAccess access; + protected final Player player; @@ -34,6 +_,22 @@ public ItemCombinerMenu(@Nullable MenuType p_39773_, int p_39774_, Inventory p_39775_, ContainerLevelAccess p_39776_) { super(p_39773_, p_39774_); + //Magma start - add location -+ this.f_39768_ = new ResultContainer(); -+ this.f_39769_ = new SimpleContainer(2) { -+ public void m_6596_() { -+ super.m_6596_(); -+ ItemCombinerMenu.this.m_6199_(this); ++ this.resultSlots = new ResultContainer(); ++ this.inputSlots = new SimpleContainer(2) { ++ public void setChanged() { ++ super.setChanged(); ++ ItemCombinerMenu.this.slotsChanged(this); + } + + // CraftBukkit start @@ -36,14 +36,14 @@ + // CraftBukkit end + }; + //Magma end - this.f_39770_ = p_39776_; - this.f_39771_ = p_39775_.f_35978_; - this.m_38897_(new Slot(this.f_39769_, 0, 27, 47)); + this.access = p_39776_; + this.player = p_39775_.player; + this.addSlot(new Slot(this.inputSlots, 0, 27, 47)); @@ -82,6 +_,7 @@ } - public boolean m_6875_(Player p_39780_) { + public boolean stillValid(Player p_39780_) { + if (!this.checkReachable) return true; // CraftBukkit - return this.f_39770_.m_39299_((p_39785_, p_39786_) -> { - return !this.m_8039_(p_39785_.m_8055_(p_39786_)) ? false : p_39780_.m_20275_((double)p_39786_.m_123341_() + 0.5D, (double)p_39786_.m_123342_() + 0.5D, (double)p_39786_.m_123343_() + 0.5D) <= 64.0D; + return this.access.evaluate((p_39785_, p_39786_) -> { + return !this.isValidBlock(p_39785_.getBlockState(p_39786_)) ? false : p_39780_.distanceToSqr((double)p_39786_.getX() + 0.5D, (double)p_39786_.getY() + 0.5D, (double)p_39786_.getZ() + 0.5D) <= 64.0D; }, true); diff --git a/patches/minecraft/net/minecraft/world/inventory/LecternMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/LecternMenu.java.patch index 240d3d43..46459652 100644 --- a/patches/minecraft/net/minecraft/world/inventory/LecternMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/LecternMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/LecternMenu.java +++ b/net/minecraft/world/inventory/LecternMenu.java @@ -15,11 +_,28 @@ - private final Container f_39819_; - private final ContainerData f_39820_; + private final Container lectern; + private final ContainerData lecternData; - public LecternMenu(int p_39822_) { - this(p_39822_, new SimpleContainer(1), new SimpleContainerData(1)); @@ -19,7 +19,7 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLectern inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLectern(this.f_39819_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLectern inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLectern(this.lectern); + bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } @@ -31,17 +31,17 @@ + } + + public LecternMenu(int p_39824_, Container p_39825_, ContainerData p_39826_, net.minecraft.world.entity.player.Inventory playerinventory) { - super(MenuType.f_39973_, p_39824_); - m_38869_(p_39825_, 1); - m_38886_(p_39826_, 1); + super(MenuType.LECTERN, p_39824_); + checkContainerSize(p_39825_, 1); + checkContainerDataCount(p_39826_, 1); @@ -32,6 +_,7 @@ } }); - this.m_38884_(p_39826_); -+ player = (org.bukkit.entity.Player) playerinventory.f_35978_.getBukkitEntity(); // CraftBukkit + this.addDataSlots(p_39826_); ++ player = (org.bukkit.entity.Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } - public boolean m_6366_(Player p_39833_, int p_39834_) { + public boolean clickMenuButton(Player p_39833_, int p_39834_) { @@ -54,6 +_,13 @@ return false; } @@ -53,15 +53,15 @@ + return false; + } + // CraftBukkit end - ItemStack itemstack = this.f_39819_.m_8016_(0); - this.f_39819_.m_6596_(); - if (!p_39833_.m_150109_().m_36054_(itemstack)) { + ItemStack itemstack = this.lectern.removeItemNoUpdate(0); + this.lectern.setChanged(); + if (!p_39833_.getInventory().add(itemstack)) { @@ -73,6 +_,8 @@ } - public boolean m_6875_(Player p_39831_) { -+ if (f_39819_ instanceof net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory && !((net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory) f_39819_).getLectern().m_59567_()) return false; // CraftBukkit + public boolean stillValid(Player p_39831_) { ++ if (lectern instanceof net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory && !((net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory) lectern).getLectern().hasBook()) return false; // CraftBukkit + if (!this.checkReachable) return true; // CraftBukkit - return this.f_39819_.m_6542_(p_39831_); + return this.lectern.stillValid(p_39831_); } diff --git a/patches/minecraft/net/minecraft/world/inventory/LoomMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/LoomMenu.java.patch index 970e9f31..f06f5a91 100644 --- a/patches/minecraft/net/minecraft/world/inventory/LoomMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/LoomMenu.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/inventory/LoomMenu.java +++ b/net/minecraft/world/inventory/LoomMenu.java @@ -32,19 +_,24 @@ - private final Slot f_39850_; - private final Slot f_39851_; - long f_39852_; -- private final Container f_39853_ = new SimpleContainer(3) { -- public void m_6596_() { -- super.m_6596_(); -- LoomMenu.this.m_6199_(this); -- LoomMenu.this.f_39847_.run(); + private final Slot patternSlot; + private final Slot resultSlot; + long lastSoundTime; +- private final Container inputContainer = new SimpleContainer(3) { +- public void setChanged() { +- super.setChanged(); +- LoomMenu.this.slotsChanged(this); +- LoomMenu.this.slotUpdateListener.run(); - } - }; -- private final Container f_39854_ = new SimpleContainer(1) { -- public void m_6596_() { -- super.m_6596_(); -- LoomMenu.this.f_39847_.run(); +- private final Container outputContainer = new SimpleContainer(1) { +- public void setChanged() { +- super.setChanged(); +- LoomMenu.this.slotUpdateListener.run(); - } - }; -+ private final Container f_39853_; -+ private final Container f_39854_; ++ private final Container inputContainer; ++ private final Container outputContainer; + + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -30,24 +30,24 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLoom inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLoom(this.f_39853_, this.f_39854_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLoom inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLoom(this.inputContainer, this.outputContainer); + bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end public LoomMenu(int p_39856_, Inventory p_39857_) { - this(p_39856_, p_39857_, ContainerLevelAccess.f_39287_); + this(p_39856_, p_39857_, ContainerLevelAccess.NULL); @@ -52,6 +_,35 @@ public LoomMenu(int p_39859_, Inventory p_39860_, final ContainerLevelAccess p_39861_) { - super(MenuType.f_39974_, p_39859_); + super(MenuType.LOOM, p_39859_); + //Magma start - add location -+ this.f_39853_ = new SimpleContainer(3) { -+ public void m_6596_() { -+ super.m_6596_(); -+ LoomMenu.this.m_6199_(this); -+ LoomMenu.this.f_39847_.run(); ++ this.inputContainer = new SimpleContainer(3) { ++ public void setChanged() { ++ super.setChanged(); ++ LoomMenu.this.slotsChanged(this); ++ LoomMenu.this.slotUpdateListener.run(); + } + + // CraftBukkit start @@ -57,10 +57,10 @@ + } + // CraftBukkit end + }; -+ this.f_39854_ = new SimpleContainer(1) { -+ public void m_6596_() { -+ super.m_6596_(); -+ LoomMenu.this.f_39847_.run(); ++ this.outputContainer = new SimpleContainer(1) { ++ public void setChanged() { ++ super.setChanged(); ++ LoomMenu.this.slotUpdateListener.run(); + } + + // CraftBukkit start @@ -71,46 +71,46 @@ + // CraftBukkit end + }; + //Magma end - this.f_39845_ = p_39861_; - this.f_39848_ = this.m_38897_(new Slot(this.f_39853_, 0, 13, 26) { - public boolean m_5857_(ItemStack p_39918_) { + this.access = p_39861_; + this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { + public boolean mayPlace(ItemStack p_39918_) { @@ -103,6 +_,7 @@ } - this.m_38895_(this.f_39846_); -+ player = (org.bukkit.entity.Player) p_39860_.f_35978_.getBukkitEntity(); // CraftBukkit + this.addDataSlot(this.selectedBannerPatternIndex); ++ player = (org.bukkit.entity.Player) p_39860_.player.getBukkitEntity(); // CraftBukkit } - public int m_39891_() { + public int getSelectedBannerPatternIndex() { @@ -110,12 +_,13 @@ } - public boolean m_6875_(Player p_39865_) { + public boolean stillValid(Player p_39865_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_39845_, p_39865_, Blocks.f_50617_); + return stillValid(this.access, p_39865_, Blocks.LOOM); } - public boolean m_6366_(Player p_39867_, int p_39868_) { -- if (p_39868_ > 0 && p_39868_ <= BannerPattern.f_58528_) { -- this.f_39846_.m_6422_(p_39868_); + public boolean clickMenuButton(Player p_39867_, int p_39868_) { +- if (p_39868_ > 0 && p_39868_ <= BannerPattern.AVAILABLE_PATTERNS) { +- this.selectedBannerPatternIndex.set(p_39868_); + if (p_39868_ > 0 && p_39868_ <= net.minecraftforge.common.ForgeHooks.getNonPatternItemCount() - 1) { -+ this.f_39846_.m_6422_(net.minecraftforge.common.ForgeHooks.getActualPatternIndex(p_39868_)); - this.m_39898_(); ++ this.selectedBannerPatternIndex.set(net.minecraftforge.common.ForgeHooks.getActualPatternIndex(p_39868_)); + this.setupResultSlot(); return true; } else { @@ -128,7 +_,7 @@ - ItemStack itemstack1 = this.f_39849_.m_7993_(); - ItemStack itemstack2 = this.f_39850_.m_7993_(); - ItemStack itemstack3 = this.f_39851_.m_7993_(); -- if (itemstack3.m_41619_() || !itemstack.m_41619_() && !itemstack1.m_41619_() && this.f_39846_.m_6501_() > 0 && (this.f_39846_.m_6501_() < BannerPattern.f_58526_ - BannerPattern.f_58527_ || !itemstack2.m_41619_())) { -+ if (itemstack3.m_41619_() || !itemstack.m_41619_() && !itemstack1.m_41619_() && this.f_39846_.m_6501_() > 0 && (this.f_39846_.m_6501_() < net.minecraftforge.common.ForgeHooks.getNonPatternItemCount() || !itemstack2.m_41619_())) { - if (!itemstack2.m_41619_() && itemstack2.m_41720_() instanceof BannerPatternItem) { - CompoundTag compoundtag = BlockItem.m_186336_(itemstack); - boolean flag = compoundtag != null && compoundtag.m_128425_("Patterns", 9) && !itemstack.m_41619_() && compoundtag.m_128437_("Patterns", 10).size() >= 6; + ItemStack itemstack1 = this.dyeSlot.getItem(); + ItemStack itemstack2 = this.patternSlot.getItem(); + ItemStack itemstack3 = this.resultSlot.getItem(); +- if (itemstack3.isEmpty() || !itemstack.isEmpty() && !itemstack1.isEmpty() && this.selectedBannerPatternIndex.get() > 0 && (this.selectedBannerPatternIndex.get() < BannerPattern.COUNT - BannerPattern.PATTERN_ITEM_COUNT || !itemstack2.isEmpty())) { ++ if (itemstack3.isEmpty() || !itemstack.isEmpty() && !itemstack1.isEmpty() && this.selectedBannerPatternIndex.get() > 0 && (this.selectedBannerPatternIndex.get() < net.minecraftforge.common.ForgeHooks.getNonPatternItemCount() || !itemstack2.isEmpty())) { + if (!itemstack2.isEmpty() && itemstack2.getItem() instanceof BannerPatternItem) { + CompoundTag compoundtag = BlockItem.getBlockEntityData(itemstack); + boolean flag = compoundtag != null && compoundtag.contains("Patterns", 9) && !itemstack.isEmpty() && compoundtag.getList("Patterns", 10).size() >= 6; @@ -224,6 +_,11 @@ ListTag listtag; - if (compoundtag != null && compoundtag.m_128425_("Patterns", 9)) { - listtag = compoundtag.m_128437_("Patterns", 10); + if (compoundtag != null && compoundtag.contains("Patterns", 9)) { + listtag = compoundtag.getList("Patterns", 10); + // CraftBukkit start + while (listtag.size() > 20) { + listtag.remove(20); diff --git a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch index f31c1b30..3af4018e 100644 --- a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch @@ -6,30 +6,30 @@ -public class MenuType { +public class MenuType extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeMenuType { - public static final MenuType f_39957_ = m_39988_("generic_9x1", ChestMenu::m_39234_); - public static final MenuType f_39958_ = m_39988_("generic_9x2", ChestMenu::m_39243_); - public static final MenuType f_39959_ = m_39988_("generic_9x3", ChestMenu::m_39255_); + public static final MenuType GENERIC_9x1 = register("generic_9x1", ChestMenu::oneRow); + public static final MenuType GENERIC_9x2 = register("generic_9x2", ChestMenu::twoRows); + public static final MenuType GENERIC_9x3 = register("generic_9x3", ChestMenu::threeRows); @@ -21,7 +_,7 @@ - public static final MenuType f_39971_ = m_39988_("grindstone", GrindstoneMenu::new); - public static final MenuType f_39972_ = m_39988_("hopper", HopperMenu::new); - public static final MenuType f_39973_ = m_39988_("lectern", (p_39992_, p_39993_) -> { + public static final MenuType GRINDSTONE = register("grindstone", GrindstoneMenu::new); + public static final MenuType HOPPER = register("hopper", HopperMenu::new); + public static final MenuType LECTERN = register("lectern", (p_39992_, p_39993_) -> { - return new LecternMenu(p_39992_); + return new LecternMenu(p_39992_, p_39993_); }); - public static final MenuType f_39974_ = m_39988_("loom", LoomMenu::new); - public static final MenuType f_39975_ = m_39988_("merchant", MerchantMenu::new); + public static final MenuType LOOM = register("loom", LoomMenu::new); + public static final MenuType MERCHANT = register("merchant", MerchantMenu::new); @@ -42,6 +_,14 @@ - public T m_39985_(int p_39986_, Inventory p_39987_) { - return this.f_39981_.m_39994_(p_39986_, p_39987_); + public T create(int p_39986_, Inventory p_39987_) { + return this.constructor.create(p_39986_, p_39987_); + } + + @Override + public T create(int windowId, Inventory playerInv, net.minecraft.network.FriendlyByteBuf extraData) { -+ if (this.f_39981_ instanceof net.minecraftforge.network.IContainerFactory) { -+ return ((net.minecraftforge.network.IContainerFactory) this.f_39981_).create(windowId, playerInv, extraData); ++ if (this.constructor instanceof net.minecraftforge.network.IContainerFactory) { ++ return ((net.minecraftforge.network.IContainerFactory) this.constructor).create(windowId, playerInv, extraData); + } -+ return m_39985_(windowId, playerInv); ++ return create(windowId, playerInv); } public interface MenuSupplier { diff --git a/patches/minecraft/net/minecraft/world/inventory/MerchantContainer.java.patch b/patches/minecraft/net/minecraft/world/inventory/MerchantContainer.java.patch index 57daccab..f5390afd 100644 --- a/patches/minecraft/net/minecraft/world/inventory/MerchantContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/MerchantContainer.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/inventory/MerchantContainer.java +++ b/net/minecraft/world/inventory/MerchantContainer.java @@ -18,6 +_,46 @@ - public int f_40000_; - private int f_40001_; + public int selectionHint; + private int futureXp; + // CraftBukkit start - add fields and methods + public java.util.List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.f_39998_; ++ return this.itemStacks; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -18,7 +18,7 @@ + + public void onClose(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { + transaction.remove(who); -+ f_39997_.m_7189_((Player) null); // SPIGOT-4860 ++ merchant.setTradingPlayer((Player) null); // SPIGOT-4860 + } + + public java.util.List getViewers() { @@ -26,7 +26,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -35,15 +35,15 @@ + } + + public org.bukkit.inventory.InventoryHolder getOwner() { -+ return (f_39997_ instanceof net.minecraft.world.entity.npc.AbstractVillager) ? (org.bukkit.craftbukkit.v1_18_R2.entity.CraftAbstractVillager) ((net.minecraft.world.entity.npc.AbstractVillager) this.f_39997_).getBukkitEntity() : null; ++ return (merchant instanceof net.minecraft.world.entity.npc.AbstractVillager) ? (org.bukkit.craftbukkit.v1_18_R2.entity.CraftAbstractVillager) ((net.minecraft.world.entity.npc.AbstractVillager) this.merchant).getBukkitEntity() : null; + } + + @Override + public org.bukkit.Location getLocation() { -+ return (f_39997_ instanceof net.minecraft.world.entity.npc.Villager) ? ((net.minecraft.world.entity.npc.Villager) this.f_39997_).getBukkitEntity().getLocation() : null; ++ return (merchant instanceof net.minecraft.world.entity.npc.Villager) ? ((net.minecraft.world.entity.npc.Villager) this.merchant).getBukkitEntity().getLocation() : null; + } + // CraftBukkit end + public MerchantContainer(Merchant p_40003_) { - this.f_39997_ = p_40003_; + this.merchant = p_40003_; } diff --git a/patches/minecraft/net/minecraft/world/inventory/MerchantMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/MerchantMenu.java.patch index 7f19d719..a712582e 100644 --- a/patches/minecraft/net/minecraft/world/inventory/MerchantMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/MerchantMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/MerchantMenu.java +++ b/net/minecraft/world/inventory/MerchantMenu.java @@ -29,6 +_,19 @@ - private boolean f_40030_; - private boolean f_40031_; + private boolean showProgressBar; + private boolean canRestock; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -11,19 +11,19 @@ + @Override + public org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView getBukkitView() { + if (bukkitEntity == null) { -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryMerchant(f_40027_, f_40028_), this); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryMerchant(trader, tradeContainer), this); + } + return bukkitEntity; + } + // CraftBukkit end + public MerchantMenu(int p_40033_, Inventory p_40034_) { - this(p_40033_, p_40034_, new ClientSideMerchant(p_40034_.f_35978_)); + this(p_40033_, p_40034_, new ClientSideMerchant(p_40034_.player)); } @@ -40,6 +_,7 @@ - this.m_38897_(new Slot(this.f_40028_, 0, 136, 37)); - this.m_38897_(new Slot(this.f_40028_, 1, 162, 37)); - this.m_38897_(new MerchantResultSlot(p_40037_.f_35978_, p_40038_, this.f_40028_, 2, 220, 37)); + this.addSlot(new Slot(this.tradeContainer, 0, 136, 37)); + this.addSlot(new Slot(this.tradeContainer, 1, 162, 37)); + this.addSlot(new MerchantResultSlot(p_40037_.player, p_40038_, this.tradeContainer, 2, 220, 37)); + this.player = p_40037_; // CraftBukkit - save player for(int i = 0; i < 3; ++i) { @@ -31,9 +31,9 @@ @@ -144,7 +_,7 @@ } - private void m_40077_() { -- if (!this.f_40027_.m_183595_()) { -+ if (!this.f_40027_.m_183595_() && this.f_40027_ instanceof Entity) { // CraftBukkit - SPIGOT-5035 - Entity entity = (Entity)this.f_40027_; - entity.m_183503_().m_7785_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), this.f_40027_.m_7596_(), SoundSource.NEUTRAL, 1.0F, 1.0F, false); + private void playTradeSound() { +- if (!this.trader.isClientSide()) { ++ if (!this.trader.isClientSide() && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035 + Entity entity = (Entity)this.trader; + entity.getLevel().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundSource.NEUTRAL, 1.0F, 1.0F, false); } diff --git a/patches/minecraft/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch b/patches/minecraft/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch index 51a473af..25fcc458 100644 --- a/patches/minecraft/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java @@ -12,8 +_,22 @@ @Nullable - private EnderChestBlockEntity f_40101_; + private EnderChestBlockEntity activeChest; - public PlayerEnderChestContainer() { + // CraftBukkit start @@ -14,7 +14,7 @@ + + @Override + public org.bukkit.Location getLocation() { -+ return this.f_40101_ != null ? new org.bukkit.Location(this.f_40101_.m_58904_().getWorld(), this.f_40101_.m_58899_().m_123341_(), this.f_40101_.m_58899_().m_123342_(), this.f_40101_.m_58899_().m_123343_()) : null; ++ return this.activeChest != null ? new org.bukkit.Location(this.activeChest.getLevel().getWorld(), this.activeChest.getBlockPos().getX(), this.activeChest.getBlockPos().getY(), this.activeChest.getBlockPos().getZ()) : null; + } + + public PlayerEnderChestContainer(Player owner) { @@ -23,4 +23,4 @@ + // CraftBukkit end } - public void m_40105_(EnderChestBlockEntity p_40106_) { + public void setActiveChest(EnderChestBlockEntity p_40106_) { diff --git a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch index aaee4a35..18c8cd0c 100644 --- a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/world/inventory/RecipeBookMenu.java @@ -29,6 +_,10 @@ - public abstract int m_6653_(); + public abstract int getSize(); + public java.util.List getRecipeBookCategories() { -+ return net.minecraft.client.RecipeBookCategories.m_92269_(this.m_5867_()); ++ return net.minecraft.client.RecipeBookCategories.getCategories(this.getRecipeBookType()); + } + - public abstract RecipeBookType m_5867_(); + public abstract RecipeBookType getRecipeBookType(); - public abstract boolean m_142157_(int p_150635_); + public abstract boolean shouldMoveToInventory(int p_150635_); diff --git a/patches/minecraft/net/minecraft/world/inventory/ResultContainer.java.patch b/patches/minecraft/net/minecraft/world/inventory/ResultContainer.java.patch index e1e70e84..c4dbdcbb 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ResultContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ResultContainer.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/inventory/ResultContainer.java @@ -13,6 +_,43 @@ @Nullable - private Recipe f_40141_; + private Recipe recipeUsed; + // CraftBukkit start + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.f_40140_; ++ return this.itemStacks; + } + + public org.bukkit.inventory.InventoryHolder getOwner() { @@ -27,7 +27,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -41,6 +41,6 @@ + } + // CraftBukkit end + - public int m_6643_() { + public int getContainerSize() { return 1; } diff --git a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch index aa5506c9..9d2c8756 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/inventory/ResultSlot.java +++ b/net/minecraft/world/inventory/ResultSlot.java @@ -41,6 +_,7 @@ - protected void m_5845_(ItemStack p_40185_) { - if (this.f_40164_ > 0) { - p_40185_.m_41678_(this.f_40163_.f_19853_, this.f_40163_, this.f_40164_); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerCraftingEvent(this.f_40163_, p_40185_, this.f_40162_); + protected void checkTakeAchievements(ItemStack p_40185_) { + if (this.removeCount > 0) { + p_40185_.onCraftedBy(this.player.level, this.player, this.removeCount); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerCraftingEvent(this.player, p_40185_, this.craftSlots); } - if (this.f_40218_ instanceof RecipeHolder) { + if (this.container instanceof RecipeHolder) { @@ -52,8 +_,9 @@ - public void m_142406_(Player p_150638_, ItemStack p_150639_) { - this.m_5845_(p_150639_); + public void onTake(Player p_150638_, ItemStack p_150639_) { + this.checkTakeAchievements(p_150639_); + net.minecraftforge.common.ForgeHooks.setCraftingPlayer(p_150638_); - NonNullList nonnulllist = p_150638_.f_19853_.m_7465_().m_44069_(RecipeType.f_44107_, this.f_40162_, p_150638_.f_19853_); + NonNullList nonnulllist = p_150638_.level.getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, this.craftSlots, p_150638_.level); - + net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); for(int i = 0; i < nonnulllist.size(); ++i) { - ItemStack itemstack = this.f_40162_.m_8020_(i); + ItemStack itemstack = this.craftSlots.getItem(i); ItemStack itemstack1 = nonnulllist.get(i); diff --git a/patches/minecraft/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch index cb5b44b6..91f12a13 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ShulkerBoxMenu.java +++ b/net/minecraft/world/inventory/ShulkerBoxMenu.java @@ -10,6 +_,21 @@ - private static final int f_150640_ = 27; - private final Container f_40186_; + private static final int CONTAINER_SIZE = 27; + private final Container container; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity; @@ -14,7 +14,7 @@ + return bukkitEntity; + } + -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.f_35978_.getBukkitEntity(), new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.f_40186_), this); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory(this.container), this); + return bukkitEntity; + } + // CraftBukkit end @@ -23,10 +23,10 @@ this(p_40188_, p_40189_, new SimpleContainer(27)); } @@ -18,6 +_,7 @@ - super(MenuType.f_39976_, p_40191_); - m_38869_(p_40193_, 27); - this.f_40186_ = p_40193_; + super(MenuType.SHULKER_BOX, p_40191_); + checkContainerSize(p_40193_, 27); + this.container = p_40193_; + this.player = p_40192_; // CraftBukkit - save player - p_40193_.m_5856_(p_40192_.f_35978_); + p_40193_.startOpen(p_40192_.player); int i = 3; int j = 9; diff --git a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch index f17ee17d..e9a5a958 100644 --- a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch @@ -3,15 +3,15 @@ @@ -74,7 +_,7 @@ @Nullable - public Pair m_7543_() { + public Pair getNoItemIcon() { - return null; + return backgroundPair; } - public ItemStack m_6201_(int p_40227_) { + public ItemStack remove(int p_40227_) { @@ -87,6 +_,38 @@ - public boolean m_6659_() { + public boolean isActive() { return true; + } + @@ -22,7 +22,7 @@ + * @return Index in associated inventory for this slot. + */ + public int getSlotIndex() { -+ return f_40217_; ++ return slot; + } + + /** @@ -31,7 +31,7 @@ + * @return true if the other slot is in the same inventory + */ + public boolean isSameInventory(Slot other) { -+ return this.f_40218_ == other.f_40218_; ++ return this.container == other.container; + } + + private Pair backgroundPair; @@ -47,4 +47,4 @@ + return this; } - public Optional m_150641_(int p_150642_, int p_150643_, Player p_150644_) { + public Optional tryRemove(int p_150642_, int p_150643_, Player p_150644_) { diff --git a/patches/minecraft/net/minecraft/world/inventory/SmithingMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/SmithingMenu.java.patch index 12a4f787..b0c801e9 100644 --- a/patches/minecraft/net/minecraft/world/inventory/SmithingMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/SmithingMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/SmithingMenu.java +++ b/net/minecraft/world/inventory/SmithingMenu.java @@ -17,6 +_,20 @@ - private UpgradeRecipe f_40242_; - private final List f_40243_; + private UpgradeRecipe selectedRecipe; + private final List recipes; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity; @@ -12,26 +12,26 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventorySmithing(f_39770_.getLocation(), this.f_39769_, this.f_39768_); -+ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.f_39771_.getBukkitEntity(), inventory, this); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventorySmithing(access.getLocation(), this.inputSlots, this.resultSlots); ++ bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end + public SmithingMenu(int p_40245_, Inventory p_40246_) { - this(p_40245_, p_40246_, ContainerLevelAccess.f_39287_); + this(p_40245_, p_40246_, ContainerLevelAccess.NULL); } @@ -54,12 +_,14 @@ - public void m_6640_() { - List list = this.f_40241_.m_7465_().m_44056_(RecipeType.f_44113_, this.f_39769_, this.f_40241_); + public void createResult() { + List list = this.level.getRecipeManager().getRecipesFor(RecipeType.SMITHING, this.inputSlots, this.level); if (list.isEmpty()) { -- this.f_39768_.m_6836_(0, ItemStack.f_41583_); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.f_41583_); // CraftBukkit +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { - this.f_40242_ = list.get(0); - ItemStack itemstack = this.f_40242_.m_5874_(this.f_39769_); - this.f_39768_.m_6029_(this.f_40242_); -- this.f_39768_.m_6836_(0, itemstack); + this.selectedRecipe = list.get(0); + ItemStack itemstack = this.selectedRecipe.assemble(this.inputSlots); + this.resultSlots.setRecipeUsed(this.selectedRecipe); +- this.resultSlots.setItem(0, itemstack); + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/inventory/StonecutterMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/StonecutterMenu.java.patch index 6d9cb1b0..e90d7fa9 100644 --- a/patches/minecraft/net/minecraft/world/inventory/StonecutterMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/StonecutterMenu.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/inventory/StonecutterMenu.java +++ b/net/minecraft/world/inventory/StonecutterMenu.java @@ -32,14 +_,24 @@ - final Slot f_40283_; - Runnable f_40291_ = () -> { + final Slot resultSlot; + Runnable slotUpdateListener = () -> { }; -- public final Container f_40284_ = new SimpleContainer(1) { -- public void m_6596_() { -- super.m_6596_(); -- StonecutterMenu.this.m_6199_(this); -- StonecutterMenu.this.f_40291_.run(); -+ public final Container f_40284_; -+ final ResultContainer f_40292_; +- public final Container container = new SimpleContainer(1) { +- public void setChanged() { +- super.setChanged(); +- StonecutterMenu.this.slotsChanged(this); +- StonecutterMenu.this.slotUpdateListener.run(); ++ public final Container container; ++ final ResultContainer resultContainer; + + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView bukkitEntity = null; @@ -22,27 +22,27 @@ + return bukkitEntity; } - }; -- final ResultContainer f_40292_ = new ResultContainer(); +- final ResultContainer resultContainer = new ResultContainer(); + -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryStonecutter inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryStonecutter(this.f_40284_, this.f_40292_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryStonecutter inventory = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryStonecutter(this.container, this.resultContainer); + bukkitEntity = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end public StonecutterMenu(int p_40294_, Inventory p_40295_) { - this(p_40294_, p_40295_, ContainerLevelAccess.f_39287_); + this(p_40294_, p_40295_, ContainerLevelAccess.NULL); @@ -47,6 +_,23 @@ public StonecutterMenu(int p_40297_, Inventory p_40298_, final ContainerLevelAccess p_40299_) { - super(MenuType.f_39980_, p_40297_); + super(MenuType.STONECUTTER, p_40297_); + //Magma start - add location -+ this.f_40292_ = new ResultContainer(); -+ this.f_40284_ = new SimpleContainer(1) { -+ public void m_6596_() { -+ super.m_6596_(); -+ StonecutterMenu.this.m_6199_(this); -+ StonecutterMenu.this.f_40291_.run(); ++ this.resultContainer = new ResultContainer(); ++ this.container = new SimpleContainer(1) { ++ public void setChanged() { ++ super.setChanged(); ++ StonecutterMenu.this.slotsChanged(this); ++ StonecutterMenu.this.slotUpdateListener.run(); + } + + // CraftBukkit start @@ -53,22 +53,22 @@ + // CraftBukkit end + }; + //Magma end - this.f_40285_ = p_40299_; - this.f_40287_ = p_40298_.f_35978_.f_19853_; - this.f_40282_ = this.m_38897_(new Slot(this.f_40284_, 0, 20, 33)); + this.access = p_40299_; + this.level = p_40298_.player.level; + this.inputSlot = this.addSlot(new Slot(this.container, 0, 20, 33)); @@ -86,6 +_,7 @@ } - this.m_38895_(this.f_40286_); -+ player = (org.bukkit.entity.Player) p_40298_.f_35978_.getBukkitEntity(); // CraftBukkit + this.addDataSlot(this.selectedRecipeIndex); ++ player = (org.bukkit.entity.Player) p_40298_.player.getBukkitEntity(); // CraftBukkit } - public int m_40338_() { + public int getSelectedRecipeIndex() { @@ -105,6 +_,7 @@ } - public boolean m_6875_(Player p_40307_) { + public boolean stillValid(Player p_40307_) { + if (!this.checkReachable) return true; // CraftBukkit - return m_38889_(this.f_40285_, p_40307_, Blocks.f_50679_); + return stillValid(this.access, p_40307_, Blocks.STONECUTTER); } diff --git a/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch index 948c3781..b09d3531 100644 --- a/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ArmorItem.java.patch @@ -2,44 +2,44 @@ +++ b/net/minecraft/world/item/ArmorItem.java @@ -49,7 +_,32 @@ LivingEntity livingentity = list.get(0); - EquipmentSlot equipmentslot = Mob.m_147233_(p_40400_); - ItemStack itemstack = p_40400_.m_41620_(1); -- livingentity.m_8061_(equipmentslot, itemstack); + EquipmentSlot equipmentslot = Mob.getEquipmentSlotForItem(p_40400_); + ItemStack itemstack = p_40400_.split(1); +- livingentity.setItemSlot(equipmentslot, itemstack); + + // CraftBukkit start -+ Level world = p_40399_.m_7727_(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_40399_.m_7961_().m_123341_(), p_40399_.m_7961_().m_123342_(), p_40399_.m_7961_().m_123343_()); ++ Level world = p_40399_.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_40399_.getPos().getX(), p_40399_.getPos().getY(), p_40399_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_40400_); + org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) livingentity.getBukkitEntity()); + if (!DispenserBlock.eventFired) { + world.getCraftServer().getPluginManager().callEvent(event); + } + if (event.isCancelled()) { -+ itemstack.m_41769_(1); ++ itemstack.grow(1); + return false; + } + if (!event.getItem().equals(craftItem)) { -+ itemstack.m_41769_(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != ArmorItem.f_40376_) { -+ idispensebehavior.m_6115_(p_40399_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != ArmorItem.DISPENSE_ITEM_BEHAVIOR) { ++ idispensebehavior.dispense(p_40399_, eventStack); + return true; + } + } + -+ livingentity.m_8061_(equipmentslot, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ livingentity.setItemSlot(equipmentslot, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end if (livingentity instanceof Mob) { - ((Mob)livingentity).m_21409_(equipmentslot, 2.0F); - ((Mob)livingentity).m_21530_(); + ((Mob)livingentity).setDropChance(equipmentslot, 2.0F); + ((Mob)livingentity).setPersistenceRequired(); @@ -71,7 +_,7 @@ - UUID uuid = f_40380_[p_40387_.m_20749_()]; - builder.put(Attributes.f_22284_, new AttributeModifier(uuid, "Armor modifier", (double)this.f_40381_, AttributeModifier.Operation.ADDITION)); - builder.put(Attributes.f_22285_, new AttributeModifier(uuid, "Armor toughness", (double)this.f_40382_, AttributeModifier.Operation.ADDITION)); + UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[p_40387_.getIndex()]; + builder.put(Attributes.ARMOR, new AttributeModifier(uuid, "Armor modifier", (double)this.defense, AttributeModifier.Operation.ADDITION)); + builder.put(Attributes.ARMOR_TOUGHNESS, new AttributeModifier(uuid, "Armor toughness", (double)this.toughness, AttributeModifier.Operation.ADDITION)); - if (p_40386_ == ArmorMaterials.NETHERITE) { -+ if (this.f_40378_ > 0) { - builder.put(Attributes.f_22278_, new AttributeModifier(uuid, "Armor knockback resistance", (double)this.f_40378_, AttributeModifier.Operation.ADDITION)); ++ if (this.knockbackResistance > 0) { + builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance", (double)this.knockbackResistance, AttributeModifier.Operation.ADDITION)); } diff --git a/patches/minecraft/net/minecraft/world/item/ArmorStandItem.java.patch b/patches/minecraft/net/minecraft/world/item/ArmorStandItem.java.patch index 63168611..da264e5c 100644 --- a/patches/minecraft/net/minecraft/world/item/ArmorStandItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ArmorStandItem.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/ArmorStandItem.java +++ b/net/minecraft/world/item/ArmorStandItem.java @@ -49,6 +_,13 @@ - float f = (float)Mth.m_14143_((Mth.m_14177_(p_40510_.m_7074_() - 180.0F) + 22.5F) / 45.0F) * 45.0F; - armorstand.m_7678_(armorstand.m_20185_(), armorstand.m_20186_(), armorstand.m_20189_(), f, 0.0F); - this.m_40506_(armorstand, level.f_46441_); + float f = (float)Mth.floor((Mth.wrapDegrees(p_40510_.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; + armorstand.moveTo(armorstand.getX(), armorstand.getY(), armorstand.getZ(), f, 0.0F); + this.randomizePose(armorstand, level.random); + + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPlaceEvent(p_40510_, armorstand).isCancelled()) { @@ -11,6 +11,6 @@ + } + // CraftBukkit end + - serverlevel.m_47205_(armorstand); - level.m_6263_((Player)null, armorstand.m_20185_(), armorstand.m_20186_(), armorstand.m_20189_(), SoundEvents.f_11684_, SoundSource.BLOCKS, 0.75F, 0.8F); - level.m_151545_(p_40510_.m_43723_(), GameEvent.f_157810_, armorstand); + serverlevel.addFreshEntityWithPassengers(armorstand); + level.playSound((Player)null, armorstand.getX(), armorstand.getY(), armorstand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F); + level.gameEvent(p_40510_.getPlayer(), GameEvent.ENTITY_PLACE, armorstand); diff --git a/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch b/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch index 20d8edb1..bf69e086 100644 --- a/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ArrowItem.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/item/ArrowItem.java +++ b/net/minecraft/world/item/ArrowItem.java @@ -15,4 +_,9 @@ - arrow.m_36878_(p_40514_); + arrow.setEffectsFromItem(p_40514_); return arrow; } + + public boolean isInfinite(ItemStack stack, ItemStack bow, net.minecraft.world.entity.player.Player player) { -+ int enchant = net.minecraft.world.item.enchantment.EnchantmentHelper.m_44843_(net.minecraft.world.item.enchantment.Enchantments.f_44952_, bow); ++ int enchant = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY_ARROWS, bow); + return enchant <= 0 ? false : this.getClass() == ArrowItem.class; + } } diff --git a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch index 46ee28fd..dcce2de6 100644 --- a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java @@ -31,11 +_,9 @@ - BlockPos blockpos = p_40529_.m_8083_(); - Player player = p_40529_.m_43723_(); - BlockState blockstate = level.m_8055_(blockpos); -- Optional optional = this.m_150690_(blockstate); -- Optional optional1 = WeatheringCopper.m_154899_(blockstate); -- Optional optional2 = Optional.ofNullable(HoneycombItem.f_150864_.get().get(blockstate.m_60734_())).map((p_150694_) -> { -- return p_150694_.m_152465_(blockstate); + BlockPos blockpos = p_40529_.getClickedPos(); + Player player = p_40529_.getPlayer(); + BlockState blockstate = level.getBlockState(blockpos); +- Optional optional = this.getStripped(blockstate); +- Optional optional1 = WeatheringCopper.getPrevious(blockstate); +- Optional optional2 = Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(blockstate.getBlock())).map((p_150694_) -> { +- return p_150694_.withPropertiesOf(blockstate); - }); + Optional optional = Optional.ofNullable(blockstate.getToolModifiedState(p_40529_, net.minecraftforge.common.ToolActions.AXE_STRIP, false)); + Optional optional1 = optional.isPresent() ? Optional.empty() : Optional.ofNullable(blockstate.getToolModifiedState(p_40529_, net.minecraftforge.common.ToolActions.AXE_SCRAPE, false)); + Optional optional2 = optional.isPresent() || optional1.isPresent() ? Optional.empty() : Optional.ofNullable(blockstate.getToolModifiedState(p_40529_, net.minecraftforge.common.ToolActions.AXE_WAX_OFF, false)); - ItemStack itemstack = p_40529_.m_43722_(); + ItemStack itemstack = p_40529_.getItemInHand(); Optional optional3 = Optional.empty(); if (optional.isPresent()) { @@ -69,9 +_,20 @@ @@ -21,13 +21,13 @@ + @javax.annotation.Nullable + public static BlockState getAxeStrippingState(BlockState originalState) { -+ Block block = f_150683_.get(originalState.m_60734_()); -+ return block != null ? block.m_49966_().m_61124_(RotatedPillarBlock.f_55923_, originalState.m_61143_(RotatedPillarBlock.f_55923_)) : null; ++ Block block = STRIPPABLES.get(originalState.getBlock()); ++ return block != null ? block.defaultBlockState().setValue(RotatedPillarBlock.AXIS, originalState.getValue(RotatedPillarBlock.AXIS)) : null; + } + - private Optional m_150690_(BlockState p_150691_) { - return Optional.ofNullable(f_150683_.get(p_150691_.m_60734_())).map((p_150689_) -> { - return p_150689_.m_49966_().m_61124_(RotatedPillarBlock.f_55923_, p_150691_.m_61143_(RotatedPillarBlock.f_55923_)); + private Optional getStripped(BlockState p_150691_) { + return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock())).map((p_150689_) -> { + return p_150689_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS)); }); + } + diff --git a/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch b/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch index dcd05588..6d9d34a1 100644 --- a/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/item/BannerItem.java +++ b/net/minecraft/world/item/BannerItem.java @@ -32,7 +_,8 @@ - DyeColor dyecolor = DyeColor.m_41053_(compoundtag1.m_128451_("Color")); - BannerPattern bannerpattern = BannerPattern.m_58575_(compoundtag1.m_128461_("Pattern")); + DyeColor dyecolor = DyeColor.byId(compoundtag1.getInt("Color")); + BannerPattern bannerpattern = BannerPattern.byHash(compoundtag1.getString("Pattern")); if (bannerpattern != null) { -- p_40544_.add((new TranslatableComponent("block.minecraft.banner." + bannerpattern.m_58572_() + "." + dyecolor.m_41065_())).m_130940_(ChatFormatting.GRAY)); -+ net.minecraft.resources.ResourceLocation fileLoc = new net.minecraft.resources.ResourceLocation(bannerpattern.m_58572_()); -+ p_40544_.add((new TranslatableComponent("block." + fileLoc.m_135827_() + ".banner." + fileLoc.m_135815_() + "." + dyecolor.m_41065_())).m_130940_(ChatFormatting.GRAY)); +- p_40544_.add((new TranslatableComponent("block.minecraft.banner." + bannerpattern.getFilename() + "." + dyecolor.getName())).withStyle(ChatFormatting.GRAY)); ++ net.minecraft.resources.ResourceLocation fileLoc = new net.minecraft.resources.ResourceLocation(bannerpattern.getFilename()); ++ p_40544_.add((new TranslatableComponent("block." + fileLoc.getNamespace() + ".banner." + fileLoc.getPath() + "." + dyecolor.getName())).withStyle(ChatFormatting.GRAY)); } } diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index 291d5cd3..940e1b62 100644 --- a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch @@ -3,12 +3,12 @@ @@ -57,6 +_,14 @@ return InteractionResult.FAIL; } else { - BlockPlaceContext blockplacecontext = this.m_7732_(p_40577_); + BlockPlaceContext blockplacecontext = this.updatePlacementContext(p_40577_); + + // CraftBukkit start - special case for handling block placement with water lilies and snow buckets + org.bukkit.block.BlockState blockstateCB = null; + if (this instanceof WaterLilyBlockItem || this instanceof SolidBucketItem) { -+ blockstateCB = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockStates.getBlockState(blockplacecontext.m_43725_(), blockplacecontext.m_8083_()); ++ blockstateCB = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockStates.getBlockState(blockplacecontext.getLevel(), blockplacecontext.getClickedPos()); + } + // CraftBukkit end + @@ -16,13 +16,13 @@ return InteractionResult.FAIL; } else { @@ -75,15 +_,29 @@ - blockstate1 = this.m_40602_(blockpos, level, itemstack, blockstate1); - this.m_7274_(blockpos, level, player, itemstack, blockstate1); - blockstate1.m_60734_().m_6402_(level, blockpos, blockstate1, player, itemstack); + blockstate1 = this.updateBlockStateFromTag(blockpos, level, itemstack, blockstate1); + this.updateCustomBlockEntityTag(blockpos, level, player, itemstack, blockstate1); + blockstate1.getBlock().setPlacedBy(level, blockpos, blockstate1, player, itemstack); + + // CraftBukkit start + if (blockstateCB != null) { -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockPlaceEvent((net.minecraft.server.level.ServerLevel) level, player, blockplacecontext.m_43724_(), blockstateCB, blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockPlaceEvent((net.minecraft.server.level.ServerLevel) level, player, blockplacecontext.getHand(), blockstateCB, blockpos.getX(), blockpos.getY(), blockpos.getZ()); + if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { + blockstateCB.update(true, false); + if (this instanceof SolidBucketItem) { @@ -34,18 +34,18 @@ + // CraftBukkit end + if (player instanceof ServerPlayer) { - CriteriaTriggers.f_10591_.m_59469_((ServerPlayer)player, blockpos, itemstack); + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, blockpos, itemstack); } } -- SoundType soundtype = blockstate1.m_60827_(); -- level.m_5594_(player, blockpos, this.m_40587_(blockstate1), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F); - level.m_142346_(player, GameEvent.f_157797_, blockpos); -- if (player == null || !player.m_150110_().f_35937_) { -+ SoundType soundtype = blockstate1.getSoundType(level, blockpos, p_40577_.m_43723_()); -+ level.m_5594_(player, blockpos, this.getPlaceSound(blockstate1, level, blockpos, p_40577_.m_43723_()), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F); -+ if (player == null || !player.m_150110_().f_35937_ && itemstack != ItemStack.f_41583_) { // CraftBukkit - itemstack.m_41774_(1); +- SoundType soundtype = blockstate1.getSoundType(); +- level.playSound(player, blockpos, this.getPlaceSound(blockstate1), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + level.gameEvent(player, GameEvent.BLOCK_PLACE, blockpos); +- if (player == null || !player.getAbilities().instabuild) { ++ SoundType soundtype = blockstate1.getSoundType(level, blockpos, p_40577_.getPlayer()); ++ level.playSound(player, blockpos, this.getPlaceSound(blockstate1, level, blockpos, p_40577_.getPlayer()), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); ++ if (player == null || !player.getAbilities().instabuild && itemstack != ItemStack.EMPTY) { // CraftBukkit + itemstack.shrink(1); } @@ -93,10 +_,16 @@ @@ -53,35 +53,35 @@ } + @Deprecated //Forge: Use more sensitive version {@link BlockItem#getPlaceSound(BlockState, IBlockReader, BlockPos, Entity) } - protected SoundEvent m_40587_(BlockState p_40588_) { - return p_40588_.m_60827_().m_56777_(); + protected SoundEvent getPlaceSound(BlockState p_40588_) { + return p_40588_.getSoundType().getPlaceSound(); } + //Forge: Sensitive version of BlockItem#getPlaceSound + protected SoundEvent getPlaceSound(BlockState state, Level world, BlockPos pos, Player entity) { -+ return state.getSoundType(world, pos, entity).m_56777_(); ++ return state.getSoundType(world, pos, entity).getPlaceSound(); + } + @Nullable - public BlockPlaceContext m_7732_(BlockPlaceContext p_40609_) { + public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { return p_40609_; @@ -117,24 +_,29 @@ - CompoundTag compoundtag = p_40605_.m_41783_(); + CompoundTag compoundtag = p_40605_.getTag(); if (compoundtag != null) { - CompoundTag compoundtag1 = compoundtag.m_128469_("BlockStateTag"); -- StateDefinition statedefinition = p_40606_.m_60734_().m_49965_(); + CompoundTag compoundtag1 = compoundtag.getCompound("BlockStateTag"); +- StateDefinition statedefinition = p_40606_.getBlock().getStateDefinition(); - -- for(String s : compoundtag1.m_128431_()) { -- Property property = statedefinition.m_61081_(s); +- for(String s : compoundtag1.getAllKeys()) { +- Property property = statedefinition.getProperty(s); - if (property != null) { -- String s1 = compoundtag1.m_128423_(s).m_7916_(); -- blockstate = m_40593_(blockstate, property, s1); +- String s1 = compoundtag1.get(s).getAsString(); +- blockstate = updateState(blockstate, property, s1); - } - } - } - - if (blockstate != p_40606_) { -- p_40604_.m_7731_(p_40603_, blockstate, 2); +- p_40604_.setBlock(p_40603_, blockstate, 2); + // CraftBukkit start + blockstate = getBlockState(blockstate, compoundtag1); } @@ -92,64 +92,64 @@ + public static BlockState getBlockState(BlockState iblockdata, CompoundTag compoundtag1) { + BlockState iblockdata1 = iblockdata; + // CraftBukkit end -+ StateDefinition statedefinition = iblockdata.m_60734_().m_49965_(); ++ StateDefinition statedefinition = iblockdata.getBlock().getStateDefinition(); + -+ for (String s : compoundtag1.m_128431_()) { -+ Property property = statedefinition.m_61081_(s); ++ for (String s : compoundtag1.getAllKeys()) { ++ Property property = statedefinition.getProperty(s); + if (property != null) { -+ String s1 = compoundtag1.m_128423_(s).m_7916_(); -+ iblockdata1 = m_40593_(iblockdata1, property, s1); ++ String s1 = compoundtag1.get(s).getAsString(); ++ iblockdata1 = updateState(iblockdata1, property, s1); + } + } + return iblockdata1; + } + + - private static > BlockState m_40593_(BlockState p_40594_, Property p_40595_, String p_40596_) { - return p_40595_.m_6215_(p_40596_).map((p_40592_) -> { - return p_40594_.m_61124_(p_40595_, p_40592_); + private static > BlockState updateState(BlockState p_40594_, Property p_40595_, String p_40596_) { + return p_40595_.getValue(p_40596_).map((p_40592_) -> { + return p_40594_.setValue(p_40595_, p_40592_); @@ -144,7 +_,14 @@ - protected boolean m_40610_(BlockPlaceContext p_40611_, BlockState p_40612_) { - Player player = p_40611_.m_43723_(); - CollisionContext collisioncontext = player == null ? CollisionContext.m_82749_() : CollisionContext.m_82750_(player); -- return (!this.m_6652_() || p_40612_.m_60710_(p_40611_.m_43725_(), p_40611_.m_8083_())) && p_40611_.m_43725_().m_45752_(p_40612_, p_40611_.m_8083_(), collisioncontext); + protected boolean canPlace(BlockPlaceContext p_40611_, BlockState p_40612_) { + Player player = p_40611_.getPlayer(); + CollisionContext collisioncontext = player == null ? CollisionContext.empty() : CollisionContext.of(player); +- return (!this.mustSurvive() || p_40612_.canSurvive(p_40611_.getLevel(), p_40611_.getClickedPos())) && p_40611_.getLevel().isUnobstructed(p_40612_, p_40611_.getClickedPos(), collisioncontext); + + // CraftBukkit start - store default return -+ boolean defaultReturn = (!this.m_6652_() || p_40612_.m_60710_(p_40611_.m_43725_(), p_40611_.m_8083_())) && p_40611_.m_43725_().m_45752_(p_40612_, p_40611_.m_8083_(), collisioncontext); -+ org.bukkit.entity.Player playerCB = (p_40611_.m_43723_() instanceof ServerPlayer) ? (org.bukkit.entity.Player) p_40611_.m_43723_().getBukkitEntity() : null; -+ org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_40611_.m_43725_(), p_40611_.m_8083_()), playerCB, org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData(p_40612_), defaultReturn); -+ p_40611_.m_43725_().getCraftServer().getPluginManager().callEvent(event); ++ boolean defaultReturn = (!this.mustSurvive() || p_40612_.canSurvive(p_40611_.getLevel(), p_40611_.getClickedPos())) && p_40611_.getLevel().isUnobstructed(p_40612_, p_40611_.getClickedPos(), collisioncontext); ++ org.bukkit.entity.Player playerCB = (p_40611_.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) p_40611_.getPlayer().getBukkitEntity() : null; ++ org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_40611_.getLevel(), p_40611_.getClickedPos()), playerCB, org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData(p_40612_), defaultReturn); ++ p_40611_.getLevel().getCraftServer().getPluginManager().callEvent(event); + return event.isBuildable(); + // CraftBukkit end } - protected boolean m_6652_() { + protected boolean mustSurvive() { @@ -164,7 +_,7 @@ if (compoundtag != null) { - BlockEntity blockentity = p_40583_.m_7702_(p_40585_); + BlockEntity blockentity = p_40583_.getBlockEntity(p_40585_); if (blockentity != null) { -- if (!p_40583_.f_46443_ && blockentity.m_6326_() && (p_40584_ == null || !p_40584_.m_36337_())) { -+ if (!p_40583_.f_46443_ && blockentity.m_6326_() && (p_40584_ == null || !(p_40584_.m_36337_() || (p_40584_.m_150110_().f_35937_ && p_40584_.getBukkitEntity().hasPermission("minecraft.nbt.place"))))) { // Spigot - add permission +- if (!p_40583_.isClientSide && blockentity.onlyOpCanSetNbt() && (p_40584_ == null || !p_40584_.canUseGameMasterBlocks())) { ++ if (!p_40583_.isClientSide && blockentity.onlyOpCanSetNbt() && (p_40584_ == null || !(p_40584_.canUseGameMasterBlocks() || (p_40584_.getAbilities().instabuild && p_40584_.getBukkitEntity().hasPermission("minecraft.nbt.place"))))) { // Spigot - add permission return false; } @@ -200,11 +_,19 @@ } - public Block m_40614_() { + public Block getBlock() { + return this.getBlockRaw() == null ? null : this.getBlockRaw().delegate.get(); + } + + private Block getBlockRaw() { - return this.f_40563_; + return this.block; } - public void m_6192_(Map p_40607_, Item p_40608_) { - p_40607_.put(this.m_40614_(), p_40608_); + public void registerBlocks(Map p_40607_, Item p_40608_) { + p_40607_.put(this.getBlock(), p_40608_); + } + + public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ blockToItemMap.remove(this.m_40614_()); ++ blockToItemMap.remove(this.getBlock()); } - public boolean m_142095_() { + public boolean canFitInsideContainerItems() { diff --git a/patches/minecraft/net/minecraft/world/item/BoatItem.java.patch b/patches/minecraft/net/minecraft/world/item/BoatItem.java.patch index 2d361717..c4a424dd 100644 --- a/patches/minecraft/net/minecraft/world/item/BoatItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BoatItem.java.patch @@ -3,30 +3,30 @@ @@ -47,6 +_,13 @@ } - if (hitresult.m_6662_() == HitResult.Type.BLOCK) { + if (hitresult.getType() == HitResult.Type.BLOCK) { + // CraftBukkit start - Boat placement + net.minecraft.world.phys.BlockHitResult blockhitresult = (net.minecraft.world.phys.BlockHitResult)hitresult; -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(p_40623_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, blockhitresult.m_82425_(), blockhitresult.m_82434_(), itemstack, p_40624_); ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent(p_40623_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, blockhitresult.getBlockPos(), blockhitresult.getDirection(), itemstack, p_40624_); + if (event.isCancelled()) { -+ return InteractionResultHolder.m_19098_(itemstack); ++ return InteractionResultHolder.pass(itemstack); + } + // CraftBukkit end - Boat boat = new Boat(p_40622_, hitresult.m_82450_().f_82479_, hitresult.m_82450_().f_82480_, hitresult.m_82450_().f_82481_); - boat.m_38332_(this.f_40616_); - boat.m_146922_(p_40623_.m_146908_()); + Boat boat = new Boat(p_40622_, hitresult.getLocation().x, hitresult.getLocation().y, hitresult.getLocation().z); + boat.setType(this.type); + boat.setYRot(p_40623_.getYRot()); @@ -54,7 +_,14 @@ - return InteractionResultHolder.m_19100_(itemstack); + return InteractionResultHolder.fail(itemstack); } else { - if (!p_40622_.f_46443_) { -- p_40622_.m_7967_(boat); + if (!p_40622_.isClientSide) { +- p_40622_.addFreshEntity(boat); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPlaceEvent(p_40622_, blockhitresult.m_82425_(), blockhitresult.m_82434_(), p_40623_, boat).isCancelled()) { -+ return InteractionResultHolder.m_19100_(itemstack); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPlaceEvent(p_40622_, blockhitresult.getBlockPos(), blockhitresult.getDirection(), p_40623_, boat).isCancelled()) { ++ return InteractionResultHolder.fail(itemstack); + } -+ if (!p_40622_.m_7967_(boat)) { -+ return InteractionResultHolder.m_19098_(itemstack); ++ if (!p_40622_.addFreshEntity(boat)) { ++ return InteractionResultHolder.pass(itemstack); + } + // CraftBukkit end - p_40622_.m_142346_(p_40623_, GameEvent.f_157810_, new BlockPos(hitresult.m_82450_())); - if (!p_40623_.m_150110_().f_35937_) { - itemstack.m_41774_(1); + p_40622_.gameEvent(p_40623_, GameEvent.ENTITY_PLACE, new BlockPos(hitresult.getLocation())); + if (!p_40623_.getAbilities().instabuild) { + itemstack.shrink(1); diff --git a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch index 09921822..e5dd4139 100644 --- a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch @@ -3,36 +3,36 @@ @@ -30,10 +_,16 @@ } - public InteractionResult m_6225_(UseOnContext p_40637_) { + public InteractionResult useOn(UseOnContext p_40637_) { + // CraftBukkit start - extract bonemeal application logic to separate, static method + return applyBonemeal(p_40637_); + } + + public static InteractionResult applyBonemeal(UseOnContext p_40637_) { + // CraftBukkit end - Level level = p_40637_.m_43725_(); - BlockPos blockpos = p_40637_.m_8083_(); - BlockPos blockpos1 = blockpos.m_142300_(p_40637_.m_43719_()); -- if (m_40627_(p_40637_.m_43722_(), level, blockpos)) { -+ if (applyBonemeal(p_40637_.m_43722_(), level, blockpos, p_40637_.m_43723_())) { - if (!level.f_46443_) { - level.m_46796_(1505, blockpos, 0); + Level level = p_40637_.getLevel(); + BlockPos blockpos = p_40637_.getClickedPos(); + BlockPos blockpos1 = blockpos.relative(p_40637_.getClickedFace()); +- if (growCrop(p_40637_.getItemInHand(), level, blockpos)) { ++ if (applyBonemeal(p_40637_.getItemInHand(), level, blockpos, p_40637_.getPlayer())) { + if (!level.isClientSide) { + level.levelEvent(1505, blockpos, 0); } @@ -54,8 +_,17 @@ } } + @Deprecated //Forge: Use Player/Hand version - public static boolean m_40627_(ItemStack p_40628_, Level p_40629_, BlockPos p_40630_) { + public static boolean growCrop(ItemStack p_40628_, Level p_40629_, BlockPos p_40630_) { + if (p_40629_ instanceof net.minecraft.server.level.ServerLevel) + return applyBonemeal(p_40628_, p_40629_, p_40630_, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.server.level.ServerLevel)p_40629_)); + return false; + } + + public static boolean applyBonemeal(ItemStack p_40628_, Level p_40629_, BlockPos p_40630_, net.minecraft.world.entity.player.Player player) { - BlockState blockstate = p_40629_.m_8055_(p_40630_); + BlockState blockstate = p_40629_.getBlockState(p_40630_); + int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, p_40629_, p_40630_, blockstate, p_40628_); + if (hook != 0) return hook > 0; - if (blockstate.m_60734_() instanceof BonemealableBlock) { - BonemealableBlock bonemealableblock = (BonemealableBlock)blockstate.m_60734_(); - if (bonemealableblock.m_7370_(p_40629_, p_40630_, blockstate, p_40629_.f_46443_)) { + if (blockstate.getBlock() instanceof BonemealableBlock) { + BonemealableBlock bonemealableblock = (BonemealableBlock)blockstate.getBlock(); + if (bonemealableblock.isValidBonemealTarget(p_40629_, p_40630_, blockstate, p_40629_.isClientSide)) { diff --git a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch index 1b2ff609..24d45321 100644 --- a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch @@ -2,36 +2,36 @@ +++ b/net/minecraft/world/item/BowItem.java @@ -26,18 +_,23 @@ Player player = (Player)p_40669_; - boolean flag = player.m_150110_().f_35937_ || EnchantmentHelper.m_44843_(Enchantments.f_44952_, p_40667_) > 0; - ItemStack itemstack = player.m_6298_(p_40667_); + boolean flag = player.getAbilities().instabuild || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY_ARROWS, p_40667_) > 0; + ItemStack itemstack = player.getProjectile(p_40667_); + -+ int i = this.m_8105_(p_40667_) - p_40670_; -+ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_40667_, p_40668_, player, i, !itemstack.m_41619_() || flag); ++ int i = this.getUseDuration(p_40667_) - p_40670_; ++ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_40667_, p_40668_, player, i, !itemstack.isEmpty() || flag); + if (i < 0) return; + - if (!itemstack.m_41619_() || flag) { - if (itemstack.m_41619_()) { - itemstack = new ItemStack(Items.f_42412_); + if (!itemstack.isEmpty() || flag) { + if (itemstack.isEmpty()) { + itemstack = new ItemStack(Items.ARROW); } -- int i = this.m_8105_(p_40667_) - p_40670_; - float f = m_40661_(i); +- int i = this.getUseDuration(p_40667_) - p_40670_; + float f = getPowerForTime(i); if (!((double)f < 0.1D)) { -- boolean flag1 = flag && itemstack.m_150930_(Items.f_42412_); -+ boolean flag1 = player.m_150110_().f_35937_ || (itemstack.m_41720_() instanceof ArrowItem && ((ArrowItem)itemstack.m_41720_()).isInfinite(itemstack, p_40667_, player)); - if (!p_40668_.f_46443_) { - ArrowItem arrowitem = (ArrowItem)(itemstack.m_41720_() instanceof ArrowItem ? itemstack.m_41720_() : Items.f_42412_); - AbstractArrow abstractarrow = arrowitem.m_6394_(p_40668_, itemstack, player); +- boolean flag1 = flag && itemstack.is(Items.ARROW); ++ boolean flag1 = player.getAbilities().instabuild || (itemstack.getItem() instanceof ArrowItem && ((ArrowItem)itemstack.getItem()).isInfinite(itemstack, p_40667_, player)); + if (!p_40668_.isClientSide) { + ArrowItem arrowitem = (ArrowItem)(itemstack.getItem() instanceof ArrowItem ? itemstack.getItem() : Items.ARROW); + AbstractArrow abstractarrow = arrowitem.createArrow(p_40668_, itemstack, player); + abstractarrow = customArrow(abstractarrow); - abstractarrow.m_37251_(player, player.m_146909_(), player.m_146908_(), 0.0F, f * 3.0F, 1.0F); + abstractarrow.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, f * 3.0F, 1.0F); if (f == 1.0F) { - abstractarrow.m_36762_(true); + abstractarrow.setCritArrow(true); @@ -57,6 +_,15 @@ - abstractarrow.m_20254_(100); + abstractarrow.setSecondsOnFire(100); } + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityShootBowEvent(player, p_40667_, itemstack, abstractarrow, player.m_7655_(), f, !flag1); ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityShootBowEvent(player, p_40667_, itemstack, abstractarrow, player.getUsedItemHand(), f, !flag1); + if (event.isCancelled()) { + event.getProjectile().remove(); + return; @@ -39,17 +39,17 @@ + flag1 = !event.shouldConsumeItem(); + // CraftBukkit end + - p_40667_.m_41622_(1, player, (p_40665_) -> { - p_40665_.m_21190_(player.m_7655_()); + p_40667_.hurtAndBreak(1, player, (p_40665_) -> { + p_40665_.broadcastBreakEvent(player.getUsedItemHand()); }); @@ -64,7 +_,17 @@ - abstractarrow.f_36705_ = AbstractArrow.Pickup.CREATIVE_ONLY; + abstractarrow.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; } -- p_40668_.m_7967_(abstractarrow); +- p_40668_.addFreshEntity(abstractarrow); + // CraftBukkit start + if (event.getProjectile() == abstractarrow.getBukkitEntity()) { -+ if (!p_40668_.m_7967_(abstractarrow)) { ++ if (!p_40668_.addFreshEntity(abstractarrow)) { + if (player instanceof net.minecraft.server.level.ServerPlayer) { + ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().updateInventory(); + } @@ -60,26 +60,26 @@ + } - p_40668_.m_6263_((Player)null, player.m_20185_(), player.m_20186_(), player.m_20189_(), SoundEvents.f_11687_, SoundSource.PLAYERS, 1.0F, 1.0F / (p_40668_.m_5822_().nextFloat() * 0.4F + 1.2F) + f * 0.5F); + p_40668_.playSound((Player)null, player.getX(), player.getY(), player.getZ(), SoundEvents.ARROW_SHOOT, SoundSource.PLAYERS, 1.0F, 1.0F / (p_40668_.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F); @@ -102,6 +_,10 @@ - public InteractionResultHolder m_7203_(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { - ItemStack itemstack = p_40673_.m_21120_(p_40674_); - boolean flag = !p_40673_.m_6298_(itemstack).m_41619_(); + public InteractionResultHolder use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { + ItemStack itemstack = p_40673_.getItemInHand(p_40674_); + boolean flag = !p_40673_.getProjectile(itemstack).isEmpty(); + + InteractionResultHolder ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); + if (ret != null) return ret; + - if (!p_40673_.m_150110_().f_35937_ && !flag) { - return InteractionResultHolder.m_19100_(itemstack); + if (!p_40673_.getAbilities().instabuild && !flag) { + return InteractionResultHolder.fail(itemstack); } else { @@ -112,6 +_,10 @@ - public Predicate m_6437_() { - return f_43005_; + public Predicate getAllSupportedProjectiles() { + return ARROW_ONLY; + } + + public AbstractArrow customArrow(AbstractArrow arrow) { + return arrow; } - public int m_6615_() { + public int getDefaultProjectileRange() { diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch index 7eb9623c..a2e9dbff 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/item/BucketItem.java @@ -32,14 +_,28 @@ public class BucketItem extends Item implements DispensibleContainerItem { - private final Fluid f_40687_; + private final Fluid content; + // Forge: Use the other constructor that takes a Supplier + @Deprecated public BucketItem(Fluid p_40689_, Item.Properties p_40690_) { super(p_40690_); - this.f_40687_ = p_40689_; + this.content = p_40689_; + this.fluidSupplier = p_40689_.delegate; + } + @@ -17,64 +17,64 @@ + */ + public BucketItem(java.util.function.Supplier supplier, Item.Properties builder) { + super(builder); -+ this.f_40687_ = null; ++ this.content = null; + this.fluidSupplier = supplier; } - public InteractionResultHolder m_7203_(Level p_40703_, Player p_40704_, InteractionHand p_40705_) { - ItemStack itemstack = p_40704_.m_21120_(p_40705_); - BlockHitResult blockhitresult = m_41435_(p_40703_, p_40704_, this.f_40687_ == Fluids.f_76191_ ? ClipContext.Fluid.SOURCE_ONLY : ClipContext.Fluid.NONE); + public InteractionResultHolder 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); + if (ret != null) return ret; - if (blockhitresult.m_6662_() == HitResult.Type.MISS) { - return InteractionResultHolder.m_19098_(itemstack); - } else if (blockhitresult.m_6662_() != HitResult.Type.BLOCK) { + if (blockhitresult.getType() == HitResult.Type.MISS) { + return InteractionResultHolder.pass(itemstack); + } else if (blockhitresult.getType() != HitResult.Type.BLOCK) { @@ -53,14 +_,26 @@ - BlockState blockstate1 = p_40703_.m_8055_(blockpos); - if (blockstate1.m_60734_() instanceof BucketPickup) { - BucketPickup bucketpickup = (BucketPickup)blockstate1.m_60734_(); + BlockState blockstate1 = p_40703_.getBlockState(blockpos); + if (blockstate1.getBlock() instanceof BucketPickup) { + BucketPickup bucketpickup = (BucketPickup)blockstate1.getBlock(); + + // CraftBukkit start -+ ItemStack dummyFluid = bucketpickup.m_142598_(org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, blockpos, blockstate1); -+ if (dummyFluid.m_41619_()) return InteractionResultHolder.m_19100_(itemstack); // Don't fire event if the bucket won't be filled. -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerBucketFillEvent((net.minecraft.server.level.ServerLevel) p_40703_, p_40704_, blockpos, blockpos, blockhitresult.m_82434_(), itemstack, dummyFluid.m_41720_()); ++ ItemStack dummyFluid = bucketpickup.pickupBlock(org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, blockpos, blockstate1); ++ if (dummyFluid.isEmpty()) return InteractionResultHolder.fail(itemstack); // Don't fire event if the bucket won't be filled. ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerBucketFillEvent((net.minecraft.server.level.ServerLevel) p_40703_, p_40704_, blockpos, blockpos, blockhitresult.getDirection(), itemstack, dummyFluid.getItem()); + if (event.isCancelled()) { -+ ((ServerPlayer) p_40704_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_40703_, blockpos)); // SPIGOT-5163 (see PlayerInteractManager) ++ ((ServerPlayer) p_40704_).connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_40703_, blockpos)); // SPIGOT-5163 (see PlayerInteractManager) + ((ServerPlayer) p_40704_).getBukkitEntity().updateInventory(); // SPIGOT-4541 -+ return InteractionResultHolder.m_19100_(itemstack); ++ return InteractionResultHolder.fail(itemstack); + } + // CraftBukkit end + - ItemStack itemstack1 = bucketpickup.m_142598_(p_40703_, blockpos, blockstate1); - if (!itemstack1.m_41619_()) { - p_40704_.m_36246_(Stats.f_12982_.m_12902_(this)); -- bucketpickup.m_142298_().ifPresent((p_150709_) -> { + ItemStack itemstack1 = bucketpickup.pickupBlock(p_40703_, blockpos, blockstate1); + if (!itemstack1.isEmpty()) { + p_40704_.awardStat(Stats.ITEM_USED.get(this)); +- bucketpickup.getPickupSound().ifPresent((p_150709_) -> { + bucketpickup.getPickupSound(blockstate1).ifPresent((p_150709_) -> { - p_40704_.m_5496_(p_150709_, 1.0F, 1.0F); + p_40704_.playSound(p_150709_, 1.0F, 1.0F); }); - p_40703_.m_142346_(p_40704_, GameEvent.f_157816_, blockpos); -- ItemStack itemstack2 = ItemUtils.m_41813_(itemstack, p_40704_, itemstack1); -+ ItemStack itemstack2 = ItemUtils.m_41813_(itemstack, p_40704_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - if (!p_40703_.f_46443_) { - CriteriaTriggers.f_10576_.m_38772_((ServerPlayer)p_40704_, itemstack1); + p_40703_.gameEvent(p_40704_, GameEvent.FLUID_PICKUP, blockpos); +- ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack1); ++ ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + if (!p_40703_.isClientSide) { + CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)p_40704_, itemstack1); } @@ -72,8 +_,8 @@ - return InteractionResultHolder.m_19100_(itemstack); + return InteractionResultHolder.fail(itemstack); } else { - BlockState blockstate = p_40703_.m_8055_(blockpos); -- BlockPos blockpos2 = blockstate.m_60734_() instanceof LiquidBlockContainer && this.f_40687_ == Fluids.f_76193_ ? blockpos : blockpos1; -- if (this.m_142073_(p_40704_, p_40703_, blockpos2, blockhitresult)) { + BlockState blockstate = p_40703_.getBlockState(blockpos); +- BlockPos blockpos2 = blockstate.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockpos : blockpos1; +- if (this.emptyContents(p_40704_, p_40703_, blockpos2, blockhitresult)) { + BlockPos blockpos2 = canBlockContainFluid(p_40703_, blockpos, blockstate) ? blockpos : blockpos1; -+ if (this.emptyContents(p_40704_, p_40703_, blockpos2, blockhitresult, blockhitresult.m_82434_(), blockpos, itemstack)) { // CraftBukkit - this.m_142131_(p_40704_, p_40703_, itemstack, blockpos2); ++ if (this.emptyContents(p_40704_, p_40703_, blockpos2, blockhitresult, blockhitresult.getDirection(), blockpos, itemstack)) { // CraftBukkit + this.checkExtraContent(p_40704_, p_40703_, itemstack, blockpos2); if (p_40704_ instanceof ServerPlayer) { - CriteriaTriggers.f_10591_.m_59469_((ServerPlayer)p_40704_, blockpos2, itemstack); + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)p_40704_, blockpos2, itemstack); @@ -98,7 +_,15 @@ - public void m_142131_(@Nullable Player p_150711_, Level p_150712_, ItemStack p_150713_, BlockPos p_150714_) { + public void checkExtraContent(@Nullable Player p_150711_, Level p_150712_, ItemStack p_150713_, BlockPos p_150714_) { } + @Deprecated //Forge: use the ItemStack sensitive version - public boolean m_142073_(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_) { + public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_) { + return this.emptyContents(p_150716_, p_150717_, p_150718_, p_150719_, null); + } + @@ -82,13 +82,13 @@ + @Nullable private Direction emptyContents_direction; + @Nullable private BlockPos emptyContents_clicked; + public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { - if (!(this.f_40687_ instanceof FlowingFluid)) { + if (!(this.content instanceof FlowingFluid)) { return false; } else { @@ -107,8 +_,34 @@ - Material material = blockstate.m_60767_(); - boolean flag = blockstate.m_60722_(this.f_40687_); - boolean flag1 = blockstate.m_60795_() || flag || block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).m_6044_(p_150717_, p_150718_, blockstate, this.f_40687_); + Material material = blockstate.getMaterial(); + boolean flag = blockstate.canBeReplaced(this.content); + boolean flag1 = blockstate.isAir() || flag || block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).canPlaceLiquid(p_150717_, p_150718_, blockstate, this.content); + var containedFluidStack = java.util.Optional.ofNullable(container).flatMap(net.minecraftforge.fluids.FluidUtil::getFluidContained); + + // CraftBukkit start @@ -105,7 +105,7 @@ + this.emptyContents_direction = null; + this.emptyContents_clicked = null; + if (event != null && event.isCancelled()) { //Magma - null check -+ ((ServerPlayer) p_150716_).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_150717_, p_150718_)); // SPIGOT-4238: needed when looking through entity ++ ((ServerPlayer) p_150716_).connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_150717_, p_150718_)); // SPIGOT-4238: needed when looking through entity + ((ServerPlayer) p_150716_).getBukkitEntity().updateInventory(); // SPIGOT-4541 + return false; + } @@ -113,22 +113,22 @@ + // CraftBukkit end + if (!flag1) { -- return p_150719_ != null && this.m_142073_(p_150716_, p_150717_, p_150719_.m_82425_().m_142300_(p_150719_.m_82434_()), (BlockHitResult)null); -+ return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.m_82425_().m_142300_(p_150719_.m_82434_()), (BlockHitResult)null, container); -+ } else if (p_150717_.m_6042_().m_63951_() && containedFluidStack.isPresent() && this.f_40687_.getAttributes().doesVaporize(p_150717_, p_150718_, containedFluidStack.get())) { -+ this.f_40687_.getAttributes().vaporize(p_150716_, p_150717_, p_150718_, containedFluidStack.get()); +- return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), (BlockHitResult)null); ++ return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), (BlockHitResult)null, container); ++ } else if (p_150717_.dimensionType().ultraWarm() && containedFluidStack.isPresent() && this.content.getAttributes().doesVaporize(p_150717_, p_150718_, containedFluidStack.get())) { ++ this.content.getAttributes().vaporize(p_150716_, p_150717_, p_150718_, containedFluidStack.get()); + return true; - } else if (p_150717_.m_6042_().m_63951_() && this.f_40687_.m_205067_(FluidTags.f_13131_)) { - int i = p_150718_.m_123341_(); - int j = p_150718_.m_123342_(); + } else if (p_150717_.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + int i = p_150718_.getX(); + int j = p_150718_.getY(); @@ -120,7 +_,7 @@ } return true; -- } else if (block instanceof LiquidBlockContainer && this.f_40687_ == Fluids.f_76193_) { -+ } else if (block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).m_6044_(p_150717_,p_150718_,blockstate,f_40687_)) { - ((LiquidBlockContainer)block).m_7361_(p_150717_, p_150718_, blockstate, ((FlowingFluid)this.f_40687_).m_76068_(false)); - this.m_7718_(p_150716_, p_150717_, p_150718_); +- } else if (block instanceof LiquidBlockContainer && this.content == Fluids.WATER) { ++ } else if (block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).canPlaceLiquid(p_150717_,p_150718_,blockstate,content)) { + ((LiquidBlockContainer)block).placeLiquid(p_150717_, p_150718_, blockstate, ((FlowingFluid)this.content).getSource(false)); + this.playEmptySound(p_150716_, p_150717_, p_150718_); return true; @@ -139,9 +_,38 @@ } @@ -141,12 +141,12 @@ + } + //Magma end + - protected void m_7718_(@Nullable Player p_40696_, LevelAccessor p_40697_, BlockPos p_40698_) { -- SoundEvent soundevent = this.f_40687_.m_205067_(FluidTags.f_13132_) ? SoundEvents.f_11780_ : SoundEvents.f_11778_; -+ SoundEvent soundevent = this.f_40687_.getAttributes().getEmptySound(); -+ if(soundevent == null) soundevent = this.f_40687_.m_205067_(FluidTags.f_13132_) ? SoundEvents.f_11780_ : SoundEvents.f_11778_; - p_40697_.m_5594_(p_40696_, p_40698_, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); - p_40697_.m_142346_(p_40696_, GameEvent.f_157769_, p_40698_); + protected void playEmptySound(@Nullable Player p_40696_, LevelAccessor p_40697_, BlockPos p_40698_) { +- SoundEvent soundevent = this.content.is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY; ++ SoundEvent soundevent = this.content.getAttributes().getEmptySound(); ++ if(soundevent == null) soundevent = this.content.is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY; + p_40697_.playSound(p_40696_, p_40698_, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); + p_40697_.gameEvent(p_40696_, GameEvent.FLUID_PLACE, p_40698_); + } + + @Override @@ -160,13 +160,13 @@ + private final java.util.function.Supplier fluidSupplier; + + public Fluid getContent() { -+ return f_40687_; ++ return content; + } + + public Fluid getFluid() { return fluidSupplier.get(); } + + private boolean canBlockContainFluid(Level worldIn, BlockPos posIn, BlockState blockstate) + { -+ return blockstate.m_60734_() instanceof LiquidBlockContainer && ((LiquidBlockContainer)blockstate.m_60734_()).m_6044_(worldIn, posIn, blockstate, this.f_40687_); ++ return blockstate.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer)blockstate.getBlock()).canPlaceLiquid(worldIn, posIn, blockstate, this.content); } } diff --git a/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch b/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch index 52a54404..866196ac 100644 --- a/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch @@ -3,17 +3,17 @@ @@ -41,7 +_,7 @@ } - public boolean m_142207_(ItemStack p_150733_, Slot p_150734_, ClickAction p_150735_, Player p_150736_) { + public boolean overrideStackedOnOther(ItemStack p_150733_, Slot p_150734_, ClickAction p_150735_, Player p_150736_) { - if (p_150735_ != ClickAction.SECONDARY) { -+ if (p_150733_.m_41613_() != 1 || p_150735_ != ClickAction.SECONDARY) { ++ if (p_150733_.getCount() != 1 || p_150735_ != ClickAction.SECONDARY) { return false; } else { - ItemStack itemstack = p_150734_.m_7993_(); + ItemStack itemstack = p_150734_.getItem(); @@ -63,6 +_,7 @@ } - public boolean m_142305_(ItemStack p_150742_, ItemStack p_150743_, Slot p_150744_, ClickAction p_150745_, Player p_150746_, SlotAccess p_150747_) { -+ if (p_150742_.m_41613_() != 1) return false; - if (p_150745_ == ClickAction.SECONDARY && p_150744_.m_150651_(p_150746_)) { - if (p_150743_.m_41619_()) { - m_150780_(p_150742_).ifPresent((p_186347_) -> { + 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_)) { + if (p_150743_.isEmpty()) { + removeOne(p_150742_).ifPresent((p_186347_) -> { diff --git a/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch b/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch index 4e416fa8..f9dae845 100644 --- a/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/item/ChorusFruitItem.java +++ b/net/minecraft/world/item/ChorusFruitItem.java @@ -30,7 +_,16 @@ - p_40714_.m_8127_(); + p_40714_.stopRiding(); } -- if (p_40714_.m_20984_(d3, d4, d5, true)) { +- if (p_40714_.randomTeleport(d3, d4, d5, true)) { + net.minecraftforge.event.entity.EntityTeleportEvent.ChorusFruit event = net.minecraftforge.event.ForgeEventFactory.onChorusFruitTeleport(p_40714_, d3, d4, d5); + if (event.isCanceled()) return itemstack; + // CraftBukkit start - handle canceled status of teleport event @@ -15,6 +15,6 @@ + } + if (status.get()) { + // CraftBukkit end - SoundEvent soundevent = p_40714_ instanceof Fox ? SoundEvents.f_11953_ : SoundEvents.f_11757_; - p_40713_.m_6263_((Player)null, d0, d1, d2, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F); - p_40714_.m_5496_(soundevent, 1.0F, 1.0F); + SoundEvent soundevent = p_40714_ instanceof Fox ? SoundEvents.FOX_TELEPORT : SoundEvents.CHORUS_FRUIT_TELEPORT; + p_40713_.playSound((Player)null, d0, d1, d2, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F); + p_40714_.playSound(soundevent, 1.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch index f4211a5f..bf3563cc 100644 --- a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch @@ -1,49 +1,49 @@ --- a/net/minecraft/world/item/CreativeModeTab.java +++ b/net/minecraft/world/item/CreativeModeTab.java @@ -85,18 +_,23 @@ - private final String f_40763_; - private final Component f_40764_; - private String f_40765_; + private final String langId; + private final Component displayName; + private String recipeFolderName; + @Deprecated - private String f_40766_ = "items.png"; + private String backgroundSuffix = "items.png"; + private net.minecraft.resources.ResourceLocation backgroundLocation; - private boolean f_40767_ = true; - private boolean f_40768_ = true; - private EnchantmentCategory[] f_40769_ = new EnchantmentCategory[0]; - private ItemStack f_40770_; + private boolean canScroll = true; + private boolean showTitle = true; + private EnchantmentCategory[] enchantmentCategories = new EnchantmentCategory[0]; + private ItemStack iconItemStack; + public CreativeModeTab(String label) { + this(-1, label); + } + public CreativeModeTab(int p_40773_, String p_40774_) { -- this.f_40762_ = p_40773_; - this.f_40763_ = p_40774_; - this.f_40764_ = new TranslatableComponent("itemGroup." + p_40774_); - this.f_40770_ = ItemStack.f_41583_; -- f_40748_[p_40773_] = this; -+ this.f_40762_ = addGroupSafe(p_40773_, this); +- this.id = p_40773_; + this.langId = p_40774_; + this.displayName = new TranslatableComponent("itemGroup." + p_40774_); + this.iconItemStack = ItemStack.EMPTY; +- TABS[p_40773_] = this; ++ this.id = addGroupSafe(p_40773_, this); } - public int m_40775_() { + public int getId() { @@ -121,15 +_,28 @@ - public abstract ItemStack m_6976_(); + public abstract ItemStack makeIcon(); + /** + * @deprecated Forge use {@link #getBackgroundImage()} instead + */ + @Deprecated - public String m_40788_() { - return this.f_40766_; + public String getBackgroundSuffix() { + return this.backgroundSuffix; } + /** + * @deprecated Forge: use {@link #setBackgroundImage(net.minecraft.resources.ResourceLocation)} instead + */ + @Deprecated - public CreativeModeTab m_40779_(String p_40780_) { - this.f_40766_ = p_40780_; + public CreativeModeTab setBackgroundSuffix(String p_40780_) { + this.backgroundSuffix = p_40780_; return this; } @@ -52,34 +52,34 @@ + return this; + } + - public CreativeModeTab m_40784_(String p_40785_) { - this.f_40765_ = p_40785_; + public CreativeModeTab setRecipeFolderName(String p_40785_) { + this.recipeFolderName = p_40785_; return this; @@ -154,10 +_,12 @@ } - public int m_40793_() { -+ if (f_40762_ > 11) return ((f_40762_ - 12) % 10) % 5; - return this.f_40762_ % 6; + public int getColumn() { ++ if (id > 11) return ((id - 12) % 10) % 5; + return this.id % 6; } - public boolean m_40794_() { -+ if (f_40762_ > 11) return ((f_40762_ - 12) % 10) < 5; - return this.f_40762_ < 6; + public boolean isTopRow() { ++ if (id > 11) return ((id - 12) % 10) < 5; + return this.id < 6; } @@ -191,5 +_,58 @@ - item.m_6787_(this, p_40778_); + item.fillItemCategory(this, p_40778_); } + } + + public int getTabPage() { -+ return f_40762_ < 12 ? 0 : ((f_40762_ - 12) / 10) + 1; ++ return id < 12 ? 0 : ((id - 12) / 10) + 1; + } + + public boolean hasSearchBar() { -+ return f_40762_ == f_40754_.f_40762_; ++ return id == TAB_SEARCH.id; + } + + /** @@ -94,7 +94,7 @@ + + public net.minecraft.resources.ResourceLocation getBackgroundImage() { + if (backgroundLocation != null) return backgroundLocation; //FORGE: allow custom namespace -+ return new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tab_" + this.m_40788_()); ++ return new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tab_" + this.getBackgroundSuffix()); + } + + private static final net.minecraft.resources.ResourceLocation CREATIVE_INVENTORY_TABS = new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); @@ -111,19 +111,19 @@ + } + + public static synchronized int getGroupCountSafe() { -+ return CreativeModeTab.f_40748_.length; ++ return CreativeModeTab.TABS.length; + } + + private static synchronized int addGroupSafe(int index, CreativeModeTab newGroup) { + if(index == -1) { -+ index = f_40748_.length; ++ index = TABS.length; + } -+ if (index >= f_40748_.length) { ++ if (index >= TABS.length) { + CreativeModeTab[] tmp = new CreativeModeTab[index + 1]; -+ System.arraycopy(f_40748_, 0, tmp, 0, f_40748_.length); -+ f_40748_ = tmp; ++ System.arraycopy(TABS, 0, tmp, 0, TABS.length); ++ TABS = tmp; + } -+ f_40748_[index] = newGroup; ++ TABS[index] = newGroup; + return index; } } diff --git a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch b/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch index 92748591..d7d05a76 100644 --- a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java @@ -105,6 +_,10 @@ - if (itemstack.m_41619_() && flag) { - itemstack = new ItemStack(Items.f_42412_); - itemstack1 = itemstack.m_41777_(); + if (itemstack.isEmpty() && flag) { + itemstack = new ItemStack(Items.ARROW); + itemstack1 = itemstack.copy(); + // CraftBukkit start - SPIGOT-4870, MC-150847 -+ } else if (itemstack1.m_41619_()) { ++ } else if (itemstack1.isEmpty()) { + return false; + // CraftBukkit end } - if (!m_40862_(p_40860_, p_40861_, itemstack, k > 0, flag)) { + if (!loadProjectile(p_40860_, p_40861_, itemstack, k > 0, flag)) { @@ -217,10 +_,27 @@ - projectile.m_6686_((double)vector3f.m_122239_(), (double)vector3f.m_122260_(), (double)vector3f.m_122269_(), p_40902_, p_40903_); + projectile.shoot((double)vector3f.x(), (double)vector3f.y(), (double)vector3f.z(), p_40902_, p_40903_); } + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityShootBowEvent(p_40896_, p_40898_, p_40899_, projectile, p_40896_.m_7655_(), p_40900_, true); ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityShootBowEvent(p_40896_, p_40898_, p_40899_, projectile, p_40896_.getUsedItemHand(), p_40900_, true); + if (event.isCancelled()) { + event.getProjectile().remove(); + return; + } + // CraftBukkit end + - p_40898_.m_41622_(flag ? 3 : 1, p_40896_, (p_40858_) -> { - p_40858_.m_21190_(p_40897_); + p_40898_.hurtAndBreak(flag ? 3 : 1, p_40896_, (p_40858_) -> { + p_40858_.broadcastBreakEvent(p_40897_); }); -- p_40895_.m_7967_(projectile); +- p_40895_.addFreshEntity(projectile); + // CraftBukkit start + if (event.getProjectile() == (projectile).getBukkitEntity()) { -+ if (!p_40895_.m_7967_(projectile)) { ++ if (!p_40895_.addFreshEntity(projectile)) { + if (p_40896_ instanceof ServerPlayer) { + ((ServerPlayer) p_40896_).getBukkitEntity().updateInventory(); + } @@ -37,14 +37,14 @@ + } + } + // CraftBukkit end - p_40895_.m_6263_((Player)null, p_40896_.m_20185_(), p_40896_.m_20186_(), p_40896_.m_20189_(), SoundEvents.f_11847_, SoundSource.PLAYERS, 1.0F, p_40900_); + p_40895_.playSound((Player)null, p_40896_.getX(), p_40896_.getY(), p_40896_.getZ(), SoundEvents.CROSSBOW_SHOOT, SoundSource.PLAYERS, 1.0F, p_40900_); } } @@ -243,6 +_,7 @@ } - public static void m_40887_(Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_) { + public static void performShooting(Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_) { + if (p_40889_ instanceof Player player && net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_40891_, p_40888_, player, 1, true) < 0) return; - List list = m_40941_(p_40891_); - float[] afloat = m_40923_(p_40889_.m_21187_()); + List list = getChargedProjectiles(p_40891_); + float[] afloat = getShotPitches(p_40889_.getRandom()); diff --git a/patches/minecraft/net/minecraft/world/item/DebugStickItem.java.patch b/patches/minecraft/net/minecraft/world/item/DebugStickItem.java.patch index 1a172e37..7b6ce3a1 100644 --- a/patches/minecraft/net/minecraft/world/item/DebugStickItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DebugStickItem.java.patch @@ -3,9 +3,9 @@ @@ -52,7 +_,7 @@ } - private boolean m_150802_(Player p_150803_, BlockState p_150804_, LevelAccessor p_150805_, BlockPos p_150806_, boolean p_150807_, ItemStack p_150808_) { -- if (!p_150803_.m_36337_()) { -+ if (!p_150803_.m_36337_() && !(p_150803_.m_150110_().f_35937_ && p_150803_.getBukkitEntity().hasPermission("minecraft.debugstick")) && !p_150803_.getBukkitEntity().hasPermission("minecraft.debugstick.always")) { // Spigot + private boolean handleInteraction(Player p_150803_, BlockState p_150804_, LevelAccessor p_150805_, BlockPos p_150806_, boolean p_150807_, ItemStack p_150808_) { +- if (!p_150803_.canUseGameMasterBlocks()) { ++ if (!p_150803_.canUseGameMasterBlocks() && !(p_150803_.getAbilities().instabuild && p_150803_.getBukkitEntity().hasPermission("minecraft.debugstick")) && !p_150803_.getBukkitEntity().hasPermission("minecraft.debugstick.always")) { // Spigot return false; } else { - Block block = p_150804_.m_60734_(); + Block block = p_150804_.getBlock(); diff --git a/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch b/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch index 4ab9035f..30f63db4 100644 --- a/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DiggerItem.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/item/DiggerItem.java +++ b/net/minecraft/world/item/DiggerItem.java @@ -61,7 +_,11 @@ - return this.f_40981_; + return this.attackDamageBaseline; } + @Deprecated // FORGE: Use stack sensitive variant below - public boolean m_8096_(BlockState p_150816_) { -+ if (net.minecraftforge.common.TierSortingRegistry.isTierSorted(m_43314_())) { -+ return net.minecraftforge.common.TierSortingRegistry.isCorrectTierForDrops(m_43314_(), p_150816_) && p_150816_.m_204336_(this.f_40979_); + public boolean isCorrectToolForDrops(BlockState p_150816_) { ++ if (net.minecraftforge.common.TierSortingRegistry.isTierSorted(getTier())) { ++ return net.minecraftforge.common.TierSortingRegistry.isCorrectTierForDrops(getTier(), p_150816_) && p_150816_.is(this.blocks); + } - int i = this.m_43314_().m_6604_(); - if (i < 3 && p_150816_.m_204336_(BlockTags.f_144284_)) { + int i = this.getTier().getLevel(); + if (i < 3 && p_150816_.is(BlockTags.NEEDS_DIAMOND_TOOL)) { return false; @@ -70,5 +_,11 @@ } else { - return i < 1 && p_150816_.m_204336_(BlockTags.f_144286_) ? false : p_150816_.m_204336_(this.f_40979_); + return i < 1 && p_150816_.is(BlockTags.NEEDS_STONE_TOOL) ? false : p_150816_.is(this.blocks); } + } + + // FORGE START + @Override + public boolean isCorrectToolForDrops(ItemStack stack, BlockState state) { -+ return state.m_204336_(f_40979_) && net.minecraftforge.common.TierSortingRegistry.isCorrectTierForDrops(m_43314_(), state); ++ return state.is(blocks) && net.minecraftforge.common.TierSortingRegistry.isCorrectTierForDrops(getTier(), state); } } diff --git a/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch b/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch index d7b14847..b981952a 100644 --- a/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch @@ -6,9 +6,9 @@ -public interface DispensibleContainerItem { +public interface DispensibleContainerItem extends net.minecraftforge.common.extensions.IForgeDispensibleContainerItem { - default void m_142131_(@Nullable Player p_150817_, Level p_150818_, ItemStack p_150819_, BlockPos p_150820_) { + default void checkExtraContent(@Nullable Player p_150817_, Level p_150818_, ItemStack p_150819_, BlockPos p_150820_) { } + @Deprecated //Forge: use the ItemStack sensitive version - boolean m_142073_(@Nullable Player p_150821_, Level p_150822_, BlockPos p_150823_, @Nullable BlockHitResult p_150824_); + boolean emptyContents(@Nullable Player p_150821_, Level p_150822_, BlockPos p_150823_, @Nullable BlockHitResult p_150824_); } diff --git a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch index 9498e226..8e5902eb 100644 --- a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/DyeColor.java +++ b/net/minecraft/world/item/DyeColor.java @@ -39,6 +_,7 @@ - private final MaterialColor f_41036_; - private final float[] f_41039_; - private final int f_41040_; + private final MaterialColor color; + private final float[] textureDiffuseColors; + private final int fireworkColor; + private final net.minecraft.tags.TagKey tag; - private final int f_41041_; + private final int textColor; private DyeColor(int p_41046_, String p_41047_, int p_41048_, MaterialColor p_41049_, int p_41050_, int p_41051_) { @@ -49,6 +_,7 @@ @@ -13,13 +13,13 @@ int j = (p_41048_ & '\uff00') >> 8; int k = (p_41048_ & 255) >> 0; + this.tag = net.minecraft.tags.ItemTags.create(new net.minecraft.resources.ResourceLocation("forge", "dyes/" + p_41047_)); - this.f_41039_ = new float[]{(float)i / 255.0F, (float)j / 255.0F, (float)k / 255.0F}; - this.f_41040_ = p_41050_; + this.textureDiffuseColors = new float[]{(float)i / 255.0F, (float)j / 255.0F, (float)k / 255.0F}; + this.fireworkColor = p_41050_; } @@ -106,5 +_,22 @@ - public String m_7912_() { - return this.f_41035_; + public String getSerializedName() { + return this.name; + } + + public net.minecraft.tags.TagKey getTag() { @@ -28,11 +28,11 @@ + + @Nullable + public static DyeColor getColor(ItemStack stack) { -+ if (stack.m_41720_() instanceof DyeItem) -+ return ((DyeItem)stack.m_41720_()).m_41089_(); ++ if (stack.getItem() instanceof DyeItem) ++ return ((DyeItem)stack.getItem()).getDyeColor(); + -+ for (DyeColor color : f_41032_) { -+ if (stack.m_204117_(color.getTag())) ++ for (DyeColor color : BY_ID) { ++ if (stack.is(color.getTag())) + return color; + } + diff --git a/patches/minecraft/net/minecraft/world/item/DyeItem.java.patch b/patches/minecraft/net/minecraft/world/item/DyeItem.java.patch index 8c88fbb2..6e0c7efe 100644 --- a/patches/minecraft/net/minecraft/world/item/DyeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DyeItem.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/item/DyeItem.java +++ b/net/minecraft/world/item/DyeItem.java @@ -26,7 +_,17 @@ - if (sheep.m_6084_() && !sheep.m_29875_() && sheep.m_29874_() != this.f_41077_) { - sheep.f_19853_.m_6269_(p_41086_, sheep, SoundEvents.f_144133_, SoundSource.PLAYERS, 1.0F, 1.0F); - if (!p_41086_.f_19853_.f_46443_) { -- sheep.m_29855_(this.f_41077_); + if (sheep.isAlive() && !sheep.isSheared() && sheep.getColor() != this.dyeColor) { + sheep.level.playSound(p_41086_, sheep, SoundEvents.DYE_USE, SoundSource.PLAYERS, 1.0F, 1.0F); + if (!p_41086_.level.isClientSide) { +- sheep.setColor(this.dyeColor); + + // CraftBukkit start -+ byte bColor = (byte) this.f_41077_.m_41060_(); ++ byte bColor = (byte) this.dyeColor.getId(); + org.bukkit.event.entity.SheepDyeWoolEvent event = new org.bukkit.event.entity.SheepDyeWoolEvent((org.bukkit.entity.Sheep) sheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor), (org.bukkit.entity.Player) p_41086_.getBukkitEntity()); -+ sheep.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ sheep.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return InteractionResult.PASS; + } -+ sheep.m_29855_(DyeColor.m_41053_((byte) event.getColor().getWoolData())); ++ sheep.setColor(DyeColor.byId((byte) event.getColor().getWoolData())); + // CraftBukkit end + - p_41085_.m_41774_(1); + p_41085_.shrink(1); } diff --git a/patches/minecraft/net/minecraft/world/item/EggItem.java.patch b/patches/minecraft/net/minecraft/world/item/EggItem.java.patch index 9c8f01d1..08c344c4 100644 --- a/patches/minecraft/net/minecraft/world/item/EggItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/EggItem.java.patch @@ -2,25 +2,25 @@ +++ b/net/minecraft/world/item/EggItem.java @@ -16,13 +_,21 @@ - public InteractionResultHolder m_7203_(Level p_41128_, Player p_41129_, InteractionHand p_41130_) { - ItemStack itemstack = p_41129_.m_21120_(p_41130_); -- p_41128_.m_6263_((Player)null, p_41129_.m_20185_(), p_41129_.m_20186_(), p_41129_.m_20189_(), SoundEvents.f_11877_, SoundSource.PLAYERS, 0.5F, 0.4F / (p_41128_.m_5822_().nextFloat() * 0.4F + 0.8F)); - if (!p_41128_.f_46443_) { + public InteractionResultHolder use(Level p_41128_, Player p_41129_, InteractionHand p_41130_) { + ItemStack itemstack = p_41129_.getItemInHand(p_41130_); +- p_41128_.playSound((Player)null, p_41129_.getX(), p_41129_.getY(), p_41129_.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (p_41128_.getRandom().nextFloat() * 0.4F + 0.8F)); + if (!p_41128_.isClientSide) { ThrownEgg thrownegg = new ThrownEgg(p_41128_, p_41129_); - thrownegg.m_37446_(itemstack); - thrownegg.m_37251_(p_41129_, p_41129_.m_146909_(), p_41129_.m_146908_(), 0.0F, 1.5F, 1.0F); -- p_41128_.m_7967_(thrownegg); + thrownegg.setItem(itemstack); + thrownegg.shootFromRotation(p_41129_, p_41129_.getXRot(), p_41129_.getYRot(), 0.0F, 1.5F, 1.0F); +- p_41128_.addFreshEntity(thrownegg); + + // CraftBukkit start -+ if (!p_41128_.m_7967_(thrownegg)) { ++ if (!p_41128_.addFreshEntity(thrownegg)) { + if (p_41129_ instanceof net.minecraft.server.level.ServerPlayer) { + ((net.minecraft.server.level.ServerPlayer) p_41129_).getBukkitEntity().updateInventory(); + } -+ return InteractionResultHolder.m_19100_(itemstack); ++ return InteractionResultHolder.fail(itemstack); + } + // CraftBukkit end } -+ p_41128_.m_6263_((Player)null, p_41129_.m_20185_(), p_41129_.m_20186_(), p_41129_.m_20189_(), SoundEvents.f_11877_, SoundSource.PLAYERS, 0.5F, 0.4F / (p_41128_.m_5822_().nextFloat() * 0.4F + 0.8F)); ++ p_41128_.playSound((Player)null, p_41129_.getX(), p_41129_.getY(), p_41129_.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (p_41128_.getRandom().nextFloat() * 0.4F + 0.8F)); - p_41129_.m_36246_(Stats.f_12982_.m_12902_(this)); - if (!p_41129_.m_150110_().f_35937_) { + p_41129_.awardStat(Stats.ITEM_USED.get(this)); + if (!p_41129_.getAbilities().instabuild) { diff --git a/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch b/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch index cbe6a406..b6f465ab 100644 --- a/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch @@ -6,23 +6,23 @@ + @Override + public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) { -+ return ElytraItem.m_41140_(stack); ++ return ElytraItem.isFlyEnabled(stack); + } + + @Override + public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) { -+ if (!entity.f_19853_.f_46443_) { ++ if (!entity.level.isClientSide) { + int nextFlightTick = flightTicks + 1; + if (nextFlightTick % 10 == 0) { + if (nextFlightTick % 20 == 0) { -+ stack.m_41622_(1, entity, e -> e.m_21166_(net.minecraft.world.entity.EquipmentSlot.CHEST)); ++ stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(net.minecraft.world.entity.EquipmentSlot.CHEST)); + } -+ entity.m_146850_(net.minecraft.world.level.gameevent.GameEvent.f_157807_); ++ entity.gameEvent(net.minecraft.world.level.gameevent.GameEvent.ELYTRA_FREE_FALL); + } + } + return true; + } + @Nullable - public SoundEvent m_142602_() { - return SoundEvents.f_11674_; + public SoundEvent getEquipSound() { + return SoundEvents.ARMOR_EQUIP_ELYTRA; diff --git a/patches/minecraft/net/minecraft/world/item/EndCrystalItem.java.patch b/patches/minecraft/net/minecraft/world/item/EndCrystalItem.java.patch index 08be8a32..acdc408a 100644 --- a/patches/minecraft/net/minecraft/world/item/EndCrystalItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/EndCrystalItem.java.patch @@ -3,12 +3,12 @@ @@ -40,6 +_,11 @@ if (level instanceof ServerLevel) { EndCrystal endcrystal = new EndCrystal(level, d0 + 0.5D, d1, d2 + 0.5D); - endcrystal.m_31056_(false); + endcrystal.setShowBottom(false); + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPlaceEvent(p_41176_, endcrystal).isCancelled()) { + return InteractionResult.FAIL; + } + // CraftBukkit end - level.m_7967_(endcrystal); - level.m_142346_(p_41176_.m_43723_(), GameEvent.f_157810_, blockpos1); - EndDragonFight enddragonfight = ((ServerLevel)level).m_8586_(); + level.addFreshEntity(endcrystal); + level.gameEvent(p_41176_.getPlayer(), GameEvent.ENTITY_PLACE, blockpos1); + EndDragonFight enddragonfight = ((ServerLevel)level).dragonFight(); diff --git a/patches/minecraft/net/minecraft/world/item/EnderEyeItem.java.patch b/patches/minecraft/net/minecraft/world/item/EnderEyeItem.java.patch index 302dfc2d..9f04fd9e 100644 --- a/patches/minecraft/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/EnderEyeItem.java.patch @@ -3,24 +3,24 @@ @@ -54,6 +_,26 @@ } - level.m_6798_(1038, blockpos1.m_142082_(1, 0, 1), 0); + level.globalLevelEvent(1038, blockpos1.offset(1, 0, 1), 0); + + // CraftBukkit start - Use relative location for far away sounds + // world.b(1038, blockposition1.c(1, 0, 1), 0); + int viewDistance = level.getCraftServer().getViewDistance() * 16; -+ BlockPos soundPos = blockpos1.m_142082_(1, 0, 1); -+ for (ServerPlayer player : level.m_142572_().m_6846_().f_11196_) { -+ double deltaX = soundPos.m_123341_() - player.m_20185_(); -+ double deltaZ = soundPos.m_123343_() - player.m_20189_(); ++ BlockPos soundPos = blockpos1.offset(1, 0, 1); ++ for (ServerPlayer player : level.getServer().getPlayerList().players) { ++ double deltaX = soundPos.getX() - player.getX(); ++ double deltaZ = soundPos.getZ() - player.getZ(); + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; + if (level.spigotConfig.endPortalSoundRadius > 0 && distanceSquared > level.spigotConfig.endPortalSoundRadius * level.spigotConfig.endPortalSoundRadius) continue; // Spigot + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); -+ double relativeX = player.m_20185_() + (deltaX / deltaLength) * viewDistance; -+ double relativeZ = player.m_20189_() + (deltaZ / deltaLength) * viewDistance; -+ player.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, new BlockPos((int) relativeX, (int) soundPos.m_123342_(), (int) relativeZ), 0, true)); ++ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; ++ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, new BlockPos((int) relativeX, (int) soundPos.getY(), (int) relativeZ), 0, true)); + } else { -+ player.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, soundPos, 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, soundPos, 0, true)); + } + } + // CraftBukkit end @@ -28,17 +28,17 @@ return InteractionResult.CONSUME; @@ -77,7 +_,13 @@ - EyeOfEnder eyeofender = new EyeOfEnder(p_41184_, p_41185_.m_20185_(), p_41185_.m_20227_(0.5D), p_41185_.m_20189_()); - eyeofender.m_36972_(itemstack); - eyeofender.m_36967_(blockpos); -- p_41184_.m_7967_(eyeofender); + EyeOfEnder eyeofender = new EyeOfEnder(p_41184_, p_41185_.getX(), p_41185_.getY(0.5D), p_41185_.getZ()); + eyeofender.setItem(itemstack); + eyeofender.signalTo(blockpos); +- p_41184_.addFreshEntity(eyeofender); + + // CraftBukkit start -+ if (!p_41184_.m_7967_(eyeofender)) { ++ if (!p_41184_.addFreshEntity(eyeofender)) { + return new InteractionResultHolder(InteractionResult.FAIL, itemstack); + } + // CraftBukkit end + if (p_41185_ instanceof ServerPlayer) { - CriteriaTriggers.f_10579_.m_73935_((ServerPlayer)p_41185_, blockpos); + CriteriaTriggers.USED_ENDER_EYE.trigger((ServerPlayer)p_41185_, blockpos); } diff --git a/patches/minecraft/net/minecraft/world/item/EnderpearlItem.java.patch b/patches/minecraft/net/minecraft/world/item/EnderpearlItem.java.patch index 17399851..8bd906cf 100644 --- a/patches/minecraft/net/minecraft/world/item/EnderpearlItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/EnderpearlItem.java.patch @@ -2,27 +2,27 @@ +++ b/net/minecraft/world/item/EnderpearlItem.java @@ -16,14 +_,22 @@ - public InteractionResultHolder m_7203_(Level p_41190_, Player p_41191_, InteractionHand p_41192_) { - ItemStack itemstack = p_41191_.m_21120_(p_41192_); -- p_41190_.m_6263_((Player)null, p_41191_.m_20185_(), p_41191_.m_20186_(), p_41191_.m_20189_(), SoundEvents.f_11857_, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41190_.m_5822_().nextFloat() * 0.4F + 0.8F)); -- p_41191_.m_36335_().m_41524_(this, 20); + public InteractionResultHolder use(Level p_41190_, Player p_41191_, InteractionHand p_41192_) { + ItemStack itemstack = p_41191_.getItemInHand(p_41192_); +- p_41190_.playSound((Player)null, p_41191_.getX(), p_41191_.getY(), p_41191_.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41190_.getRandom().nextFloat() * 0.4F + 0.8F)); +- p_41191_.getCooldowns().addCooldown(this, 20); + // CraftBukkit start - change order - if (!p_41190_.f_46443_) { + if (!p_41190_.isClientSide) { ThrownEnderpearl thrownenderpearl = new ThrownEnderpearl(p_41190_, p_41191_); - thrownenderpearl.m_37446_(itemstack); - thrownenderpearl.m_37251_(p_41191_, p_41191_.m_146909_(), p_41191_.m_146908_(), 0.0F, 1.5F, 1.0F); -- p_41190_.m_7967_(thrownenderpearl); + thrownenderpearl.setItem(itemstack); + thrownenderpearl.shootFromRotation(p_41191_, p_41191_.getXRot(), p_41191_.getYRot(), 0.0F, 1.5F, 1.0F); +- p_41190_.addFreshEntity(thrownenderpearl); + -+ if (!p_41190_.m_7967_(thrownenderpearl)) { ++ if (!p_41190_.addFreshEntity(thrownenderpearl)) { + if (p_41191_ instanceof net.minecraft.server.level.ServerPlayer) { + ((net.minecraft.server.level.ServerPlayer) p_41191_).getBukkitEntity().updateInventory(); + } -+ return InteractionResultHolder.m_19100_(itemstack); ++ return InteractionResultHolder.fail(itemstack); + } } -+ p_41190_.m_6263_((Player)null, p_41191_.m_20185_(), p_41191_.m_20186_(), p_41191_.m_20189_(), SoundEvents.f_11857_, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41190_.m_5822_().nextFloat() * 0.4F + 0.8F)); -+ p_41191_.m_36335_().m_41524_(this, 20); ++ p_41190_.playSound((Player)null, p_41191_.getX(), p_41191_.getY(), p_41191_.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41190_.getRandom().nextFloat() * 0.4F + 0.8F)); ++ p_41191_.getCooldowns().addCooldown(this, 20); + // CraftBukkit end - p_41191_.m_36246_(Stats.f_12982_.m_12902_(this)); - if (!p_41191_.m_150110_().f_35937_) { + p_41191_.awardStat(Stats.ITEM_USED.get(this)); + if (!p_41191_.getAbilities().instabuild) { diff --git a/patches/minecraft/net/minecraft/world/item/FireChargeItem.java.patch b/patches/minecraft/net/minecraft/world/item/FireChargeItem.java.patch index 2f51ac7d..1394a848 100644 --- a/patches/minecraft/net/minecraft/world/item/FireChargeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/FireChargeItem.java.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/world/item/FireChargeItem.java +++ b/net/minecraft/world/item/FireChargeItem.java @@ -29,12 +_,28 @@ - if (!CampfireBlock.m_51321_(blockstate) && !CandleBlock.m_152845_(blockstate) && !CandleCakeBlock.m_152910_(blockstate)) { - blockpos = blockpos.m_142300_(p_41204_.m_43719_()); - if (BaseFireBlock.m_49255_(level, blockpos, p_41204_.m_8125_())) { + if (!CampfireBlock.canLight(blockstate) && !CandleBlock.canLight(blockstate) && !CandleCakeBlock.canLight(blockstate)) { + blockpos = blockpos.relative(p_41204_.getClickedFace()); + if (BaseFireBlock.canBePlacedAt(level, blockpos, p_41204_.getHorizontalDirection())) { + // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, p_41204_.m_43723_()).isCancelled()) { -+ if (!p_41204_.m_43723_().m_150110_().f_35937_) { -+ p_41204_.m_43722_().m_41774_(1); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, p_41204_.getPlayer()).isCancelled()) { ++ if (!p_41204_.getPlayer().getAbilities().instabuild) { ++ p_41204_.getItemInHand().shrink(1); + } + return InteractionResult.PASS; + } + // CraftBukkit end - this.m_41205_(level, blockpos); - level.m_46597_(blockpos, BaseFireBlock.m_49245_(level, blockpos)); - level.m_142346_(p_41204_.m_43723_(), GameEvent.f_157797_, blockpos); + this.playSound(level, blockpos); + level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(level, blockpos)); + level.gameEvent(p_41204_.getPlayer(), GameEvent.BLOCK_PLACE, blockpos); flag = true; } } else { + // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, p_41204_.m_43723_()).isCancelled()) { -+ if (!p_41204_.m_43723_().m_150110_().f_35937_) { -+ p_41204_.m_43722_().m_41774_(1); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, p_41204_.getPlayer()).isCancelled()) { ++ if (!p_41204_.getPlayer().getAbilities().instabuild) { ++ p_41204_.getItemInHand().shrink(1); + } + return InteractionResult.PASS; + } + // CraftBukkit end - this.m_41205_(level, blockpos); - level.m_46597_(blockpos, blockstate.m_61124_(BlockStateProperties.f_61443_, Boolean.valueOf(true))); - level.m_142346_(p_41204_.m_43723_(), GameEvent.f_157797_, blockpos); + this.playSound(level, blockpos); + level.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); + level.gameEvent(p_41204_.getPlayer(), GameEvent.BLOCK_PLACE, blockpos); diff --git a/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch b/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch index b095b5ea..63a4694c 100644 --- a/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/item/FishingRodItem.java +++ b/net/minecraft/world/item/FishingRodItem.java @@ -29,11 +_,21 @@ - p_41290_.m_6263_((Player)null, p_41291_.m_20185_(), p_41291_.m_20186_(), p_41291_.m_20189_(), SoundEvents.f_11939_, SoundSource.NEUTRAL, 1.0F, 0.4F / (p_41290_.m_5822_().nextFloat() * 0.4F + 0.8F)); - p_41290_.m_151545_(p_41291_, GameEvent.f_157814_, p_41291_); + p_41290_.playSound((Player)null, p_41291_.getX(), p_41291_.getY(), p_41291_.getZ(), SoundEvents.FISHING_BOBBER_RETRIEVE, SoundSource.NEUTRAL, 1.0F, 0.4F / (p_41290_.getRandom().nextFloat() * 0.4F + 0.8F)); + p_41290_.gameEvent(p_41291_, GameEvent.FISHING_ROD_REEL_IN, p_41291_); } else { -- p_41290_.m_6263_((Player)null, p_41291_.m_20185_(), p_41291_.m_20186_(), p_41291_.m_20189_(), SoundEvents.f_11941_, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41290_.m_5822_().nextFloat() * 0.4F + 0.8F)); - if (!p_41290_.f_46443_) { - int k = EnchantmentHelper.m_44916_(itemstack); - int j = EnchantmentHelper.m_44904_(itemstack); -- p_41290_.m_7967_(new FishingHook(p_41291_, p_41290_, j, k)); +- p_41290_.playSound((Player)null, p_41291_.getX(), p_41291_.getY(), p_41291_.getZ(), SoundEvents.FISHING_BOBBER_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41290_.getRandom().nextFloat() * 0.4F + 0.8F)); + if (!p_41290_.isClientSide) { + int k = EnchantmentHelper.getFishingSpeedBonus(itemstack); + int j = EnchantmentHelper.getFishingLuckBonus(itemstack); +- p_41290_.addFreshEntity(new FishingHook(p_41291_, p_41290_, j, k)); + + // CraftBukkit start + FishingHook entityfishinghook = new FishingHook(p_41291_, p_41290_, j, k); + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) p_41291_.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.FISHING); + p_41290_.getCraftServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { -+ p_41291_.f_36083_ = null; -+ return InteractionResultHolder.m_19098_(itemstack); ++ p_41291_.fishing = null; ++ return InteractionResultHolder.pass(itemstack); + } -+ p_41290_.m_6263_((Player)null, p_41291_.m_20185_(), p_41291_.m_20186_(), p_41291_.m_20189_(), SoundEvents.f_11941_, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41290_.m_5822_().nextFloat() * 0.4F + 0.8F)); -+ p_41290_.m_7967_(entityfishinghook); ++ p_41290_.playSound((Player)null, p_41291_.getX(), p_41291_.getY(), p_41291_.getZ(), SoundEvents.FISHING_BOBBER_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_41290_.getRandom().nextFloat() * 0.4F + 0.8F)); ++ p_41290_.addFreshEntity(entityfishinghook); + // CraftBukkit end } - p_41291_.m_36246_(Stats.f_12982_.m_12902_(this)); + p_41291_.awardStat(Stats.ITEM_USED.get(this)); diff --git a/patches/minecraft/net/minecraft/world/item/FlintAndSteelItem.java.patch b/patches/minecraft/net/minecraft/world/item/FlintAndSteelItem.java.patch index 26954504..77d24f0f 100644 --- a/patches/minecraft/net/minecraft/world/item/FlintAndSteelItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/FlintAndSteelItem.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/world/item/FlintAndSteelItem.java +++ b/net/minecraft/world/item/FlintAndSteelItem.java @@ -30,6 +_,14 @@ - if (!CampfireBlock.m_51321_(blockstate) && !CandleBlock.m_152845_(blockstate) && !CandleCakeBlock.m_152910_(blockstate)) { - BlockPos blockpos1 = blockpos.m_142300_(p_41297_.m_43719_()); - if (BaseFireBlock.m_49255_(level, blockpos1, p_41297_.m_8125_())) { + if (!CampfireBlock.canLight(blockstate) && !CandleBlock.canLight(blockstate) && !CandleCakeBlock.canLight(blockstate)) { + BlockPos blockpos1 = blockpos.relative(p_41297_.getClickedFace()); + if (BaseFireBlock.canBePlacedAt(level, blockpos1, p_41297_.getHorizontalDirection())) { + // CraftBukkit start - Store the clicked block + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, player).isCancelled()) { -+ p_41297_.m_43722_().m_41622_(1, player, (entityhuman1) -> { -+ entityhuman1.m_21190_(p_41297_.m_43724_()); ++ p_41297_.getItemInHand().hurtAndBreak(1, player, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(p_41297_.getHand()); + }); + return InteractionResult.PASS; + } + // CraftBukkit end - level.m_5594_(player, blockpos1, SoundEvents.f_11942_, SoundSource.BLOCKS, 1.0F, level.m_5822_().nextFloat() * 0.4F + 0.8F); - BlockState blockstate1 = BaseFireBlock.m_49245_(level, blockpos1); - level.m_7731_(blockpos1, blockstate1, 11); + level.playSound(player, blockpos1, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.4F + 0.8F); + BlockState blockstate1 = BaseFireBlock.getState(level, blockpos1); + level.setBlock(blockpos1, blockstate1, 11); @@ -47,6 +_,14 @@ return InteractionResult.FAIL; } } else { + // CraftBukkit start - Store the clicked block + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(level, blockpos, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, player).isCancelled()) { -+ p_41297_.m_43722_().m_41622_(1, player, (entityhuman1) -> { -+ entityhuman1.m_21190_(p_41297_.m_43724_()); ++ p_41297_.getItemInHand().hurtAndBreak(1, player, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(p_41297_.getHand()); + }); + return InteractionResult.PASS; + } + // CraftBukkit end - level.m_5594_(player, blockpos, SoundEvents.f_11942_, SoundSource.BLOCKS, 1.0F, level.m_5822_().nextFloat() * 0.4F + 0.8F); - level.m_7731_(blockpos, blockstate.m_61124_(BlockStateProperties.f_61443_, Boolean.valueOf(true)), 11); - level.m_142346_(player, GameEvent.f_157797_, blockpos); + level.playSound(player, blockpos, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.4F + 0.8F); + level.setBlock(blockpos, blockstate.setValue(BlockStateProperties.LIT, Boolean.valueOf(true)), 11); + level.gameEvent(player, GameEvent.BLOCK_PLACE, blockpos); diff --git a/patches/minecraft/net/minecraft/world/item/HangingEntityItem.java.patch b/patches/minecraft/net/minecraft/world/item/HangingEntityItem.java.patch index 219185c5..f00b6360 100644 --- a/patches/minecraft/net/minecraft/world/item/HangingEntityItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/HangingEntityItem.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/item/HangingEntityItem.java @@ -52,6 +_,16 @@ - if (hangingentity.m_7088_()) { - if (!level.f_46443_) { + if (hangingentity.survives()) { + if (!level.isClientSide) { + // CraftBukkit start - fire HangingPlaceEvent -+ org.bukkit.entity.Player who = (p_41331_.m_43723_() == null) ? null : (org.bukkit.entity.Player) p_41331_.m_43723_().getBukkitEntity(); -+ org.bukkit.block.Block blockClicked = level.getWorld().getBlockAt(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ org.bukkit.entity.Player who = (p_41331_.getPlayer() == null) ? null : (org.bukkit.entity.Player) p_41331_.getPlayer().getBukkitEntity(); ++ org.bukkit.block.Block blockClicked = level.getWorld().getBlockAt(blockpos.getX(), blockpos.getY(), blockpos.getZ()); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.notchToBlockFace(direction); + org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) ((HangingEntity) hangingentity).getBukkitEntity(), who, blockClicked, blockFace, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asBukkitCopy(itemstack)); + level.getCraftServer().getPluginManager().callEvent(event); @@ -14,6 +14,6 @@ + return InteractionResult.FAIL; + } + // CraftBukkit end - hangingentity.m_7084_(); - level.m_142346_(player, GameEvent.f_157810_, blockpos); - level.m_7967_(hangingentity); + hangingentity.playPlacementSound(); + level.gameEvent(player, GameEvent.ENTITY_PLACE, blockpos); + level.addFreshEntity(hangingentity); diff --git a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch index b245809e..55ce3afc 100644 --- a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch @@ -10,27 +10,27 @@ + * or override {@link net.minecraftforge.common.extensions.IForgeBlock#getToolModifiedState(BlockState, UseOnContext, net.minecraftforge.common.ToolAction, boolean)}. + */ + @Deprecated - protected static final Map, Consumer>> f_41332_ = Maps.newHashMap(ImmutableMap.of(Blocks.f_50440_, Pair.of(HoeItem::m_150856_, m_150858_(Blocks.f_50093_.m_49966_())), Blocks.f_152481_, Pair.of(HoeItem::m_150856_, m_150858_(Blocks.f_50093_.m_49966_())), Blocks.f_50493_, Pair.of(HoeItem::m_150856_, m_150858_(Blocks.f_50093_.m_49966_())), Blocks.f_50546_, Pair.of(HoeItem::m_150856_, m_150858_(Blocks.f_50493_.m_49966_())), Blocks.f_152549_, Pair.of((p_150861_) -> { + protected static final Map, Consumer>> TILLABLES = Maps.newHashMap(ImmutableMap.of(Blocks.GRASS_BLOCK, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.FARMLAND.defaultBlockState())), Blocks.DIRT_PATH, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.FARMLAND.defaultBlockState())), Blocks.DIRT, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.FARMLAND.defaultBlockState())), Blocks.COARSE_DIRT, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.DIRT.defaultBlockState())), Blocks.ROOTED_DIRT, Pair.of((p_150861_) -> { return true; - }, m_150849_(Blocks.f_50493_.m_49966_(), Items.f_151017_)))); + }, changeIntoStateAndDropItem(Blocks.DIRT.defaultBlockState(), Items.HANGING_ROOTS)))); @@ -30,9 +_,12 @@ } - public InteractionResult m_6225_(UseOnContext p_41341_) { + public InteractionResult useOn(UseOnContext p_41341_) { + int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(p_41341_); + if (hook != 0) return hook > 0 ? InteractionResult.SUCCESS : InteractionResult.FAIL; - Level level = p_41341_.m_43725_(); - BlockPos blockpos = p_41341_.m_8083_(); -- Pair, Consumer> pair = f_41332_.get(level.m_8055_(blockpos).m_60734_()); -+ BlockState toolModifiedState = level.m_8055_(blockpos).getToolModifiedState(p_41341_, net.minecraftforge.common.ToolActions.HOE_TILL, false); -+ Pair, Consumer> pair = toolModifiedState == null ? null : Pair.of(ctx -> true, m_150858_(toolModifiedState)); + Level level = p_41341_.getLevel(); + BlockPos blockpos = p_41341_.getClickedPos(); +- Pair, Consumer> pair = TILLABLES.get(level.getBlockState(blockpos).getBlock()); ++ BlockState toolModifiedState = level.getBlockState(blockpos).getToolModifiedState(p_41341_, net.minecraftforge.common.ToolActions.HOE_TILL, false); ++ Pair, Consumer> pair = toolModifiedState == null ? null : Pair.of(ctx -> true, changeIntoState(toolModifiedState)); if (pair == null) { return InteractionResult.PASS; } else { @@ -72,5 +_,10 @@ - public static boolean m_150856_(UseOnContext p_150857_) { - return p_150857_.m_43719_() != Direction.DOWN && p_150857_.m_43725_().m_8055_(p_150857_.m_8083_().m_7494_()).m_60795_(); + public static boolean onlyIfAirAbove(UseOnContext p_150857_) { + return p_150857_.getClickedFace() != Direction.DOWN && p_150857_.getLevel().getBlockState(p_150857_.getClickedPos().above()).isAir(); + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch index 2000648a..bbc4c5d8 100644 --- a/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/HorseArmorItem.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/item/HorseArmorItem.java @@ -5,16 +_,20 @@ public class HorseArmorItem extends Item { - private static final String f_150882_ = "textures/entity/horse/"; - private final int f_41361_; -- private final String f_41362_; -+ private final ResourceLocation f_41362_; + private static final String TEX_FOLDER = "textures/entity/horse/"; + private final int protection; +- private final String texture; ++ private final ResourceLocation texture; public HorseArmorItem(int p_41364_, String p_41365_, Item.Properties p_41366_) { + this(p_41364_, new ResourceLocation("textures/entity/horse/armor/horse_armor_" + p_41365_ + ".png"), p_41366_); @@ -13,14 +13,14 @@ + + public HorseArmorItem(int p_41364_, ResourceLocation p_41365_, Item.Properties p_41366_) { super(p_41366_); - this.f_41361_ = p_41364_; -- this.f_41362_ = "textures/entity/horse/armor/horse_armor_" + p_41365_ + ".png"; -+ this.f_41362_ = p_41365_; + this.protection = p_41364_; +- this.texture = "textures/entity/horse/armor/horse_armor_" + p_41365_ + ".png"; ++ this.texture = p_41365_; } - public ResourceLocation m_41367_() { -- return new ResourceLocation(this.f_41362_); -+ return f_41362_; + public ResourceLocation getTexture() { +- return new ResourceLocation(this.texture); ++ return texture; } - public int m_41368_() { + public int getProtection() { diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index a3df9e66..047e6a63 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -6,14 +6,14 @@ -public class Item implements ItemLike { +public class Item extends net.minecraftforge.registries.ForgeRegistryEntry implements ItemLike, net.minecraftforge.common.extensions.IForgeItem { - private static final Logger f_150883_ = LogUtils.getLogger(); -- public static final Map f_41373_ = Maps.newHashMap(); -+ public static final Map f_41373_ = net.minecraftforge.registries.GameData.getBlockItemMap(); - protected static final UUID f_41374_ = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - protected static final UUID f_41375_ = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); - public static final int f_150884_ = 64; + private static final Logger LOGGER = LogUtils.getLogger(); +- public static final Map BY_BLOCK = Maps.newHashMap(); ++ public static final Map BY_BLOCK = net.minecraftforge.registries.GameData.getBlockItemMap(); + protected static final UUID BASE_ATTACK_DAMAGE_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); + protected static final UUID BASE_ATTACK_SPEED_UUID = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); + public static final int MAX_STACK_SIZE = 64; @@ -97,7 +_,8 @@ - f_150883_.error("Item classes should end with Item and {} doesn't.", (Object)s); + LOGGER.error("Item classes should end with Item and {} doesn't.", (Object)s); } } - @@ -23,53 +23,53 @@ /** @deprecated */ @@ -106,6 +_,8 @@ - return this.f_204113_; + return this.builtInRegistryHolder; } + /** @deprecated Forge: Use damage source sensitive version */ + @Deprecated - public void m_5929_(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { + public void onUseTick(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { } @@ -132,9 +_,9 @@ } - public InteractionResultHolder m_7203_(Level p_41432_, Player p_41433_, InteractionHand p_41434_) { -- if (this.m_41472_()) { -- ItemStack itemstack = p_41433_.m_21120_(p_41434_); -- if (p_41433_.m_36391_(this.m_41473_().m_38747_())) { -+ ItemStack itemstack = p_41433_.m_21120_(p_41434_); -+ if (itemstack.m_41614_()) { -+ if (p_41433_.m_36391_(itemstack.getFoodProperties(p_41433_).m_38747_())) { - p_41433_.m_6672_(p_41434_); - return InteractionResultHolder.m_19096_(itemstack); + public InteractionResultHolder use(Level p_41432_, Player p_41433_, InteractionHand p_41434_) { +- if (this.isEdible()) { +- ItemStack itemstack = p_41433_.getItemInHand(p_41434_); +- if (p_41433_.canEat(this.getFoodProperties().canAlwaysEat())) { ++ ItemStack itemstack = p_41433_.getItemInHand(p_41434_); ++ if (itemstack.isEdible()) { ++ if (p_41433_.canEat(itemstack.getFoodProperties(p_41433_).canAlwaysEat())) { + p_41433_.startUsingItem(p_41434_); + return InteractionResultHolder.consume(itemstack); } else { @@ -149,10 +_,12 @@ - return this.m_41472_() ? p_41411_.m_5584_(p_41410_, p_41409_) : p_41409_; + return this.isEdible() ? p_41411_.eat(p_41410_, p_41409_) : p_41409_; } + @Deprecated // Use ItemStack sensitive version. - public final int m_41459_() { - return this.f_41370_; + public final int getMaxStackSize() { + return this.maxStackSize; } + @Deprecated // Use ItemStack sensitive version. - public final int m_41462_() { - return this.f_41371_; + public final int getMaxDamage() { + return this.maxDamage; } @@ -166,11 +_,12 @@ } - public int m_142158_(ItemStack p_150900_) { -- return Math.round(13.0F - (float)p_150900_.m_41773_() * 13.0F / (float)this.f_41371_); -+ return Math.round(13.0F - (float)p_150900_.m_41773_() * 13.0F / (float)this.getMaxDamage(p_150900_)); + public int getBarWidth(ItemStack p_150900_) { +- return Math.round(13.0F - (float)p_150900_.getDamageValue() * 13.0F / (float)this.maxDamage); ++ return Math.round(13.0F - (float)p_150900_.getDamageValue() * 13.0F / (float)this.getMaxDamage(p_150900_)); } - public int m_142159_(ItemStack p_150901_) { -- float f = Math.max(0.0F, ((float)this.f_41371_ - (float)p_150901_.m_41773_()) / (float)this.f_41371_); + public int getBarColor(ItemStack p_150901_) { +- float f = Math.max(0.0F, ((float)this.maxDamage - (float)p_150901_.getDamageValue()) / (float)this.maxDamage); + float stackMaxDamage = this.getMaxDamage(p_150901_); -+ float f = Math.max(0.0F, (stackMaxDamage - (float)p_150901_.m_41773_()) / stackMaxDamage); - return Mth.m_14169_(f / 3.0F, 1.0F, 1.0F); ++ float f = Math.max(0.0F, (stackMaxDamage - (float)p_150901_.getDamageValue()) / stackMaxDamage); + return Mth.hsvToRgb(f / 3.0F, 1.0F, 1.0F); } @@ -227,10 +_,12 @@ @@ -77,57 +77,57 @@ @Nullable + @Deprecated // Use ItemStack sensitive version. - public final Item m_41469_() { - return this.f_41378_; + public final Item getCraftingRemainingItem() { + return this.craftingRemainingItem; } + @Deprecated // Use ItemStack sensitive version. - public boolean m_41470_() { - return this.f_41378_ != null; + public boolean hasCraftingRemainingItem() { + return this.craftingRemainingItem != null; } @@ -251,7 +_,7 @@ - public int m_8105_(ItemStack p_41454_) { - if (p_41454_.m_41720_().m_41472_()) { -- return this.m_41473_().m_38748_() ? 16 : 32; -+ return p_41454_.getFoodProperties(null).m_38748_() ? 16 : 32; + public int getUseDuration(ItemStack p_41454_) { + if (p_41454_.getItem().isEdible()) { +- return this.getFoodProperties().isFastFood() ? 16 : 32; ++ return p_41454_.getFoodProperties(null).isFastFood() ? 16 : 32; } else { return 0; } @@ -293,7 +_,7 @@ } - public boolean m_8120_(ItemStack p_41456_) { -- return this.m_41459_() == 1 && this.m_41465_(); + public boolean isEnchantable(ItemStack p_41456_) { +- return this.getMaxStackSize() == 1 && this.canBeDepleted(); + return this.getItemStackLimit(p_41456_) == 1 && this.isDamageable(p_41456_); } - protected static BlockHitResult m_41435_(Level p_41436_, Player p_41437_, ClipContext.Fluid p_41438_) { + protected static BlockHitResult getPlayerPOVHitResult(Level p_41436_, Player p_41437_, ClipContext.Fluid p_41438_) { @@ -306,8 +_,8 @@ - float f5 = Mth.m_14031_(-f * ((float)Math.PI / 180F)); + float f5 = Mth.sin(-f * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; - double d0 = 5.0D; -- Vec3 vec31 = vec3.m_82520_((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D); -+ double d0 = p_41437_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_();; -+ Vec3 vec31 = vec3.m_82520_((double)f6 * d0, (double)f5 * d0, (double)f7 * d0); - return p_41436_.m_45547_(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); +- Vec3 vec31 = vec3.add((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D); ++ double d0 = p_41437_.getAttribute(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).getValue();; ++ Vec3 vec31 = vec3.add((double)f6 * d0, (double)f5 * d0, (double)f7 * d0); + return p_41436_.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); } @@ -323,6 +_,7 @@ } - protected boolean m_41389_(CreativeModeTab p_41390_) { + protected boolean allowdedIn(CreativeModeTab p_41390_) { + if (getCreativeTabs().stream().anyMatch(tab -> tab == p_41390_)) return true; - CreativeModeTab creativemodetab = this.m_41471_(); - return creativemodetab != null && (p_41390_ == CreativeModeTab.f_40754_ || p_41390_ == creativemodetab); + CreativeModeTab creativemodetab = this.getItemCategory(); + return creativemodetab != null && (p_41390_ == CreativeModeTab.TAB_SEARCH || p_41390_ == creativemodetab); } @@ -336,12 +_,20 @@ return false; } + @Deprecated // Use ItemStack sensitive version. - public Multimap m_7167_(EquipmentSlot p_41388_) { + public Multimap getDefaultAttributeModifiers(EquipmentSlot p_41388_) { return ImmutableMultimap.of(); } @@ -138,21 +138,21 @@ + return canRepair && isDamageable(stack); + } + - public boolean m_41463_(ItemStack p_41464_) { + public boolean useOnRelease(ItemStack p_41464_) { - return false; -+ return p_41464_.m_41720_() == Items.f_42717_; ++ return p_41464_.getItem() == Items.CROSSBOW; } - public ItemStack m_7968_() { + public ItemStack getDefaultInstance() { @@ -352,6 +_,8 @@ - return this.f_41380_ != null; + return this.foodProperties != null; } + // Use IForgeItem#getFoodProperties(ItemStack, LivingEntity) in favour of this. + @Deprecated @Nullable - public FoodProperties m_41473_() { - return this.f_41380_; + public FoodProperties getFoodProperties() { + return this.foodProperties; @@ -382,6 +_,32 @@ return true; } @@ -184,20 +184,20 @@ + // END FORGE + public static class Properties { - int f_41478_ = 64; - int f_41479_; + int maxStackSize = 64; + int maxDamage; @@ -393,6 +_,7 @@ @Nullable - FoodProperties f_41483_; - boolean f_41484_; + FoodProperties foodProperties; + boolean isFireResistant; + private boolean canRepair = true; - public Item.Properties m_41489_(FoodProperties p_41490_) { - this.f_41483_ = p_41490_; + public Item.Properties food(FoodProperties p_41490_) { + this.foodProperties = p_41490_; @@ -435,6 +_,11 @@ - public Item.Properties m_41486_() { - this.f_41484_ = true; + public Item.Properties fireResistant() { + this.isFireResistant = true; + return this; + } + diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 66fca620..a07f5357 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -7,30 +7,30 @@ -public final class ItemStack { + +public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeItemStack { - public static final Codec f_41582_ = RecordCodecBuilder.create((p_41697_) -> { - return p_41697_.group(Registry.f_122827_.m_194605_().fieldOf("id").forGetter((p_150946_) -> { - return p_150946_.f_41589_; + public static final Codec CODEC = RecordCodecBuilder.create((p_41697_) -> { + return p_41697_.group(Registry.ITEM.byNameCodec().fieldOf("id").forGetter((p_150946_) -> { + return p_150946_.item; @@ -82,6 +_,9 @@ - return Optional.ofNullable(p_150939_.f_41590_); + return Optional.ofNullable(p_150939_.tag); })).apply(p_41697_, ItemStack::new); }); + private net.minecraftforge.registries.IRegistryDelegate delegate; + private CompoundTag capNBT; + - private static final Logger f_41585_ = LogUtils.getLogger(); - public static final ItemStack f_41583_ = new ItemStack((Item)null); - public static final DecimalFormat f_41584_ = Util.m_137469_(new DecimalFormat("#.##"), (p_41704_) -> { + private static final Logger LOGGER = LogUtils.getLogger(); + public static final ItemStack EMPTY = new ItemStack((Item)null); + public static final DecimalFormat ATTRIBUTE_MODIFIER_FORMAT = Util.make(new DecimalFormat("#.##"), (p_41704_) -> { @@ -104,7 +_,7 @@ - private int f_41588_; + private int popTime; /** @deprecated */ @Deprecated -- private final Item f_41589_; -+ private Item f_41589_; +- private final Item item; ++ private Item item; @Nullable - private CompoundTag f_41590_; - private boolean f_41591_; + private CompoundTag tag; + private boolean emptyCacheFlag; @@ -119,6 +_,18 @@ - return this.m_41720_().m_142422_(this); + return this.getItem().getTooltipImage(this); } + //Magma start - forge caps @@ -49,148 +49,148 @@ this(p_41599_, 1); } @@ -132,14 +_,29 @@ - p_41606_.ifPresent(this::m_41751_); + p_41606_.ifPresent(this::setTag); } - public ItemStack(ItemLike p_41601_, int p_41602_) { -- this.f_41589_ = p_41601_ == null ? null : p_41601_.m_5456_(); -- this.f_41587_ = p_41602_; -- if (this.f_41589_ != null && this.f_41589_.m_41465_()) { +- this.item = p_41601_ == null ? null : p_41601_.asItem(); +- this.count = p_41602_; +- if (this.item != null && this.item.canBeDepleted()) { + public ItemStack(ItemLike p_41601_, int p_41602_) { this(p_41601_, p_41602_, (CompoundTag) null); } + public ItemStack(ItemLike p_41604_, int p_41605_, @Nullable CompoundTag p_41606_) { + super(ItemStack.class, true); + this.capNBT = p_41606_; -+ this.f_41589_ = p_41604_ == null ? null : p_41604_.m_5456_(); -+ this.delegate = p_41604_ == null ? null : p_41604_.m_5456_().delegate; -+ this.f_41587_ = p_41605_; ++ this.item = p_41604_ == null ? null : p_41604_.asItem(); ++ this.delegate = p_41604_ == null ? null : p_41604_.asItem().delegate; ++ this.count = p_41605_; + this.forgeInit(); -+ if (this.f_41589_ != null && this.f_41589_.isDamageable(this)) { - this.m_41721_(this.m_41773_()); ++ if (this.item != null && this.item.isDamageable(this)) { + this.setDamageValue(this.getDamageValue()); } - this.m_41617_(); + this.updateEmptyCacheFlag(); + } + + // Called to run this stack through the data converter to handle older storage methods and serialized items + public void convertStack(int version) { + if (0 < version && version < org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.INSTANCE.getDataVersion()) { + CompoundTag savedStack = new CompoundTag(); -+ this.m_41739_(savedStack); -+ savedStack = (CompoundTag) net.minecraft.server.MinecraftServer.getServer().f_129759_.update(net.minecraft.util.datafix.fixes.References.f_16782_, new com.mojang.serialization.Dynamic<>(net.minecraft.nbt.NbtOps.f_128958_, savedStack), version, org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); ++ this.save(savedStack); ++ savedStack = (CompoundTag) net.minecraft.server.MinecraftServer.getServer().fixerUpper.update(net.minecraft.util.datafix.fixes.References.ITEM_STACK, new com.mojang.serialization.Dynamic<>(net.minecraft.nbt.NbtOps.INSTANCE, savedStack), version, org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); + this.load(savedStack); + } } - private void m_41617_() { + private void updateEmptyCacheFlag() { @@ -147,18 +_,47 @@ - this.f_41591_ = this.m_41619_(); + this.emptyCacheFlag = this.isEmpty(); } + // CraftBukkit - break into own method + private void load(CompoundTag p_41608_) { -+ this.capNBT = p_41608_.m_128441_("ForgeCaps") ? p_41608_.m_128469_("ForgeCaps") : null; ++ this.capNBT = p_41608_.contains("ForgeCaps") ? p_41608_.getCompound("ForgeCaps") : null; + Item rawItem = -+ this.f_41589_ = Registry.f_122827_.m_7745_(new ResourceLocation(p_41608_.m_128461_("id"))); ++ this.item = Registry.ITEM.get(new ResourceLocation(p_41608_.getString("id"))); + this.delegate = rawItem.delegate; -+ this.f_41587_ = p_41608_.m_128445_("Count"); -+ if (p_41608_.m_128425_("tag", 10)) { ++ this.count = p_41608_.getByte("Count"); ++ if (p_41608_.contains("tag", 10)) { + // CraftBukkit start - make defensive copy as this data may be coming from the save thread -+ this.f_41590_ = p_41608_.m_128469_("tag").m_6426_(); ++ this.tag = p_41608_.getCompound("tag").copy(); + // CraftBukkit end -+ this.m_41720_().m_142312_(this.f_41590_); ++ this.getItem().verifyTagAfterLoad(this.tag); + } + this.forgeInit(); + -+ if (this.m_41720_().isDamageable(this)) { -+ this.m_41721_(this.m_41773_()); ++ if (this.getItem().isDamageable(this)) { ++ this.setDamageValue(this.getDamageValue()); + } + } + private ItemStack(CompoundTag p_41608_) { -- this.f_41589_ = Registry.f_122827_.m_7745_(new ResourceLocation(p_41608_.m_128461_("id"))); +- this.item = Registry.ITEM.get(new ResourceLocation(p_41608_.getString("id"))); + super(ItemStack.class, true); + //Magma start - create copy of load method to prevent mixin inject failure -+ this.capNBT = p_41608_.m_128441_("ForgeCaps") ? p_41608_.m_128469_("ForgeCaps") : null; ++ this.capNBT = p_41608_.contains("ForgeCaps") ? p_41608_.getCompound("ForgeCaps") : null; + Item rawItem = -+ this.f_41589_ = Registry.f_122827_.m_7745_(new ResourceLocation(p_41608_.m_128461_("id"))); ++ this.item = Registry.ITEM.get(new ResourceLocation(p_41608_.getString("id"))); + this.delegate = rawItem.delegate; - this.f_41587_ = p_41608_.m_128445_("Count"); - if (p_41608_.m_128425_("tag", 10)) { -- this.f_41590_ = p_41608_.m_128469_("tag"); + this.count = p_41608_.getByte("Count"); + if (p_41608_.contains("tag", 10)) { +- this.tag = p_41608_.getCompound("tag"); + // CraftBukkit start - make defensive copy as this data may be coming from the save thread -+ this.f_41590_ = p_41608_.m_128469_("tag").m_6426_(); ++ this.tag = p_41608_.getCompound("tag").copy(); + // CraftBukkit end - this.m_41720_().m_142312_(this.f_41590_); + this.getItem().verifyTagAfterLoad(this.tag); } + this.forgeInit(); -- if (this.m_41720_().m_41465_()) { -+ if (this.m_41720_().isDamageable(this)) { - this.m_41721_(this.m_41773_()); +- if (this.getItem().canBeDepleted()) { ++ if (this.getItem().isDamageable(this)) { + this.setDamageValue(this.getDamageValue()); } - + //Magma end + // CraftBukkit end - this.m_41617_(); + this.updateEmptyCacheFlag(); } @@ -190,7 +_,7 @@ } - public Item m_41720_() { -- return this.f_41591_ ? Items.f_41852_ : this.f_41589_; -+ return this.f_41591_ || this.delegate == null ? Items.f_41852_ : this.delegate.get(); + public Item getItem() { +- return this.emptyCacheFlag ? Items.AIR : this.item; ++ return this.emptyCacheFlag || this.delegate == null ? Items.AIR : this.delegate.get(); } - public boolean m_204117_(TagKey p_204118_) { + public boolean is(TagKey p_204118_) { @@ -206,17 +_,157 @@ } - public InteractionResult m_41661_(UseOnContext p_41662_) { -+ if (!p_41662_.m_43725_().f_46443_) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(p_41662_); -+ return onItemUse(p_41662_, (c) -> m_41720_().m_6225_(p_41662_), p_41662_.m_43724_()); // CraftBukkit - take hand + public InteractionResult useOn(UseOnContext p_41662_) { ++ if (!p_41662_.getLevel().isClientSide) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(p_41662_); ++ return onItemUse(p_41662_, (c) -> getItem().useOn(p_41662_), p_41662_.getHand()); // CraftBukkit - take hand + } + + public InteractionResult onItemUseFirst(UseOnContext p_41662_) { -+ return onItemUse(p_41662_, (c) -> m_41720_().onItemUseFirst(this, p_41662_), p_41662_.m_43724_()); // CraftBukkit - take hand ++ return onItemUse(p_41662_, (c) -> getItem().onItemUseFirst(this, p_41662_), p_41662_.getHand()); // CraftBukkit - take hand + } + + public InteractionResult onItemUse(UseOnContext p_41662_, java.util.function.Function callback, InteractionHand hand) { // CraftBukkit - add hand - Player player = p_41662_.m_43723_(); - BlockPos blockpos = p_41662_.m_8083_(); - BlockInWorld blockinworld = new BlockInWorld(p_41662_.m_43725_(), blockpos, false); - if (player != null && !player.m_150110_().f_35938_ && !this.m_204121_(p_41662_.m_43725_().m_5962_().m_175515_(Registry.f_122901_), blockinworld)) { + Player player = p_41662_.getPlayer(); + BlockPos blockpos = p_41662_.getClickedPos(); + BlockInWorld blockinworld = new BlockInWorld(p_41662_.getLevel(), blockpos, false); + if (player != null && !player.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(p_41662_.getLevel().registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY), blockinworld)) { return InteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here + CompoundTag oldData = this.getTagClone(); -+ int oldCount = this.m_41613_(); -+ net.minecraft.server.level.ServerLevel world = (net.minecraft.server.level.ServerLevel) p_41662_.m_43725_(); -+ if (!(this.m_41720_() instanceof BucketItem || this.m_41720_() instanceof SolidBucketItem)) { // if not bucket ++ int oldCount = this.getCount(); ++ net.minecraft.server.level.ServerLevel world = (net.minecraft.server.level.ServerLevel) p_41662_.getLevel(); ++ if (!(this.getItem() instanceof BucketItem || this.getItem() instanceof SolidBucketItem)) { // if not bucket + world.captureBlockStates = true; + // special case bonemeal -+ if (this.m_41720_() == Items.f_42499_) { ++ if (this.getItem() == Items.BONE_MEAL) { + world.captureTreeGeneration = true; + } + } - Item item = this.m_41720_(); -- InteractionResult interactionresult = item.m_6225_(p_41662_); + Item item = this.getItem(); +- InteractionResult interactionresult = item.useOn(p_41662_); + InteractionResult interactionresult = callback.apply(p_41662_); + CompoundTag newData = this.getTagClone(); -+ int newCount = this.m_41613_(); -+ this.m_41764_(interactionresult == InteractionResult.PASS && newCount != oldCount ? newCount : oldCount); //Magma - special case for mods that return PASS but do change the count ++ int newCount = this.getCount(); ++ this.setCount(interactionresult == InteractionResult.PASS && newCount != oldCount ? newCount : oldCount); //Magma - special case for mods that return PASS but do change the count + this.setTagClone(oldData); + world.captureBlockStates = false; -+ if (interactionresult.m_19077_() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { ++ if (interactionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { + world.captureTreeGeneration = false; -+ org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockpos.getX(), blockpos.getY(), blockpos.getZ()); + org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; + net.minecraft.world.level.block.SaplingBlock.treeType = null; + List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); + world.capturedBlockStates.clear(); + org.bukkit.event.world.StructureGrowEvent structureEvent = null; + if (treeType != null) { -+ boolean isBonemeal = m_41720_() == Items.f_42499_; ++ boolean isBonemeal = getItem() == Items.BONE_MEAL; + structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, isBonemeal, (org.bukkit.entity.Player) player.getBukkitEntity(), blocks); + org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); + } @@ -199,9 +199,9 @@ + org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); + if (!fertilizeEvent.isCancelled()) { + // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.m_41613_() == oldCount && java.util.Objects.equals(this.f_41590_, oldData)) { -+ this.m_41751_(newData); -+ this.m_41764_(newCount); ++ if (this.getCount() == oldCount && java.util.Objects.equals(this.tag, oldData)) { ++ this.setTag(newData); ++ this.setCount(newCount); + } + for (org.bukkit.block.BlockState blockstate : blocks) { + blockstate.update(true); @@ -211,14 +211,14 @@ + return interactionresult; + } + world.captureTreeGeneration = false; - if (player != null && interactionresult.m_146666_()) { + if (player != null && interactionresult.shouldAwardStats()) { + org.bukkit.event.block.BlockPlaceEvent placeEvent = null; + List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); + world.capturedBlockStates.clear(); + if (blocks.size() > 1) { -+ placeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockMultiPlaceEvent(world, player, hand, blocks, blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ placeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockMultiPlaceEvent(world, player, hand, blocks, blockpos.getX(), blockpos.getY(), blockpos.getZ()); + } else if (blocks.size() == 1) { -+ placeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockPlaceEvent(world, player, hand, blocks.get(0), blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ placeEvent = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockPlaceEvent(world, player, hand, blocks.get(0), blockpos.getX(), blockpos.getY(), blockpos.getZ()); + } + if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { + interactionresult = InteractionResult.FAIL; // cancel placement @@ -233,68 +233,68 @@ + // Brute force all possible updates + BlockPos placedPos = ((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) placeEvent.getBlock()).getPosition(); + for (net.minecraft.core.Direction dir : net.minecraft.core.Direction.values()) { -+ ((ServerPlayer) player).f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(world, placedPos.m_142300_(dir))); ++ ((ServerPlayer) player).connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(world, placedPos.relative(dir))); + } + SignItem.openSign = null; // SPIGOT-6758 - Reset on early return + } else { + // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.m_41613_() == oldCount && java.util.Objects.equals(this.f_41590_, oldData)) { -+ this.m_41751_(newData); -+ this.m_41764_(newCount); ++ if (this.getCount() == oldCount && java.util.Objects.equals(this.tag, oldData)) { ++ this.setTag(newData); ++ this.setCount(newCount); + } + for (java.util.Map.Entry e : world.capturedTileEntities.entrySet()) { -+ world.m_151523_(e.getValue()); ++ world.setBlockEntity(e.getValue()); + } + for (org.bukkit.block.BlockState blockstate : blocks) { + int updateFlag = ((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState) blockstate).getFlag(); + BlockState oldBlock = ((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState) blockstate).getHandle(); + BlockPos newblockposition = ((org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState) blockstate).getPosition(); -+ BlockState block = world.m_8055_(newblockposition); -+ if (!(block.m_60734_() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically -+ block.m_60734_().m_6807_(block, world, newblockposition, oldBlock, true); ++ BlockState block = world.getBlockState(newblockposition); ++ if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically ++ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true); + } -+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.m_8055_(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point ++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point + } + // Special case juke boxes as they update their tile entity. Copied from ItemRecord. + // PAIL: checkme on updates. + if (item instanceof RecordItem) { -+ ((net.minecraft.world.level.block.JukeboxBlock) net.minecraft.world.level.block.Blocks.f_50131_).m_54269_(world, blockpos, world.m_8055_(blockpos), this); -+ world.m_5898_((Player) null, 1010, blockpos, Item.m_41393_(this.f_41589_)); -+ this.m_41774_(1); ++ ((net.minecraft.world.level.block.JukeboxBlock) net.minecraft.world.level.block.Blocks.JUKEBOX).setRecord(world, blockpos, world.getBlockState(blockpos), this); ++ world.levelEvent((Player) null, 1010, blockpos, Item.getId(this.item)); ++ this.shrink(1); + //player.awardStat(Stats.PLAY_RECORD); //Magma - moved back to RecordItem + } -+ if (item == Items.f_42679_) { // Special case skulls to allow wither spawns to be cancelled ++ if (item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled + BlockPos bp = blockpos; -+ if (!world.m_8055_(blockpos).m_60767_().m_76336_()) { -+ if (!world.m_8055_(blockpos).m_60767_().m_76333_()) { ++ if (!world.getBlockState(blockpos).getMaterial().isReplaceable()) { ++ if (!world.getBlockState(blockpos).getMaterial().isSolid()) { + bp = null; + } else { -+ bp = bp.m_142300_(p_41662_.m_43719_()); ++ bp = bp.relative(p_41662_.getClickedFace()); + } + } + if (bp != null) { -+ net.minecraft.world.level.block.entity.BlockEntity te = world.m_7702_(bp); ++ net.minecraft.world.level.block.entity.BlockEntity te = world.getBlockEntity(bp); + if (te instanceof net.minecraft.world.level.block.entity.SkullBlockEntity) { -+ net.minecraft.world.level.block.WitherSkullBlock.m_58255_(world, bp, (net.minecraft.world.level.block.entity.SkullBlockEntity) te); ++ net.minecraft.world.level.block.WitherSkullBlock.checkSpawn(world, bp, (net.minecraft.world.level.block.entity.SkullBlockEntity) te); + } + } + } + // SPIGOT-4678 + if (item instanceof SignItem && SignItem.openSign != null) { + try { -+ player.m_7739_((net.minecraft.world.level.block.entity.SignBlockEntity) world.m_7702_(SignItem.openSign)); ++ player.openTextEdit((net.minecraft.world.level.block.entity.SignBlockEntity) world.getBlockEntity(SignItem.openSign)); + } finally { + SignItem.openSign = null; + } + } + // SPIGOT-1288 - play sound stripped from ItemBlock + if (item instanceof BlockItem blockItem) { -+ net.minecraft.world.level.block.SoundType soundeffecttype = blockItem.m_40614_().m_49962_(blockinworld.m_61168_()); //Magma - pass block state instead of null -+ world.m_5594_(player, blockpos, soundeffecttype.m_56777_(), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.m_56773_() + 1.0F) / 2.0F, soundeffecttype.m_56774_() * 0.8F); ++ net.minecraft.world.level.block.SoundType soundeffecttype = blockItem.getBlock().getSoundType(blockinworld.getState()); //Magma - pass block state instead of null ++ world.playSound(player, blockpos, soundeffecttype.getPlaceSound(), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); + } -+ player.m_36246_(Stats.f_12982_.m_12902_(item)); ++ player.awardStat(Stats.ITEM_USED.get(item)); + } - player.m_36246_(Stats.f_12982_.m_12902_(item)); + player.awardStat(Stats.ITEM_USED.get(item)); } + world.capturedTileEntities.clear(); + world.capturedBlockStates.clear(); @@ -303,55 +303,55 @@ return interactionresult; } @@ -242,11 +_,15 @@ - p_41740_.m_128365_("tag", this.f_41590_.m_6426_()); + p_41740_.put("tag", this.tag.copy()); } + CompoundTag cnbt = this.serializeCaps(); -+ if (cnbt != null && !cnbt.m_128456_()) { -+ p_41740_.m_128365_("ForgeCaps", cnbt); ++ if (cnbt != null && !cnbt.isEmpty()) { ++ p_41740_.put("ForgeCaps", cnbt); + } return p_41740_; } - public int m_41741_() { -- return this.m_41720_().m_41459_(); -+ return this.m_41720_().getItemStackLimit(this); + public int getMaxStackSize() { +- return this.getItem().getMaxStackSize(); ++ return this.getItem().getItemStackLimit(this); } - public boolean m_41753_() { + public boolean isStackable() { @@ -254,7 +_,7 @@ } - public boolean m_41763_() { -- if (!this.f_41591_ && this.m_41720_().m_41462_() > 0) { -+ if (!this.f_41591_ && this.m_41720_().isDamageable(this)) { - CompoundTag compoundtag = this.m_41783_(); - return compoundtag == null || !compoundtag.m_128471_("Unbreakable"); + public boolean isDamageableItem() { +- if (!this.emptyCacheFlag && this.getItem().getMaxDamage() > 0) { ++ if (!this.emptyCacheFlag && this.getItem().isDamageable(this)) { + CompoundTag compoundtag = this.getTag(); + return compoundtag == null || !compoundtag.getBoolean("Unbreakable"); } else { @@ -263,19 +_,19 @@ } - public boolean m_41768_() { -- return this.m_41763_() && this.m_41773_() > 0; -+ return this.m_41763_() && m_41720_().isDamaged(this); + public boolean isDamaged() { +- return this.isDamageableItem() && this.getDamageValue() > 0; ++ return this.isDamageableItem() && getItem().isDamaged(this); } - public int m_41773_() { -- return this.f_41590_ == null ? 0 : this.f_41590_.m_128451_("Damage"); -+ return this.m_41720_().getDamage(this); + public int getDamageValue() { +- return this.tag == null ? 0 : this.tag.getInt("Damage"); ++ return this.getItem().getDamage(this); } - public void m_41721_(int p_41722_) { -- this.m_41784_().m_128405_("Damage", Math.max(0, p_41722_)); -+ this.m_41720_().setDamage(this, p_41722_); + public void setDamageValue(int p_41722_) { +- this.getOrCreateTag().putInt("Damage", Math.max(0, p_41722_)); ++ this.getItem().setDamage(this, p_41722_); } - public int m_41776_() { -- return this.m_41720_().m_41462_(); -+ return this.m_41720_().getMaxDamage(this); + public int getMaxDamage() { +- return this.getItem().getMaxDamage(); ++ return this.getItem().getMaxDamage(this); } - public boolean m_41629_(int p_41630_, Random p_41631_, @Nullable ServerPlayer p_41632_) { + public boolean hurt(int p_41630_, Random p_41631_, @Nullable ServerPlayer p_41632_) { @@ -293,6 +_,19 @@ } @@ -373,94 +373,94 @@ return false; } @@ -311,9 +_,17 @@ - public void m_41622_(int p_41623_, T p_41624_, Consumer p_41625_) { - if (!p_41624_.f_19853_.f_46443_ && (!(p_41624_ instanceof Player) || !((Player)p_41624_).m_150110_().f_35937_)) { - if (this.m_41763_()) { -+ p_41623_ = this.m_41720_().damageItem(this, p_41623_, p_41624_, p_41625_); - if (this.m_41629_(p_41623_, p_41624_.m_21187_(), p_41624_ instanceof ServerPlayer ? (ServerPlayer)p_41624_ : null)) { + public void hurtAndBreak(int p_41623_, T p_41624_, Consumer p_41625_) { + if (!p_41624_.level.isClientSide && (!(p_41624_ instanceof Player) || !((Player)p_41624_).getAbilities().instabuild)) { + if (this.isDamageableItem()) { ++ p_41623_ = this.getItem().damageItem(this, p_41623_, p_41624_, p_41625_); + if (this.hurt(p_41623_, p_41624_.getRandom(), p_41624_ instanceof ServerPlayer ? (ServerPlayer)p_41624_ : null)) { p_41625_.accept(p_41624_); - Item item = this.m_41720_(); + Item item = this.getItem(); + + // CraftBukkit start - Check for item breaking -+ if (this.f_41587_ == 1 && p_41624_ instanceof Player) { ++ if (this.count == 1 && p_41624_ instanceof Player) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerItemBreakEvent((Player) p_41624_, this); + } + // CraftBukkit end + - this.m_41774_(1); + this.shrink(1); if (p_41624_ instanceof Player) { - ((Player)p_41624_).m_36246_(Stats.f_12983_.m_12902_(item)); + ((Player)p_41624_).awardStat(Stats.ITEM_BROKEN.get(item)); @@ -363,7 +_,7 @@ } - public boolean m_41735_(BlockState p_41736_) { -- return this.m_41720_().m_8096_(p_41736_); -+ return this.m_41720_().isCorrectToolForDrops(this, p_41736_); + public boolean isCorrectToolForDrops(BlockState p_41736_) { +- return this.getItem().isCorrectToolForDrops(p_41736_); ++ return this.getItem().isCorrectToolForDrops(this, p_41736_); } - public InteractionResult m_41647_(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) { + public InteractionResult interactLivingEntity(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) { @@ -374,7 +_,7 @@ - if (this.m_41619_()) { - return f_41583_; + if (this.isEmpty()) { + return EMPTY; } else { -- ItemStack itemstack = new ItemStack(this.m_41720_(), this.f_41587_); -+ ItemStack itemstack = new ItemStack(this.m_41720_(), this.f_41587_, this.serializeCaps()); - itemstack.m_41754_(this.m_41612_()); - if (this.f_41590_ != null) { - itemstack.f_41590_ = this.f_41590_.m_6426_(); +- ItemStack itemstack = new ItemStack(this.getItem(), this.count); ++ ItemStack itemstack = new ItemStack(this.getItem(), this.count, this.serializeCaps()); + itemstack.setPopTime(this.getPopTime()); + if (this.tag != null) { + itemstack.tag = this.tag.copy(); @@ -391,7 +_,7 @@ - if (p_41659_.f_41590_ == null && p_41660_.f_41590_ != null) { + if (p_41659_.tag == null && p_41660_.tag != null) { return false; } else { -- return p_41659_.f_41590_ == null || p_41659_.f_41590_.equals(p_41660_.f_41590_); -+ return (p_41659_.f_41590_ == null || p_41659_.f_41590_.equals(p_41660_.f_41590_)) && p_41659_.areCapsCompatible(p_41660_); +- return p_41659_.tag == null || p_41659_.tag.equals(p_41660_.tag); ++ return (p_41659_.tag == null || p_41659_.tag.equals(p_41660_.tag)) && p_41659_.areCapsCompatible(p_41660_); } } else { return false; @@ -414,7 +_,7 @@ - } else if (this.f_41590_ == null && p_41745_.f_41590_ != null) { + } else if (this.tag == null && p_41745_.tag != null) { return false; } else { -- return this.f_41590_ == null || this.f_41590_.equals(p_41745_.f_41590_); -+ return (this.f_41590_ == null || this.f_41590_.equals(p_41745_.f_41590_)) && this.areCapsCompatible(p_41745_); +- return this.tag == null || this.tag.equals(p_41745_.tag); ++ return (this.tag == null || this.tag.equals(p_41745_.tag)) && this.areCapsCompatible(p_41745_); } } @@ -499,6 +_,17 @@ - return this.f_41590_; + return this.tag; } + // CraftBukkit start + @Nullable + private CompoundTag getTagClone() { -+ return this.f_41590_ == null ? null : this.f_41590_.m_6426_(); ++ return this.tag == null ? null : this.tag.copy(); + } + + private void setTagClone(@Nullable CompoundTag nbtttagcompound) { -+ this.m_41751_(nbtttagcompound == null ? null : nbtttagcompound.m_6426_()); ++ this.setTag(nbtttagcompound == null ? null : nbtttagcompound.copy()); + } + // CraftBukkit end + - public CompoundTag m_41784_() { - if (this.f_41590_ == null) { - this.m_41751_(new CompoundTag()); + public CompoundTag getOrCreateTag() { + if (this.tag == null) { + this.setTag(new CompoundTag()); @@ -538,7 +_,7 @@ - public void m_41751_(@Nullable CompoundTag p_41752_) { - this.f_41590_ = p_41752_; -- if (this.m_41720_().m_41465_()) { -+ if (this.m_41720_().isDamageable(this)) { - this.m_41721_(this.m_41773_()); + public void setTag(@Nullable CompoundTag p_41752_) { + this.tag = p_41752_; +- if (this.getItem().canBeDepleted()) { ++ if (this.getItem().isDamageable(this)) { + this.setDamageValue(this.getDamageValue()); } @@ -599,7 +_,7 @@ - public List m_41651_(@Nullable Player p_41652_, TooltipFlag p_41653_) { + public List getTooltipLines(@Nullable Player p_41652_, TooltipFlag p_41653_) { List list = Lists.newArrayList(); -- MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.m_41786_()).m_130940_(this.m_41791_().f_43022_); -+ MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.m_41786_()).m_130938_(this.m_41791_().getStyleModifier()); - if (this.m_41788_()) { - mutablecomponent.m_130940_(ChatFormatting.ITALIC); +- MutableComponent mutablecomponent = (new TextComponent("")).append(this.getHoverName()).withStyle(this.getRarity().color); ++ MutableComponent mutablecomponent = (new TextComponent("")).append(this.getHoverName()).withStyle(this.getRarity().getStyleModifier()); + if (this.hasCustomHoverName()) { + mutablecomponent.withStyle(ChatFormatting.ITALIC); } @@ -738,6 +_,7 @@ } @@ -473,31 +473,31 @@ @@ -746,7 +_,7 @@ } - private int m_41618_() { -- return this.m_41782_() && this.f_41590_.m_128425_("HideFlags", 99) ? this.f_41590_.m_128451_("HideFlags") : 0; -+ return this.m_41782_() && this.f_41590_.m_128425_("HideFlags", 99) ? this.f_41590_.m_128451_("HideFlags") : this.m_41720_().getDefaultTooltipHideFlags(this); + private int getHideFlags() { +- return this.hasTag() && this.tag.contains("HideFlags", 99) ? this.tag.getInt("HideFlags") : 0; ++ return this.hasTag() && this.tag.contains("HideFlags", 99) ? this.tag.getInt("HideFlags") : this.getItem().getDefaultTooltipHideFlags(this); } - public void m_41654_(ItemStack.TooltipPart p_41655_) { + public void hideTooltipPart(ItemStack.TooltipPart p_41655_) { @@ -852,6 +_,12 @@ } - public void m_41742_(int p_41743_) { + public void setRepairCost(int p_41743_) { + // CraftBukkit start - remove RepairCost tag when 0 (SPIGOT-3945) + if (p_41743_ == 0) { -+ this.m_41749_("RepairCost"); ++ this.removeTagKey("RepairCost"); + return; + } + // CraftBukkit end - this.m_41784_().m_128405_("RepairCost", p_41743_); + this.getOrCreateTag().putInt("RepairCost", p_41743_); } @@ -874,9 +_,10 @@ } } } else { -- multimap = this.m_41720_().m_7167_(p_41639_); -+ multimap = this.m_41720_().getAttributeModifiers(p_41639_, this); +- multimap = this.getItem().getDefaultAttributeModifiers(p_41639_); ++ multimap = this.getItem().getAttributeModifiers(p_41639_, this); } + multimap = net.minecraftforge.common.ForgeHooks.getAttributeModifiers(this, p_41639_, multimap); @@ -511,42 +511,42 @@ + // CraftBukkit start + @Deprecated + public void setItem(Item item) { -+ this.f_41589_ = item; ++ this.item = item; + this.delegate = item.delegate; + } + + // CraftBukkit end + - public Component m_41611_() { - MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.m_41786_()); - if (this.m_41788_()) { + public Component getDisplayName() { + MutableComponent mutablecomponent = (new TextComponent("")).append(this.getHoverName()); + if (this.hasCustomHoverName()) { @@ -904,7 +_,7 @@ - MutableComponent mutablecomponent1 = ComponentUtils.m_130748_(mutablecomponent); - if (!this.f_41591_) { -- mutablecomponent1.m_130940_(this.m_41791_().f_43022_).m_130938_((p_204127_) -> { -+ mutablecomponent1.m_130938_(this.m_41791_().getStyleModifier()).m_130938_((p_204127_) -> { - return p_204127_.m_131144_(new HoverEvent(HoverEvent.Action.f_130832_, new HoverEvent.ItemStackInfo(this))); + MutableComponent mutablecomponent1 = ComponentUtils.wrapInSquareBrackets(mutablecomponent); + if (!this.emptyCacheFlag) { +- mutablecomponent1.withStyle(this.getRarity().color).withStyle((p_204127_) -> { ++ mutablecomponent1.withStyle(this.getRarity().getStyleModifier()).withStyle((p_204127_) -> { + return p_204127_.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(this))); }); } @@ -957,12 +_,31 @@ - this.m_41720_().m_5929_(p_41732_, p_41733_, this, p_41734_); + this.getItem().onUseTick(p_41732_, p_41733_, this, p_41734_); } + /** @deprecated Forge: Use damage source sensitive version */ + @Deprecated - public void m_150924_(ItemEntity p_150925_) { - this.m_41720_().m_142023_(p_150925_); + public void onDestroyed(ItemEntity p_150925_) { + this.getItem().onDestroyed(p_150925_); } - public boolean m_41614_() { - return this.m_41720_().m_41472_(); + public boolean isEdible() { + return this.getItem().isEdible(); + } + + // FORGE START + public void deserializeNBT(CompoundTag nbt) { -+ final ItemStack itemStack = ItemStack.m_41712_(nbt); -+ this.m_41751_(itemStack.m_41783_()); ++ final ItemStack itemStack = ItemStack.of(nbt); ++ this.setTag(itemStack.getTag()); + if (itemStack.capNBT != null) deserializeCaps(itemStack.capNBT); + } + @@ -555,9 +555,9 @@ + */ + private void forgeInit() { + if (this.delegate != null) { -+ this.gatherCapabilities(() -> f_41589_.initCapabilities(this, this.capNBT)); ++ this.gatherCapabilities(() -> item.initCapabilities(this, this.capNBT)); + if (this.capNBT != null) deserializeCaps(this.capNBT); + } } - public SoundEvent m_41615_() { + public SoundEvent getDrinkingSound() { diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch index 16bbaba9..cd6e6111 100644 --- a/patches/minecraft/net/minecraft/world/item/Items.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -6,24 +6,24 @@ +@net.minecraftforge.registries.ObjectHolder("minecraft") public class Items { - public static final Item f_41852_ = m_42810_(Blocks.f_50016_, new AirItem(Blocks.f_50016_, new Item.Properties())); - public static final Item f_41905_ = m_42807_(Blocks.f_50069_, CreativeModeTab.f_40749_); + public static final Item AIR = registerBlock(Blocks.AIR, new AirItem(Blocks.AIR, new Item.Properties())); + public static final Item STONE = registerBlock(Blocks.STONE, CreativeModeTab.TAB_BUILDING_BLOCKS); @@ -1138,11 +_,23 @@ } - private static Item m_151089_(Block p_151090_, CreativeModeTab p_151091_, Block... p_151092_) { -- BlockItem blockitem = new BlockItem(p_151090_, (new Item.Properties()).m_41491_(p_151091_)); -+ BlockItem blockitem = new BlockItem(p_151090_, (new Item.Properties()).m_41491_(p_151091_)) { + private static Item registerBlock(Block p_151090_, CreativeModeTab p_151091_, Block... p_151092_) { +- BlockItem blockitem = new BlockItem(p_151090_, (new Item.Properties()).tab(p_151091_)); ++ BlockItem blockitem = new BlockItem(p_151090_, (new Item.Properties()).tab(p_151091_)) { + @Override -+ public void m_6192_(java.util.Map map, Item self) { -+ super.m_6192_(map, self); ++ public void registerBlocks(java.util.Map map, Item self) { ++ super.registerBlocks(map, self); + for (Block b : p_151092_) { + map.put(b, self); + } + } - for(Block block : p_151092_) { -- Item.f_41373_.put(block, blockitem); +- Item.BY_BLOCK.put(block, blockitem); - } + @Override + public void removeFromBlockToItemMap(java.util.Map map, Item self) { @@ -34,5 +34,5 @@ + } + }; - return m_42803_(blockitem); + return registerBlock(blockitem); } diff --git a/patches/minecraft/net/minecraft/world/item/LeadItem.java.patch b/patches/minecraft/net/minecraft/world/item/LeadItem.java.patch index dce8d21a..3822fc10 100644 --- a/patches/minecraft/net/minecraft/world/item/LeadItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/LeadItem.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/item/LeadItem.java +++ b/net/minecraft/world/item/LeadItem.java @@ -44,8 +_,24 @@ - if (mob.m_21524_() == p_42830_) { + if (mob.getLeashHolder() == p_42830_) { if (leashfenceknotentity == null) { - leashfenceknotentity = LeashFenceKnotEntity.m_31844_(p_42831_, p_42832_); + leashfenceknotentity = LeashFenceKnotEntity.getOrCreateKnot(p_42831_, p_42832_); + + // CraftBukkit start - fire HangingPlaceEvent + org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) leashfenceknotentity.getBukkitEntity(), p_42830_ != null ? (org.bukkit.entity.Player) p_42830_.getBukkitEntity() : null, p_42831_.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF); + p_42831_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ leashfenceknotentity.m_146870_(); ++ leashfenceknotentity.discard(); + return InteractionResult.PASS; + } + // CraftBukkit end + - leashfenceknotentity.m_7084_(); + leashfenceknotentity.playPlacementSound(); } + + // CraftBukkit start @@ -23,5 +23,5 @@ + } + // CraftBukkit end - mob.m_21463_(leashfenceknotentity, true); + mob.setLeashedTo(leashfenceknotentity, true); flag = true; diff --git a/patches/minecraft/net/minecraft/world/item/MapItem.java.patch b/patches/minecraft/net/minecraft/world/item/MapItem.java.patch index 4a2a9d2d..d7101ab3 100644 --- a/patches/minecraft/net/minecraft/world/item/MapItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MapItem.java.patch @@ -3,11 +3,11 @@ @@ -55,20 +_,34 @@ @Nullable - public static MapItemSavedData m_42853_(ItemStack p_42854_, Level p_42855_) { -- Integer integer = m_151131_(p_42854_); -- return m_151128_(integer, p_42855_); + public static MapItemSavedData getSavedData(ItemStack p_42854_, Level p_42855_) { +- Integer integer = getMapId(p_42854_); +- return getSavedData(integer, p_42855_); + // Forge: Add instance method so that mods can override -+ Item map = p_42854_.m_41720_(); ++ Item map = p_42854_.getItem(); + if(map instanceof MapItem) { + return ((MapItem)map).getCustomMapData(p_42854_, p_42855_); + } @@ -16,21 +16,21 @@ + + @Nullable + protected MapItemSavedData getCustomMapData(ItemStack p_42910_, Level p_42911_) { -+ Integer integer = m_151131_(p_42910_); -+ return m_151128_(integer, p_42911_); ++ Integer integer = getMapId(p_42910_); ++ return getSavedData(integer, p_42911_); } @Nullable - public static Integer m_151131_(ItemStack p_151132_) { - CompoundTag compoundtag = p_151132_.m_41783_(); -- return compoundtag != null && compoundtag.m_128425_("map", 99) ? compoundtag.m_128451_("map") : null; -+ return compoundtag != null && compoundtag.m_128425_("map", 99) ? compoundtag.m_128451_("map") : -1; // CraftBukkit - make new maps for no tag + public static Integer getMapId(ItemStack p_151132_) { + CompoundTag compoundtag = p_151132_.getTag(); +- return compoundtag != null && compoundtag.contains("map", 99) ? compoundtag.getInt("map") : null; ++ return compoundtag != null && compoundtag.contains("map", 99) ? compoundtag.getInt("map") : -1; // CraftBukkit - make new maps for no tag } - public static int m_151120_(Level p_151121_, int p_151122_, int p_151123_, int p_151124_, boolean p_151125_, boolean p_151126_, ResourceKey p_151127_) { - MapItemSavedData mapitemsaveddata = MapItemSavedData.m_164780_((double)p_151122_, (double)p_151123_, (byte)p_151124_, p_151125_, p_151126_, p_151127_); - int i = p_151121_.m_7354_(); - p_151121_.m_142325_(m_42848_(i), mapitemsaveddata); + public static int createNewSavedData(Level p_151121_, int p_151122_, int p_151123_, int p_151124_, boolean p_151125_, boolean p_151126_, ResourceKey p_151127_) { + MapItemSavedData mapitemsaveddata = MapItemSavedData.createFresh((double)p_151122_, (double)p_151123_, (byte)p_151124_, p_151125_, p_151126_, p_151127_); + int i = p_151121_.getFreeMapId(); + p_151121_.setMapData(makeKey(i), mapitemsaveddata); + // CraftBukkit start + org.bukkit.event.server.MapInitializeEvent event = new org.bukkit.event.server.MapInitializeEvent(mapitemsaveddata.mapView); + org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); diff --git a/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch index 2391ebcc..336fd0bd 100644 --- a/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MilkBucketItem.java.patch @@ -3,27 +3,27 @@ @@ -17,6 +_,8 @@ } - public ItemStack m_5922_(ItemStack p_42923_, Level p_42924_, LivingEntity p_42925_) { + public ItemStack finishUsingItem(ItemStack p_42923_, Level p_42924_, LivingEntity p_42925_) { + // Magma - todo: Add Milk Effect Cause -+ if (!p_42924_.f_46443_) p_42925_.curePotionEffects(p_42923_); // FORGE - move up so stack.shrink does not turn stack into air ++ if (!p_42924_.isClientSide) p_42925_.curePotionEffects(p_42923_); // FORGE - move up so stack.shrink does not turn stack into air if (p_42925_ instanceof ServerPlayer) { ServerPlayer serverplayer = (ServerPlayer)p_42925_; - CriteriaTriggers.f_10592_.m_23682_(serverplayer, p_42923_); + CriteriaTriggers.CONSUME_ITEM.trigger(serverplayer, p_42923_); @@ -27,10 +_,6 @@ - p_42923_.m_41774_(1); + p_42923_.shrink(1); } -- if (!p_42924_.f_46443_) { -- p_42925_.m_21219_(); +- if (!p_42924_.isClientSide) { +- p_42925_.removeAllEffects(); - } - - return p_42923_.m_41619_() ? new ItemStack(Items.f_42446_) : p_42923_; + return p_42923_.isEmpty() ? new ItemStack(Items.BUCKET) : p_42923_; } @@ -44,5 +_,10 @@ - public InteractionResultHolder m_7203_(Level p_42927_, Player p_42928_, InteractionHand p_42929_) { - return ItemUtils.m_150959_(p_42927_, p_42928_, p_42929_); + public InteractionResultHolder use(Level p_42927_, Player p_42928_, InteractionHand p_42929_) { + return ItemUtils.startUsingInstantly(p_42927_, p_42928_, p_42929_); + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch index ed8b46e3..803ab277 100644 --- a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch @@ -1,51 +1,51 @@ --- a/net/minecraft/world/item/MinecartItem.java +++ b/net/minecraft/world/item/MinecartItem.java @@ -28,7 +_,7 @@ - double d2 = p_42949_.m_7094_() + (double)direction.m_122431_() * 1.125D; - BlockPos blockpos = p_42949_.m_7961_().m_142300_(direction); - BlockState blockstate = level.m_8055_(blockpos); -- RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()) : RailShape.NORTH_SOUTH; -+ RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; + double d2 = p_42949_.z() + (double)direction.getStepZ() * 1.125D; + BlockPos blockpos = p_42949_.getPos().relative(direction); + BlockState blockstate = level.getBlockState(blockpos); +- RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) : RailShape.NORTH_SOUTH; ++ RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; double d3; - if (blockstate.m_204336_(BlockTags.f_13034_)) { - if (railshape.m_61745_()) { + if (blockstate.is(BlockTags.RAILS)) { + if (railshape.isAscending()) { @@ -50,13 +_,38 @@ } } -- AbstractMinecart abstractminecart = AbstractMinecart.m_38119_(level, d0, d1 + d3, d2, ((MinecartItem)p_42950_.m_41720_()).f_42935_); +- AbstractMinecart abstractminecart = AbstractMinecart.createMinecart(level, d0, d1 + d3, d2, ((MinecartItem)p_42950_.getItem()).type); + // CraftBukkit start -+ ItemStack itemstack1 = p_42950_.m_41620_(1); -+ org.bukkit.block.Block block2 = level.getWorld().getBlockAt(p_42949_.m_7961_().m_123341_(), p_42949_.m_7961_().m_123342_(), p_42949_.m_7961_().m_123343_()); ++ ItemStack itemstack1 = p_42950_.split(1); ++ org.bukkit.block.Block block2 = level.getWorld().getBlockAt(p_42949_.getPos().getX(), p_42949_.getPos().getY(), p_42949_.getPos().getZ()); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack1); + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); + if (!DispenserBlock.eventFired) { + level.getCraftServer().getPluginManager().callEvent(event); + } + if (event.isCancelled()) { -+ p_42950_.m_41769_(1); ++ p_42950_.grow(1); + return p_42950_; + } + if (!event.getItem().equals(craftItem)) { -+ p_42950_.m_41769_(1); ++ p_42950_.grow(1); + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.f_52661_.get(eventStack.m_41720_()); -+ if (idispensebehavior != DispenseItemBehavior.f_123393_ && idispensebehavior != this) { -+ idispensebehavior.m_6115_(p_42949_, eventStack); ++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(p_42949_, eventStack); + return p_42950_; + } + } + itemstack1 = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ AbstractMinecart abstractminecart = AbstractMinecart.m_38119_(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((MinecartItem) itemstack1.m_41720_()).f_42935_); ++ AbstractMinecart abstractminecart = AbstractMinecart.createMinecart(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((MinecartItem) itemstack1.getItem()).type); + - if (p_42950_.m_41788_()) { - abstractminecart.m_6593_(p_42950_.m_41786_()); + if (p_42950_.hasCustomHoverName()) { + abstractminecart.setCustomName(p_42950_.getHoverName()); } -- level.m_7967_(abstractminecart); -- p_42950_.m_41774_(1); -+ if (!level.m_7967_(abstractminecart)) p_42950_.m_41769_(1); +- level.addFreshEntity(abstractminecart); +- p_42950_.shrink(1); ++ if (!level.addFreshEntity(abstractminecart)) p_42950_.grow(1); + // p_42950_.shrink(1); // CraftBukkit - handled during event processing + // CraftBukkit end return p_42950_; @@ -53,24 +53,24 @@ @@ -81,7 +_,7 @@ } else { - ItemStack itemstack = p_42943_.m_43722_(); - if (!level.f_46443_) { -- RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? blockstate.m_61143_(((BaseRailBlock)blockstate.m_60734_()).m_7978_()) : RailShape.NORTH_SOUTH; -+ RailShape railshape = blockstate.m_60734_() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.m_60734_()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; + ItemStack itemstack = p_42943_.getItemInHand(); + if (!level.isClientSide) { +- RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) : RailShape.NORTH_SOUTH; ++ RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; double d0 = 0.0D; - if (railshape.m_61745_()) { + if (railshape.isAscending()) { d0 = 0.5D; @@ -92,7 +_,12 @@ - abstractminecart.m_6593_(itemstack.m_41786_()); + abstractminecart.setCustomName(itemstack.getHoverName()); } -- level.m_7967_(abstractminecart); +- level.addFreshEntity(abstractminecart); + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityPlaceEvent(p_42943_, abstractminecart).isCancelled()) { + return InteractionResult.FAIL; + } + // CraftBukkit end -+ if (!level.m_7967_(abstractminecart)) return InteractionResult.PASS; // CraftBukkit - level.m_142346_(p_42943_.m_43723_(), GameEvent.f_157810_, blockpos); ++ if (!level.addFreshEntity(abstractminecart)) return InteractionResult.PASS; // CraftBukkit + level.gameEvent(p_42943_.getPlayer(), GameEvent.ENTITY_PLACE, blockpos); } diff --git a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch index ffd239d6..71b0498f 100644 --- a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch @@ -4,16 +4,16 @@ import net.minecraft.world.level.material.Fluid; public class MobBucketItem extends BucketItem { -- private final EntityType f_151134_; -- private final SoundEvent f_151135_; +- private final EntityType type; +- private final SoundEvent emptySound; + private final java.util.function.Supplier> entityTypeSupplier; + private final java.util.function.Supplier emptySoundSupplier; + @Deprecated public MobBucketItem(EntityType p_151137_, Fluid p_151138_, SoundEvent p_151139_, Item.Properties p_151140_) { - super(p_151138_, p_151140_); -- this.f_151134_ = p_151137_; -- this.f_151135_ = p_151139_; +- this.type = p_151137_; +- this.emptySound = p_151139_; + this(() -> p_151137_, () -> p_151138_, () -> p_151139_, p_151140_); + } + @@ -23,30 +23,30 @@ + this.entityTypeSupplier = entitySupplier; } - public void m_142131_(@Nullable Player p_151146_, Level p_151147_, ItemStack p_151148_, BlockPos p_151149_) { + public void checkExtraContent(@Nullable Player p_151146_, Level p_151147_, ItemStack p_151148_, BlockPos p_151149_) { @@ -41,11 +_,11 @@ } - protected void m_7718_(@Nullable Player p_151151_, LevelAccessor p_151152_, BlockPos p_151153_) { -- p_151152_.m_5594_(p_151151_, p_151153_, this.f_151135_, SoundSource.NEUTRAL, 1.0F, 1.0F); -+ p_151152_.m_5594_(p_151151_, p_151153_, getEmptySound(), SoundSource.NEUTRAL, 1.0F, 1.0F); + protected void playEmptySound(@Nullable Player p_151151_, LevelAccessor p_151152_, BlockPos p_151153_) { +- p_151152_.playSound(p_151151_, p_151153_, this.emptySound, SoundSource.NEUTRAL, 1.0F, 1.0F); ++ p_151152_.playSound(p_151151_, p_151153_, getEmptySound(), SoundSource.NEUTRAL, 1.0F, 1.0F); } - private void m_151141_(ServerLevel p_151142_, ItemStack p_151143_, BlockPos p_151144_) { -- Entity entity = this.f_151134_.m_20592_(p_151142_, p_151143_, (Player)null, p_151144_, MobSpawnType.BUCKET, true, false); -+ Entity entity = getFishType().m_20592_(p_151142_, p_151143_, (Player)null, p_151144_, MobSpawnType.BUCKET, true, false); + private void spawn(ServerLevel p_151142_, ItemStack p_151143_, BlockPos p_151144_) { +- Entity entity = this.type.spawn(p_151142_, p_151143_, (Player)null, p_151144_, MobSpawnType.BUCKET, true, false); ++ Entity entity = getFishType().spawn(p_151142_, p_151143_, (Player)null, p_151144_, MobSpawnType.BUCKET, true, false); if (entity instanceof Bucketable) { Bucketable bucketable = (Bucketable)entity; - bucketable.m_142278_(p_151143_.m_41784_()); + bucketable.loadFromBucketTag(p_151143_.getOrCreateTag()); @@ -55,7 +_,7 @@ } - public void m_7373_(ItemStack p_151155_, @Nullable Level p_151156_, List p_151157_, TooltipFlag p_151158_) { -- if (this.f_151134_ == EntityType.f_20489_) { -+ if (getFishType() == EntityType.f_20489_) { - CompoundTag compoundtag = p_151155_.m_41783_(); - if (compoundtag != null && compoundtag.m_128425_("BucketVariantTag", 3)) { - int i = compoundtag.m_128451_("BucketVariantTag"); + public void appendHoverText(ItemStack p_151155_, @Nullable Level p_151156_, List p_151157_, TooltipFlag p_151158_) { +- if (this.type == EntityType.TROPICAL_FISH) { ++ if (getFishType() == EntityType.TROPICAL_FISH) { + CompoundTag compoundtag = p_151155_.getTag(); + if (compoundtag != null && compoundtag.contains("BucketVariantTag", 3)) { + int i = compoundtag.getInt("BucketVariantTag"); @@ -81,5 +_,14 @@ } } diff --git a/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch index 3cc3068a..e472644d 100644 --- a/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/item/PickaxeItem.java @@ -6,4 +_,9 @@ public PickaxeItem(Tier p_42961_, int p_42962_, float p_42963_, Item.Properties p_42964_) { - super((float)p_42962_, p_42963_, p_42961_, BlockTags.f_144282_, p_42964_); + super((float)p_42962_, p_42963_, p_42961_, BlockTags.MINEABLE_WITH_PICKAXE, p_42964_); } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/PlayerHeadItem.java.patch b/patches/minecraft/net/minecraft/world/item/PlayerHeadItem.java.patch index afccaa0e..3fbfab3e 100644 --- a/patches/minecraft/net/minecraft/world/item/PlayerHeadItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/PlayerHeadItem.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/PlayerHeadItem.java +++ b/net/minecraft/world/item/PlayerHeadItem.java @@ -45,6 +_,16 @@ - SkullBlockEntity.m_155738_(gameprofile, (p_151177_) -> { - p_151179_.m_128365_("SkullOwner", NbtUtils.m_129230_(new CompoundTag(), p_151177_)); + SkullBlockEntity.updateGameprofile(gameprofile, (p_151177_) -> { + p_151179_.put("SkullOwner", NbtUtils.writeGameProfile(new CompoundTag(), p_151177_)); }); + // CraftBukkit start + } else { -+ net.minecraft.nbt.ListTag textures = p_151179_.m_128469_("SkullOwner").m_128469_("Properties").m_128437_("textures", 10); // Safe due to method contracts ++ net.minecraft.nbt.ListTag textures = p_151179_.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts + for (int i = 0; i < textures.size(); i++) { -+ if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).m_128425_("Signature", 8) && ((CompoundTag) textures.get(i)).m_128461_("Value").trim().isEmpty()) { -+ p_151179_.m_128473_("SkullOwner"); ++ if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).contains("Signature", 8) && ((CompoundTag) textures.get(i)).getString("Value").trim().isEmpty()) { ++ p_151179_.remove("SkullOwner"); + break; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch b/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch index 263a4981..4feb39fc 100644 --- a/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/item/PotionItem.java +++ b/net/minecraft/world/item/PotionItem.java @@ -41,7 +_,7 @@ - if (mobeffectinstance.m_19544_().m_8093_()) { - mobeffectinstance.m_19544_().m_19461_(player, player, p_42986_, mobeffectinstance.m_19564_(), 1.0D); + if (mobeffectinstance.getEffect().isInstantenous()) { + mobeffectinstance.getEffect().applyInstantenousEffect(player, player, p_42986_, mobeffectinstance.getAmplifier(), 1.0D); } else { -- p_42986_.m_7292_(new MobEffectInstance(mobeffectinstance)); +- p_42986_.addEffect(new MobEffectInstance(mobeffectinstance)); + p_42986_.addEffect(new MobEffectInstance(mobeffectinstance), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/item/Rarity.java.patch b/patches/minecraft/net/minecraft/world/item/Rarity.java.patch index a7607d4c..2af5d9b7 100644 --- a/patches/minecraft/net/minecraft/world/item/Rarity.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Rarity.java.patch @@ -13,16 +13,16 @@ + /** @deprecated Forge: Use {@link #getStyleModifier()} */ + @Deprecated - public final ChatFormatting f_43022_; + public final ChatFormatting color; + private final java.util.function.UnaryOperator styleModifier; private Rarity(ChatFormatting p_43028_) { - this.f_43022_ = p_43028_; -+ this.styleModifier = style -> style.m_131140_(p_43028_); + this.color = p_43028_; ++ this.styleModifier = style -> style.withColor(p_43028_); + } + + Rarity(java.util.function.UnaryOperator styleModifier) { -+ this.f_43022_ = ChatFormatting.BLACK; ++ this.color = ChatFormatting.BLACK; + this.styleModifier = styleModifier; + } + diff --git a/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch b/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch index d79b0b91..6ed7fe35 100644 --- a/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch @@ -5,19 +5,19 @@ public class RecordItem extends Item { + @Deprecated // Forge: refer to WorldRender#playRecord. Modders: there's no need to reflectively modify this map! - private static final Map f_43032_ = Maps.newHashMap(); - private final int f_43033_; + private static final Map BY_NAME = Maps.newHashMap(); + private final int analogOutput; + @Deprecated // Forge: refer to soundSupplier - private final SoundEvent f_43034_; + private final SoundEvent sound; + private final java.util.function.Supplier soundSupplier; + @Deprecated // Forge: Use the constructor that takes a supplier instead public RecordItem(int p_43037_, SoundEvent p_43038_, Item.Properties p_43039_) { super(p_43039_); - this.f_43033_ = p_43037_; - this.f_43034_ = p_43038_; - f_43032_.put(this.f_43034_, this); -+ this.soundSupplier = this.f_43034_.delegate; + this.analogOutput = p_43037_; + this.sound = p_43038_; + BY_NAME.put(this.sound, this); ++ this.soundSupplier = this.sound.delegate; + } + + /** @@ -33,36 +33,36 @@ + public RecordItem(int comparatorValue, java.util.function.Supplier soundSupplier, Item.Properties builder) + { + super(builder); -+ this.f_43033_ = comparatorValue; -+ this.f_43034_ = null; ++ this.analogOutput = comparatorValue; ++ this.sound = null; + this.soundSupplier = soundSupplier; } - public InteractionResult m_6225_(UseOnContext p_43048_) { + public InteractionResult useOn(UseOnContext p_43048_) { @@ -38,13 +_,15 @@ - if (blockstate.m_60713_(Blocks.f_50131_) && !blockstate.m_61143_(JukeboxBlock.f_54254_)) { - ItemStack itemstack = p_43048_.m_43722_(); - if (!level.f_46443_) { -- ((JukeboxBlock)Blocks.f_50131_).m_54269_(level, blockpos, blockstate, itemstack); -- level.m_5898_((Player)null, 1010, blockpos, Item.m_41393_(this)); -- itemstack.m_41774_(1); + if (blockstate.is(Blocks.JUKEBOX) && !blockstate.getValue(JukeboxBlock.HAS_RECORD)) { + ItemStack itemstack = p_43048_.getItemInHand(); + if (!level.isClientSide) { +- ((JukeboxBlock)Blocks.JUKEBOX).setRecord(level, blockpos, blockstate, itemstack); +- level.levelEvent((Player)null, 1010, blockpos, Item.getId(this)); +- itemstack.shrink(1); + //Magma - move before return - Player player = p_43048_.m_43723_(); + Player player = p_43048_.getPlayer(); if (player != null) { - player.m_36220_(Stats.f_12965_); + player.awardStat(Stats.PLAY_RECORD); } + if (true) return InteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack -+ ((JukeboxBlock)Blocks.f_50131_).m_54269_(level, blockpos, blockstate, itemstack); -+ level.m_5898_((Player)null, 1010, blockpos, Item.m_41393_(this)); -+ itemstack.m_41774_(1); ++ ((JukeboxBlock)Blocks.JUKEBOX).setRecord(level, blockpos, blockstate, itemstack); ++ level.levelEvent((Player)null, 1010, blockpos, Item.getId(this)); ++ itemstack.shrink(1); } - return InteractionResult.m_19078_(level.f_46443_); + return InteractionResult.sidedSuccess(level.isClientSide); @@ -71,6 +_,6 @@ } - public SoundEvent m_43051_() { -- return this.f_43034_; + public SoundEvent getSound() { +- return this.sound; + return this.soundSupplier.get(); } } diff --git a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch index 987e147d..6f948855 100644 --- a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch @@ -5,27 +5,27 @@ } + @Override -+ public net.minecraft.world.InteractionResult m_6880_(ItemStack stack, net.minecraft.world.entity.player.Player playerIn, LivingEntity entity, net.minecraft.world.InteractionHand hand) { ++ public net.minecraft.world.InteractionResult interactLivingEntity(ItemStack stack, net.minecraft.world.entity.player.Player playerIn, LivingEntity entity, net.minecraft.world.InteractionHand hand) { + if (entity instanceof net.minecraftforge.common.IForgeShearable target) { -+ if (entity.f_19853_.f_46443_) return net.minecraft.world.InteractionResult.SUCCESS; -+ BlockPos pos = new BlockPos(entity.m_20185_(), entity.m_20186_(), entity.m_20189_()); -+ if (target.isShearable(stack, entity.f_19853_, pos)) { ++ if (entity.level.isClientSide) return net.minecraft.world.InteractionResult.SUCCESS; ++ BlockPos pos = new BlockPos(entity.getX(), entity.getY(), entity.getZ()); ++ if (target.isShearable(stack, entity.level, pos)) { + // Magma start + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handlePlayerShearEntityEvent(playerIn, entity, stack, hand)) { + return InteractionResult.PASS; + } + // Magma end -+ java.util.List drops = target.onSheared(playerIn, stack, entity.f_19853_, pos, -+ net.minecraft.world.item.enchantment.EnchantmentHelper.m_44843_(net.minecraft.world.item.enchantment.Enchantments.f_44987_, stack)); ++ java.util.List drops = target.onSheared(playerIn, stack, entity.level, pos, ++ net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_FORTUNE, stack)); + java.util.Random rand = new java.util.Random(); + drops.forEach(d -> { + //Magma - make sure shear drops actually drop + entity.forceDrops = true; // CraftBukkit -+ net.minecraft.world.entity.item.ItemEntity ent = entity.m_5552_(d, 1.0F); ++ net.minecraft.world.entity.item.ItemEntity ent = entity.spawnAtLocation(d, 1.0F); + entity.forceDrops = false; // CraftBukkit -+ ent.m_20256_(ent.m_20184_().m_82520_((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F))); ++ ent.setDeltaMovement(ent.getDeltaMovement().add((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F))); + }); -+ stack.m_41622_(1, playerIn, e -> e.m_21190_(hand)); ++ stack.hurtAndBreak(1, playerIn, e -> e.broadcastBreakEvent(hand)); + } + return net.minecraft.world.InteractionResult.SUCCESS; + } @@ -37,6 +37,6 @@ + return net.minecraftforge.common.ToolActions.DEFAULT_SHEARS_ACTIONS.contains(toolAction); + } + - public InteractionResult m_6225_(UseOnContext p_186371_) { - Level level = p_186371_.m_43725_(); - BlockPos blockpos = p_186371_.m_8083_(); + public InteractionResult useOn(UseOnContext p_186371_) { + Level level = p_186371_.getLevel(); + BlockPos blockpos = p_186371_.getClickedPos(); diff --git a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch index 2722f5ca..04d48a0e 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 @@ -51,4 +_,11 @@ - CompoundTag compoundtag = BlockItem.m_186336_(p_43103_); - return compoundtag != null ? DyeColor.m_41053_(compoundtag.m_128451_("Base")) : DyeColor.WHITE; + CompoundTag compoundtag = BlockItem.getBlockEntityData(p_43103_); + return compoundtag != null ? DyeColor.byId(compoundtag.getInt("Base")) : DyeColor.WHITE; } + + /* ******************** FORGE START ******************** */ diff --git a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch index 8c8620a7..7f66d8d3 100644 --- a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch @@ -3,15 +3,15 @@ @@ -32,9 +_,9 @@ return InteractionResult.PASS; } else { - Player player = p_43119_.m_43723_(); -- BlockState blockstate1 = f_43110_.get(blockstate.m_60734_()); + Player player = p_43119_.getPlayer(); +- BlockState blockstate1 = FLATTENABLES.get(blockstate.getBlock()); + BlockState blockstate1 = blockstate.getToolModifiedState(p_43119_, net.minecraftforge.common.ToolActions.SHOVEL_FLATTEN, false); BlockState blockstate2 = null; -- if (blockstate1 != null && level.m_8055_(blockpos.m_7494_()).m_60795_()) { -+ if (blockstate1 != null && level.m_46859_(blockpos.m_7494_())) { - level.m_5594_(player, blockpos, SoundEvents.f_12406_, SoundSource.BLOCKS, 1.0F, 1.0F); +- if (blockstate1 != null && level.getBlockState(blockpos.above()).isAir()) { ++ if (blockstate1 != null && level.isEmptyBlock(blockpos.above())) { + level.playSound(player, blockpos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); blockstate2 = blockstate1; - } else if (blockstate.m_60734_() instanceof CampfireBlock && blockstate.m_61143_(CampfireBlock.f_51227_)) { + } else if (blockstate.getBlock() instanceof CampfireBlock && blockstate.getValue(CampfireBlock.LIT)) { @@ -61,5 +_,15 @@ return InteractionResult.PASS; } @@ -20,7 +20,7 @@ + + @javax.annotation.Nullable + public static BlockState getShovelPathingState(BlockState originalState) { -+ return f_43110_.get(originalState.m_60734_()); ++ return FLATTENABLES.get(originalState.getBlock()); + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/SignItem.java.patch b/patches/minecraft/net/minecraft/world/item/SignItem.java.patch index 69210f0e..3cf1bafa 100644 --- a/patches/minecraft/net/minecraft/world/item/SignItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SignItem.java.patch @@ -11,10 +11,10 @@ super(p_43127_, p_43128_, p_43126_); } @@ -16,7 +_,10 @@ - protected boolean m_7274_(BlockPos p_43130_, Level p_43131_, @Nullable Player p_43132_, ItemStack p_43133_, BlockState p_43134_) { - boolean flag = super.m_7274_(p_43130_, p_43131_, p_43132_, p_43133_, p_43134_); - if (!p_43131_.f_46443_ && !flag && p_43132_ != null) { -- p_43132_.m_7739_((SignBlockEntity)p_43131_.m_7702_(p_43130_)); + protected boolean updateCustomBlockEntityTag(BlockPos p_43130_, Level p_43131_, @Nullable Player p_43132_, ItemStack p_43133_, BlockState p_43134_) { + boolean flag = super.updateCustomBlockEntityTag(p_43130_, p_43131_, p_43132_, p_43133_, p_43134_); + if (!p_43131_.isClientSide && !flag && p_43132_ != null) { +- p_43132_.openTextEdit((SignBlockEntity)p_43131_.getBlockEntity(p_43130_)); + // CraftBukkit start - SPIGOT-4678 + // p_43132_.openTextEdit((SignBlockEntity)p_43131_.getBlockEntity(p_43130_)); + SignItem.openSign = p_43130_; diff --git a/patches/minecraft/net/minecraft/world/item/SnowballItem.java.patch b/patches/minecraft/net/minecraft/world/item/SnowballItem.java.patch index 25d716fd..e1ac25c3 100644 --- a/patches/minecraft/net/minecraft/world/item/SnowballItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SnowballItem.java.patch @@ -2,36 +2,34 @@ +++ b/net/minecraft/world/item/SnowballItem.java @@ -16,19 +_,29 @@ - public InteractionResultHolder m_7203_(Level p_43142_, Player p_43143_, InteractionHand p_43144_) { - ItemStack itemstack = p_43143_.m_21120_(p_43144_); -- p_43142_.m_6263_((Player)null, p_43143_.m_20185_(), p_43143_.m_20186_(), p_43143_.m_20189_(), SoundEvents.f_12473_, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_43142_.m_5822_().nextFloat() * 0.4F + 0.8F)); + public InteractionResultHolder use(Level p_43142_, Player p_43143_, InteractionHand p_43144_) { + ItemStack itemstack = p_43143_.getItemInHand(p_43144_); +- p_43142_.playSound((Player)null, p_43143_.getX(), p_43143_.getY(), p_43143_.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_43142_.getRandom().nextFloat() * 0.4F + 0.8F)); + // CraftBukkit - moved down - if (!p_43142_.f_46443_) { + if (!p_43142_.isClientSide) { Snowball snowball = new Snowball(p_43142_, p_43143_); - snowball.m_37446_(itemstack); - snowball.m_37251_(p_43143_, p_43143_.m_146909_(), p_43143_.m_146908_(), 0.0F, 1.5F, 1.0F); -- p_43142_.m_7967_(snowball); + snowball.setItem(itemstack); + snowball.shootFromRotation(p_43143_, p_43143_.getXRot(), p_43143_.getYRot(), 0.0F, 1.5F, 1.0F); +- p_43142_.addFreshEntity(snowball); + -+ if (p_43142_.m_7967_(snowball)) { -+ if (!p_43143_.m_150110_().f_35937_) { -+ itemstack.m_41774_(1); ++ if (p_43142_.addFreshEntity(snowball)) { ++ if (!p_43143_.getAbilities().instabuild) { ++ itemstack.shrink(1); + } -+ p_43142_.m_6263_((Player)null, p_43143_.m_20185_(), p_43143_.m_20186_(), p_43143_.m_20189_(), SoundEvents.f_12473_, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_43142_.m_5822_().nextFloat() * 0.4F + 0.8F)); ++ p_43142_.playSound((Player)null, p_43143_.getX(), p_43143_.getY(), p_43143_.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (p_43142_.getRandom().nextFloat() * 0.4F + 0.8F)); + } else if (p_43143_ instanceof net.minecraft.server.level.ServerPlayer) { + ((net.minecraft.server.level.ServerPlayer) p_43143_).getBukkitEntity().updateInventory(); + } } + // CraftBukkit end - p_43143_.m_36246_(Stats.f_12982_.m_12902_(this)); -- if (!p_43143_.m_150110_().f_35937_) { -- itemstack.m_41774_(1); + p_43143_.awardStat(Stats.ITEM_USED.get(this)); + /* CraftBukkit - moved up -+ if (!p_43143_.getAbilities().instabuild) { -+ itemstack.shrink(1); + if (!p_43143_.getAbilities().instabuild) { + itemstack.shrink(1); } - + */ - return InteractionResultHolder.m_19092_(itemstack, p_43142_.m_5776_()); + return InteractionResultHolder.sidedSuccess(itemstack, p_43142_.isClientSide()); } } diff --git a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch index 40455c32..6d46f171 100644 --- a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java @@ -39,11 +_,14 @@ - private final int f_151201_; - private final EntityType f_43204_; + private final int highlightColor; + private final EntityType defaultType; + /** @deprecated Forge: Use {@link net.minecraftforge.common.ForgeSpawnEggItem} instead for suppliers */ + @Deprecated public SpawnEggItem(EntityType p_43207_, int p_43208_, int p_43209_, Item.Properties p_43210_) { super(p_43210_); - this.f_43204_ = p_43207_; - this.f_151200_ = p_43208_; - this.f_151201_ = p_43209_; + this.defaultType = p_43207_; + this.backgroundColor = p_43208_; + this.highlightColor = p_43209_; + if (p_43207_ != null) - f_43201_.put(p_43207_, this); + BY_ID.put(p_43207_, this); } @@ -125,6 +_,8 @@ - return p_43212_ == 0 ? this.f_151200_ : this.f_151201_; + return p_43212_ == 0 ? this.backgroundColor : this.highlightColor; } + /** @deprecated Forge: call {@link net.minecraftforge.common.ForgeSpawnEggItem#fromEntityType(EntityType)} instead */ + @Deprecated @Nullable - public static SpawnEggItem m_43213_(@Nullable EntityType p_43214_) { - return f_43201_.get(p_43214_); + public static SpawnEggItem byId(@Nullable EntityType p_43214_) { + return BY_ID.get(p_43214_); @@ -164,7 +_,8 @@ return Optional.empty(); } else { - mob.m_7678_(p_43220_.m_7096_(), p_43220_.m_7098_(), p_43220_.m_7094_(), 0.0F, 0.0F); -- p_43219_.m_47205_(mob); + mob.moveTo(p_43220_.x(), p_43220_.y(), p_43220_.z(), 0.0F, 0.0F); +- p_43219_.addFreshEntityWithPassengers(mob); + p_43219_.prepareEntity(mob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); //Magma - add spawn reason -+ p_43219_.m_7967_(mob); - if (p_43221_.m_41788_()) { - mob.m_6593_(p_43221_.m_41786_()); ++ p_43219_.addFreshEntity(mob); + if (p_43221_.hasCustomHoverName()) { + mob.setCustomName(p_43221_.getHoverName()); } diff --git a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch index b2f8cd30..723f5f73 100644 --- a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java @@ -42,4 +_,9 @@ - super.m_6192_(p_43252_, p_43253_); - p_43252_.put(this.f_43246_, p_43253_); + super.registerBlocks(p_43252_, p_43253_); + p_43252_.put(this.wallBlock, p_43253_); } + + public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { + super.removeFromBlockToItemMap(blockToItemMap, itemIn); -+ blockToItemMap.remove(this.f_43246_); ++ blockToItemMap.remove(this.wallBlock); + } } diff --git a/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch b/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch index a7b45f95..45fc44cb 100644 --- a/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/item/SuspiciousStewItem.java +++ b/net/minecraft/world/item/SuspiciousStewItem.java @@ -22,6 +_,7 @@ - ListTag listtag = compoundtag.m_128437_("Effects", 9); + ListTag listtag = compoundtag.getList("Effects", 9); CompoundTag compoundtag1 = new CompoundTag(); - compoundtag1.m_128344_("EffectId", (byte)MobEffect.m_19459_(p_43260_)); + compoundtag1.putByte("EffectId", (byte)MobEffect.getId(p_43260_)); + net.minecraftforge.common.ForgeHooks.saveMobEffect(compoundtag1, "forge:effect_if", p_43260_); - compoundtag1.m_128405_("EffectDuration", p_43261_); + compoundtag1.putInt("EffectDuration", p_43261_); listtag.add(compoundtag1); - compoundtag.m_128365_("Effects", listtag); + compoundtag.put("Effects", listtag); @@ -41,6 +_,7 @@ } - MobEffect mobeffect = MobEffect.m_19453_(compoundtag1.m_128445_("EffectId")); + MobEffect mobeffect = MobEffect.byId(compoundtag1.getByte("EffectId")); + mobeffect = net.minecraftforge.common.ForgeHooks.loadMobEffect(compoundtag1, "forge:effect_id", mobeffect); if (mobeffect != null) { - p_43265_.m_7292_(new MobEffectInstance(mobeffect, j)); + p_43265_.addEffect(new MobEffectInstance(mobeffect, j)); } diff --git a/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch b/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch index 7980a356..82c08666 100644 --- a/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/SwordItem.java +++ b/net/minecraft/world/item/SwordItem.java @@ -70,4 +_,9 @@ - public Multimap m_7167_(EquipmentSlot p_43274_) { - return p_43274_ == EquipmentSlot.MAINHAND ? this.f_43267_ : super.m_7167_(p_43274_); + public Multimap getDefaultAttributeModifiers(EquipmentSlot p_43274_) { + return p_43274_ == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getDefaultAttributeModifiers(p_43274_); } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/Tier.java.patch b/patches/minecraft/net/minecraft/world/item/Tier.java.patch index 75fb95b6..abe781e2 100644 --- a/patches/minecraft/net/minecraft/world/item/Tier.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Tier.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/world/item/Tier.java @@ -9,9 +_,12 @@ - float m_6631_(); + float getAttackDamageBonus(); + @Deprecated // FORGE: Use TierSortingRegistry to define which tiers are better than others - int m_6604_(); + int getLevel(); - int m_6601_(); + int getEnchantmentValue(); - Ingredient m_6282_(); + Ingredient getRepairIngredient(); + + @javax.annotation.Nullable default net.minecraft.tags.TagKey getTag() { return null; } } diff --git a/patches/minecraft/net/minecraft/world/item/Tiers.java.patch b/patches/minecraft/net/minecraft/world/item/Tiers.java.patch index 4db0e19a..bf04bc46 100644 --- a/patches/minecraft/net/minecraft/world/item/Tiers.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Tiers.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/Tiers.java +++ b/net/minecraft/world/item/Tiers.java @@ -64,4 +_,6 @@ - public Ingredient m_6282_() { - return this.f_43326_.m_13971_(); + public Ingredient getRepairIngredient() { + return this.repairIngredient.get(); } + + @javax.annotation.Nullable public net.minecraft.tags.TagKey getTag() { return net.minecraftforge.common.ForgeHooks.getTagFromVanillaTier(this); } diff --git a/patches/minecraft/net/minecraft/world/item/TridentItem.java.patch b/patches/minecraft/net/minecraft/world/item/TridentItem.java.patch index b667a007..6c1c808f 100644 --- a/patches/minecraft/net/minecraft/world/item/TridentItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/TridentItem.java.patch @@ -1,56 +1,54 @@ --- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java @@ -59,9 +_,11 @@ - int j = EnchantmentHelper.m_44932_(p_43394_); - if (j <= 0 || player.m_20070_()) { - if (!p_43395_.f_46443_) { -- p_43394_.m_41622_(1, player, (p_43388_) -> { -- p_43388_.m_21190_(p_43396_.m_7655_()); + int j = EnchantmentHelper.getRiptide(p_43394_); + if (j <= 0 || player.isInWaterOrRain()) { + if (!p_43395_.isClientSide) { + /* CraftBukkit - moved down -+ p_43394_.hurtAndBreak(1, player, (p_43388_) -> { -+ p_43388_.broadcastBreakEvent(p_43396_.getUsedItemHand()); + p_43394_.hurtAndBreak(1, player, (p_43388_) -> { + p_43388_.broadcastBreakEvent(p_43396_.getUsedItemHand()); }); + */ if (j == 0) { ThrownTrident throwntrident = new ThrownTrident(p_43395_, player, p_43394_); - throwntrident.m_37251_(player, player.m_146909_(), player.m_146908_(), 0.0F, 2.5F + (float)j * 0.5F, 1.0F); + throwntrident.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, 2.5F + (float)j * 0.5F, 1.0F); @@ -69,16 +_,38 @@ - throwntrident.f_36705_ = AbstractArrow.Pickup.CREATIVE_ONLY; + throwntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; } -- p_43395_.m_7967_(throwntrident); +- p_43395_.addFreshEntity(throwntrident); + // CraftBukkit start -+ if (!p_43395_.m_7967_(throwntrident)) { ++ if (!p_43395_.addFreshEntity(throwntrident)) { + if (player instanceof net.minecraft.server.level.ServerPlayer) { + ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().updateInventory(); + } + return; + } -+ p_43394_.m_41622_(1, player, (p_43388_) -> { -+ p_43388_.m_21190_(p_43396_.m_7655_()); ++ p_43394_.hurtAndBreak(1, player, (p_43388_) -> { ++ p_43388_.broadcastBreakEvent(p_43396_.getUsedItemHand()); + }); -+ throwntrident.f_37555_ = p_43394_.m_41777_(); // SPIGOT-4511 update since damage call moved ++ throwntrident.tridentItem = p_43394_.copy(); // SPIGOT-4511 update since damage call moved + // CraftBukkit end + - p_43395_.m_6269_((Player)null, throwntrident, SoundEvents.f_12520_, SoundSource.PLAYERS, 1.0F, 1.0F); - if (!player.m_150110_().f_35937_) { - player.m_150109_().m_36057_(p_43394_); + p_43395_.playSound((Player)null, throwntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F); + if (!player.getAbilities().instabuild) { + player.getInventory().removeItem(p_43394_); } + // CraftBukkit start - SPIGOT-5458 also need in this branch :( + } else { -+ p_43394_.m_41622_(1, player, (entityhuman1) -> { -+ entityhuman1.m_21190_(p_43396_.m_7655_()); ++ p_43394_.hurtAndBreak(1, player, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(p_43396_.getUsedItemHand()); + }); + // CraftBukkkit end } } - player.m_36246_(Stats.f_12982_.m_12902_(this)); + player.awardStat(Stats.ITEM_USED.get(this)); if (j > 0) { + // CraftBukkit start + org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_43394_)); + event.getPlayer().getServer().getPluginManager().callEvent(event); + // CraftBukkit end - float f7 = player.m_146908_(); - float f = player.m_146909_(); - float f1 = -Mth.m_14031_(f7 * ((float)Math.PI / 180F)) * Mth.m_14089_(f * ((float)Math.PI / 180F)); + float f7 = player.getYRot(); + float f = player.getXRot(); + float f1 = -Mth.sin(f7 * ((float)Math.PI / 180F)) * Mth.cos(f * ((float)Math.PI / 180F)); diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch index c4ade901..bfd1eb50 100644 --- a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch +++ b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch @@ -7,5 +7,5 @@ -public class Potion { +public class Potion extends net.minecraftforge.registries.ForgeRegistryEntry { @Nullable - private final String f_43481_; - private final ImmutableList f_43482_; + private final String name; + private final ImmutableList effects; diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch index 0ff07b68..4ff6e607 100644 --- a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch +++ b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -3,70 +3,70 @@ @@ -57,7 +_,7 @@ int i = 0; - for(int j = f_43494_.size(); i < j; ++i) { -- if ((f_43494_.get(i)).f_43534_ == p_43512_) { -+ if ((f_43494_.get(i)).f_43534_.get() == p_43512_) { + for(int j = POTION_MIXES.size(); i < j; ++i) { +- if ((POTION_MIXES.get(i)).to == p_43512_) { ++ if ((POTION_MIXES.get(i)).to.get() == p_43512_) { return true; } } @@ -79,7 +_,7 @@ - for(int j = f_43495_.size(); i < j; ++i) { - PotionBrewing.Mix mix = f_43495_.get(i); -- if (mix.f_43532_ == item && mix.f_43533_.test(p_43521_)) { -+ if (mix.f_43532_.get() == item && mix.f_43533_.test(p_43521_)) { + for(int j = CONTAINER_MIXES.size(); i < j; ++i) { + PotionBrewing.Mix mix = CONTAINER_MIXES.get(i); +- if (mix.from == item && mix.ingredient.test(p_43521_)) { ++ if (mix.from.get() == item && mix.ingredient.test(p_43521_)) { return true; } } @@ -93,7 +_,7 @@ - for(int j = f_43494_.size(); i < j; ++i) { - PotionBrewing.Mix mix = f_43494_.get(i); -- if (mix.f_43532_ == potion && mix.f_43533_.test(p_43526_)) { -+ if (mix.f_43532_.get() == potion && mix.f_43533_.test(p_43526_)) { + for(int j = POTION_MIXES.size(); i < j; ++i) { + PotionBrewing.Mix mix = POTION_MIXES.get(i); +- if (mix.from == potion && mix.ingredient.test(p_43526_)) { ++ if (mix.from.get() == potion && mix.ingredient.test(p_43526_)) { return true; } } @@ -109,8 +_,8 @@ - for(int j = f_43495_.size(); i < j; ++i) { - PotionBrewing.Mix mix = f_43495_.get(i); -- if (mix.f_43532_ == item && mix.f_43533_.test(p_43530_)) { -- return PotionUtils.m_43549_(new ItemStack(mix.f_43534_), potion); -+ if (mix.f_43532_.get() == item && mix.f_43533_.test(p_43530_)) { -+ return PotionUtils.m_43549_(new ItemStack(mix.f_43534_.get()), potion); + for(int j = CONTAINER_MIXES.size(); i < j; ++i) { + PotionBrewing.Mix mix = CONTAINER_MIXES.get(i); +- if (mix.from == item && mix.ingredient.test(p_43530_)) { +- return PotionUtils.setPotion(new ItemStack(mix.to), potion); ++ if (mix.from.get() == item && mix.ingredient.test(p_43530_)) { ++ return PotionUtils.setPotion(new ItemStack(mix.to.get()), potion); } } @@ -118,8 +_,8 @@ - for(int k = f_43494_.size(); i < k; ++i) { - PotionBrewing.Mix mix1 = f_43494_.get(i); -- if (mix1.f_43532_ == potion && mix1.f_43533_.test(p_43530_)) { -- return PotionUtils.m_43549_(new ItemStack(item), mix1.f_43534_); -+ if (mix1.f_43532_.get() == potion && mix1.f_43533_.test(p_43530_)) { -+ return PotionUtils.m_43549_(new ItemStack(item), mix1.f_43534_.get()); + for(int k = POTION_MIXES.size(); i < k; ++i) { + PotionBrewing.Mix mix1 = POTION_MIXES.get(i); +- if (mix1.from == potion && mix1.ingredient.test(p_43530_)) { +- return PotionUtils.setPotion(new ItemStack(item), mix1.to); ++ if (mix1.from.get() == potion && mix1.ingredient.test(p_43530_)) { ++ return PotionUtils.setPotion(new ItemStack(item), mix1.to.get()); } } } @@ -212,15 +_,15 @@ - f_43494_.add(new PotionBrewing.Mix<>(p_43514_, Ingredient.m_43929_(p_43515_), p_43516_)); + POTION_MIXES.add(new PotionBrewing.Mix<>(p_43514_, Ingredient.of(p_43515_), p_43516_)); } - public static class Mix { -- final T f_43532_; +- final T from; + public static class Mix> { -+ public final net.minecraftforge.registries.IRegistryDelegate f_43532_; - public final Ingredient f_43533_; -- final T f_43534_; -+ public final net.minecraftforge.registries.IRegistryDelegate f_43534_; ++ public final net.minecraftforge.registries.IRegistryDelegate from; + public final Ingredient ingredient; +- final T to; ++ public final net.minecraftforge.registries.IRegistryDelegate to; public Mix(T p_43536_, Ingredient p_43537_, T p_43538_) { -- this.f_43532_ = p_43536_; -+ this.f_43532_ = p_43536_.delegate; - this.f_43533_ = p_43537_; -- this.f_43534_ = p_43538_; -+ this.f_43534_ = p_43538_.delegate; +- this.from = p_43536_; ++ this.from = p_43536_.delegate; + this.ingredient = p_43537_; +- this.to = p_43538_; ++ this.to = p_43538_.delegate; } } } 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 ec057917..43e422be 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java @@ -81,8 +_,8 @@ for(int i = 0; i < nonnulllist.size(); ++i) { - ItemStack itemstack = p_43791_.m_8020_(i); - if (!itemstack.m_41619_()) { -- if (itemstack.m_41720_().m_41470_()) { -- nonnulllist.set(i, new ItemStack(itemstack.m_41720_().m_41469_())); + ItemStack itemstack = p_43791_.getItem(i); + if (!itemstack.isEmpty()) { +- if (itemstack.getItem().hasCraftingRemainingItem()) { +- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); + if (itemstack.hasContainerItem()) { + nonnulllist.set(i, itemstack.getContainerItem()); - } else if (itemstack.m_41782_() && BannerBlockEntity.m_58504_(itemstack) > 0) { - ItemStack itemstack1 = itemstack.m_41777_(); - itemstack1.m_41764_(1); + } else if (itemstack.hasTag() && BannerBlockEntity.getPatternCount(itemstack) > 0) { + ItemStack itemstack1 = itemstack.copy(); + itemstack1.setCount(1); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BlastingRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BlastingRecipe.java.patch index 31b23443..86c71f0b 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BlastingRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BlastingRecipe.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/crafting/BlastingRecipe.java +++ b/net/minecraft/world/item/crafting/BlastingRecipe.java @@ -16,4 +_,15 @@ - public RecipeSerializer m_7707_() { - return RecipeSerializer.f_44092_; + public RecipeSerializer getSerializer() { + return RecipeSerializer.BLASTING_RECIPE; } + + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_43730_); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlastingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlastingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.f_43727_), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_43729_), this.f_43731_, this.f_43732_); -+ recipe.setGroup(this.f_43728_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlastingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlastingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.id), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); + return recipe; + } + // CraftBukkit end 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 49d15ffc..4f856730 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -3,11 +3,11 @@ @@ -79,8 +_,8 @@ for(int i = 0; i < nonnulllist.size(); ++i) { - ItemStack itemstack = p_43820_.m_8020_(i); -- if (itemstack.m_41720_().m_41470_()) { -- nonnulllist.set(i, new ItemStack(itemstack.m_41720_().m_41469_())); + ItemStack itemstack = p_43820_.getItem(i); +- if (itemstack.getItem().hasCraftingRemainingItem()) { +- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); + if (itemstack.hasContainerItem()) { + nonnulllist.set(i, itemstack.getContainerItem()); - } else if (itemstack.m_41720_() instanceof WrittenBookItem) { - ItemStack itemstack1 = itemstack.m_41777_(); - itemstack1.m_41764_(1); + } else if (itemstack.getItem() instanceof WrittenBookItem) { + ItemStack itemstack1 = itemstack.copy(); + itemstack1.setCount(1); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch index cadeec9a..fe5e668a 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/crafting/CampfireCookingRecipe.java +++ b/net/minecraft/world/item/crafting/CampfireCookingRecipe.java @@ -16,4 +_,15 @@ - public RecipeSerializer m_7707_() { - return RecipeSerializer.f_44094_; + public RecipeSerializer getSerializer() { + return RecipeSerializer.CAMPFIRE_COOKING_RECIPE; } + + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_43730_); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftCampfireRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftCampfireRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.f_43727_), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_43729_), this.f_43731_, this.f_43732_); -+ recipe.setGroup(this.f_43728_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftCampfireRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftCampfireRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.id), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); + return recipe; + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/item/crafting/CustomRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/CustomRecipe.java.patch index e35713b5..f1e1ff26 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/CustomRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/CustomRecipe.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/CustomRecipe.java +++ b/net/minecraft/world/item/crafting/CustomRecipe.java @@ -21,4 +_,12 @@ - public ItemStack m_8043_() { - return ItemStack.f_41583_; + public ItemStack getResultItem() { + return ItemStack.EMPTY; } + + // CraftBukkit start 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 b9eea3f5..6836cad5 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -10,58 +10,58 @@ + INVALIDATION_COUNTER.incrementAndGet(); + } + - public static final Ingredient f_43901_ = new Ingredient(Stream.empty()); - private final Ingredient.Value[] f_43902_; + public static final Ingredient EMPTY = new Ingredient(Stream.empty()); + private final Ingredient.Value[] values; @Nullable - public ItemStack[] f_43903_; + public ItemStack[] itemStacks; @Nullable - private IntList f_43904_; + private IntList stackingIds; + private int invalidationCounter; + + public boolean exact; // Bukkit public Ingredient(Stream p_43907_) { - this.f_43902_ = p_43907_.toArray((p_43933_) -> { + this.values = p_43907_.toArray((p_43933_) -> { @@ -67,6 +_,16 @@ - return p_43914_.m_41619_(); + return p_43914_.isEmpty(); } else { - for(ItemStack itemstack : this.f_43903_) { + for(ItemStack itemstack : this.itemStacks) { + + // CraftBukkit start + if (exact) { -+ if (itemstack.m_41720_() == itemstack.m_41720_() && ItemStack.m_41658_(p_43914_, itemstack)) { ++ if (itemstack.getItem() == itemstack.getItem() && ItemStack.tagMatches(p_43914_, itemstack)) { + return true; + } + continue; + } + // CraftBukkit end + - if (itemstack.m_150930_(p_43914_.m_41720_())) { + if (itemstack.is(p_43914_.getItem())) { return true; } @@ -78,7 +_,8 @@ } - public IntList m_43931_() { -- if (this.f_43904_ == null) { -+ if (this.f_43904_ == null || checkInvalidation()) { + public IntList getStackingIds() { +- if (this.stackingIds == null) { ++ if (this.stackingIds == null || checkInvalidation()) { + this.markValid(); - this.m_43948_(); - this.f_43904_ = new IntArrayList(this.f_43903_.length); + this.dissolve(); + this.stackingIds = new IntArrayList(this.itemStacks.length); @@ -94,6 +_,10 @@ - public final void m_43923_(FriendlyByteBuf p_43924_) { - this.m_43948_(); + public final void toNetwork(FriendlyByteBuf p_43924_) { + this.dissolve(); + if (!this.isVanilla()) { + net.minecraftforge.common.crafting.CraftingHelper.write(p_43924_, this); + return; + } - p_43924_.m_178352_(Arrays.asList(this.f_43903_), FriendlyByteBuf::m_130055_); + p_43924_.writeCollection(Arrays.asList(this.itemStacks), FriendlyByteBuf::writeItem); } @@ -115,6 +_,38 @@ - return this.f_43902_.length == 0 && (this.f_43903_ == null || this.f_43903_.length == 0) && (this.f_43904_ == null || this.f_43904_.isEmpty()); + return this.values.length == 0 && (this.itemStacks == null || this.itemStacks.length == 0) && (this.stackingIds == null || this.stackingIds.isEmpty()); } + public final boolean checkInvalidation() { @@ -78,8 +78,8 @@ + } + + protected void invalidate() { -+ this.f_43903_ = null; -+ this.f_43904_ = null; ++ this.itemStacks = null; ++ this.stackingIds = null; + } + + public boolean isSimple() { @@ -96,25 +96,25 @@ + return net.minecraftforge.common.crafting.VanillaIngredientSerializer.INSTANCE; + } + - public static Ingredient m_43938_(Stream p_43939_) { + public static Ingredient fromValues(Stream p_43939_) { Ingredient ingredient = new Ingredient(p_43939_); - return ingredient.f_43902_.length == 0 ? f_43901_ : ingredient; + return ingredient.values.length == 0 ? EMPTY : ingredient; @@ -143,11 +_,15 @@ } - public static Ingredient m_43940_(FriendlyByteBuf p_43941_) { -- return m_43938_(p_43941_.m_178366_(FriendlyByteBuf::m_130267_).stream().map(Ingredient.ItemValue::new)); -+ var size = p_43941_.m_130242_(); -+ if (size == -1) return net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_43941_.m_130281_(), p_43941_); -+ return m_43938_(Stream.generate(() -> new Ingredient.ItemValue(p_43941_.m_130267_())).limit(size)); + public static Ingredient fromNetwork(FriendlyByteBuf p_43941_) { +- return fromValues(p_43941_.readList(FriendlyByteBuf::readItem).stream().map(Ingredient.ItemValue::new)); ++ var size = p_43941_.readVarInt(); ++ if (size == -1) return net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_43941_.readResourceLocation(), p_43941_); ++ return fromValues(Stream.generate(() -> new Ingredient.ItemValue(p_43941_.readItem())).limit(size)); } - public static Ingredient m_43917_(@Nullable JsonElement p_43918_) { + public static Ingredient fromJson(@Nullable JsonElement p_43918_) { if (p_43918_ != null && !p_43918_.isJsonNull()) { + Ingredient ret = net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_43918_); + if (ret != null) return ret; if (p_43918_.isJsonObject()) { - return m_43938_(Stream.of(m_43919_(p_43918_.getAsJsonObject()))); + return fromValues(Stream.of(valueFromJson(p_43918_.getAsJsonObject()))); } else if (p_43918_.isJsonArray()) { @@ -182,6 +_,12 @@ } @@ -123,18 +123,18 @@ + //Merges several vanilla Ingredients together. As a quirk of how the json is structured, we can't tell if its a single Ingredient type or multiple so we split per item and re-merge here. + //Only public for internal use, so we can access a private field in here. + public static Ingredient merge(Collection parts) { -+ return m_43938_(parts.stream().flatMap(i -> Arrays.stream(i.f_43902_))); ++ return fromValues(parts.stream().flatMap(i -> Arrays.stream(i.values))); + } + public static class ItemValue implements Ingredient.Value { - private final ItemStack f_43951_; + private final ItemStack item; @@ -214,6 +_,9 @@ list.add(new ItemStack(holder)); } + if (list.size() == 0 && !net.minecraftforge.common.ForgeConfig.SERVER.treatEmptyTagsAsAir.get()) { -+ list.add(new ItemStack(net.minecraft.world.level.block.Blocks.f_50375_).m_41714_(new net.minecraft.network.chat.TextComponent("Empty Tag: " + this.f_43959_.f_203868_()))); ++ list.add(new ItemStack(net.minecraft.world.level.block.Blocks.BARRIER).setHoverName(new net.minecraft.network.chat.TextComponent("Empty Tag: " + this.tag.location()))); + } 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 index fd79cda5..55f0431e 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/item/crafting/Recipe.java +++ b/net/minecraft/world/item/crafting/Recipe.java @@ -21,9 +_,9 @@ - NonNullList nonnulllist = NonNullList.m_122780_(p_44004_.m_6643_(), ItemStack.f_41583_); + NonNullList nonnulllist = NonNullList.withSize(p_44004_.getContainerSize(), ItemStack.EMPTY); for(int i = 0; i < nonnulllist.size(); ++i) { -- Item item = p_44004_.m_8020_(i).m_41720_(); -- if (item.m_41470_()) { -- nonnulllist.set(i, new ItemStack(item.m_41469_())); -+ ItemStack item = p_44004_.m_8020_(i); +- Item item = p_44004_.getItem(i).getItem(); +- if (item.hasCraftingRemainingItem()) { +- nonnulllist.set(i, new ItemStack(item.getCraftingRemainingItem())); ++ ItemStack item = p_44004_.getItem(i); + if (item.hasContainerItem()) { + nonnulllist.set(i, item.getContainerItem()); } } @@ -55,7 +_,11 @@ - default boolean m_142505_() { - NonNullList nonnulllist = this.m_7527_(); + default boolean isIncomplete() { + NonNullList nonnulllist = this.getIngredients(); return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch((p_151268_) -> { -- return p_151268_.m_43908_().length == 0; +- return p_151268_.getItems().length == 0; + return net.minecraftforge.common.ForgeHooks.hasNoElements(p_151268_); }); } 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 d5351140..d04f8d7d 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 @@ -37,45 +_,101 @@ - public Map, Map>> f_44007_ = ImmutableMap.of(); - private Map> f_199900_ = ImmutableMap.of(); - private boolean f_44008_; + public Map, Map>> recipes = ImmutableMap.of(); + private Map> byName = ImmutableMap.of(); + private boolean hasErrors; + 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}. */ @@ -13,143 +13,143 @@ + } + + public RecipeManager(net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { - super(f_44005_, "recipes"); + super(GSON, "recipes"); + this.context = context; } - protected void m_5787_(Map p_44037_, ResourceManager p_44038_, ProfilerFiller p_44039_) { - this.f_44008_ = false; + protected void apply(Map p_44037_, ResourceManager p_44038_, ProfilerFiller p_44039_) { + this.hasErrors = false; - Map, Builder>> map = Maps.newHashMap(); + Map, it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>> map = Maps.newHashMap(); Builder> builder = ImmutableMap.builder(); + + // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable + Map, it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>> map1 = Maps.newHashMap(); -+ for (RecipeType recipeType : Registry.f_122864_) { ++ for (RecipeType recipeType : Registry.RECIPE_TYPE) { + map1.put(recipeType, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); + } + // CraftBukkit end for(Entry entry : p_44037_.entrySet()) { ResourceLocation resourcelocation = entry.getKey(); -+ if (resourcelocation.m_135815_().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. ++ if (resourcelocation.getPath().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. try { -- Recipe recipe = m_44045_(resourcelocation, GsonHelper.m_13918_(entry.getValue(), "top element")); -- map.computeIfAbsent(recipe.m_6671_(), (p_44075_) -> { +- Recipe recipe = fromJson(resourcelocation, GsonHelper.convertToJsonObject(entry.getValue(), "top element")); +- map.computeIfAbsent(recipe.getType(), (p_44075_) -> { - return ImmutableMap.builder(); - }).put(resourcelocation, recipe); + if (entry.getValue().isJsonObject() && !net.minecraftforge.common.crafting.CraftingHelper.processConditions(entry.getValue().getAsJsonObject(), "conditions", this.context)) { -+ f_44006_.debug("Skipping loading recipe {} as it's conditions were not met", resourcelocation); ++ LOGGER.debug("Skipping loading recipe {} as it's conditions were not met", resourcelocation); + continue; + } -+ Recipe recipe = fromJson(resourcelocation, GsonHelper.m_13918_(entry.getValue(), "top element"), this.context); ++ Recipe recipe = fromJson(resourcelocation, GsonHelper.convertToJsonObject(entry.getValue(), "top element"), this.context); + if (recipe == null) { -+ f_44006_.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation); ++ LOGGER.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation); + continue; + } + // Magma start -+ map.computeIfAbsent(recipe.m_6671_(), (recipeType) -> new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()) ++ map.computeIfAbsent(recipe.getType(), (recipeType) -> new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()) + .putAndMoveToFirst(resourcelocation, recipe); + // Magma end builder.put(resourcelocation, recipe); } catch (IllegalArgumentException | JsonParseException jsonparseexception) { - f_44006_.error("Parsing error loading recipe {}", resourcelocation, jsonparseexception); + LOGGER.error("Parsing error loading recipe {}", resourcelocation, jsonparseexception); } } -- this.f_44007_ = map.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (p_44033_) -> { +- this.recipes = map.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (p_44033_) -> { - return p_44033_.getValue().build(); - })); -- this.f_199900_ = builder.build(); -+ this.f_44007_ = (Map) map; // Magma -+ this.f_199900_ = Maps.newHashMap(builder.build()); // CraftBukkit - f_44006_.info("Loaded {} recipes", (int)map.size()); +- this.byName = builder.build(); ++ this.recipes = (Map) map; // Magma ++ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit + LOGGER.info("Loaded {} recipes", (int)map.size()); } + // CraftBukkit start - Magma Start + public void addRecipe(Recipe recipe) { + org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot -+ if (this.f_44007_ instanceof ImmutableMap) { -+ this.f_44007_ = new java.util.HashMap<>(f_44007_); ++ if (this.recipes instanceof ImmutableMap) { ++ this.recipes = new java.util.HashMap<>(recipes); + } -+ if (this.f_199900_ instanceof ImmutableMap) { -+ this.f_199900_ = new java.util.HashMap<>(f_199900_); ++ if (this.byName instanceof ImmutableMap) { ++ this.byName = new java.util.HashMap<>(byName); + } -+ Map> original = this.f_44007_.get(recipe.m_6671_()); ++ Map> original = this.recipes.get(recipe.getType()); + it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap> map; + if (!(original instanceof it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap)) { + it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap> hashMap = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); + hashMap.putAll(original); -+ this.f_44007_.put(recipe.m_6671_(), hashMap); ++ this.recipes.put(recipe.getType(), hashMap); + map = hashMap; + } else { + map = ((it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>) original); + } + -+ if (this.f_199900_.containsKey(recipe.m_6423_()) || map.containsKey(recipe.m_6423_())) { -+ throw new IllegalStateException("Duplicate recipe ignored with ID " + recipe.m_6423_()); ++ if (this.byName.containsKey(recipe.getId()) || map.containsKey(recipe.getId())) { ++ throw new IllegalStateException("Duplicate recipe ignored with ID " + recipe.getId()); + } else { -+ map.putAndMoveToFirst(recipe.m_6423_(), recipe); -+ this.f_199900_.put(recipe.m_6423_(), recipe); ++ map.putAndMoveToFirst(recipe.getId(), recipe); ++ this.byName.put(recipe.getId(), recipe); + } + } + // CraftBukkit end - Magma End + - public boolean m_151269_() { - return this.f_44008_; + public boolean hadErrorsLoading() { + return this.hasErrors; } - public > Optional m_44015_(RecipeType p_44016_, C p_44017_, Level p_44018_) { -- return this.m_44054_(p_44016_).values().stream().flatMap((p_44064_) -> { + public > Optional getRecipeFor(RecipeType p_44016_, C p_44017_, Level p_44018_) { +- return this.byType(p_44016_).values().stream().flatMap((p_44064_) -> { + // CraftBukkit start -+ Optional recipe = this.m_44054_(p_44016_).values().stream().flatMap((p_44064_) -> { - return p_44016_.m_44115_(p_44064_, p_44018_, p_44017_).stream(); ++ Optional recipe = this.byType(p_44016_).values().stream().flatMap((p_44064_) -> { + return p_44016_.tryMatch(p_44064_, p_44018_, p_44017_).stream(); }).findFirst(); + p_44017_.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found + // CraftBukkit end + return recipe; } - public > List m_44013_(RecipeType p_44014_) { + public > List getAllRecipesFor(RecipeType p_44014_) { @@ -127,11 +_,17 @@ }); } + /** @deprecated Forge: use {@linkplain #fromJson(ResourceLocation, JsonObject, net.minecraftforge.common.crafting.conditions.ICondition.IContext) overload with context}. */ + @Deprecated - public static Recipe m_44045_(ResourceLocation p_44046_, JsonObject p_44047_) { + public static Recipe fromJson(ResourceLocation p_44046_, JsonObject p_44047_) { + return fromJson(p_44046_, p_44047_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY); + } + + public static Recipe fromJson(ResourceLocation p_44046_, JsonObject p_44047_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { - String s = GsonHelper.m_13906_(p_44047_, "type"); - return Registry.f_122865_.m_6612_(new ResourceLocation(s)).orElseThrow(() -> { + String s = GsonHelper.getAsString(p_44047_, "type"); + return Registry.RECIPE_SERIALIZER.getOptional(new ResourceLocation(s)).orElseThrow(() -> { return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'"); -- }).m_6729_(p_44046_, p_44047_); +- }).fromJson(p_44046_, p_44047_); + }).fromJson(p_44046_, p_44047_, context); } - public void m_44024_(Iterable> p_44025_) { + public void replaceRecipes(Iterable> p_44025_) { @@ -152,4 +_,21 @@ - this.f_44007_ = ImmutableMap.copyOf(map); - this.f_199900_ = builder.build(); + this.recipes = ImmutableMap.copyOf(map); + this.byName = builder.build(); } + + // CraftBukkit start + public boolean removeRecipe(ResourceLocation mcKey) { -+ for (Map> recipes : f_44007_.values()) { ++ for (Map> recipes : recipes.values()) { + recipes.remove(mcKey); + } -+ return f_199900_.remove(mcKey) != null; ++ return byName.remove(mcKey) != null; + } + + public void clearRecipes() { -+ this.f_44007_ = Maps.newHashMap(); -+ for (RecipeType recipeType : Registry.f_122864_) { -+ this.f_44007_.put(recipeType, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); ++ this.recipes = Maps.newHashMap(); ++ for (RecipeType recipeType : Registry.RECIPE_TYPE) { ++ this.recipes.put(recipeType, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); + } -+ this.f_199900_ = Maps.newHashMap(); ++ this.byName = Maps.newHashMap(); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch index cb6936df..9be09684 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch @@ -6,17 +6,17 @@ -public interface RecipeSerializer> { +public interface RecipeSerializer> extends net.minecraftforge.registries.IForgeRegistryEntry>, net.minecraftforge.common.extensions.IForgeRecipeSerializer { - RecipeSerializer f_44076_ = m_44098_("crafting_shaped", new ShapedRecipe.Serializer()); - RecipeSerializer f_44077_ = m_44098_("crafting_shapeless", new ShapelessRecipe.Serializer()); - SimpleRecipeSerializer f_44078_ = m_44098_("crafting_special_armordye", new SimpleRecipeSerializer<>(ArmorDyeRecipe::new)); + RecipeSerializer SHAPED_RECIPE = register("crafting_shaped", new ShapedRecipe.Serializer()); + RecipeSerializer SHAPELESS_RECIPE = register("crafting_shapeless", new ShapelessRecipe.Serializer()); + SimpleRecipeSerializer ARMOR_DYE = register("crafting_special_armordye", new SimpleRecipeSerializer<>(ArmorDyeRecipe::new)); @@ -28,8 +_,10 @@ - RecipeSerializer f_44095_ = m_44098_("stonecutting", new SingleItemRecipe.Serializer<>(StonecutterRecipe::new)); - RecipeSerializer f_44096_ = m_44098_("smithing", new UpgradeRecipe.Serializer()); + RecipeSerializer STONECUTTER = register("stonecutting", new SingleItemRecipe.Serializer<>(StonecutterRecipe::new)); + RecipeSerializer SMITHING = register("smithing", new UpgradeRecipe.Serializer()); + //Forge: use fromJson with IContext if you need the context - T m_6729_(ResourceLocation p_44103_, JsonObject p_44104_); + T fromJson(ResourceLocation p_44103_, JsonObject p_44104_); + @javax.annotation.Nullable - T m_8005_(ResourceLocation p_44105_, FriendlyByteBuf p_44106_); + T fromNetwork(ResourceLocation p_44105_, FriendlyByteBuf p_44106_); - void m_6178_(FriendlyByteBuf p_44101_, T p_44102_); + void toNetwork(FriendlyByteBuf p_44101_, T p_44102_); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch index 932886a2..7191dc12 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch @@ -4,8 +4,8 @@ list.add(itemstack); if (list.size() > 1) { ItemStack itemstack1 = list.get(0); -- if (!itemstack.m_150930_(itemstack1.m_41720_()) || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.m_41720_().m_41465_()) { -+ if (itemstack.m_41720_() != itemstack1.m_41720_() || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.isRepairable()) { +- if (!itemstack.is(itemstack1.getItem()) || itemstack1.getCount() != 1 || itemstack.getCount() != 1 || !itemstack1.getItem().canBeDepleted()) { ++ if (itemstack.getItem() != itemstack1.getItem() || itemstack1.getCount() != 1 || itemstack.getCount() != 1 || !itemstack1.isRepairable()) { return false; } } @@ -13,26 +13,26 @@ list.add(itemstack); if (list.size() > 1) { ItemStack itemstack1 = list.get(0); -- if (!itemstack.m_150930_(itemstack1.m_41720_()) || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.m_41720_().m_41465_()) { -+ if (itemstack.m_41720_() != itemstack1.m_41720_() || itemstack1.m_41613_() != 1 || itemstack.m_41613_() != 1 || !itemstack1.isRepairable()) { - return ItemStack.f_41583_; +- if (!itemstack.is(itemstack1.getItem()) || itemstack1.getCount() != 1 || itemstack.getCount() != 1 || !itemstack1.getItem().canBeDepleted()) { ++ if (itemstack.getItem() != itemstack1.getItem() || itemstack1.getCount() != 1 || itemstack.getCount() != 1 || !itemstack1.isRepairable()) { + return ItemStack.EMPTY; } } @@ -56,12 +_,12 @@ if (list.size() == 2) { ItemStack itemstack3 = list.get(0); ItemStack itemstack4 = list.get(1); -- if (itemstack3.m_150930_(itemstack4.m_41720_()) && itemstack3.m_41613_() == 1 && itemstack4.m_41613_() == 1 && itemstack3.m_41720_().m_41465_()) { -+ if (itemstack3.m_41720_() == itemstack4.m_41720_() && itemstack3.m_41613_() == 1 && itemstack4.m_41613_() == 1 && itemstack3.isRepairable()) { - Item item = itemstack3.m_41720_(); -- int j = item.m_41462_() - itemstack3.m_41773_(); -- int k = item.m_41462_() - itemstack4.m_41773_(); -- int l = j + k + item.m_41462_() * 5 / 100; -- int i1 = item.m_41462_() - l; -+ int j = itemstack3.m_41776_() - itemstack3.m_41773_(); -+ int k = itemstack3.m_41776_() - itemstack4.m_41773_(); -+ int l = j + k + itemstack3.m_41776_() * 5 / 100; -+ int i1 = itemstack3.m_41776_() - l; +- if (itemstack3.is(itemstack4.getItem()) && itemstack3.getCount() == 1 && itemstack4.getCount() == 1 && itemstack3.getItem().canBeDepleted()) { ++ if (itemstack3.getItem() == itemstack4.getItem() && itemstack3.getCount() == 1 && itemstack4.getCount() == 1 && itemstack3.isRepairable()) { + Item item = itemstack3.getItem(); +- int j = item.getMaxDamage() - itemstack3.getDamageValue(); +- int k = item.getMaxDamage() - itemstack4.getDamageValue(); +- int l = j + k + item.getMaxDamage() * 5 / 100; +- int i1 = item.getMaxDamage() - l; ++ int j = itemstack3.getMaxDamage() - itemstack3.getDamageValue(); ++ int k = itemstack3.getMaxDamage() - itemstack4.getDamageValue(); ++ int l = j + k + itemstack3.getMaxDamage() * 5 / 100; ++ int i1 = itemstack3.getMaxDamage() - l; if (i1 < 0) { i1 = 0; } 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 a6656267..8456c7b7 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -19,21 +19,21 @@ + if (MAX_HEIGHT < height) MAX_HEIGHT = height; + } + - final int f_44146_; - final int f_44147_; - final NonNullList f_44148_; + final int width; + final int height; + final NonNullList recipeItems; @@ -39,6 +_,64 @@ - this.f_44149_ = p_44158_; + this.result = p_44158_; } + // CraftBukkit start + public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_44149_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftShapedRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftShapedRecipe(result, this); -+ recipe.setGroup(this.f_44151_); -+ switch (this.f_44147_) { ++ recipe.setGroup(this.group); ++ switch (this.height) { + case 1: -+ switch (this.f_44146_) { ++ switch (this.width) { + case 1: + recipe.shape("a"); + break; @@ -46,7 +46,7 @@ + } + break; + case 2: -+ switch (this.f_44146_) { ++ switch (this.width) { + case 1: + recipe.shape("a","b"); + break; @@ -59,7 +59,7 @@ + } + break; + case 3: -+ switch (this.f_44146_) { ++ switch (this.width) { + case 1: + recipe.shape("a","b","c"); + break; @@ -73,7 +73,7 @@ + break; + } + char c = 'a'; -+ for (Ingredient list : this.f_44148_) { ++ for (Ingredient list : this.recipeItems) { + org.bukkit.inventory.RecipeChoice choice = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(list); + if (choice != null) { + recipe.setIngredient(c, choice); @@ -84,42 +84,42 @@ + } + // CraftBukkit end + - public ResourceLocation m_6423_() { - return this.f_44150_; + public ResourceLocation getId() { + return this.id; } @@ -110,10 +_,20 @@ - return this.f_44146_; + return this.width; } + @Override + public int getRecipeWidth() { -+ return m_44220_(); ++ return getWidth(); + } + - public int m_44221_() { - return this.f_44147_; + public int getHeight() { + return this.height; } + @Override + public int getRecipeHeight() { -+ return m_44221_(); ++ return getHeight(); + } + - static NonNullList m_44202_(String[] p_44203_, Map p_44204_, int p_44205_, int p_44206_) { - NonNullList nonnulllist = NonNullList.m_122780_(p_44205_ * p_44206_, Ingredient.f_43901_); + static NonNullList dissolvePattern(String[] p_44203_, Map p_44204_, int p_44205_, int p_44206_) { + NonNullList nonnulllist = NonNullList.withSize(p_44205_ * p_44206_, Ingredient.EMPTY); Set set = Sets.newHashSet(p_44204_.keySet()); @@ -180,7 +_,7 @@ return nonnulllist.isEmpty() || nonnulllist.stream().filter((p_151277_) -> { - return !p_151277_.m_43947_(); + return !p_151277_.isEmpty(); }).anyMatch((p_151273_) -> { -- return p_151273_.m_43908_().length == 0; +- return p_151273_.getItems().length == 0; + return net.minecraftforge.common.ForgeHooks.hasNoElements(p_151273_); }); } @@ -202,15 +_,15 @@ - static String[] m_44196_(JsonArray p_44197_) { + static String[] patternFromJson(JsonArray p_44197_) { String[] astring = new String[p_44197_.size()]; - if (astring.length > 3) { - throw new JsonSyntaxException("Invalid pattern: too many rows, 3 is maximum"); @@ -129,7 +129,7 @@ throw new JsonSyntaxException("Invalid pattern: empty pattern not allowed"); } else { for(int i = 0; i < astring.length; ++i) { - String s = GsonHelper.m_13805_(p_44197_.get(i), "pattern[" + i + "]"); + String s = GsonHelper.convertToString(p_44197_.get(i), "pattern[" + i + "]"); - if (s.length() > 3) { - throw new JsonSyntaxException("Invalid pattern: too many columns, 3 is maximum"); + if (s.length() > MAX_WIDTH) { @@ -140,12 +140,12 @@ @@ -244,17 +_,7 @@ } - public static ItemStack m_151274_(JsonObject p_151275_) { -- Item item = m_151278_(p_151275_); + public static ItemStack itemStackFromJson(JsonObject p_151275_) { +- Item item = itemFromJson(p_151275_); - if (p_151275_.has("data")) { - throw new JsonParseException("Disallowed data tag found"); - } else { -- int i = GsonHelper.m_13824_(p_151275_, "count", 1); +- int i = GsonHelper.getAsInt(p_151275_, "count", 1); - if (i < 1) { - throw new JsonSyntaxException("Invalid output count: " + i); - } else { @@ -155,7 +155,7 @@ + return net.minecraftforge.common.crafting.CraftingHelper.getItemStack(p_151275_, true, true); } - public static Item m_151278_(JsonObject p_151279_) { + public static Item itemFromJson(JsonObject p_151279_) { @@ -269,7 +_,8 @@ } } @@ -163,6 +163,6 @@ - public static class Serializer implements RecipeSerializer { + public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { + private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shaped"); - public ShapedRecipe m_6729_(ResourceLocation p_44236_, JsonObject p_44237_) { - String s = GsonHelper.m_13851_(p_44237_, "group", ""); - Map map = ShapedRecipe.m_44210_(GsonHelper.m_13930_(p_44237_, "key")); + public ShapedRecipe fromJson(ResourceLocation p_44236_, JsonObject p_44237_) { + String s = GsonHelper.getAsString(p_44237_, "group", ""); + Map map = ShapedRecipe.keyFromJson(GsonHelper.getAsJsonObject(p_44237_, "key")); 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 2a8abf0a..4d516e30 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java @@ -18,13 +_,28 @@ - final String f_44242_; - final ItemStack f_44243_; - final NonNullList f_44244_; + final String group; + final ItemStack result; + final NonNullList ingredients; + private final boolean isSimple; public ShapelessRecipe(ResourceLocation p_44246_, String p_44247_, ItemStack p_44248_, NonNullList p_44249_) { - this.f_44241_ = p_44246_; - this.f_44242_ = p_44247_; - this.f_44243_ = p_44248_; - this.f_44244_ = p_44249_; + this.id = p_44246_; + this.group = p_44247_; + this.result = p_44248_; + this.ingredients = p_44249_; - } + this.isSimple = p_44249_.stream().allMatch(Ingredient::isSimple); + } @@ -18,50 +18,50 @@ + // CraftBukkit start + @SuppressWarnings("unchecked") + public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_44243_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftShapelessRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftShapelessRecipe(result, this); -+ recipe.setGroup(this.f_44242_); -+ for (Ingredient list : this.f_44244_) { ++ recipe.setGroup(this.group); ++ for (Ingredient list : this.ingredients) { + recipe.addIngredient(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(list)); + } + return recipe; + } + // CraftBukkit end - public ResourceLocation m_6423_() { - return this.f_44241_; + public ResourceLocation getId() { + return this.id; @@ -48,17 +_,20 @@ - public boolean m_5818_(CraftingContainer p_44262_, Level p_44263_) { + public boolean matches(CraftingContainer p_44262_, Level p_44263_) { StackedContents stackedcontents = new StackedContents(); + java.util.List inputs = new java.util.ArrayList<>(); int i = 0; - for(int j = 0; j < p_44262_.m_6643_(); ++j) { - ItemStack itemstack = p_44262_.m_8020_(j); - if (!itemstack.m_41619_()) { + for(int j = 0; j < p_44262_.getContainerSize(); ++j) { + ItemStack itemstack = p_44262_.getItem(j); + if (!itemstack.isEmpty()) { ++i; + if (isSimple) - stackedcontents.m_36468_(itemstack, 1); + stackedcontents.accountStack(itemstack, 1); + else inputs.add(itemstack); } } -- return i == this.f_44244_.size() && stackedcontents.m_36475_(this, (IntList)null); -+ return i == this.f_44244_.size() && (isSimple ? stackedcontents.m_36475_(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.f_44244_) != null); +- return i == this.ingredients.size() && stackedcontents.canCraft(this, (IntList)null); ++ return i == this.ingredients.size() && (isSimple ? stackedcontents.canCraft(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.ingredients) != null); } - public ItemStack m_5874_(CraftingContainer p_44260_) { + public ItemStack assemble(CraftingContainer p_44260_) { @@ -69,14 +_,15 @@ - return p_44252_ * p_44253_ >= this.f_44244_.size(); + return p_44252_ * p_44253_ >= this.ingredients.size(); } - public static class Serializer implements RecipeSerializer { + public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { + private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shapeless"); - public ShapelessRecipe m_6729_(ResourceLocation p_44290_, JsonObject p_44291_) { - String s = GsonHelper.m_13851_(p_44291_, "group", ""); - NonNullList nonnulllist = m_44275_(GsonHelper.m_13933_(p_44291_, "ingredients")); + public ShapelessRecipe fromJson(ResourceLocation p_44290_, JsonObject p_44291_) { + String s = GsonHelper.getAsString(p_44291_, "group", ""); + NonNullList nonnulllist = itemsFromJson(GsonHelper.getAsJsonArray(p_44291_, "ingredients")); if (nonnulllist.isEmpty()) { throw new JsonParseException("No ingredients for shapeless recipe"); - } else if (nonnulllist.size() > 9) { @@ -69,14 +69,14 @@ + } else if (nonnulllist.size() > ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT) { + throw new JsonParseException("Too many ingredients for shapeless recipe. The maximum is " + (ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT)); } else { - ItemStack itemstack = ShapedRecipe.m_151274_(GsonHelper.m_13930_(p_44291_, "result")); + ItemStack itemstack = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(p_44291_, "result")); return new ShapelessRecipe(p_44290_, s, itemstack, nonnulllist); @@ -88,7 +_,7 @@ for(int i = 0; i < p_44276_.size(); ++i) { - Ingredient ingredient = Ingredient.m_43917_(p_44276_.get(i)); -- if (!ingredient.m_43947_()) { -+ if (net.minecraftforge.common.ForgeConfig.SERVER.skipEmptyShapelessCheck.get() || !ingredient.m_43947_()) { + Ingredient ingredient = Ingredient.fromJson(p_44276_.get(i)); +- if (!ingredient.isEmpty()) { ++ if (net.minecraftforge.common.ForgeConfig.SERVER.skipEmptyShapelessCheck.get() || !ingredient.isEmpty()) { nonnulllist.add(ingredient); } } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch index 51f3a55a..fdedbec3 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/item/crafting/ShulkerBoxColoring.java +++ b/net/minecraft/world/item/crafting/ShulkerBoxColoring.java @@ -25,7 +_,7 @@ - if (Block.m_49814_(itemstack.m_41720_()) instanceof ShulkerBoxBlock) { + if (Block.byItem(itemstack.getItem()) instanceof ShulkerBoxBlock) { ++i; } else { -- if (!(itemstack.m_41720_() instanceof DyeItem)) { -+ if (!itemstack.m_204117_(net.minecraftforge.common.Tags.Items.DYES)) { +- if (!(itemstack.getItem() instanceof DyeItem)) { ++ if (!itemstack.is(net.minecraftforge.common.Tags.Items.DYES)) { return false; } @@ -43,7 +_,7 @@ - public ItemStack m_5874_(CraftingContainer p_44322_) { - ItemStack itemstack = ItemStack.f_41583_; -- DyeItem dyeitem = (DyeItem)Items.f_42535_; + public ItemStack assemble(CraftingContainer p_44322_) { + ItemStack itemstack = ItemStack.EMPTY; +- DyeItem dyeitem = (DyeItem)Items.WHITE_DYE; + net.minecraft.world.item.DyeColor dyecolor = net.minecraft.world.item.DyeColor.WHITE; - for(int i = 0; i < p_44322_.m_6643_(); ++i) { - ItemStack itemstack1 = p_44322_.m_8020_(i); + for(int i = 0; i < p_44322_.getContainerSize(); ++i) { + ItemStack itemstack1 = p_44322_.getItem(i); @@ -51,13 +_,14 @@ - Item item = itemstack1.m_41720_(); - if (Block.m_49814_(item) instanceof ShulkerBoxBlock) { + Item item = itemstack1.getItem(); + if (Block.byItem(item) instanceof ShulkerBoxBlock) { itemstack = itemstack1; - } else if (item instanceof DyeItem) { - dyeitem = (DyeItem)item; @@ -31,8 +31,8 @@ } } -- ItemStack itemstack2 = ShulkerBoxBlock.m_56250_(dyeitem.m_41089_()); -+ ItemStack itemstack2 = ShulkerBoxBlock.m_56250_(dyecolor); - if (itemstack.m_41782_()) { - itemstack2.m_41751_(itemstack.m_41783_().m_6426_()); +- ItemStack itemstack2 = ShulkerBoxBlock.getColoredItemStack(dyeitem.getDyeColor()); ++ ItemStack itemstack2 = ShulkerBoxBlock.getColoredItemStack(dyecolor); + if (itemstack.hasTag()) { + itemstack2.setTag(itemstack.getTag().copy()); } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch index 4ed9bf21..2bc89414 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch @@ -6,25 +6,25 @@ -public class SimpleCookingSerializer implements RecipeSerializer { +public class SimpleCookingSerializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { - private final int f_44327_; - private final SimpleCookingSerializer.CookieBaker f_44328_; + private final int defaultCookingTime; + private final SimpleCookingSerializer.CookieBaker factory; @@ -21,11 +_,17 @@ - String s = GsonHelper.m_13851_(p_44348_, "group", ""); - JsonElement jsonelement = (JsonElement)(GsonHelper.m_13885_(p_44348_, "ingredient") ? GsonHelper.m_13933_(p_44348_, "ingredient") : GsonHelper.m_13930_(p_44348_, "ingredient")); - Ingredient ingredient = Ingredient.m_43917_(jsonelement); + String s = GsonHelper.getAsString(p_44348_, "group", ""); + JsonElement jsonelement = (JsonElement)(GsonHelper.isArrayNode(p_44348_, "ingredient") ? GsonHelper.getAsJsonArray(p_44348_, "ingredient") : GsonHelper.getAsJsonObject(p_44348_, "ingredient")); + Ingredient ingredient = Ingredient.fromJson(jsonelement); + //Forge: Check if primitive string to keep vanilla or a object which can contain a count field. + if (!p_44348_.has("result")) throw new com.google.gson.JsonSyntaxException("Missing result, expected to find a string or object"); + ItemStack itemstack; -+ if (p_44348_.get("result").isJsonObject()) itemstack = ShapedRecipe.m_151274_(GsonHelper.m_13930_(p_44348_, "result")); ++ if (p_44348_.get("result").isJsonObject()) itemstack = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(p_44348_, "result")); + else { - String s1 = GsonHelper.m_13906_(p_44348_, "result"); + String s1 = GsonHelper.getAsString(p_44348_, "result"); ResourceLocation resourcelocation = new ResourceLocation(s1); -- ItemStack itemstack = new ItemStack(Registry.f_122827_.m_6612_(resourcelocation).orElseThrow(() -> { -+ itemstack = new ItemStack(Registry.f_122827_.m_6612_(resourcelocation).orElseThrow(() -> { +- ItemStack itemstack = new ItemStack(Registry.ITEM.getOptional(resourcelocation).orElseThrow(() -> { ++ itemstack = new ItemStack(Registry.ITEM.getOptional(resourcelocation).orElseThrow(() -> { return new IllegalStateException("Item: " + s1 + " does not exist"); })); + } - float f = GsonHelper.m_13820_(p_44348_, "experience", 0.0F); - int i = GsonHelper.m_13824_(p_44348_, "cookingtime", this.f_44327_); - return this.f_44328_.m_44352_(p_44347_, s, ingredient, itemstack, f, i); + float f = GsonHelper.getAsFloat(p_44348_, "experience", 0.0F); + int i = GsonHelper.getAsInt(p_44348_, "cookingtime", this.defaultCookingTime); + return this.factory.create(p_44347_, s, ingredient, itemstack, f, i); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch index e9eb0879..82339546 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SimpleRecipeSerializer.java.patch @@ -6,6 +6,6 @@ -public class SimpleRecipeSerializer> implements RecipeSerializer { +public class SimpleRecipeSerializer> extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { - private final Function f_44397_; + private final Function constructor; public SimpleRecipeSerializer(Function p_44399_) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch index 9e0e51b3..e9f8fa60 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SingleItemRecipe.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/crafting/SingleItemRecipe.java +++ b/net/minecraft/world/item/crafting/SingleItemRecipe.java @@ -60,7 +_,7 @@ - return this.f_44410_.m_41777_(); + return this.result.copy(); } - public static class Serializer implements RecipeSerializer { + public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { - final SingleItemRecipe.Serializer.SingleItemMaker f_44433_; + final SingleItemRecipe.Serializer.SingleItemMaker factory; protected Serializer(SingleItemRecipe.Serializer.SingleItemMaker p_44435_) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch index cb9e4206..443a582a 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/crafting/SmeltingRecipe.java +++ b/net/minecraft/world/item/crafting/SmeltingRecipe.java @@ -16,4 +_,14 @@ - public RecipeSerializer m_7707_() { - return RecipeSerializer.f_44091_; + public RecipeSerializer getSerializer() { + return RecipeSerializer.SMELTING_RECIPE; } + + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_43730_); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftFurnaceRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftFurnaceRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.f_43727_), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_43729_), this.f_43731_, this.f_43732_); -+ recipe.setGroup(this.f_43728_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftFurnaceRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftFurnaceRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.id), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); + return recipe; + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SmokingRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SmokingRecipe.java.patch index 649f1097..97054062 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SmokingRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SmokingRecipe.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/crafting/SmokingRecipe.java +++ b/net/minecraft/world/item/crafting/SmokingRecipe.java @@ -16,4 +_,15 @@ - public RecipeSerializer m_7707_() { - return RecipeSerializer.f_44093_; + public RecipeSerializer getSerializer() { + return RecipeSerializer.SMOKING_RECIPE; } + + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_43730_); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmokingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmokingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.f_43727_), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_43729_), this.f_43731_, this.f_43732_); -+ recipe.setGroup(this.f_43728_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmokingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmokingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.id), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); + return recipe; + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch index 3d54b972..a8fa4d54 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/crafting/StonecutterRecipe.java +++ b/net/minecraft/world/item/crafting/StonecutterRecipe.java @@ -18,4 +_,15 @@ - public ItemStack m_8042_() { - return new ItemStack(Blocks.f_50679_); + public ItemStack getToastSymbol() { + return new ItemStack(Blocks.STONECUTTER); } + + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_44410_); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftStonecuttingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftStonecuttingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.f_44411_), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_44409_)); -+ recipe.setGroup(this.f_44412_); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftStonecuttingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftStonecuttingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.id), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.ingredient)); ++ recipe.setGroup(this.group); + return recipe; + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch index bd5b7794..3c683a08 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/UpgradeRecipe.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/world/item/crafting/UpgradeRecipe.java @@ -68,11 +_,20 @@ - public boolean m_142505_() { - return Stream.of(this.f_44518_, this.f_44519_).anyMatch((p_151284_) -> { -- return p_151284_.m_43908_().length == 0; + public boolean isIncomplete() { + return Stream.of(this.base, this.addition).anyMatch((p_151284_) -> { +- return p_151284_.getItems().length == 0; + return net.minecraftforge.common.ForgeHooks.hasNoElements(p_151284_); }); } @@ -13,13 +13,13 @@ + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe() { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.f_44520_); -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmithingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmithingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.f_44521_), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_44518_), org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.f_44519_)); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack result = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmithingRecipe recipe = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftSmithingRecipe(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(this.id), result, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.v1_18_R2.inventory.CraftRecipe.toBukkit(this.addition)); + return recipe; + } + // CraftBukkit end + + public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements RecipeSerializer { - public UpgradeRecipe m_6729_(ResourceLocation p_44562_, JsonObject p_44563_) { - Ingredient ingredient = Ingredient.m_43917_(GsonHelper.m_13930_(p_44563_, "base")); - Ingredient ingredient1 = Ingredient.m_43917_(GsonHelper.m_13930_(p_44563_, "addition")); + public UpgradeRecipe fromJson(ResourceLocation p_44562_, JsonObject p_44563_) { + Ingredient ingredient = Ingredient.fromJson(GsonHelper.getAsJsonObject(p_44563_, "base")); + Ingredient ingredient1 = Ingredient.fromJson(GsonHelper.getAsJsonObject(p_44563_, "addition")); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/DamageEnchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/DamageEnchantment.java.patch index f5458ef2..adfdb1bb 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/DamageEnchantment.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/DamageEnchantment.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/item/enchantment/DamageEnchantment.java @@ -59,7 +_,7 @@ LivingEntity livingentity = (LivingEntity)p_44639_; - if (this.f_44621_ == 2 && p_44640_ > 0 && livingentity.m_6336_() == MobType.f_21642_) { - int i = 20 + p_44638_.m_21187_().nextInt(10 * p_44640_); -- livingentity.m_7292_(new MobEffectInstance(MobEffects.f_19597_, i, 3)); -+ livingentity.addEffect(new MobEffectInstance(MobEffects.f_19597_, i, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + if (this.type == 2 && p_44640_ > 0 && livingentity.getMobType() == MobType.ARTHROPOD) { + int i = 20 + p_44638_.getRandom().nextInt(10 * p_44640_); +- livingentity.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, i, 3)); ++ livingentity.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, i, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/DiggingEnchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/DiggingEnchantment.java.patch index 489259e4..73f4532b 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/DiggingEnchantment.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/DiggingEnchantment.java.patch @@ -3,8 +3,8 @@ @@ -22,6 +_,6 @@ } - public boolean m_6081_(ItemStack p_44668_) { -- return p_44668_.m_150930_(Items.f_42574_) ? true : super.m_6081_(p_44668_); -+ return p_44668_.m_41720_() instanceof net.minecraft.world.item.ShearsItem ? true : super.m_6081_(p_44668_); + public boolean canEnchant(ItemStack p_44668_) { +- return p_44668_.is(Items.SHEARS) ? true : super.canEnchant(p_44668_); ++ return p_44668_.getItem() instanceof net.minecraft.world.item.ShearsItem ? true : super.canEnchant(p_44668_); } } diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch index fc28b1fa..77b7553c 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch @@ -6,30 +6,30 @@ -public abstract class Enchantment { +public abstract class Enchantment extends net.minecraftforge.registries.ForgeRegistryEntry implements net.minecraftforge.common.extensions.IForgeEnchantment { - private final EquipmentSlot[] f_44671_; - private final Enchantment.Rarity f_44674_; - public final EnchantmentCategory f_44672_; + private final EquipmentSlot[] slots; + private final Enchantment.Rarity rarity; + public final EnchantmentCategory category; @@ -71,6 +_,7 @@ return 0; } + @Deprecated // Forge: Use ItemStack aware version in IForgeEnchantment - public float m_7335_(int p_44682_, MobType p_44683_) { + public float getDamageBonus(int p_44682_, MobType p_44683_) { return 0.0F; } @@ -111,7 +_,7 @@ } - public boolean m_6081_(ItemStack p_44689_) { -- return this.f_44672_.m_7454_(p_44689_.m_41720_()); + public boolean canEnchant(ItemStack p_44689_) { +- return this.category.canEnchant(p_44689_.getItem()); + return canApplyAtEnchantingTable(p_44689_); } - public void m_7677_(LivingEntity p_44686_, Entity p_44687_, int p_44688_) { + public void doPostAttack(LivingEntity p_44686_, Entity p_44687_, int p_44688_) { @@ -133,6 +_,24 @@ } - public boolean m_6592_() { + public boolean isDiscoverable() { + return true; + } + diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch index 16b5f155..380f24bd 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentCategory.java.patch @@ -7,13 +7,13 @@ -public enum EnchantmentCategory { +public enum EnchantmentCategory implements net.minecraftforge.common.IExtensibleEnum { ARMOR { - public boolean m_7454_(Item p_44751_) { + public boolean canEnchant(Item p_44751_) { return p_44751_ instanceof ArmorItem; @@ -85,5 +_,19 @@ } }; -- public abstract boolean m_7454_(Item p_44743_); +- public abstract boolean canEnchant(Item p_44743_); + private java.util.function.Predicate delegate; + + private EnchantmentCategory() {} @@ -26,7 +26,7 @@ + throw new IllegalStateException("Enum not extended"); + } + -+ public boolean m_7454_(Item p_44743_) { ++ public boolean canEnchant(Item p_44743_) { + return this.delegate == null ? false : this.delegate.test(p_44743_); + } } 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 92372e37..e045c18e 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -1,38 +1,38 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentHelper.java +++ b/net/minecraft/world/item/enchantment/EnchantmentHelper.java @@ -150,7 +_,7 @@ - public static float m_44833_(ItemStack p_44834_, MobType p_44835_) { + public static float getDamageBonus(ItemStack p_44834_, MobType p_44835_) { MutableFloat mutablefloat = new MutableFloat(); - m_44850_((p_44887_, p_44888_) -> { -- mutablefloat.add(p_44887_.m_7335_(p_44888_, p_44835_)); + runIterationOnItem((p_44887_, p_44888_) -> { +- mutablefloat.add(p_44887_.getDamageBonus(p_44888_, p_44835_)); + mutablefloat.add(p_44887_.getDamageBonus(p_44888_, p_44835_, p_44834_)); }, p_44834_); return mutablefloat.floatValue(); } @@ -298,7 +_,7 @@ - public static int m_44872_(Random p_44873_, int p_44874_, int p_44875_, ItemStack p_44876_) { - Item item = p_44876_.m_41720_(); -- int i = item.m_6473_(); + public static int getEnchantmentCost(Random p_44873_, int p_44874_, int p_44875_, ItemStack p_44876_) { + Item item = p_44876_.getItem(); +- int i = item.getEnchantmentValue(); + int i = p_44876_.getItemEnchantability(); if (i <= 0) { return 0; } else { @@ -336,7 +_,7 @@ - public static List m_44909_(Random p_44910_, ItemStack p_44911_, int p_44912_, boolean p_44913_) { + public static List selectEnchantment(Random p_44910_, ItemStack p_44911_, int p_44912_, boolean p_44913_) { List list = Lists.newArrayList(); - Item item = p_44911_.m_41720_(); -- int i = item.m_6473_(); + Item item = p_44911_.getItem(); +- int i = item.getEnchantmentValue(); + int i = p_44911_.getItemEnchantability(); if (i <= 0) { return list; } else { @@ -392,7 +_,7 @@ - boolean flag = p_44819_.m_150930_(Items.f_42517_); + boolean flag = p_44819_.is(Items.BOOK); - for(Enchantment enchantment : Registry.f_122825_) { -- if ((!enchantment.m_6591_() || p_44820_) && enchantment.m_6592_() && (enchantment.f_44672_.m_7454_(item) || flag)) { -+ if ((!enchantment.m_6591_() || p_44820_) && enchantment.m_6592_() && (enchantment.canApplyAtEnchantingTable(p_44819_) || (flag && enchantment.isAllowedOnBooks()))) { - for(int i = enchantment.m_6586_(); i > enchantment.m_44702_() - 1; --i) { - if (p_44818_ >= enchantment.m_6183_(i) && p_44818_ <= enchantment.m_6175_(i)) { + for(Enchantment enchantment : Registry.ENCHANTMENT) { +- if ((!enchantment.isTreasureOnly() || p_44820_) && enchantment.isDiscoverable() && (enchantment.category.canEnchant(item) || flag)) { ++ if ((!enchantment.isTreasureOnly() || p_44820_) && enchantment.isDiscoverable() && (enchantment.canApplyAtEnchantingTable(p_44819_) || (flag && enchantment.isAllowedOnBooks()))) { + for(int i = enchantment.getMaxLevel(); i > enchantment.getMinLevel() - 1; --i) { + if (p_44818_ >= enchantment.getMinCost(i) && p_44818_ <= enchantment.getMaxCost(i)) { list.add(new EnchantmentInstance(enchantment, i)); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch index d9d2fafe..8ce8d2a8 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantments.java.patch @@ -6,5 +6,5 @@ +@net.minecraftforge.registries.ObjectHolder("minecraft") public class Enchantments { - private static final EquipmentSlot[] f_44964_ = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; - public static final Enchantment f_44965_ = m_44992_("protection", new ProtectionEnchantment(Enchantment.Rarity.COMMON, ProtectionEnchantment.Type.ALL, f_44964_)); + private static final EquipmentSlot[] ARMOR_SLOTS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; + public static final Enchantment ALL_DAMAGE_PROTECTION = register("protection", new ProtectionEnchantment(Enchantment.Rarity.COMMON, ProtectionEnchantment.Type.ALL, ARMOR_SLOTS)); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch index 12d3dc34..cf3f1de2 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java +++ b/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java @@ -44,9 +_,13 @@ - BlockState blockstate1 = p_45020_.m_8055_(blockpos$mutableblockpos); - if (blockstate1.m_60795_()) { - BlockState blockstate2 = p_45020_.m_8055_(blockpos); -- if (blockstate2.m_60767_() == Material.f_76305_ && blockstate2.m_61143_(LiquidBlock.f_54688_) == 0 && blockstate.m_60710_(p_45020_, blockpos) && p_45020_.m_45752_(blockstate, blockpos, CollisionContext.m_82749_())) { -- p_45020_.m_46597_(blockpos, blockstate); -- p_45020_.m_186460_(blockpos, Blocks.f_50449_, Mth.m_14072_(p_45019_.m_21187_(), 60, 120)); -+ boolean isFull = blockstate2.m_60734_() == Blocks.f_49990_ && blockstate2.m_61143_(LiquidBlock.f_54688_) == 0; //TODO: Forge, modded waters? -+ if (blockstate2.m_60767_() == Material.f_76305_ && isFull && blockstate.m_60710_(p_45020_, blockpos) && p_45020_.m_45752_(blockstate, blockpos, CollisionContext.m_82749_()) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(p_45019_, net.minecraftforge.common.util.BlockSnapshot.create(p_45020_.m_46472_(), p_45020_, blockpos), net.minecraft.core.Direction.UP)) { + BlockState blockstate1 = p_45020_.getBlockState(blockpos$mutableblockpos); + if (blockstate1.isAir()) { + BlockState blockstate2 = p_45020_.getBlockState(blockpos); +- if (blockstate2.getMaterial() == Material.WATER && blockstate2.getValue(LiquidBlock.LEVEL) == 0 && blockstate.canSurvive(p_45020_, blockpos) && p_45020_.isUnobstructed(blockstate, blockpos, CollisionContext.empty())) { +- p_45020_.setBlockAndUpdate(blockpos, blockstate); +- p_45020_.scheduleTick(blockpos, Blocks.FROSTED_ICE, Mth.nextInt(p_45019_.getRandom(), 60, 120)); ++ boolean isFull = blockstate2.getBlock() == Blocks.WATER && blockstate2.getValue(LiquidBlock.LEVEL) == 0; //TODO: Forge, modded waters? ++ if (blockstate2.getMaterial() == Material.WATER && isFull && blockstate.canSurvive(p_45020_, blockpos) && p_45020_.isUnobstructed(blockstate, blockpos, CollisionContext.empty()) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(p_45019_, net.minecraftforge.common.util.BlockSnapshot.create(p_45020_.dimension(), p_45020_, blockpos), net.minecraft.core.Direction.UP)) { + // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_45020_, blockpos, blockstate, p_45019_)) { -+ p_45020_.m_186460_(blockpos, Blocks.f_50449_, Mth.m_14072_(p_45019_.m_21187_(), 60, 120)); ++ p_45020_.scheduleTick(blockpos, Blocks.FROSTED_ICE, Mth.nextInt(p_45019_.getRandom(), 60, 120)); + } + // CraftBukkit End } diff --git a/patches/minecraft/net/minecraft/world/item/trading/Merchant.java.patch b/patches/minecraft/net/minecraft/world/item/trading/Merchant.java.patch index bc9fc379..f6edc9bc 100644 --- a/patches/minecraft/net/minecraft/world/item/trading/Merchant.java.patch +++ b/patches/minecraft/net/minecraft/world/item/trading/Merchant.java.patch @@ -3,7 +3,7 @@ @@ -49,4 +_,6 @@ } - boolean m_183595_(); + boolean isClientSide(); + + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMerchant getCraftMerchant(); // CraftBukkit } diff --git a/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch b/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch index 978defe5..53607d71 100644 --- a/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/trading/MerchantOffer.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/trading/MerchantOffer.java +++ b/net/minecraft/world/item/trading/MerchantOffer.java @@ -17,6 +_,23 @@ - public float f_45318_; - public int f_45319_ = 1; + public float priceMultiplier; + public int xp = 1; + // CraftBukkit start + private org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMerchantRecipe bukkitHandle; // CraftBukkit @@ -22,39 +22,39 @@ + // CraftBukkit end + public MerchantOffer(CompoundTag p_45351_) { - this.f_45310_ = ItemStack.m_41712_(p_45351_.m_128469_("buy")); - this.f_45311_ = ItemStack.m_41712_(p_45351_.m_128469_("buyB")); + this.baseCostA = ItemStack.of(p_45351_.getCompound("buy")); + this.costB = ItemStack.of(p_45351_.getCompound("buyB")); @@ -73,9 +_,10 @@ - public ItemStack m_45358_() { - int i = this.f_45310_.m_41613_(); -+ if (i <= 0) return ItemStack.f_41583_; // CraftBukkit - SPIGOT-5476 - ItemStack itemstack = this.f_45310_.m_41777_(); - int j = Math.max(0, Mth.m_14143_((float)(i * this.f_45317_) * this.f_45318_)); -- itemstack.m_41764_(Mth.m_14045_(i + j + this.f_45316_, 1, this.f_45310_.m_41720_().m_41459_())); -+ itemstack.m_41764_(Mth.m_14045_(i + j + this.f_45316_, 1, this.f_45310_.m_41741_())); + public ItemStack getCostA() { + int i = this.baseCostA.getCount(); ++ if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476 + ItemStack itemstack = this.baseCostA.copy(); + int j = Math.max(0, Mth.floor((float)(i * this.demand) * this.priceMultiplier)); +- itemstack.setCount(Mth.clamp(i + j + this.specialPriceDiff, 1, this.baseCostA.getItem().getMaxStackSize())); ++ itemstack.setCount(Mth.clamp(i + j + this.specialPriceDiff, 1, this.baseCostA.getMaxStackSize())); return itemstack; } @@ -179,7 +_,7 @@ return true; } else { - ItemStack itemstack = p_45366_.m_41777_(); -- if (itemstack.m_41720_().m_41465_()) { -+ if (itemstack.m_41720_().isDamageable(itemstack)) { - itemstack.m_41721_(itemstack.m_41773_()); + ItemStack itemstack = p_45366_.copy(); +- if (itemstack.getItem().canBeDepleted()) { ++ if (itemstack.getItem().isDamageable(itemstack)) { + itemstack.setDamageValue(itemstack.getDamageValue()); } @@ -191,7 +_,11 @@ - if (!this.m_45355_(p_45362_, p_45363_)) { + if (!this.satisfiedBy(p_45362_, p_45363_)) { return false; } else { -- p_45362_.m_41774_(this.m_45358_().m_41613_()); +- p_45362_.shrink(this.getCostA().getCount()); + // CraftBukkit start -+ if (!this.m_45358_().m_41619_()) { -+ p_45362_.m_41774_(this.m_45358_().m_41613_()); ++ if (!this.getCostA().isEmpty()) { ++ p_45362_.shrink(this.getCostA().getCount()); + } + // CraftBukkit end - if (!this.m_45364_().m_41619_()) { - p_45363_.m_41774_(this.m_45364_().m_41613_()); + if (!this.getCostB().isEmpty()) { + p_45363_.shrink(this.getCostB().getCount()); } diff --git a/patches/minecraft/net/minecraft/world/level/BaseCommandBlock.java.patch b/patches/minecraft/net/minecraft/world/level/BaseCommandBlock.java.patch index abad83e1..0e676433 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java @@ -30,6 +_,10 @@ - private Component f_45403_; - private String f_45404_ = ""; - private Component f_45405_ = f_45398_; + private Component lastOutput; + private String command = ""; + private Component name = DEFAULT_NAME; + // CraftBukkit start + @Override + public abstract org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper); + // CraftBukkit end - public int m_45436_() { - return this.f_45401_; + public int getSuccessCount() { + return this.successCount; @@ -120,7 +_,7 @@ } }); -- minecraftserver.m_129892_().m_82117_(commandsourcestack, this.f_45404_); -+ minecraftserver.m_129892_().dispatchServerCommand(commandsourcestack, this.f_45404_); // CraftBukkit +- minecraftserver.getCommands().performCommand(commandsourcestack, this.command); ++ minecraftserver.getCommands().dispatchServerCommand(commandsourcestack, this.command); // CraftBukkit } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.m_127521_(throwable, "Executing command block"); - CrashReportCategory crashreportcategory = crashreport.m_127514_("Command to be executed"); + CrashReport crashreport = CrashReport.forThrowable(throwable, "Executing command block"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Command to be executed"); diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index 0ff653a4..9c149950 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -2,32 +2,32 @@ +++ b/net/minecraft/world/level/BaseSpawner.java @@ -43,6 +_,7 @@ - public void m_45462_(EntityType p_45463_) { - this.f_45444_.m_186567_().m_128359_("id", Registry.f_122826_.m_7981_(p_45463_).toString()); -+ this.f_45443_ = SimpleWeightedRandomList.m_185864_(); // CraftBukkit - SPIGOT-3496, MC-92282 + public void setEntityId(EntityType p_45463_) { + this.nextSpawnData.getEntityToSpawn().putString("id", Registry.ENTITY_TYPE.getKey(p_45463_).toString()); ++ this.spawnPotentials = SimpleWeightedRandomList.empty(); // CraftBukkit - SPIGOT-3496, MC-92282 } - private boolean m_151343_(Level p_151344_, BlockPos p_151345_) { + private boolean isNearPlayer(Level p_151344_, BlockPos p_151345_) { @@ -125,16 +_,38 @@ - entity.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), p_151312_.f_46441_.nextFloat() * 360.0F, 0.0F); + entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), p_151312_.random.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob) { Mob mob = (Mob)entity; -+ net.minecraftforge.eventbus.api.Event.Result res = net.minecraftforge.event.ForgeEventFactory.canEntitySpawn(mob, p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this, MobSpawnType.SPAWNER); ++ net.minecraftforge.eventbus.api.Event.Result res = net.minecraftforge.event.ForgeEventFactory.canEntitySpawn(mob, p_151312_, (float)entity.getX(), (float)entity.getY(), (float)entity.getZ(), this, MobSpawnType.SPAWNER); + if (res == net.minecraftforge.eventbus.api.Event.Result.DENY) continue; + if (res == net.minecraftforge.eventbus.api.Event.Result.DEFAULT) - if (this.f_45444_.m_186574_().isEmpty() && !mob.m_5545_(p_151312_, MobSpawnType.SPAWNER) || !mob.m_6914_(p_151312_)) { + if (this.nextSpawnData.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, MobSpawnType.SPAWNER) || !mob.checkSpawnObstruction(p_151312_)) { continue; } - if (this.f_45444_.m_186567_().m_128440_() == 1 && this.f_45444_.m_186567_().m_128425_("id", 8)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, (LevelAccessor)p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this, MobSpawnType.SPAWNER)) - ((Mob)entity).m_6518_(p_151312_, p_151312_.m_6436_(entity.m_142538_()), MobSpawnType.SPAWNER, (SpawnGroupData)null, (CompoundTag)null); + if (this.nextSpawnData.getEntityToSpawn().size() == 1 && this.nextSpawnData.getEntityToSpawn().contains("id", 8)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, (LevelAccessor)p_151312_, (float)entity.getX(), (float)entity.getY(), (float)entity.getZ(), this, MobSpawnType.SPAWNER)) + ((Mob)entity).finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, (SpawnGroupData)null, (CompoundTag)null); } - } - -- if (!p_151312_.m_8860_(entity)) { +- if (!p_151312_.tryAddFreshEntityWithPassengers(entity)) { + // Spigot Start -+ if (entity.f_19853_.spigotConfig.nerfSpawnerMobs) { ++ if (entity.level.spigotConfig.nerfSpawnerMobs) { + ((Mob) entity).aware = false; + } + // Spigot End @@ -35,24 +35,24 @@ + + // Spigot Start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callSpawnerSpawnEvent(entity, p_151313_).isCancelled()) { -+ Entity vehicle = entity.m_20202_(); ++ Entity vehicle = entity.getVehicle(); + if (vehicle != null) { -+ vehicle.m_146870_(); ++ vehicle.discard(); + } -+ for (Entity passenger : entity.m_146897_()) { -+ passenger.m_146870_(); ++ for (Entity passenger : entity.getIndirectPassengers()) { ++ passenger.discard(); + } + continue; + } + // Spigot End + + if (!p_151312_.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit - this.m_151350_(p_151312_, p_151313_); + this.delay(p_151312_, p_151313_); return; } @@ -271,4 +_,12 @@ - public double m_45474_() { - return this.f_45446_; + public double getoSpin() { + return this.oSpin; } + + @Nullable diff --git a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch index d4593661..770e1ef8 100644 --- a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch @@ -7,37 +7,37 @@ -public interface BlockGetter extends LevelHeightAccessor { +public interface BlockGetter extends LevelHeightAccessor, net.minecraftforge.common.extensions.IForgeBlockGetter { @Nullable - BlockEntity m_7702_(BlockPos p_45570_); + BlockEntity getBlockEntity(BlockPos p_45570_); @@ -32,7 +_,7 @@ - FluidState m_6425_(BlockPos p_45569_); + FluidState getFluidState(BlockPos p_45569_); - default int m_7146_(BlockPos p_45572_) { -- return this.m_8055_(p_45572_).m_60791_(); -+ return this.m_8055_(p_45572_).getLightEmission(this, p_45572_); + default int getLightEmission(BlockPos p_45572_) { +- return this.getBlockState(p_45572_).getLightEmission(); ++ return this.getBlockState(p_45572_).getLightEmission(this, p_45572_); } - default int m_7469_() { + default int getMaxLightLevel() { @@ -53,6 +_,22 @@ - return BlockHitResult.m_82426_(p_151370_.m_151404_(), Direction.m_122366_(vec3.f_82479_, vec3.f_82480_, vec3.f_82481_), new BlockPos(p_151370_.m_151404_())); + return BlockHitResult.miss(p_151370_.getTo(), Direction.getNearest(vec3.x, vec3.y, vec3.z), new BlockPos(p_151370_.getTo())); }); } + + // CraftBukkit start + default BlockHitResult clip(ClipContext p_45548_, BlockPos p_217297_2_) { -+ BlockState blockstate = this.m_8055_(p_217297_2_); -+ FluidState fluidstate = this.m_6425_(p_217297_2_); -+ Vec3 vec3 = p_45548_.m_45702_(); -+ Vec3 vec31 = p_45548_.m_45693_(); -+ VoxelShape voxelshape = p_45548_.m_45694_(blockstate, this, p_217297_2_); -+ BlockHitResult blockraytraceresult = this.m_45558_(vec3, vec31, p_217297_2_, voxelshape, blockstate); -+ VoxelShape voxelshape1 = p_45548_.m_45698_(fluidstate, this, p_217297_2_); -+ BlockHitResult blockraytraceresult1 = voxelshape1.m_83220_(vec3, vec31, p_217297_2_); -+ double d0 = blockraytraceresult == null ? Double.MAX_VALUE : p_45548_.m_45702_().m_82557_(blockraytraceresult.m_82450_()); -+ double d1 = blockraytraceresult1 == null ? Double.MAX_VALUE : p_45548_.m_45702_().m_82557_(blockraytraceresult1.m_82450_()); ++ BlockState blockstate = this.getBlockState(p_217297_2_); ++ FluidState fluidstate = this.getFluidState(p_217297_2_); ++ Vec3 vec3 = p_45548_.getFrom(); ++ Vec3 vec31 = p_45548_.getTo(); ++ VoxelShape voxelshape = p_45548_.getBlockShape(blockstate, this, p_217297_2_); ++ BlockHitResult blockraytraceresult = this.clipWithInteractionOverride(vec3, vec31, p_217297_2_, voxelshape, blockstate); ++ VoxelShape voxelshape1 = p_45548_.getFluidShape(fluidstate, this, p_217297_2_); ++ BlockHitResult blockraytraceresult1 = voxelshape1.clip(vec3, vec31, p_217297_2_); ++ double d0 = blockraytraceresult == null ? Double.MAX_VALUE : p_45548_.getFrom().distanceToSqr(blockraytraceresult.getLocation()); ++ double d1 = blockraytraceresult1 == null ? Double.MAX_VALUE : p_45548_.getFrom().distanceToSqr(blockraytraceresult1.getLocation()); + return d0 <= d1 ? blockraytraceresult : blockraytraceresult1; + } + // CraftBukkit end - default BlockHitResult m_45547_(ClipContext p_45548_) { - return m_151361_(p_45548_.m_45702_(), p_45548_.m_45693_(), p_45548_, (p_151359_, p_151360_) -> { + default BlockHitResult clip(ClipContext p_45548_) { + return traverseBlocks(p_45548_.getFrom(), p_45548_.getTo(), p_45548_, (p_151359_, p_151360_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch b/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch index a9fdcd54..1bfbbd31 100644 --- a/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ClipContext.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java @@ -20,12 +_,12 @@ - private final ClipContext.Fluid f_45685_; - private final CollisionContext f_45686_; + private final ClipContext.Fluid fluid; + private final CollisionContext collisionContext; - public ClipContext(Vec3 p_45688_, Vec3 p_45689_, ClipContext.Block p_45690_, ClipContext.Fluid p_45691_, Entity p_45692_) { + public ClipContext(Vec3 p_45688_, Vec3 p_45689_, ClipContext.Block p_45690_, ClipContext.Fluid p_45691_, @javax.annotation.Nullable Entity p_45692_) { - this.f_45682_ = p_45688_; - this.f_45683_ = p_45689_; - this.f_45684_ = p_45690_; - this.f_45685_ = p_45691_; -- this.f_45686_ = CollisionContext.m_82750_(p_45692_); -+ this.f_45686_ = p_45692_ == null ? CollisionContext.m_82749_() : CollisionContext.m_82750_(p_45692_); + this.from = p_45688_; + this.to = p_45689_; + this.block = p_45690_; + this.fluid = p_45691_; +- this.collisionContext = CollisionContext.of(p_45692_); ++ this.collisionContext = p_45692_ == null ? CollisionContext.empty() : CollisionContext.of(p_45692_); } - public Vec3 m_45693_() { + public Vec3 getTo() { diff --git a/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch b/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch index 42260929..06e33c34 100644 --- a/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch +++ b/patches/minecraft/net/minecraft/world/level/DataPackConfig.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/level/DataPackConfig.java +++ b/net/minecraft/world/level/DataPackConfig.java @@ -18,7 +_,7 @@ - private final List f_45845_; + private final List disabled; public DataPackConfig(List p_45848_, List p_45849_) { -- this.f_45844_ = ImmutableList.copyOf(p_45848_); -+ this.f_45844_ = com.google.common.collect.Lists.newArrayList(p_45848_); - this.f_45845_ = ImmutableList.copyOf(p_45849_); +- this.enabled = ImmutableList.copyOf(p_45848_); ++ this.enabled = com.google.common.collect.Lists.newArrayList(p_45848_); + this.disabled = ImmutableList.copyOf(p_45849_); } @@ -28,5 +_,9 @@ - public List m_45855_() { - return this.f_45845_; + public List getDisabled() { + return this.disabled; + } + + public void addModPacks(List modPacks) { -+ f_45844_.addAll(modPacks.stream().filter(p->!f_45844_.contains(p)).collect(java.util.stream.Collectors.toList())); ++ enabled.addAll(modPacks.stream().filter(p->!enabled.contains(p)).collect(java.util.stream.Collectors.toList())); } } diff --git a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch index 89ab51d9..3575d670 100644 --- a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/Explosion.java +++ b/net/minecraft/world/level/Explosion.java @@ -57,6 +_,8 @@ - private final ExplosionDamageCalculator f_46019_; - private final List f_46020_ = Lists.newArrayList(); - private final Map f_46021_ = Maps.newHashMap(); + private final ExplosionDamageCalculator damageCalculator; + private final List toBlow = Lists.newArrayList(); + private final Map hitPlayers = Maps.newHashMap(); + private final Vec3 position; + public boolean wasCanceled = false; // CraftBukkit - add field @@ -11,49 +11,49 @@ this(p_151471_, p_151472_, p_151473_, p_151474_, p_151475_, p_151476_, false, Explosion.BlockInteraction.DESTROY); @@ -78,7 +_,7 @@ public Explosion(Level p_46051_, @Nullable Entity p_46052_, @Nullable DamageSource p_46053_, @Nullable ExplosionDamageCalculator p_46054_, double p_46055_, double p_46056_, double p_46057_, float p_46058_, boolean p_46059_, Explosion.BlockInteraction p_46060_) { - this.f_46012_ = p_46051_; - this.f_46016_ = p_46052_; -- this.f_46017_ = p_46058_; -+ this.f_46017_ = (float) Math.max(p_46058_, 0.0); // CraftBukkit - clamp bad values - this.f_46013_ = p_46055_; - this.f_46014_ = p_46056_; - this.f_46015_ = p_46057_; + this.level = p_46051_; + this.source = p_46052_; +- this.radius = p_46058_; ++ this.radius = (float) Math.max(p_46058_, 0.0); // CraftBukkit - clamp bad values + this.x = p_46055_; + this.y = p_46056_; + this.z = p_46057_; @@ -86,6 +_,7 @@ - this.f_46010_ = p_46060_; - this.f_46018_ = p_46053_ == null ? DamageSource.m_19358_(this) : p_46053_; - this.f_46019_ = p_46054_ == null ? this.m_46062_(p_46052_) : p_46054_; -+ this.position = new Vec3(this.f_46013_, this.f_46014_, this.f_46015_); + this.blockInteraction = p_46060_; + this.damageSource = p_46053_ == null ? DamageSource.explosion(this) : p_46053_; + this.damageCalculator = p_46054_ == null ? this.makeDamageCalculator(p_46052_) : p_46054_; ++ this.position = new Vec3(this.x, this.y, this.z); } - private ExplosionDamageCalculator m_46062_(@Nullable Entity p_46063_) { + private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity p_46063_) { @@ -126,6 +_,11 @@ } - public void m_46061_() { + public void explode() { + // CraftBukkit start -+ if (this.f_46017_ < 0.1F) { ++ if (this.radius < 0.1F) { + return; + } + // CraftBukkit end - this.f_46012_.m_142346_(this.f_46016_, GameEvent.f_157812_, new BlockPos(this.f_46013_, this.f_46014_, this.f_46015_)); + this.level.gameEvent(this.source, GameEvent.EXPLODE, new BlockPos(this.x, this.y, this.z)); Set set = Sets.newHashSet(); int i = 16; @@ -181,6 +_,7 @@ - int j2 = Mth.m_14107_(this.f_46015_ - (double)f2 - 1.0D); - int j1 = Mth.m_14107_(this.f_46015_ + (double)f2 + 1.0D); - List list = this.f_46012_.m_45933_(this.f_46016_, new AABB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); -+ net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.f_46012_, this, list, f2); - Vec3 vec3 = new Vec3(this.f_46013_, this.f_46014_, this.f_46015_); + int j2 = Mth.floor(this.z - (double)f2 - 1.0D); + int j1 = Mth.floor(this.z + (double)f2 + 1.0D); + 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(int k2 = 0; k2 < list.size(); ++k2) { @@ -198,7 +_,37 @@ d9 /= d13; - double d14 = (double)m_46064_(vec3, entity); + double d14 = (double)getSeenPercent(vec3, entity); double d10 = (1.0D - d12) * d14; -- entity.m_6469_(this.m_46077_(), (float)((int)((d10 * d10 + d10) / 2.0D * 7.0D * (double)f2 + 1.0D))); +- entity.hurt(this.getDamageSource(), (float)((int)((d10 * d10 + d10) / 2.0D * 7.0D * (double)f2 + 1.0D))); + + // CraftBukkit start -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = f_46016_; ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = source; + entity.lastDamageCancelled = false; + + // Special case ender dragon only give knockback if no damage is cancelled @@ -67,13 +67,13 @@ + } + + if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon) { -+ for (net.minecraft.world.entity.boss.EnderDragonPart entityComplexPart : ((net.minecraft.world.entity.boss.enderdragon.EnderDragon) entity).f_31089_) { ++ for (net.minecraft.world.entity.boss.EnderDragonPart entityComplexPart : ((net.minecraft.world.entity.boss.enderdragon.EnderDragon) entity).subEntities) { + if (list.contains(entityComplexPart)) { -+ entityComplexPart.m_6469_(this.m_46077_(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f2 + 1.0D))); ++ entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f2 + 1.0D))); + } + } + } else { -+ entity.m_6469_(this.m_46077_(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f2 + 1.0D))); ++ entity.hurt(this.getDamageSource(), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f2 + 1.0D))); + } + + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.entityDamage = null; @@ -84,20 +84,20 @@ + double d11 = d10; if (entity instanceof LivingEntity) { - d11 = ProtectionEnchantment.m_45135_((LivingEntity)entity, d10); + d11 = ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity)entity, d10); @@ -236,17 +_,62 @@ ObjectArrayList> objectarraylist = new ObjectArrayList<>(); - Collections.shuffle(this.f_46020_, this.f_46012_.f_46441_); + Collections.shuffle(this.toBlow, this.level.random); + // CraftBukkit start -+ org.bukkit.World bworld = this.f_46012_.getWorld(); -+ org.bukkit.entity.Entity explode = this.f_46016_ == null ? null : this.f_46016_.getBukkitEntity(); -+ org.bukkit.Location location = new org.bukkit.Location(bworld, this.f_46013_, this.f_46014_, this.f_46015_); ++ org.bukkit.World bworld = this.level.getWorld(); ++ org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity(); ++ org.bukkit.Location location = new org.bukkit.Location(bworld, this.x, this.y, this.z); + + List blockList = Lists.newArrayList(); -+ for (int i1 = this.f_46020_.size() - 1; i1 >= 0; i1--) { -+ BlockPos cpos = (BlockPos) this.f_46020_.get(i1); -+ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.m_123341_(), cpos.m_123342_(), cpos.m_123343_()); ++ for (int i1 = this.toBlow.size() - 1; i1 >= 0; i1--) { ++ BlockPos cpos = (BlockPos) this.toBlow.get(i1); ++ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); + if (!bblock.getType().isAir()) { + blockList.add(bblock); + } @@ -108,24 +108,24 @@ + float yield; + + if (explode != null) { -+ org.bukkit.event.entity.EntityExplodeEvent event = new org.bukkit.event.entity.EntityExplodeEvent(explode, location, blockList, this.f_46010_ == Explosion.BlockInteraction.DESTROY ? 1.0F / this.f_46017_ : 1.0F); -+ this.f_46012_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.entity.EntityExplodeEvent event = new org.bukkit.event.entity.EntityExplodeEvent(explode, location, blockList, this.blockInteraction == Explosion.BlockInteraction.DESTROY ? 1.0F / this.radius : 1.0F); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + cancelled = event.isCancelled(); + bukkitBlocks = event.blockList(); + yield = event.getYield(); + } else { -+ org.bukkit.event.block.BlockExplodeEvent event = new org.bukkit.event.block.BlockExplodeEvent(location.getBlock(), blockList, this.f_46010_ == Explosion.BlockInteraction.DESTROY ? 1.0F / this.f_46017_ : 1.0F); -+ this.f_46012_.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.block.BlockExplodeEvent event = new org.bukkit.event.block.BlockExplodeEvent(location.getBlock(), blockList, this.blockInteraction == Explosion.BlockInteraction.DESTROY ? 1.0F / this.radius : 1.0F); ++ this.level.getCraftServer().getPluginManager().callEvent(event); + cancelled = event.isCancelled(); + bukkitBlocks = event.blockList(); + yield = event.getYield(); + } + -+ this.f_46020_.clear(); ++ this.toBlow.clear(); + + for (org.bukkit.block.Block bblock : bukkitBlocks) { + BlockPos coords = new BlockPos(bblock.getX(), bblock.getY(), bblock.getZ()); -+ f_46020_.add(coords); ++ toBlow.add(coords); + } + + if (cancelled) { @@ -134,41 +134,41 @@ + } + // CraftBukkit end + - for(BlockPos blockpos : this.f_46020_) { - BlockState blockstate = this.f_46012_.m_8055_(blockpos); - Block block = blockstate.m_60734_(); - if (!blockstate.m_60795_()) { - BlockPos blockpos1 = blockpos.m_7949_(); - this.f_46012_.m_46473_().m_6180_("explosion_blocks"); -- if (block.m_6903_(this) && this.f_46012_ instanceof ServerLevel) { -+ if (blockstate.canDropFromExplosion(this.f_46012_, blockpos, this) && this.f_46012_ instanceof ServerLevel) { - BlockEntity blockentity = blockstate.m_155947_() ? this.f_46012_.m_7702_(blockpos) : null; - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_46012_)).m_78977_(this.f_46012_.f_46441_).m_78972_(LootContextParams.f_81460_, Vec3.m_82512_(blockpos)).m_78972_(LootContextParams.f_81463_, ItemStack.f_41583_).m_78984_(LootContextParams.f_81462_, blockentity).m_78984_(LootContextParams.f_81455_, this.f_46016_); -- if (this.f_46010_ == Explosion.BlockInteraction.DESTROY) { -- lootcontext$builder.m_78972_(LootContextParams.f_81464_, this.f_46017_); -+ if (this.f_46010_ == Explosion.BlockInteraction.DESTROY || yield < 1.0F) { // CraftBukkit - add yield -+ lootcontext$builder.m_78972_(LootContextParams.f_81464_, 1.0F / yield); // CraftBukkit - add yield + for(BlockPos blockpos : this.toBlow) { + BlockState blockstate = this.level.getBlockState(blockpos); + Block block = blockstate.getBlock(); + if (!blockstate.isAir()) { + BlockPos blockpos1 = blockpos.immutable(); + this.level.getProfiler().push("explosion_blocks"); +- if (block.dropFromExplosion(this) && this.level instanceof ServerLevel) { ++ if (blockstate.canDropFromExplosion(this.level, blockpos, this) && this.level instanceof ServerLevel) { + BlockEntity blockentity = blockstate.hasBlockEntity() ? this.level.getBlockEntity(blockpos) : null; + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.level)).withRandom(this.level.random).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockpos)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParams.BLOCK_ENTITY, blockentity).withOptionalParameter(LootContextParams.THIS_ENTITY, this.source); +- if (this.blockInteraction == Explosion.BlockInteraction.DESTROY) { +- lootcontext$builder.withParameter(LootContextParams.EXPLOSION_RADIUS, this.radius); ++ if (this.blockInteraction == Explosion.BlockInteraction.DESTROY || yield < 1.0F) { // CraftBukkit - add yield ++ lootcontext$builder.withParameter(LootContextParams.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield } - blockstate.m_60724_(lootcontext$builder).forEach((p_46074_) -> { + blockstate.getDrops(lootcontext$builder).forEach((p_46074_) -> { @@ -254,8 +_,7 @@ }); } -- this.f_46012_.m_7731_(blockpos, Blocks.f_50016_.m_49966_(), 3); -- block.m_7592_(this.f_46012_, blockpos, this); -+ blockstate.onBlockExploded(this.f_46012_, blockpos, this); - this.f_46012_.m_46473_().m_7238_(); +- this.level.setBlock(blockpos, Blocks.AIR.defaultBlockState(), 3); +- block.wasExploded(this.level, blockpos, this); ++ blockstate.onBlockExploded(this.level, blockpos, this); + this.level.getProfiler().pop(); } } @@ -268,7 +_,11 @@ - if (this.f_46009_) { - for(BlockPos blockpos2 : this.f_46020_) { - if (this.f_46011_.nextInt(3) == 0 && this.f_46012_.m_8055_(blockpos2).m_60795_() && this.f_46012_.m_8055_(blockpos2.m_7495_()).m_60804_(this.f_46012_, blockpos2.m_7495_())) { -- this.f_46012_.m_46597_(blockpos2, BaseFireBlock.m_49245_(this.f_46012_, blockpos2)); + if (this.fire) { + for(BlockPos blockpos2 : this.toBlow) { + if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockpos2).isAir() && this.level.getBlockState(blockpos2.below()).isSolidRender(this.level, blockpos2.below())) { +- this.level.setBlockAndUpdate(blockpos2, BaseFireBlock.getState(this.level, blockpos2)); + // CraftBukkit start - Ignition by explosion -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(this.f_46012_, blockpos2.m_123341_(), blockpos2.m_123342_(), blockpos2.m_123343_(), this).isCancelled()) { -+ this.f_46012_.m_46597_(blockpos2, BaseFireBlock.m_49245_(this.f_46012_, blockpos2)); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(this.level, blockpos2.getX(), blockpos2.getY(), blockpos2.getZ(), this).isCancelled()) { ++ this.level.setBlockAndUpdate(blockpos2, BaseFireBlock.getState(this.level, blockpos2)); + } + // CraftBukkit end } @@ -177,15 +177,15 @@ @@ -276,6 +_,7 @@ } - private static void m_46067_(ObjectArrayList> p_46068_, ItemStack p_46069_, BlockPos p_46070_) { -+ if (p_46069_.m_41619_()) return; // CraftBukkit - SPIGOT-5425 + private static void addBlockDrops(ObjectArrayList> p_46068_, ItemStack p_46069_, BlockPos p_46070_) { ++ if (p_46069_.isEmpty()) return; // CraftBukkit - SPIGOT-5425 int i = p_46068_.size(); for(int j = 0; j < i; ++j) { @@ -327,6 +_,15 @@ - public List m_46081_() { - return this.f_46020_; + public List getToBlow() { + return this.toBlow; + } + + public Vec3 getPosition() { @@ -194,7 +194,7 @@ + + @Nullable + public Entity getExploder() { -+ return this.f_46016_; ++ return this.source; } public static enum BlockInteraction { diff --git a/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch b/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch index 5a10defa..ed145a93 100644 --- a/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ExplosionDamageCalculator.java.patch @@ -3,9 +3,9 @@ @@ -7,7 +_,7 @@ public class ExplosionDamageCalculator { - public Optional m_6617_(Explosion p_46099_, BlockGetter p_46100_, BlockPos p_46101_, BlockState p_46102_, FluidState p_46103_) { -- return p_46102_.m_60795_() && p_46103_.m_76178_() ? Optional.empty() : Optional.of(Math.max(p_46102_.m_60734_().m_7325_(), p_46103_.m_76190_())); -+ return p_46102_.m_60795_() && p_46103_.m_76178_() ? Optional.empty() : Optional.of(Math.max(p_46102_.getExplosionResistance(p_46100_, p_46101_, p_46099_), p_46103_.getExplosionResistance(p_46100_, p_46101_, p_46099_))); + public Optional getBlockExplosionResistance(Explosion p_46099_, BlockGetter p_46100_, BlockPos p_46101_, BlockState p_46102_, FluidState p_46103_) { +- return p_46102_.isAir() && p_46103_.isEmpty() ? Optional.empty() : Optional.of(Math.max(p_46102_.getBlock().getExplosionResistance(), p_46103_.getExplosionResistance())); ++ return p_46102_.isAir() && p_46103_.isEmpty() ? Optional.empty() : Optional.of(Math.max(p_46102_.getExplosionResistance(p_46100_, p_46101_, p_46099_), p_46103_.getExplosionResistance(p_46100_, p_46101_, p_46099_))); } - public boolean m_6714_(Explosion p_46094_, BlockGetter p_46095_, BlockPos p_46096_, BlockState p_46097_, float p_46098_) { + public boolean shouldBlockExplode(Explosion p_46094_, BlockGetter p_46095_, BlockPos p_46096_, BlockState p_46097_, float p_46098_) { diff --git a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch index 24cafcb4..efd19611 100644 --- a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch @@ -3,21 +3,21 @@ @@ -19,15 +_,31 @@ } - public static ForcedChunksSavedData m_151483_(CompoundTag p_151484_) { -- return new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.m_128467_("Forced"))); -+ ForcedChunksSavedData savedData = new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.m_128467_("Forced"))); + public static ForcedChunksSavedData load(CompoundTag p_151484_) { +- return new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.getLongArray("Forced"))); ++ ForcedChunksSavedData savedData = new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.getLongArray("Forced"))); + net.minecraftforge.common.world.ForgeChunkManager.readForgeForcedChunks(p_151484_, savedData.blockForcedChunks, savedData.entityForcedChunks); + return savedData; } - public CompoundTag m_7176_(CompoundTag p_46120_) { - p_46120_.m_128388_("Forced", this.f_46114_.toLongArray()); + public CompoundTag save(CompoundTag p_46120_) { + p_46120_.putLongArray("Forced", this.chunks.toLongArray()); + net.minecraftforge.common.world.ForgeChunkManager.writeForgeForcedChunks(p_46120_, this.blockForcedChunks, this.entityForcedChunks); return p_46120_; } - public LongSet m_46116_() { - return this.f_46114_; + public LongSet getChunks() { + return this.chunks; + } + + /* ======================================== FORGE START =====================================*/ diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch index 98545176..d987e5a8 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -5,103 +5,103 @@ import net.minecraft.world.scores.Scoreboard; -public abstract class Level implements LevelAccessor, AutoCloseable { -- public static final Codec> f_46427_ = ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(Registry.f_122819_), ResourceKey::m_135782_); -- public static final ResourceKey f_46428_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("overworld")); -- public static final ResourceKey f_46429_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("the_nether")); -- public static final ResourceKey f_46430_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("the_end")); -- public static final int f_151505_ = 30000000; -- public static final int f_151506_ = 512; -- public static final int f_151507_ = 32; -- private static final Direction[] f_46422_ = Direction.values(); -- public static final int f_151508_ = 15; -- public static final int f_151509_ = 24000; -- public static final int f_151510_ = 20000000; -- public static final int f_151511_ = -20000000; -- protected final List f_151512_ = Lists.newArrayList(); -- private final List f_151503_ = Lists.newArrayList(); -- private boolean f_151504_; -- private final Thread f_46423_; -- private final boolean f_46424_; -- private int f_46425_; -- protected int f_46435_ = (new Random()).nextInt(); -- protected final int f_46436_ = 1013904223; -- public float f_46437_; -- public float f_46438_; -- public float f_46439_; -- public float f_46440_; -- public final Random f_46441_ = new Random(); -- final DimensionType f_46445_; -- private final Holder f_204147_; -- public final WritableLevelData f_46442_; -- private final Supplier f_46446_; -- public final boolean f_46443_; -- private final WorldBorder f_46447_; -- private final BiomeManager f_46420_; -- private final ResourceKey f_46421_; -- private long f_186455_; +- public static final Codec> RESOURCE_KEY_CODEC = ResourceLocation.CODEC.xmap(ResourceKey.elementKey(Registry.DIMENSION_REGISTRY), ResourceKey::location); +- public static final ResourceKey OVERWORLD = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("overworld")); +- public static final ResourceKey NETHER = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("the_nether")); +- public static final ResourceKey END = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("the_end")); +- public static final int MAX_LEVEL_SIZE = 30000000; +- public static final int LONG_PARTICLE_CLIP_RANGE = 512; +- public static final int SHORT_PARTICLE_CLIP_RANGE = 32; +- private static final Direction[] DIRECTIONS = Direction.values(); +- public static final int MAX_BRIGHTNESS = 15; +- public static final int TICKS_PER_DAY = 24000; +- public static final int MAX_ENTITY_SPAWN_Y = 20000000; +- public static final int MIN_ENTITY_SPAWN_Y = -20000000; +- protected final List blockEntityTickers = Lists.newArrayList(); +- private final List pendingBlockEntityTickers = Lists.newArrayList(); +- private boolean tickingBlockEntities; +- private final Thread thread; +- private final boolean isDebug; +- private int skyDarken; +- protected int randValue = (new Random()).nextInt(); +- protected final int addend = 1013904223; +- public float oRainLevel; +- public float rainLevel; +- public float oThunderLevel; +- public float thunderLevel; +- public final Random random = new Random(); +- final DimensionType dimensionType; +- private final Holder dimensionTypeRegistration; +- public final WritableLevelData levelData; +- private final Supplier profiler; +- public final boolean isClientSide; +- private final WorldBorder worldBorder; +- private final BiomeManager biomeManager; +- private final ResourceKey dimension; +- private long subTickCount; - - protected Level(WritableLevelData p_204149_, ResourceKey p_204150_, Holder p_204151_, Supplier p_204152_, boolean p_204153_, boolean p_204154_, long p_204155_) { -- this.f_46446_ = p_204152_; -- this.f_46442_ = p_204149_; -- this.f_204147_ = p_204151_; -- this.f_46445_ = p_204151_.m_203334_(); -- this.f_46421_ = p_204150_; -- this.f_46443_ = p_204153_; -- if (this.f_46445_.m_63959_() != 1.0D) { -- this.f_46447_ = new WorldBorder() { -- public double m_6347_() { -- return super.m_6347_() / Level.this.f_46445_.m_63959_(); +- this.profiler = p_204152_; +- this.levelData = p_204149_; +- this.dimensionTypeRegistration = p_204151_; +- this.dimensionType = p_204151_.value(); +- this.dimension = p_204150_; +- this.isClientSide = p_204153_; +- if (this.dimensionType.coordinateScale() != 1.0D) { +- this.worldBorder = new WorldBorder() { +- public double getCenterX() { +- return super.getCenterX() / Level.this.dimensionType.coordinateScale(); - } - -- public double m_6345_() { -- return super.m_6345_() / Level.this.f_46445_.m_63959_(); +- public double getCenterZ() { +- return super.getCenterZ() / Level.this.dimensionType.coordinateScale(); - } - }; - } else { -- this.f_46447_ = new WorldBorder(); +- this.worldBorder = new WorldBorder(); - } - -- this.f_46423_ = Thread.currentThread(); -- this.f_46420_ = new BiomeManager(this, p_204155_); -- this.f_46424_ = p_204154_; +- this.thread = Thread.currentThread(); +- this.biomeManager = new BiomeManager(this, p_204155_); +- this.isDebug = p_204154_; - } - -- public boolean m_5776_() { -- return this.f_46443_; +- public boolean isClientSide() { +- return this.isClientSide; - } - - @Nullable -- public MinecraftServer m_142572_() { +- public MinecraftServer getServer() { - return null; - } - -- public boolean m_46739_(BlockPos p_46740_) { -- return !this.m_151570_(p_46740_) && m_46457_(p_46740_); +- public boolean isInWorldBounds(BlockPos p_46740_) { +- return !this.isOutsideBuildHeight(p_46740_) && isInWorldBoundsHorizontal(p_46740_); - } - -- public static boolean m_46741_(BlockPos p_46742_) { -- return !m_46724_(p_46742_.m_123342_()) && m_46457_(p_46742_); +- public static boolean isInSpawnableBounds(BlockPos p_46742_) { +- return !isOutsideSpawnableHeight(p_46742_.getY()) && isInWorldBoundsHorizontal(p_46742_); - } - -- private static boolean m_46457_(BlockPos p_46458_) { -- return p_46458_.m_123341_() >= -30000000 && p_46458_.m_123343_() >= -30000000 && p_46458_.m_123341_() < 30000000 && p_46458_.m_123343_() < 30000000; +- private static boolean isInWorldBoundsHorizontal(BlockPos p_46458_) { +- return p_46458_.getX() >= -30000000 && p_46458_.getZ() >= -30000000 && p_46458_.getX() < 30000000 && p_46458_.getZ() < 30000000; - } - -- private static boolean m_46724_(int p_46725_) { +- private static boolean isOutsideSpawnableHeight(int p_46725_) { - return p_46725_ < -20000000 || p_46725_ >= 20000000; - } - -- public LevelChunk m_46745_(BlockPos p_46746_) { -- return this.m_6325_(SectionPos.m_123171_(p_46746_.m_123341_()), SectionPos.m_123171_(p_46746_.m_123343_())); +- public LevelChunk getChunkAt(BlockPos p_46746_) { +- return this.getChunk(SectionPos.blockToSectionCoord(p_46746_.getX()), SectionPos.blockToSectionCoord(p_46746_.getZ())); - } - -- public LevelChunk m_6325_(int p_46727_, int p_46728_) { -- return (LevelChunk)this.m_46819_(p_46727_, p_46728_, ChunkStatus.f_62326_); +- public LevelChunk getChunk(int p_46727_, int p_46728_) { +- return (LevelChunk)this.getChunk(p_46727_, p_46728_, ChunkStatus.FULL); - } - - @Nullable -- public ChunkAccess m_6522_(int p_46502_, int p_46503_, ChunkStatus p_46504_, boolean p_46505_) { -- ChunkAccess chunkaccess = this.m_7726_().m_7587_(p_46502_, p_46503_, p_46504_, p_46505_); +- public ChunkAccess getChunk(int p_46502_, int p_46503_, ChunkStatus p_46504_, boolean p_46505_) { +- ChunkAccess chunkaccess = this.getChunkSource().getChunk(p_46502_, p_46503_, p_46504_, p_46505_); - if (chunkaccess == null && p_46505_) { - throw new IllegalStateException("Should always be able to create a chunk!"); - } else { @@ -109,92 +109,92 @@ - } - } - -- public boolean m_7731_(BlockPos p_46601_, BlockState p_46602_, int p_46603_) { -- return this.m_6933_(p_46601_, p_46602_, p_46603_, 512); +- public boolean setBlock(BlockPos p_46601_, BlockState p_46602_, int p_46603_) { +- return this.setBlock(p_46601_, p_46602_, p_46603_, 512); - } - -- public boolean m_6933_(BlockPos p_46605_, BlockState p_46606_, int p_46607_, int p_46608_) { -- if (this.m_151570_(p_46605_)) { +- public boolean setBlock(BlockPos p_46605_, BlockState p_46606_, int p_46607_, int p_46608_) { +- if (this.isOutsideBuildHeight(p_46605_)) { - return false; -- } else if (!this.f_46443_ && this.m_46659_()) { +- } else if (!this.isClientSide && this.isDebug()) { - return false; - } else { -- LevelChunk levelchunk = this.m_46745_(p_46605_); -- Block block = p_46606_.m_60734_(); -- BlockState blockstate = levelchunk.m_6978_(p_46605_, p_46606_, (p_46607_ & 64) != 0); +- LevelChunk levelchunk = this.getChunkAt(p_46605_); +- Block block = p_46606_.getBlock(); +- BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, (p_46607_ & 64) != 0); - if (blockstate == null) { - return false; - } else { -- BlockState blockstate1 = this.m_8055_(p_46605_); -- if ((p_46607_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.m_60739_(this, p_46605_) != blockstate.m_60739_(this, p_46605_) || blockstate1.m_60791_() != blockstate.m_60791_() || blockstate1.m_60787_() || blockstate.m_60787_())) { -- this.m_46473_().m_6180_("queueCheckLight"); -- this.m_7726_().m_7827_().m_142202_(p_46605_); -- this.m_46473_().m_7238_(); +- BlockState blockstate1 = this.getBlockState(p_46605_); +- if ((p_46607_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.getLightBlock(this, p_46605_) != blockstate.getLightBlock(this, p_46605_) || blockstate1.getLightEmission() != blockstate.getLightEmission() || blockstate1.useShapeForLightOcclusion() || blockstate.useShapeForLightOcclusion())) { +- this.getProfiler().push("queueCheckLight"); +- this.getChunkSource().getLightEngine().checkBlock(p_46605_); +- this.getProfiler().pop(); - } - - if (blockstate1 == p_46606_) { - if (blockstate != blockstate1) { -- this.m_6550_(p_46605_, blockstate, blockstate1); +- this.setBlocksDirty(p_46605_, blockstate, blockstate1); - } - -- if ((p_46607_ & 2) != 0 && (!this.f_46443_ || (p_46607_ & 4) == 0) && (this.f_46443_ || levelchunk.m_6708_() != null && levelchunk.m_6708_().m_140114_(ChunkHolder.FullChunkStatus.TICKING))) { -- this.m_7260_(p_46605_, blockstate, p_46606_, p_46607_); +- if ((p_46607_ & 2) != 0 && (!this.isClientSide || (p_46607_ & 4) == 0) && (this.isClientSide || levelchunk.getFullStatus() != null && levelchunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING))) { +- this.sendBlockUpdated(p_46605_, blockstate, p_46606_, p_46607_); - } - - if ((p_46607_ & 1) != 0) { -- this.m_6289_(p_46605_, blockstate.m_60734_()); -- if (!this.f_46443_ && p_46606_.m_60807_()) { -- this.m_46717_(p_46605_, block); +- this.blockUpdated(p_46605_, blockstate.getBlock()); +- if (!this.isClientSide && p_46606_.hasAnalogOutputSignal()) { +- this.updateNeighbourForOutputSignal(p_46605_, block); - } - } - - if ((p_46607_ & 16) == 0 && p_46608_ > 0) { - int i = p_46607_ & -34; -- blockstate.m_60762_(this, p_46605_, i, p_46608_ - 1); -- p_46606_.m_60705_(this, p_46605_, i, p_46608_ - 1); -- p_46606_.m_60762_(this, p_46605_, i, p_46608_ - 1); +- blockstate.updateIndirectNeighbourShapes(this, p_46605_, i, p_46608_ - 1); +- p_46606_.updateNeighbourShapes(this, p_46605_, i, p_46608_ - 1); +- p_46606_.updateIndirectNeighbourShapes(this, p_46605_, i, p_46608_ - 1); - } - -- this.m_6559_(p_46605_, blockstate, blockstate1); +- this.onBlockStateChange(p_46605_, blockstate, blockstate1); - } - + +public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider implements LevelAccessor, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { -+ public static final Codec> f_46427_ = ResourceLocation.f_135803_.xmap( ResourceKey.m_135797_( Registry.f_122819_ ), ResourceKey::m_135782_ ); -+ public static final ResourceKey f_46428_ = ResourceKey.m_135785_( Registry.f_122819_, new ResourceLocation( "overworld" ) ); -+ public static final ResourceKey f_46429_ = ResourceKey.m_135785_( Registry.f_122819_, new ResourceLocation( "the_nether" ) ); -+ public static final ResourceKey f_46430_ = ResourceKey.m_135785_( Registry.f_122819_, new ResourceLocation( "the_end" ) ); -+ public static final int f_151505_ = 30000000; -+ public static final int f_151506_ = 512; -+ public static final int f_151507_ = 32; -+ private static final Direction[] f_46422_ = Direction.values(); -+ public static final int f_151508_ = 15; -+ public static final int f_151509_ = 24000; -+ public static final int f_151510_ = 20000000; -+ public static final int f_151511_ = -20000000; -+ protected final List f_151512_ = Lists.newArrayList(); ++ public static final Codec> RESOURCE_KEY_CODEC = ResourceLocation.CODEC.xmap( ResourceKey.elementKey( Registry.DIMENSION_REGISTRY ), ResourceKey::location ); ++ public static final ResourceKey OVERWORLD = ResourceKey.create( Registry.DIMENSION_REGISTRY, new ResourceLocation( "overworld" ) ); ++ public static final ResourceKey NETHER = ResourceKey.create( Registry.DIMENSION_REGISTRY, new ResourceLocation( "the_nether" ) ); ++ public static final ResourceKey END = ResourceKey.create( Registry.DIMENSION_REGISTRY, new ResourceLocation( "the_end" ) ); ++ public static final int MAX_LEVEL_SIZE = 30000000; ++ public static final int LONG_PARTICLE_CLIP_RANGE = 512; ++ public static final int SHORT_PARTICLE_CLIP_RANGE = 32; ++ private static final Direction[] DIRECTIONS = Direction.values(); ++ public static final int MAX_BRIGHTNESS = 15; ++ public static final int TICKS_PER_DAY = 24000; ++ public static final int MAX_ENTITY_SPAWN_Y = 20000000; ++ public static final int MIN_ENTITY_SPAWN_Y = -20000000; ++ protected final List blockEntityTickers = Lists.newArrayList(); + protected final org.magmafoundation.magma.mcpatch.updatesuppression.NeighborUpdater neighborUpdater; -+ private final List f_151503_ = Lists.newArrayList(); -+ private boolean f_151504_; -+ private final Thread f_46423_; -+ private final boolean f_46424_; -+ private int f_46425_; -+ protected int f_46435_ = (new Random()).nextInt(); -+ protected final int f_46436_ = 1013904223; -+ public float f_46437_; -+ public float f_46438_; -+ public float f_46439_; -+ public float f_46440_; -+ public final Random f_46441_ = new Random(); -+ final DimensionType f_46445_; -+ private final Holder f_204147_; -+ public final WritableLevelData f_46442_; -+ private final Supplier f_46446_; -+ public final boolean f_46443_; -+ private final WorldBorder f_46447_; -+ private final BiomeManager f_46420_; -+ private final ResourceKey f_46421_; -+ private long f_186455_; ++ private final List pendingBlockEntityTickers = Lists.newArrayList(); ++ private boolean tickingBlockEntities; ++ private final Thread thread; ++ private final boolean isDebug; ++ private int skyDarken; ++ protected int randValue = (new Random()).nextInt(); ++ protected final int addend = 1013904223; ++ public float oRainLevel; ++ public float rainLevel; ++ public float oThunderLevel; ++ public float thunderLevel; ++ public final Random random = new Random(); ++ final DimensionType dimensionType; ++ private final Holder dimensionTypeRegistration; ++ public final WritableLevelData levelData; ++ private final Supplier profiler; ++ public final boolean isClientSide; ++ private final WorldBorder worldBorder; ++ private final BiomeManager biomeManager; ++ private final ResourceKey dimension; ++ private long subTickCount; + public boolean restoringBlockSnapshots = false; + public boolean captureBlockSnapshots = false; + public java.util.ArrayList capturedBlockSnapshots = new java.util.ArrayList<>(); @@ -238,7 +238,7 @@ + + //Magma - remove abstract modifier to fix abstract method error + public ResourceKey getTypeKey() { -+ return net.minecraft.world.level.levelgen.WorldGenSettings.m_190052_(typeKey); ++ return net.minecraft.world.level.levelgen.WorldGenSettings.levelToLevelStem(typeKey); + } + + public static void setGeneratorAndEnv(org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { @@ -252,7 +252,7 @@ + super( Level.class ); + this.typeKey = p_204150_; + try { -+ this.init_levelName = p_204149_ == null ? org.apache.logging.log4j.util.Strings.EMPTY : ((net.minecraft.world.level.storage.ServerLevelData) p_204149_).m_5462_(); ++ this.init_levelName = p_204149_ == null ? org.apache.logging.log4j.util.Strings.EMPTY : ((net.minecraft.world.level.storage.ServerLevelData) p_204149_).getLevelName(); + } catch (ClassCastException e) { + org.magmafoundation.magma.Magma.LOGGER.error("Failed to get level name from WritableLevelData, using empty string instead", e); + this.init_levelName = org.apache.logging.log4j.util.Strings.EMPTY; @@ -267,71 +267,71 @@ + } + } + if (generator == null && p_204150_ != null) { //Magma -+ generator = getCraftServer().getGenerator( p_204150_.getRegistryName().m_135827_() ); ++ generator = getCraftServer().getGenerator( p_204150_.getRegistryName().getNamespace() ); + } + if (environment == null) { + environment = org.magmafoundation.magma.forge.ForgeInject.environments.getOrDefault(getTypeKey(), org.bukkit.World.Environment.CUSTOM); + } + // CraftBukkit end -+ this.f_46446_ = p_204152_; -+ this.f_46442_ = p_204149_; -+ this.f_204147_ = p_204151_; -+ this.f_46445_ = p_204151_.m_203334_(); -+ this.f_46421_ = p_204150_; -+ this.f_46443_ = p_204153_; -+ if (this.f_46445_.m_63959_() != 1.0D) { -+ this.f_46447_ = new WorldBorder() { -+ public double m_6347_() { -+ return super.m_6347_(); // CraftBukkit ++ this.profiler = p_204152_; ++ this.levelData = p_204149_; ++ this.dimensionTypeRegistration = p_204151_; ++ this.dimensionType = p_204151_.value(); ++ this.dimension = p_204150_; ++ this.isClientSide = p_204153_; ++ if (this.dimensionType.coordinateScale() != 1.0D) { ++ this.worldBorder = new WorldBorder() { ++ public double getCenterX() { ++ return super.getCenterX(); // CraftBukkit + } + -+ public double m_6345_() { -+ return super.m_6345_(); // CraftBukkit ++ public double getCenterZ() { ++ return super.getCenterZ(); // CraftBukkit + } + }; + } else { -+ this.f_46447_ = new WorldBorder(); ++ this.worldBorder = new WorldBorder(); + } + -+ this.f_46423_ = Thread.currentThread(); -+ this.f_46420_ = new BiomeManager( this, p_204155_ ); -+ this.f_46424_ = p_204154_; ++ this.thread = Thread.currentThread(); ++ this.biomeManager = new BiomeManager( this, p_204155_ ); ++ this.isDebug = p_204154_; + this.neighborUpdater = new org.magmafoundation.magma.mcpatch.updatesuppression.CollectingNeighborUpdater(this, org.magmafoundation.magma.configuration.MagmaConfig.instance.updateSuppressionMaxUpdates.getValues()); + // CraftBukkit start -+ m_6857_().world = this; //Magma - fix ClassCastException ++ getWorldBorder().world = this; //Magma - fix ClassCastException + // From PlayerList.setPlayerFileData -+ m_6857_().m_61929_( new net.minecraft.world.level.border.BorderChangeListener() { ++ getWorldBorder().addListener( new net.minecraft.world.level.border.BorderChangeListener() { + @Override -+ public void m_6312_(WorldBorder worldborder, double d0) { ++ public void onBorderSizeSet(WorldBorder worldborder, double d0) { + getCraftServer().getHandle().broadcastAll( new net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket( worldborder ), worldborder.world ); + } + + @Override -+ public void m_6689_(WorldBorder worldborder, double d0, double d1, long i) { ++ public void onBorderSizeLerping(WorldBorder worldborder, double d0, double d1, long i) { + getCraftServer().getHandle().broadcastAll( new net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket( worldborder ), worldborder.world ); + } + + @Override -+ public void m_7721_(WorldBorder worldborder, double d0, double d1) { ++ public void onBorderCenterSet(WorldBorder worldborder, double d0, double d1) { + getCraftServer().getHandle().broadcastAll( new net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket( worldborder ), worldborder.world ); + } + + @Override -+ public void m_5904_(WorldBorder worldborder, int i) { ++ public void onBorderSetWarningTime(WorldBorder worldborder, int i) { + getCraftServer().getHandle().broadcastAll( new net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket( worldborder ), worldborder.world ); + } + + @Override -+ public void m_5903_(WorldBorder worldborder, int i) { ++ public void onBorderSetWarningBlocks(WorldBorder worldborder, int i) { + getCraftServer().getHandle().broadcastAll( new net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket( worldborder ), worldborder.world ); + } + + @Override -+ public void m_6315_(WorldBorder worldborder, double d0) { ++ public void onBorderSetDamagePerBlock(WorldBorder worldborder, double d0) { + } + + @Override -+ public void m_6313_(WorldBorder worldborder, double d0) { ++ public void onBorderSetDamageSafeZOne(WorldBorder worldborder, double d0) { + } + } ); + // CraftBukkit end @@ -341,42 +341,42 @@ + this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); + } + -+ public boolean m_5776_() { -+ return this.f_46443_; ++ public boolean isClientSide() { ++ return this.isClientSide; + } + + @Nullable -+ public MinecraftServer m_142572_() { ++ public MinecraftServer getServer() { + return MinecraftServer.getServer(); + } + -+ public boolean m_46739_(BlockPos p_46740_) { -+ return !this.m_151570_( p_46740_ ) && m_46457_( p_46740_ ); ++ public boolean isInWorldBounds(BlockPos p_46740_) { ++ return !this.isOutsideBuildHeight( p_46740_ ) && isInWorldBoundsHorizontal( p_46740_ ); + } + -+ public static boolean m_46741_(BlockPos p_46742_) { -+ return !m_46724_( p_46742_.m_123342_() ) && m_46457_( p_46742_ ); ++ public static boolean isInSpawnableBounds(BlockPos p_46742_) { ++ return !isOutsideSpawnableHeight( p_46742_.getY() ) && isInWorldBoundsHorizontal( p_46742_ ); + } + -+ private static boolean m_46457_(BlockPos p_46458_) { -+ return p_46458_.m_123341_() >= -30000000 && p_46458_.m_123343_() >= -30000000 && p_46458_.m_123341_() < 30000000 && p_46458_.m_123343_() < 30000000; ++ private static boolean isInWorldBoundsHorizontal(BlockPos p_46458_) { ++ return p_46458_.getX() >= -30000000 && p_46458_.getZ() >= -30000000 && p_46458_.getX() < 30000000 && p_46458_.getZ() < 30000000; + } + -+ private static boolean m_46724_(int p_46725_) { ++ private static boolean isOutsideSpawnableHeight(int p_46725_) { + return p_46725_ < -20000000 || p_46725_ >= 20000000; + } + -+ public LevelChunk m_46745_(BlockPos p_46746_) { -+ return this.m_6325_( SectionPos.m_123171_( p_46746_.m_123341_() ), SectionPos.m_123171_( p_46746_.m_123343_() ) ); ++ public LevelChunk getChunkAt(BlockPos p_46746_) { ++ return this.getChunk( SectionPos.blockToSectionCoord( p_46746_.getX() ), SectionPos.blockToSectionCoord( p_46746_.getZ() ) ); + } + -+ public LevelChunk m_6325_(int p_46727_, int p_46728_) { -+ return (LevelChunk) this.m_46819_( p_46727_, p_46728_, ChunkStatus.f_62326_ ); ++ public LevelChunk getChunk(int p_46727_, int p_46728_) { ++ return (LevelChunk) this.getChunk( p_46727_, p_46728_, ChunkStatus.FULL ); + } + + @Nullable -+ public ChunkAccess m_6522_(int p_46502_, int p_46503_, ChunkStatus p_46504_, boolean p_46505_) { -+ ChunkAccess chunkaccess = this.m_7726_().m_7587_( p_46502_, p_46503_, p_46504_, p_46505_ ); ++ public ChunkAccess getChunk(int p_46502_, int p_46503_, ChunkStatus p_46504_, boolean p_46505_) { ++ ChunkAccess chunkaccess = this.getChunkSource().getChunk( p_46502_, p_46503_, p_46504_, p_46505_ ); + if (chunkaccess == null && p_46505_) { + throw new IllegalStateException( "Should always be able to create a chunk!" ); + } else { @@ -384,17 +384,17 @@ + } + } + -+ public boolean m_7731_(BlockPos p_46601_, BlockState p_46602_, int p_46603_) { -+ return this.m_6933_(p_46601_, p_46602_, p_46603_, 512); ++ public boolean setBlock(BlockPos p_46601_, BlockState p_46602_, int p_46603_) { ++ return this.setBlock(p_46601_, p_46602_, p_46603_, 512); + } + -+ public boolean m_6933_(BlockPos p_46605_, BlockState p_46606_, int p_46607_, int p_46608_) { ++ public boolean setBlock(BlockPos p_46605_, BlockState p_46606_, int p_46607_, int p_46608_) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + org.bukkit.craftbukkit.v1_18_R2.block.CapturedBlockState blockstate = capturedBlockStates.get(p_46605_); + if (blockstate == null) { + blockstate = org.bukkit.craftbukkit.v1_18_R2.block.CapturedBlockState.getTreeBlockState(this, p_46605_, p_46607_); -+ this.capturedBlockStates.put(p_46605_.m_7949_(), blockstate); ++ this.capturedBlockStates.put(p_46605_.immutable(), blockstate); + } + blockstate.setData(p_46606_); return true; @@ -402,324 +402,324 @@ - } - } - -- public void m_6559_(BlockPos p_46609_, BlockState p_46610_, BlockState p_46611_) { +- public void onBlockStateChange(BlockPos p_46609_, BlockState p_46610_, BlockState p_46611_) { - } - -- public boolean m_7471_(BlockPos p_46623_, boolean p_46624_) { -- FluidState fluidstate = this.m_6425_(p_46623_); -- return this.m_7731_(p_46623_, fluidstate.m_76188_(), 3 | (p_46624_ ? 64 : 0)); +- public boolean removeBlock(BlockPos p_46623_, boolean p_46624_) { +- FluidState fluidstate = this.getFluidState(p_46623_); +- return this.setBlock(p_46623_, fluidstate.createLegacyBlock(), 3 | (p_46624_ ? 64 : 0)); - } - -- public boolean m_7740_(BlockPos p_46626_, boolean p_46627_, @Nullable Entity p_46628_, int p_46629_) { -- BlockState blockstate = this.m_8055_(p_46626_); -- if (blockstate.m_60795_()) { +- public boolean destroyBlock(BlockPos p_46626_, boolean p_46627_, @Nullable Entity p_46628_, int p_46629_) { +- BlockState blockstate = this.getBlockState(p_46626_); +- if (blockstate.isAir()) { - return false; - } else { -- FluidState fluidstate = this.m_6425_(p_46626_); -- if (!(blockstate.m_60734_() instanceof BaseFireBlock)) { -- this.m_46796_(2001, p_46626_, Block.m_49956_(blockstate)); +- FluidState fluidstate = this.getFluidState(p_46626_); +- if (!(blockstate.getBlock() instanceof BaseFireBlock)) { +- this.levelEvent(2001, p_46626_, Block.getId(blockstate)); - } - - if (p_46627_) { -- BlockEntity blockentity = blockstate.m_155947_() ? this.m_7702_(p_46626_) : null; -- Block.m_49881_(blockstate, this, p_46626_, blockentity, p_46628_, ItemStack.f_41583_); +- BlockEntity blockentity = blockstate.hasBlockEntity() ? this.getBlockEntity(p_46626_) : null; +- Block.dropResources(blockstate, this, p_46626_, blockentity, p_46628_, ItemStack.EMPTY); - } - -- boolean flag = this.m_6933_(p_46626_, fluidstate.m_76188_(), 3, p_46629_); +- boolean flag = this.setBlock(p_46626_, fluidstate.createLegacyBlock(), 3, p_46629_); - if (flag) { -- this.m_142346_(p_46628_, GameEvent.f_157794_, p_46626_); +- this.gameEvent(p_46628_, GameEvent.BLOCK_DESTROY, p_46626_); - } - - return flag; - } - } - -- public void m_142052_(BlockPos p_151531_, BlockState p_151532_) { +- public void addDestroyBlockEffect(BlockPos p_151531_, BlockState p_151532_) { - } - -- public boolean m_46597_(BlockPos p_46598_, BlockState p_46599_) { -- return this.m_7731_(p_46598_, p_46599_, 3); +- public boolean setBlockAndUpdate(BlockPos p_46598_, BlockState p_46599_) { +- return this.setBlock(p_46598_, p_46599_, 3); - } - -- public abstract void m_7260_(BlockPos p_46612_, BlockState p_46613_, BlockState p_46614_, int p_46615_); +- public abstract void sendBlockUpdated(BlockPos p_46612_, BlockState p_46613_, BlockState p_46614_, int p_46615_); - -- public void m_6550_(BlockPos p_46678_, BlockState p_46679_, BlockState p_46680_) { +- public void setBlocksDirty(BlockPos p_46678_, BlockState p_46679_, BlockState p_46680_) { - } - -- public void m_46672_(BlockPos p_46673_, Block p_46674_) { -- this.m_46586_(p_46673_.m_142125_(), p_46674_, p_46673_); -- this.m_46586_(p_46673_.m_142126_(), p_46674_, p_46673_); -- this.m_46586_(p_46673_.m_7495_(), p_46674_, p_46673_); -- this.m_46586_(p_46673_.m_7494_(), p_46674_, p_46673_); -- this.m_46586_(p_46673_.m_142127_(), p_46674_, p_46673_); -- this.m_46586_(p_46673_.m_142128_(), p_46674_, p_46673_); +- public void updateNeighborsAt(BlockPos p_46673_, Block p_46674_) { +- this.neighborChanged(p_46673_.west(), p_46674_, p_46673_); +- this.neighborChanged(p_46673_.east(), p_46674_, p_46673_); +- this.neighborChanged(p_46673_.below(), p_46674_, p_46673_); +- this.neighborChanged(p_46673_.above(), p_46674_, p_46673_); +- this.neighborChanged(p_46673_.north(), p_46674_, p_46673_); +- this.neighborChanged(p_46673_.south(), p_46674_, p_46673_); - } - -- public void m_46590_(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { +- public void updateNeighborsAtExceptFromFacing(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { - if (p_46593_ != Direction.WEST) { -- this.m_46586_(p_46591_.m_142125_(), p_46592_, p_46591_); +- this.neighborChanged(p_46591_.west(), p_46592_, p_46591_); - } - - if (p_46593_ != Direction.EAST) { -- this.m_46586_(p_46591_.m_142126_(), p_46592_, p_46591_); +- this.neighborChanged(p_46591_.east(), p_46592_, p_46591_); - } - - if (p_46593_ != Direction.DOWN) { -- this.m_46586_(p_46591_.m_7495_(), p_46592_, p_46591_); +- this.neighborChanged(p_46591_.below(), p_46592_, p_46591_); - } - - if (p_46593_ != Direction.UP) { -- this.m_46586_(p_46591_.m_7494_(), p_46592_, p_46591_); +- this.neighborChanged(p_46591_.above(), p_46592_, p_46591_); - } - - if (p_46593_ != Direction.NORTH) { -- this.m_46586_(p_46591_.m_142127_(), p_46592_, p_46591_); +- this.neighborChanged(p_46591_.north(), p_46592_, p_46591_); - } - - if (p_46593_ != Direction.SOUTH) { -- this.m_46586_(p_46591_.m_142128_(), p_46592_, p_46591_); +- this.neighborChanged(p_46591_.south(), p_46592_, p_46591_); - } - - } - -- public void m_46586_(BlockPos p_46587_, Block p_46588_, BlockPos p_46589_) { -- if (!this.f_46443_) { -- BlockState blockstate = this.m_8055_(p_46587_); +- public void neighborChanged(BlockPos p_46587_, Block p_46588_, BlockPos p_46589_) { +- if (!this.isClientSide) { +- BlockState blockstate = this.getBlockState(p_46587_); - - try { -- blockstate.m_60690_(this, p_46587_, p_46588_, p_46589_, false); +- blockstate.neighborChanged(this, p_46587_, p_46588_, p_46589_, false); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Exception while updating neighbours"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being updated"); -- crashreportcategory.m_128165_("Source block type", () -> { +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Block being updated"); +- crashreportcategory.setDetail("Source block type", () -> { - try { -- return String.format("ID #%s (%s // %s)", Registry.f_122824_.m_7981_(p_46588_), p_46588_.m_7705_(), p_46588_.getClass().getCanonicalName()); +- return String.format("ID #%s (%s // %s)", Registry.BLOCK.getKey(p_46588_), p_46588_.getDescriptionId(), p_46588_.getClass().getCanonicalName()); - } catch (Throwable throwable1) { -- return "ID #" + Registry.f_122824_.m_7981_(p_46588_); +- return "ID #" + Registry.BLOCK.getKey(p_46588_); - } - }); -- CrashReportCategory.m_178950_(crashreportcategory, this, p_46587_, blockstate); +- CrashReportCategory.populateBlockDetails(crashreportcategory, this, p_46587_, blockstate); - throw new ReportedException(crashreport); - } - } - } - -- public int m_6924_(Heightmap.Types p_46571_, int p_46572_, int p_46573_) { +- public int getHeight(Heightmap.Types p_46571_, int p_46572_, int p_46573_) { - int i; - if (p_46572_ >= -30000000 && p_46573_ >= -30000000 && p_46572_ < 30000000 && p_46573_ < 30000000) { -- if (this.m_7232_(SectionPos.m_123171_(p_46572_), SectionPos.m_123171_(p_46573_))) { -- i = this.m_6325_(SectionPos.m_123171_(p_46572_), SectionPos.m_123171_(p_46573_)).m_5885_(p_46571_, p_46572_ & 15, p_46573_ & 15) + 1; +- if (this.hasChunk(SectionPos.blockToSectionCoord(p_46572_), SectionPos.blockToSectionCoord(p_46573_))) { +- i = this.getChunk(SectionPos.blockToSectionCoord(p_46572_), SectionPos.blockToSectionCoord(p_46573_)).getHeight(p_46571_, p_46572_ & 15, p_46573_ & 15) + 1; - } else { -- i = this.m_141937_(); +- i = this.getMinBuildHeight(); - } - } else { -- i = this.m_5736_() + 1; +- i = this.getSeaLevel() + 1; - } - - return i; - } - -- public LevelLightEngine m_5518_() { -- return this.m_7726_().m_7827_(); +- public LevelLightEngine getLightEngine() { +- return this.getChunkSource().getLightEngine(); - } - -- public BlockState m_8055_(BlockPos p_46732_) { -- if (this.m_151570_(p_46732_)) { -- return Blocks.f_50626_.m_49966_(); +- public BlockState getBlockState(BlockPos p_46732_) { +- if (this.isOutsideBuildHeight(p_46732_)) { +- return Blocks.VOID_AIR.defaultBlockState(); - } else { -- LevelChunk levelchunk = this.m_6325_(SectionPos.m_123171_(p_46732_.m_123341_()), SectionPos.m_123171_(p_46732_.m_123343_())); -- return levelchunk.m_8055_(p_46732_); +- LevelChunk levelchunk = this.getChunk(SectionPos.blockToSectionCoord(p_46732_.getX()), SectionPos.blockToSectionCoord(p_46732_.getZ())); +- return levelchunk.getBlockState(p_46732_); - } - } - -- public FluidState m_6425_(BlockPos p_46671_) { -- if (this.m_151570_(p_46671_)) { -- return Fluids.f_76191_.m_76145_(); +- public FluidState getFluidState(BlockPos p_46671_) { +- if (this.isOutsideBuildHeight(p_46671_)) { +- return Fluids.EMPTY.defaultFluidState(); - } else { -- LevelChunk levelchunk = this.m_46745_(p_46671_); -- return levelchunk.m_6425_(p_46671_); +- LevelChunk levelchunk = this.getChunkAt(p_46671_); +- return levelchunk.getFluidState(p_46671_); - } - } - -- public boolean m_46461_() { -- return !this.m_6042_().m_63967_() && this.f_46425_ < 4; +- public boolean isDay() { +- return !this.dimensionType().hasFixedTime() && this.skyDarken < 4; - } - -- public boolean m_46462_() { -- return !this.m_6042_().m_63967_() && !this.m_46461_(); +- public boolean isNight() { +- return !this.dimensionType().hasFixedTime() && !this.isDay(); - } - -- public void m_5594_(@Nullable Player p_46560_, BlockPos p_46561_, SoundEvent p_46562_, SoundSource p_46563_, float p_46564_, float p_46565_) { -- this.m_6263_(p_46560_, (double)p_46561_.m_123341_() + 0.5D, (double)p_46561_.m_123342_() + 0.5D, (double)p_46561_.m_123343_() + 0.5D, p_46562_, p_46563_, p_46564_, p_46565_); +- public void playSound(@Nullable Player p_46560_, BlockPos p_46561_, SoundEvent p_46562_, SoundSource p_46563_, float p_46564_, float p_46565_) { +- this.playSound(p_46560_, (double)p_46561_.getX() + 0.5D, (double)p_46561_.getY() + 0.5D, (double)p_46561_.getZ() + 0.5D, p_46562_, p_46563_, p_46564_, p_46565_); - } - -- public abstract void m_6263_(@Nullable Player p_46543_, double p_46544_, double p_46545_, double p_46546_, SoundEvent p_46547_, SoundSource p_46548_, float p_46549_, float p_46550_); +- public abstract void playSound(@Nullable Player p_46543_, double p_46544_, double p_46545_, double p_46546_, SoundEvent p_46547_, SoundSource p_46548_, float p_46549_, float p_46550_); - -- public abstract void m_6269_(@Nullable Player p_46551_, Entity p_46552_, SoundEvent p_46553_, SoundSource p_46554_, float p_46555_, float p_46556_); +- public abstract void playSound(@Nullable Player p_46551_, Entity p_46552_, SoundEvent p_46553_, SoundSource p_46554_, float p_46555_, float p_46556_); - -- public void m_7785_(double p_46482_, double p_46483_, double p_46484_, SoundEvent p_46485_, SoundSource p_46486_, float p_46487_, float p_46488_, boolean p_46489_) { +- public void playLocalSound(double p_46482_, double p_46483_, double p_46484_, SoundEvent p_46485_, SoundSource p_46486_, float p_46487_, float p_46488_, boolean p_46489_) { - } - -- public void m_7106_(ParticleOptions p_46631_, double p_46632_, double p_46633_, double p_46634_, double p_46635_, double p_46636_, double p_46637_) { +- public void addParticle(ParticleOptions p_46631_, double p_46632_, double p_46633_, double p_46634_, double p_46635_, double p_46636_, double p_46637_) { - } - -- public void m_6493_(ParticleOptions p_46638_, boolean p_46639_, double p_46640_, double p_46641_, double p_46642_, double p_46643_, double p_46644_, double p_46645_) { +- public void addParticle(ParticleOptions p_46638_, boolean p_46639_, double p_46640_, double p_46641_, double p_46642_, double p_46643_, double p_46644_, double p_46645_) { - } - -- public void m_7107_(ParticleOptions p_46684_, double p_46685_, double p_46686_, double p_46687_, double p_46688_, double p_46689_, double p_46690_) { +- public void addAlwaysVisibleParticle(ParticleOptions p_46684_, double p_46685_, double p_46686_, double p_46687_, double p_46688_, double p_46689_, double p_46690_) { - } - -- public void m_6485_(ParticleOptions p_46691_, boolean p_46692_, double p_46693_, double p_46694_, double p_46695_, double p_46696_, double p_46697_, double p_46698_) { +- public void addAlwaysVisibleParticle(ParticleOptions p_46691_, boolean p_46692_, double p_46693_, double p_46694_, double p_46695_, double p_46696_, double p_46697_, double p_46698_) { - } - -- public float m_46490_(float p_46491_) { -- float f = this.m_46942_(p_46491_); +- public float getSunAngle(float p_46491_) { +- float f = this.getTimeOfDay(p_46491_); - return f * ((float)Math.PI * 2F); - } - -- public void m_151525_(TickingBlockEntity p_151526_) { -- (this.f_151504_ ? this.f_151503_ : this.f_151512_).add(p_151526_); +- public void addBlockEntityTicker(TickingBlockEntity p_151526_) { +- (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); - } - -- protected void m_46463_() { -- ProfilerFiller profilerfiller = this.m_46473_(); -- profilerfiller.m_6180_("blockEntities"); -- this.f_151504_ = true; -- if (!this.f_151503_.isEmpty()) { -- this.f_151512_.addAll(this.f_151503_); -- this.f_151503_.clear(); +- protected void tickBlockEntities() { +- ProfilerFiller profilerfiller = this.getProfiler(); +- profilerfiller.push("blockEntities"); +- this.tickingBlockEntities = true; +- if (!this.pendingBlockEntityTickers.isEmpty()) { +- this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); +- this.pendingBlockEntityTickers.clear(); - } - -- Iterator iterator = this.f_151512_.iterator(); +- Iterator iterator = this.blockEntityTickers.iterator(); - - while(iterator.hasNext()) { - TickingBlockEntity tickingblockentity = iterator.next(); -- if (tickingblockentity.m_142220_()) { +- if (tickingblockentity.isRemoved()) { - iterator.remove(); -- } else if (this.m_183438_(ChunkPos.m_151388_(tickingblockentity.m_142689_()))) { -- tickingblockentity.m_142224_(); +- } else if (this.shouldTickBlocksAt(ChunkPos.asLong(tickingblockentity.getPos()))) { +- tickingblockentity.tick(); - } - } - -- this.f_151504_ = false; -- profilerfiller.m_7238_(); +- this.tickingBlockEntities = false; +- profilerfiller.pop(); - } - -- public void m_46653_(Consumer p_46654_, T p_46655_) { +- public void guardEntityTick(Consumer p_46654_, T p_46655_) { - try { - p_46654_.accept(p_46655_); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking entity"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Entity being ticked"); -- p_46655_.m_7976_(crashreportcategory); +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking entity"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Entity being ticked"); +- p_46655_.fillCrashReportCategory(crashreportcategory); - throw new ReportedException(crashreport); - } - } - -- public boolean m_183599_(Entity p_186458_) { +- public boolean shouldTickDeath(Entity p_186458_) { - return true; - } - -- public boolean m_183438_(long p_186456_) { +- public boolean shouldTickBlocksAt(long p_186456_) { - return true; - } - -- public Explosion m_46511_(@Nullable Entity p_46512_, double p_46513_, double p_46514_, double p_46515_, float p_46516_, Explosion.BlockInteraction p_46517_) { -- return this.m_7703_(p_46512_, (DamageSource)null, (ExplosionDamageCalculator)null, p_46513_, p_46514_, p_46515_, p_46516_, false, p_46517_); +- public Explosion explode(@Nullable Entity p_46512_, double p_46513_, double p_46514_, double p_46515_, float p_46516_, Explosion.BlockInteraction p_46517_) { +- return this.explode(p_46512_, (DamageSource)null, (ExplosionDamageCalculator)null, p_46513_, p_46514_, p_46515_, p_46516_, false, p_46517_); - } - -- public Explosion m_46518_(@Nullable Entity p_46519_, double p_46520_, double p_46521_, double p_46522_, float p_46523_, boolean p_46524_, Explosion.BlockInteraction p_46525_) { -- return this.m_7703_(p_46519_, (DamageSource)null, (ExplosionDamageCalculator)null, p_46520_, p_46521_, p_46522_, p_46523_, p_46524_, p_46525_); +- public Explosion explode(@Nullable Entity p_46519_, double p_46520_, double p_46521_, double p_46522_, float p_46523_, boolean p_46524_, Explosion.BlockInteraction p_46525_) { +- return this.explode(p_46519_, (DamageSource)null, (ExplosionDamageCalculator)null, p_46520_, p_46521_, p_46522_, p_46523_, p_46524_, p_46525_); - } - -- public Explosion m_7703_(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { +- public Explosion explode(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { - Explosion explosion = new Explosion(this, p_46526_, p_46527_, p_46528_, p_46529_, p_46530_, p_46531_, p_46532_, p_46533_, p_46534_); -- explosion.m_46061_(); -- explosion.m_46075_(true); +- explosion.explode(); +- explosion.finalizeExplosion(true); - return explosion; - } - -- public abstract String m_46464_(); +- public abstract String gatherChunkSourceStats(); - - @Nullable -- public BlockEntity m_7702_(BlockPos p_46716_) { -- if (this.m_151570_(p_46716_)) { +- public BlockEntity getBlockEntity(BlockPos p_46716_) { +- if (this.isOutsideBuildHeight(p_46716_)) { - return null; - } else { -- return !this.f_46443_ && Thread.currentThread() != this.f_46423_ ? null : this.m_46745_(p_46716_).m_5685_(p_46716_, LevelChunk.EntityCreationType.IMMEDIATE); +- return !this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(p_46716_).getBlockEntity(p_46716_, LevelChunk.EntityCreationType.IMMEDIATE); - } - } - -- public void m_151523_(BlockEntity p_151524_) { -- BlockPos blockpos = p_151524_.m_58899_(); -- if (!this.m_151570_(blockpos)) { -- this.m_46745_(blockpos).m_142170_(p_151524_); +- public void setBlockEntity(BlockEntity p_151524_) { +- BlockPos blockpos = p_151524_.getBlockPos(); +- if (!this.isOutsideBuildHeight(blockpos)) { +- this.getChunkAt(blockpos).addAndRegisterBlockEntity(p_151524_); - } - } - -- public void m_46747_(BlockPos p_46748_) { -- if (!this.m_151570_(p_46748_)) { -- this.m_46745_(p_46748_).m_8114_(p_46748_); +- public void removeBlockEntity(BlockPos p_46748_) { +- if (!this.isOutsideBuildHeight(p_46748_)) { +- this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); - } - } - -- public boolean m_46749_(BlockPos p_46750_) { -- return this.m_151570_(p_46750_) ? false : this.m_7726_().m_5563_(SectionPos.m_123171_(p_46750_.m_123341_()), SectionPos.m_123171_(p_46750_.m_123343_())); +- public boolean isLoaded(BlockPos p_46750_) { +- return this.isOutsideBuildHeight(p_46750_) ? false : this.getChunkSource().hasChunk(SectionPos.blockToSectionCoord(p_46750_.getX()), SectionPos.blockToSectionCoord(p_46750_.getZ())); - } - -- public boolean m_46578_(BlockPos p_46579_, Entity p_46580_, Direction p_46581_) { -- if (this.m_151570_(p_46579_)) { +- public boolean loadedAndEntityCanStandOnFace(BlockPos p_46579_, Entity p_46580_, Direction p_46581_) { +- if (this.isOutsideBuildHeight(p_46579_)) { - return false; - } else { -- ChunkAccess chunkaccess = this.m_6522_(SectionPos.m_123171_(p_46579_.m_123341_()), SectionPos.m_123171_(p_46579_.m_123343_()), ChunkStatus.f_62326_, false); -- return chunkaccess == null ? false : chunkaccess.m_8055_(p_46579_).m_60638_(this, p_46579_, p_46580_, p_46581_); +- ChunkAccess chunkaccess = this.getChunk(SectionPos.blockToSectionCoord(p_46579_.getX()), SectionPos.blockToSectionCoord(p_46579_.getZ()), ChunkStatus.FULL, false); +- return chunkaccess == null ? false : chunkaccess.getBlockState(p_46579_).entityCanStandOnFace(this, p_46579_, p_46580_, p_46581_); - } - } - -- public boolean m_46575_(BlockPos p_46576_, Entity p_46577_) { -- return this.m_46578_(p_46576_, p_46577_, Direction.UP); +- public boolean loadedAndEntityCanStandOn(BlockPos p_46576_, Entity p_46577_) { +- return this.loadedAndEntityCanStandOnFace(p_46576_, p_46577_, Direction.UP); - } - -- public void m_46465_() { -- double d0 = 1.0D - (double)(this.m_46722_(1.0F) * 5.0F) / 16.0D; -- double d1 = 1.0D - (double)(this.m_46661_(1.0F) * 5.0F) / 16.0D; -- double d2 = 0.5D + 2.0D * Mth.m_14008_((double)Mth.m_14089_(this.m_46942_(1.0F) * ((float)Math.PI * 2F)), -0.25D, 0.25D); -- this.f_46425_ = (int)((1.0D - d2 * d0 * d1) * 11.0D); +- public void updateSkyBrightness() { +- double d0 = 1.0D - (double)(this.getRainLevel(1.0F) * 5.0F) / 16.0D; +- double d1 = 1.0D - (double)(this.getThunderLevel(1.0F) * 5.0F) / 16.0D; +- double d2 = 0.5D + 2.0D * Mth.clamp((double)Mth.cos(this.getTimeOfDay(1.0F) * ((float)Math.PI * 2F)), -0.25D, 0.25D); +- this.skyDarken = (int)((1.0D - d2 * d0 * d1) * 11.0D); - } - -- public void m_46703_(boolean p_46704_, boolean p_46705_) { -- this.m_7726_().m_6707_(p_46704_, p_46705_); +- public void setSpawnSettings(boolean p_46704_, boolean p_46705_) { +- this.getChunkSource().setSpawnSettings(p_46704_, p_46705_); - } - -- protected void m_46466_() { -- if (this.f_46442_.m_6533_()) { -- this.f_46438_ = 1.0F; -- if (this.f_46442_.m_6534_()) { -- this.f_46440_ = 1.0F; +- protected void prepareWeather() { +- if (this.levelData.isRaining()) { +- this.rainLevel = 1.0F; +- if (this.levelData.isThundering()) { +- this.thunderLevel = 1.0F; - } - } - - } - - public void close() throws IOException { -- this.m_7726_().close(); +- this.getChunkSource().close(); - } - - @Nullable -- public BlockGetter m_7925_(int p_46711_, int p_46712_) { -- return this.m_6522_(p_46711_, p_46712_, ChunkStatus.f_62326_, false); +- public BlockGetter getChunkForCollisions(int p_46711_, int p_46712_) { +- return this.getChunk(p_46711_, p_46712_, ChunkStatus.FULL, false); - } - -- public List m_6249_(@Nullable Entity p_46536_, AABB p_46537_, Predicate p_46538_) { -- this.m_46473_().m_6174_("getEntities"); +- public List getEntities(@Nullable Entity p_46536_, AABB p_46537_, Predicate p_46538_) { +- this.getProfiler().incrementCounter("getEntities"); - List list = Lists.newArrayList(); -- this.m_142646_().m_142232_(p_46537_, (p_151522_) -> { +- this.getEntities().get(p_46537_, (p_151522_) -> { - if (p_151522_ != p_46536_ && p_46538_.test(p_151522_)) { - list.add(p_151522_); - } - - if (p_151522_ instanceof EnderDragon) { -- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_151522_).m_31156_()) { +- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_151522_).getSubEntities()) { - if (p_151522_ != p_46536_ && p_46538_.test(enderdragonpart)) { - list.add(enderdragonpart); - } @@ -730,10 +730,10 @@ - return list; - } - -- public List m_142425_(EntityTypeTest p_151528_, AABB p_151529_, Predicate p_151530_) { -- this.m_46473_().m_6174_("getEntities"); +- public List getEntities(EntityTypeTest p_151528_, AABB p_151529_, Predicate p_151530_) { +- this.getProfiler().incrementCounter("getEntities"); - List list = Lists.newArrayList(); -- this.m_142646_().m_142137_(p_151528_, p_151529_, (p_151539_) -> { +- this.getEntities().get(p_151528_, p_151529_, (p_151539_) -> { - if (p_151530_.test(p_151539_)) { - list.add(p_151539_); - } @@ -741,8 +741,8 @@ - if (p_151539_ instanceof EnderDragon) { - EnderDragon enderdragon = (EnderDragon)p_151539_; - -- for(EnderDragonPart enderdragonpart : enderdragon.m_31156_()) { -- T t = p_151528_.m_141992_(enderdragonpart); +- for(EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { +- T t = p_151528_.tryCast(enderdragonpart); - if (t != null && p_151530_.test(t)) { - list.add(t); - } @@ -754,59 +754,59 @@ - } - - @Nullable -- public abstract Entity m_6815_(int p_46492_); +- public abstract Entity getEntity(int p_46492_); - -- public void m_151543_(BlockPos p_151544_) { -- if (this.m_46805_(p_151544_)) { -- this.m_46745_(p_151544_).m_8092_(true); +- public void blockEntityChanged(BlockPos p_151544_) { +- if (this.hasChunkAt(p_151544_)) { +- this.getChunkAt(p_151544_).setUnsaved(true); - } - - } - -- public int m_5736_() { +- public int getSeaLevel() { - return 63; - } - -- public int m_46751_(BlockPos p_46752_) { +- public int getDirectSignalTo(BlockPos p_46752_) { - int i = 0; -- i = Math.max(i, this.m_46852_(p_46752_.m_7495_(), Direction.DOWN)); +- i = Math.max(i, this.getDirectSignal(p_46752_.below(), Direction.DOWN)); - if (i >= 15) { - return i; - } else { -- i = Math.max(i, this.m_46852_(p_46752_.m_7494_(), Direction.UP)); +- i = Math.max(i, this.getDirectSignal(p_46752_.above(), Direction.UP)); - if (i >= 15) { + } + // CraftBukkit end -+ if (this.m_151570_(p_46605_)) { ++ if (this.isOutsideBuildHeight(p_46605_)) { + return false; -+ } else if (!this.f_46443_ && this.m_46659_()) { ++ } else if (!this.isClientSide && this.isDebug()) { + return false; + } else { -+ LevelChunk levelchunk = this.m_46745_(p_46605_); -+ Block block = p_46606_.m_60734_(); ++ LevelChunk levelchunk = this.getChunkAt(p_46605_); ++ Block block = p_46606_.getBlock(); + -+ p_46605_ = p_46605_.m_7949_(); // Forge - prevent mutable BlockPos leaks ++ p_46605_ = p_46605_.immutable(); // Forge - prevent mutable BlockPos leaks + net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null; -+ if (this.captureBlockSnapshots && !this.f_46443_) { -+ blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.create(this.f_46421_, this, p_46605_, p_46607_); ++ if (this.captureBlockSnapshots && !this.isClientSide) { ++ blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.create(this.dimension, this, p_46605_, p_46607_); + this.capturedBlockSnapshots.add(blockSnapshot); + } + -+ BlockState old = m_8055_(p_46605_); ++ BlockState old = getBlockState(p_46605_); + int oldLight = old.getLightEmission(this, p_46605_); -+ int oldOpacity = old.m_60739_(this, p_46605_); ++ int oldOpacity = old.getLightBlock(this, p_46605_); + + // CraftBukkit start - capture blockstates + boolean captured = false; + if (this.captureBlockStates && !this.capturedBlockStates.containsKey(p_46605_)) { + org.bukkit.craftbukkit.v1_18_R2.block.CapturedBlockState blockstate = org.bukkit.craftbukkit.v1_18_R2.block.CapturedBlockState.getBlockState(this, p_46605_, p_46607_); -+ this.capturedBlockStates.put(p_46605_.m_7949_(), blockstate); ++ this.capturedBlockStates.put(p_46605_.immutable(), blockstate); + captured = true; + } + // CraftBukkit end + if ((p_46607_ & 1024) == 0) //Magma - doplace call + levelchunk.doPlace(); -+ BlockState blockstate = levelchunk.m_6978_(p_46605_, p_46606_, (p_46607_ & 64) != 0); ++ BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, (p_46607_ & 64) != 0); + + if (blockstate == null) { + // CraftBukkit start - remove blockstate if failed (or the same) @@ -817,11 +817,11 @@ + if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot); + return false; + } else { -+ BlockState blockstate1 = this.m_8055_( p_46605_ ); -+ if ((p_46607_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.m_60739_(this, p_46605_) != oldOpacity || blockstate1.getLightEmission(this, p_46605_) != oldLight || blockstate1.m_60787_() || blockstate.m_60787_())) { -+ this.m_46473_().m_6180_("queueCheckLight"); -+ this.m_7726_().m_7827_().m_142202_(p_46605_); -+ this.m_46473_().m_7238_(); ++ BlockState blockstate1 = this.getBlockState( p_46605_ ); ++ if ((p_46607_ & 128) == 0 && blockstate1 != blockstate && (blockstate1.getLightBlock(this, p_46605_) != oldOpacity || blockstate1.getLightEmission(this, p_46605_) != oldLight || blockstate1.useShapeForLightOcclusion() || blockstate.useShapeForLightOcclusion())) { ++ this.getProfiler().push("queueCheckLight"); ++ this.getChunkSource().getLightEngine().checkBlock(p_46605_); ++ this.getProfiler().pop(); + } + + if (blockSnapshot == null) { // Don't notify clients or update physics while capturing blockstates @@ -841,34 +841,34 @@ + + // Split off from original setBlockState(BlockPos, BlockState, int, int) method in order to directly send client and physic updates + public void markAndNotifyBlock(BlockPos p_46605_, @Nullable LevelChunk levelchunk, BlockState blockstate, BlockState p_46606_, int p_46607_, int p_46608_) { -+ Block block = p_46606_.m_60734_(); -+ BlockState blockstate1 = m_8055_( p_46605_ ); ++ Block block = p_46606_.getBlock(); ++ BlockState blockstate1 = getBlockState( p_46605_ ); + { + { + if (blockstate1 == p_46606_) { + if (blockstate != blockstate1) { -+ this.m_6550_( p_46605_, blockstate, blockstate1 ); ++ this.setBlocksDirty( p_46605_, blockstate, blockstate1 ); + } + -+ if ((p_46607_ & 2) != 0 && (!this.f_46443_ || (p_46607_ & 4) == 0) && (this.f_46443_ || levelchunk.m_6708_() != null && levelchunk.m_6708_().m_140114_( ChunkHolder.FullChunkStatus.TICKING ))) { -+ this.m_7260_( p_46605_, blockstate, p_46606_, p_46607_ ); ++ if ((p_46607_ & 2) != 0 && (!this.isClientSide || (p_46607_ & 4) == 0) && (this.isClientSide || levelchunk.getFullStatus() != null && levelchunk.getFullStatus().isOrAfter( ChunkHolder.FullChunkStatus.TICKING ))) { ++ this.sendBlockUpdated( p_46605_, blockstate, p_46606_, p_46607_ ); + } + + if ((p_46607_ & 1) != 0) { -+ this.m_6289_( p_46605_, blockstate.m_60734_() ); -+ if (!this.f_46443_ && p_46606_.m_60807_()) { -+ this.m_46717_( p_46605_, block ); ++ this.blockUpdated( p_46605_, blockstate.getBlock() ); ++ if (!this.isClientSide && p_46606_.hasAnalogOutputSignal()) { ++ this.updateNeighbourForOutputSignal( p_46605_, block ); + } + } + + if ((p_46607_ & 16) == 0 && p_46608_ > 0) { + int i = p_46607_ & -34; -+ blockstate.m_60762_( this, p_46605_, i, p_46608_ - 1 ); ++ blockstate.updateIndirectNeighbourShapes( this, p_46605_, i, p_46608_ - 1 ); + + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.CraftWorld world = ((net.minecraft.server.level.ServerLevel) this).getWorld(); + if (world != null) { -+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( world.getBlockAt( p_46605_.m_123341_(), p_46605_.m_123342_(), p_46605_.m_123343_() ), org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData( p_46606_ ) ); ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( world.getBlockAt( p_46605_.getX(), p_46605_.getY(), p_46605_.getZ() ), org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData( p_46606_ ) ); + this.getCraftServer().getPluginManager().callEvent( event ); + if (event.isCancelled()) { + return; @@ -876,132 +876,132 @@ + } + // CraftBukkit end + -+ p_46606_.m_60705_( this, p_46605_, i, p_46608_ - 1 ); -+ p_46606_.m_60762_( this, p_46605_, i, p_46608_ - 1 ); ++ p_46606_.updateNeighbourShapes( this, p_46605_, i, p_46608_ - 1 ); ++ p_46606_.updateIndirectNeighbourShapes( this, p_46605_, i, p_46608_ - 1 ); + } + -+ this.m_6559_( p_46605_, blockstate, blockstate1 ); ++ this.onBlockStateChange( p_46605_, blockstate, blockstate1 ); + p_46606_.onBlockStateChange(this, p_46605_, blockstate); + } + } + } + } + -+ public void m_6559_(BlockPos p_46609_, BlockState p_46610_, BlockState p_46611_) { ++ public void onBlockStateChange(BlockPos p_46609_, BlockState p_46610_, BlockState p_46611_) { + } + -+ public boolean m_7471_(BlockPos p_46623_, boolean p_46624_) { -+ FluidState fluidstate = this.m_6425_( p_46623_ ); -+ return this.m_7731_( p_46623_, fluidstate.m_76188_(), 3 | (p_46624_ ? 64 : 0) ); ++ public boolean removeBlock(BlockPos p_46623_, boolean p_46624_) { ++ FluidState fluidstate = this.getFluidState( p_46623_ ); ++ return this.setBlock( p_46623_, fluidstate.createLegacyBlock(), 3 | (p_46624_ ? 64 : 0) ); + } + -+ public boolean m_7740_(BlockPos p_46626_, boolean p_46627_, @Nullable Entity p_46628_, int p_46629_) { -+ BlockState blockstate = this.m_8055_( p_46626_ ); -+ if (blockstate.m_60795_()) { ++ public boolean destroyBlock(BlockPos p_46626_, boolean p_46627_, @Nullable Entity p_46628_, int p_46629_) { ++ BlockState blockstate = this.getBlockState( p_46626_ ); ++ if (blockstate.isAir()) { + return false; + } else { -+ FluidState fluidstate = this.m_6425_( p_46626_ ); -+ if (!(blockstate.m_60734_() instanceof BaseFireBlock)) { -+ this.m_46796_( 2001, p_46626_, Block.m_49956_( blockstate ) ); ++ FluidState fluidstate = this.getFluidState( p_46626_ ); ++ if (!(blockstate.getBlock() instanceof BaseFireBlock)) { ++ this.levelEvent( 2001, p_46626_, Block.getId( blockstate ) ); + } + + if (p_46627_) { -+ BlockEntity blockentity = blockstate.m_155947_() ? this.m_7702_( p_46626_ ) : null; -+ Block.m_49881_( blockstate, this, p_46626_, blockentity, p_46628_, ItemStack.f_41583_ ); ++ BlockEntity blockentity = blockstate.hasBlockEntity() ? this.getBlockEntity( p_46626_ ) : null; ++ Block.dropResources( blockstate, this, p_46626_, blockentity, p_46628_, ItemStack.EMPTY ); + } + -+ boolean flag = this.m_6933_( p_46626_, fluidstate.m_76188_(), 3, p_46629_ ); ++ boolean flag = this.setBlock( p_46626_, fluidstate.createLegacyBlock(), 3, p_46629_ ); + if (flag) { -+ this.m_142346_( p_46628_, GameEvent.f_157794_, p_46626_ ); ++ this.gameEvent( p_46628_, GameEvent.BLOCK_DESTROY, p_46626_ ); + } + + return flag; + } + } + -+ public void m_142052_(BlockPos p_151531_, BlockState p_151532_) { ++ public void addDestroyBlockEffect(BlockPos p_151531_, BlockState p_151532_) { + } + -+ public boolean m_46597_(BlockPos p_46598_, BlockState p_46599_) { -+ return this.m_7731_( p_46598_, p_46599_, 3 ); ++ public boolean setBlockAndUpdate(BlockPos p_46598_, BlockState p_46599_) { ++ return this.setBlock( p_46598_, p_46599_, 3 ); + } + -+ public abstract void m_7260_(BlockPos p_46612_, BlockState p_46613_, BlockState p_46614_, int p_46615_); ++ public abstract void sendBlockUpdated(BlockPos p_46612_, BlockState p_46613_, BlockState p_46614_, int p_46615_); + -+ public void m_6550_(BlockPos p_46678_, BlockState p_46679_, BlockState p_46680_) { ++ public void setBlocksDirty(BlockPos p_46678_, BlockState p_46679_, BlockState p_46680_) { + } + -+ public void m_46672_(BlockPos p_46673_, Block p_46674_) { -+ net.minecraftforge.event.ForgeEventFactory.onNeighborNotify( this, p_46673_, this.m_8055_( p_46673_ ), java.util.EnumSet.allOf( Direction.class ), false ).isCanceled(); ++ 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(); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) + return; -+ this.m_46586_( p_46673_.m_142125_(), p_46674_, p_46673_ ); -+ this.m_46586_( p_46673_.m_142126_(), p_46674_, p_46673_ ); -+ this.m_46586_( p_46673_.m_7495_(), p_46674_, p_46673_ ); -+ this.m_46586_( p_46673_.m_7494_(), p_46674_, p_46673_ ); -+ this.m_46586_( p_46673_.m_142127_(), p_46674_, p_46673_ ); -+ this.m_46586_( p_46673_.m_142128_(), p_46674_, p_46673_ ); ++ this.neighborChanged( p_46673_.west(), p_46674_, p_46673_ ); ++ this.neighborChanged( p_46673_.east(), p_46674_, p_46673_ ); ++ this.neighborChanged( p_46673_.below(), p_46674_, p_46673_ ); ++ this.neighborChanged( p_46673_.above(), p_46674_, p_46673_ ); ++ this.neighborChanged( p_46673_.north(), p_46674_, p_46673_ ); ++ this.neighborChanged( p_46673_.south(), p_46674_, p_46673_ ); + } + -+ public void m_46590_(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { ++ public void updateNeighborsAtExceptFromFacing(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) + return; + + java.util.EnumSet directions = java.util.EnumSet.allOf( Direction.class ); + directions.remove( p_46593_ ); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify( this, p_46591_, this.m_8055_( p_46591_ ), directions, false ).isCanceled()) ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify( this, p_46591_, this.getBlockState( p_46591_ ), directions, false ).isCanceled()) + return; + + if (p_46593_ != Direction.WEST) { -+ this.m_46586_( p_46591_.m_142125_(), p_46592_, p_46591_ ); ++ this.neighborChanged( p_46591_.west(), p_46592_, p_46591_ ); + } + + if (p_46593_ != Direction.EAST) { -+ this.m_46586_( p_46591_.m_142126_(), p_46592_, p_46591_ ); ++ this.neighborChanged( p_46591_.east(), p_46592_, p_46591_ ); + } + + if (p_46593_ != Direction.DOWN) { -+ this.m_46586_( p_46591_.m_7495_(), p_46592_, p_46591_ ); ++ this.neighborChanged( p_46591_.below(), p_46592_, p_46591_ ); + } + + if (p_46593_ != Direction.UP) { -+ this.m_46586_( p_46591_.m_7494_(), p_46592_, p_46591_ ); ++ this.neighborChanged( p_46591_.above(), p_46592_, p_46591_ ); + } + + if (p_46593_ != Direction.NORTH) { -+ this.m_46586_( p_46591_.m_142127_(), p_46592_, p_46591_ ); ++ this.neighborChanged( p_46591_.north(), p_46592_, p_46591_ ); + } + + if (p_46593_ != Direction.SOUTH) { -+ this.m_46586_( p_46591_.m_142128_(), p_46592_, p_46591_ ); ++ this.neighborChanged( p_46591_.south(), p_46592_, p_46591_ ); + } + + } + -+ public void m_46586_(BlockPos p_46587_, Block p_46588_, BlockPos p_46589_) { -+ if (!this.f_46443_) { -+ BlockState blockstate = this.m_8055_( p_46587_ ); ++ public void neighborChanged(BlockPos p_46587_, Block p_46588_, BlockPos p_46589_) { ++ if (!this.isClientSide) { ++ BlockState blockstate = this.getBlockState( p_46587_ ); + + try { + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) + this.neighborChanged(blockstate, p_46587_, p_46588_, p_46589_, false); + else -+ blockstate.m_60690_(this, p_46587_, p_46588_, p_46589_, false); ++ blockstate.neighborChanged(this, p_46587_, p_46588_, p_46589_, false); + // Spigot Start + } catch (StackOverflowError ex) { + lastPhysicsProblem = new BlockPos(p_46587_); + // Spigot End + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Exception while updating neighbours" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Block being updated" ); -+ crashreportcategory.m_128165_( "Source block type", () -> { ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Exception while updating neighbours" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Block being updated" ); ++ crashreportcategory.setDetail( "Source block type", () -> { + try { -+ return String.format( "ID #%s (%s // %s)", p_46588_.getRegistryName(), p_46588_.m_7705_(), p_46588_.getClass().getCanonicalName() ); ++ return String.format( "ID #%s (%s // %s)", p_46588_.getRegistryName(), p_46588_.getDescriptionId(), p_46588_.getClass().getCanonicalName() ); + } catch (Throwable throwable1) { + return "ID #" + p_46588_.getRegistryName(); + } + } ); -+ CrashReportCategory.m_178950_( crashreportcategory, this, p_46587_, blockstate ); ++ CrashReportCategory.populateBlockDetails( crashreportcategory, this, p_46587_, blockstate ); + throw new ReportedException( crashreport ); + } + } @@ -1011,7 +1011,7 @@ + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.CraftWorld world = ((net.minecraft.server.level.ServerLevel) this).getWorld(); + if (world != null) { -+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( world.getBlockAt( p_220380_.m_123341_(), p_220380_.m_123342_(), p_220380_.m_123343_() ), org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData( p_220379_ ), world.getBlockAt( p_220382_.m_123341_(), p_220382_.m_123342_(), p_220382_.m_123343_() ) ); ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( world.getBlockAt( p_220380_.getX(), p_220380_.getY(), p_220380_.getZ() ), org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData( p_220379_ ), world.getBlockAt( p_220382_.getX(), p_220382_.getY(), p_220382_.getZ() ) ); + this.getCraftServer().getPluginManager().callEvent( event ); + + if (event.isCancelled()) { @@ -1025,26 +1025,26 @@ + this.neighborUpdater.shapeUpdate(p_220385_, p_220386_, p_220387_, p_220388_, p_220389_, p_220390_); + } + -+ public int m_6924_(Heightmap.Types p_46571_, int p_46572_, int p_46573_) { ++ public int getHeight(Heightmap.Types p_46571_, int p_46572_, int p_46573_) { + int i; + if (p_46572_ >= -30000000 && p_46573_ >= -30000000 && p_46572_ < 30000000 && p_46573_ < 30000000) { -+ if (this.m_7232_( SectionPos.m_123171_( p_46572_ ), SectionPos.m_123171_( p_46573_ ) )) { -+ i = this.m_6325_( SectionPos.m_123171_( p_46572_ ), SectionPos.m_123171_( p_46573_ ) ).m_5885_( p_46571_, p_46572_ & 15, p_46573_ & 15 ) + 1; ++ if (this.hasChunk( SectionPos.blockToSectionCoord( p_46572_ ), SectionPos.blockToSectionCoord( p_46573_ ) )) { ++ i = this.getChunk( SectionPos.blockToSectionCoord( p_46572_ ), SectionPos.blockToSectionCoord( p_46573_ ) ).getHeight( p_46571_, p_46572_ & 15, p_46573_ & 15 ) + 1; + } else { -+ i = this.m_141937_(); ++ i = this.getMinBuildHeight(); + } + } else { -+ i = this.m_5736_() + 1; ++ i = this.getSeaLevel() + 1; + } + + return i; + } + -+ public LevelLightEngine m_5518_() { -+ return this.m_7726_().m_7827_(); ++ public LevelLightEngine getLightEngine() { ++ return this.getChunkSource().getLightEngine(); + } + -+ public BlockState m_8055_(BlockPos p_46732_) { ++ public BlockState getBlockState(BlockPos p_46732_) { + // CraftBukkit start - tree generation + if (captureTreeGeneration) { + org.bukkit.craftbukkit.v1_18_R2.block.CapturedBlockState previous = capturedBlockStates.get( p_46732_ ); @@ -1053,137 +1053,137 @@ + } + } + // CraftBukkit end -+ if (this.m_151570_( p_46732_ )) { -+ return Blocks.f_50626_.m_49966_(); ++ if (this.isOutsideBuildHeight( p_46732_ )) { ++ return Blocks.VOID_AIR.defaultBlockState(); + } else { -+ LevelChunk levelchunk = this.m_6325_( SectionPos.m_123171_( p_46732_.m_123341_() ), SectionPos.m_123171_( p_46732_.m_123343_() ) ); -+ return levelchunk.m_8055_( p_46732_ ); ++ LevelChunk levelchunk = this.getChunk( SectionPos.blockToSectionCoord( p_46732_.getX() ), SectionPos.blockToSectionCoord( p_46732_.getZ() ) ); ++ return levelchunk.getBlockState( p_46732_ ); + } + } + -+ public FluidState m_6425_(BlockPos p_46671_) { -+ if (this.m_151570_( p_46671_ )) { -+ return Fluids.f_76191_.m_76145_(); ++ public FluidState getFluidState(BlockPos p_46671_) { ++ if (this.isOutsideBuildHeight( p_46671_ )) { ++ return Fluids.EMPTY.defaultFluidState(); + } else { -+ LevelChunk levelchunk = this.m_46745_( p_46671_ ); -+ return levelchunk.m_6425_( p_46671_ ); ++ LevelChunk levelchunk = this.getChunkAt( p_46671_ ); ++ return levelchunk.getFluidState( p_46671_ ); + } + } + -+ public boolean m_46461_() { -+ return !this.m_6042_().m_63967_() && this.f_46425_ < 4; ++ public boolean isDay() { ++ return !this.dimensionType().hasFixedTime() && this.skyDarken < 4; + } + -+ public boolean m_46462_() { -+ return !this.m_6042_().m_63967_() && !this.m_46461_(); ++ public boolean isNight() { ++ return !this.dimensionType().hasFixedTime() && !this.isDay(); + } + -+ public void m_5594_(@Nullable Player p_46560_, BlockPos p_46561_, SoundEvent p_46562_, SoundSource p_46563_, float p_46564_, float p_46565_) { -+ this.m_6263_( p_46560_, (double) p_46561_.m_123341_() + 0.5D, (double) p_46561_.m_123342_() + 0.5D, (double) p_46561_.m_123343_() + 0.5D, p_46562_, p_46563_, p_46564_, p_46565_ ); ++ public void playSound(@Nullable Player p_46560_, BlockPos p_46561_, SoundEvent p_46562_, SoundSource p_46563_, float p_46564_, float p_46565_) { ++ this.playSound( p_46560_, (double) p_46561_.getX() + 0.5D, (double) p_46561_.getY() + 0.5D, (double) p_46561_.getZ() + 0.5D, p_46562_, p_46563_, p_46564_, p_46565_ ); + } + -+ public abstract void m_6263_(@Nullable Player p_46543_, double p_46544_, double p_46545_, double p_46546_, SoundEvent p_46547_, SoundSource p_46548_, float p_46549_, float p_46550_); ++ public abstract void playSound(@Nullable Player p_46543_, double p_46544_, double p_46545_, double p_46546_, SoundEvent p_46547_, SoundSource p_46548_, float p_46549_, float p_46550_); + -+ public abstract void m_6269_(@Nullable Player p_46551_, Entity p_46552_, SoundEvent p_46553_, SoundSource p_46554_, float p_46555_, float p_46556_); ++ public abstract void playSound(@Nullable Player p_46551_, Entity p_46552_, SoundEvent p_46553_, SoundSource p_46554_, float p_46555_, float p_46556_); + -+ public void m_7785_(double p_46482_, double p_46483_, double p_46484_, SoundEvent p_46485_, SoundSource p_46486_, float p_46487_, float p_46488_, boolean p_46489_) { ++ public void playLocalSound(double p_46482_, double p_46483_, double p_46484_, SoundEvent p_46485_, SoundSource p_46486_, float p_46487_, float p_46488_, boolean p_46489_) { + } + -+ public void m_7106_(ParticleOptions p_46631_, double p_46632_, double p_46633_, double p_46634_, double p_46635_, double p_46636_, double p_46637_) { ++ public void addParticle(ParticleOptions p_46631_, double p_46632_, double p_46633_, double p_46634_, double p_46635_, double p_46636_, double p_46637_) { + } + -+ public void m_6493_(ParticleOptions p_46638_, boolean p_46639_, double p_46640_, double p_46641_, double p_46642_, double p_46643_, double p_46644_, double p_46645_) { ++ public void addParticle(ParticleOptions p_46638_, boolean p_46639_, double p_46640_, double p_46641_, double p_46642_, double p_46643_, double p_46644_, double p_46645_) { + } + -+ public void m_7107_(ParticleOptions p_46684_, double p_46685_, double p_46686_, double p_46687_, double p_46688_, double p_46689_, double p_46690_) { ++ public void addAlwaysVisibleParticle(ParticleOptions p_46684_, double p_46685_, double p_46686_, double p_46687_, double p_46688_, double p_46689_, double p_46690_) { + } + -+ public void m_6485_(ParticleOptions p_46691_, boolean p_46692_, double p_46693_, double p_46694_, double p_46695_, double p_46696_, double p_46697_, double p_46698_) { ++ public void addAlwaysVisibleParticle(ParticleOptions p_46691_, boolean p_46692_, double p_46693_, double p_46694_, double p_46695_, double p_46696_, double p_46697_, double p_46698_) { + } + -+ public float m_46490_(float p_46491_) { -+ float f = this.m_46942_( p_46491_ ); ++ public float getSunAngle(float p_46491_) { ++ float f = this.getTimeOfDay( p_46491_ ); + return f * ((float) Math.PI * 2F); + } + -+ public void m_151525_(TickingBlockEntity p_151526_) { -+ (this.f_151504_ ? this.f_151503_ : this.f_151512_).add( p_151526_ ); ++ public void addBlockEntityTicker(TickingBlockEntity p_151526_) { ++ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add( p_151526_ ); + } + + public void addFreshBlockEntities(java.util.Collection beList) { -+ if (this.f_151504_) { ++ if (this.tickingBlockEntities) { + this.pendingFreshBlockEntities.addAll( beList ); + } else { + this.freshBlockEntities.addAll( beList ); + } + } + -+ protected void m_46463_() { -+ ProfilerFiller profilerfiller = this.m_46473_(); -+ profilerfiller.m_6180_( "blockEntities" ); ++ protected void tickBlockEntities() { ++ ProfilerFiller profilerfiller = this.getProfiler(); ++ profilerfiller.push( "blockEntities" ); + timings.tileEntityPending.startTiming(); // Spigot + if (!this.pendingFreshBlockEntities.isEmpty()) { + this.freshBlockEntities.addAll( this.pendingFreshBlockEntities ); + this.pendingFreshBlockEntities.clear(); + } + -+ this.f_151504_ = true; ++ this.tickingBlockEntities = true; + if (!this.freshBlockEntities.isEmpty()) { + this.freshBlockEntities.forEach( BlockEntity::onLoad ); + this.freshBlockEntities.clear(); + } -+ if (!this.f_151503_.isEmpty()) { -+ this.f_151512_.addAll( this.f_151503_ ); -+ this.f_151503_.clear(); ++ if (!this.pendingBlockEntityTickers.isEmpty()) { ++ this.blockEntityTickers.addAll( this.pendingBlockEntityTickers ); ++ this.pendingBlockEntityTickers.clear(); + } + timings.tileEntityPending.stopTiming(); // Spigot + + timings.tileEntityTick.startTiming(); // Spigot -+ Iterator iterator = this.f_151512_.iterator(); ++ Iterator iterator = this.blockEntityTickers.iterator(); + + // Spigot start + int tilesThisCycle = 0; + for (tileLimiter.initTick(); -+ tilesThisCycle < f_151512_.size() && (tilesThisCycle % 10 != 0 || tileLimiter.shouldContinue()); ++ tilesThisCycle < blockEntityTickers.size() && (tilesThisCycle % 10 != 0 || tileLimiter.shouldContinue()); + tileTickPosition++, tilesThisCycle++) { -+ tileTickPosition = (tileTickPosition < f_151512_.size()) ? tileTickPosition : 0; -+ TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.f_151512_.get(tileTickPosition); ++ tileTickPosition = (tileTickPosition < blockEntityTickers.size()) ? tileTickPosition : 0; ++ TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition); + // Spigot start + if (tickingblockentity == null) { + getCraftServer().getLogger().severe( "Spigot has detected a null entity and has removed it, preventing a crash" ); + tilesThisCycle--; -+ this.f_151512_.remove(tileTickPosition--); ++ this.blockEntityTickers.remove(tileTickPosition--); + continue; + } + // Spigot end -+ if (tickingblockentity.m_142220_()) { ++ if (tickingblockentity.isRemoved()) { + // Spigot start + tilesThisCycle--; -+ this.f_151512_.remove(tileTickPosition--); ++ this.blockEntityTickers.remove(tileTickPosition--); + // Spigot end -+ } else if (this.m_183438_( ChunkPos.m_151388_( tickingblockentity.m_142689_() ) )) { -+ tickingblockentity.m_142224_(); ++ } else if (this.shouldTickBlocksAt( ChunkPos.asLong( tickingblockentity.getPos() ) )) { ++ tickingblockentity.tick(); + } + } + + timings.tileEntityTick.stopTiming(); // Spigot -+ this.f_151504_ = false; -+ co.aikar.timings.TimingHistory.tileEntityTicks += this.f_151512_.size(); // Paper -+ profilerfiller.m_7238_(); ++ this.tickingBlockEntities = false; ++ co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper ++ profilerfiller.pop(); + spigotConfig.currentPrimedTnt = 0; // Spigot + } + -+ public void m_46653_(Consumer p_46654_, T p_46655_) { ++ public void guardEntityTick(Consumer p_46654_, T p_46655_) { + try { + net.minecraftforge.server.timings.TimeTracker.ENTITY_UPDATE.trackStart( p_46655_ ); + p_46654_.accept( p_46655_ ); + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Ticking entity" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Entity being ticked" ); -+ p_46655_.m_7976_( crashreportcategory ); ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Ticking entity" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Entity being ticked" ); ++ p_46655_.fillCrashReportCategory( crashreportcategory ); + if (net.minecraftforge.common.ForgeConfig.SERVER.removeErroringEntities.get()) { -+ com.mojang.logging.LogUtils.getLogger().error( "{}", crashreport.m_127526_() ); -+ p_46655_.m_146870_(); ++ com.mojang.logging.LogUtils.getLogger().error( "{}", crashreport.getFriendlyReport() ); ++ p_46655_.discard(); + } else + throw new ReportedException( crashreport ); + } finally { @@ -1191,11 +1191,11 @@ + } + } + -+ public boolean m_183599_(Entity p_186458_) { ++ public boolean shouldTickDeath(Entity p_186458_) { + return true; + } + -+ public boolean m_183438_(long p_186456_) { ++ public boolean shouldTickBlocksAt(long p_186456_) { + return true; + } + @@ -1205,29 +1205,29 @@ + explosion_createFire = fire; + } + -+ public Explosion m_46511_(@Nullable Entity p_46512_, double p_46513_, double p_46514_, double p_46515_, float p_46516_, Explosion.BlockInteraction p_46517_) { ++ public Explosion explode(@Nullable Entity p_46512_, double p_46513_, double p_46514_, double p_46515_, float p_46516_, Explosion.BlockInteraction p_46517_) { + boolean temp = explosion_createFire; + explosion_createFire = false; -+ return this.m_7703_( p_46512_, (DamageSource) null, (ExplosionDamageCalculator) null, p_46513_, p_46514_, p_46515_, p_46516_, temp, p_46517_ ); ++ return this.explode( p_46512_, (DamageSource) null, (ExplosionDamageCalculator) null, p_46513_, p_46514_, p_46515_, p_46516_, temp, p_46517_ ); + } + //Magma end + -+ public Explosion m_46518_(@Nullable Entity p_46519_, double p_46520_, double p_46521_, double p_46522_, float p_46523_, boolean p_46524_, Explosion.BlockInteraction p_46525_) { -+ return this.m_7703_( p_46519_, (DamageSource) null, (ExplosionDamageCalculator) null, p_46520_, p_46521_, p_46522_, p_46523_, p_46524_, p_46525_ ); ++ public Explosion explode(@Nullable Entity p_46519_, double p_46520_, double p_46521_, double p_46522_, float p_46523_, boolean p_46524_, Explosion.BlockInteraction p_46525_) { ++ return this.explode( p_46519_, (DamageSource) null, (ExplosionDamageCalculator) null, p_46520_, p_46521_, p_46522_, p_46523_, p_46524_, p_46525_ ); + } + -+ public Explosion m_7703_(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { ++ public Explosion explode(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { + Explosion explosion = new Explosion( this, p_46526_, p_46527_, p_46528_, p_46529_, p_46530_, p_46531_, p_46532_, p_46533_, p_46534_ ); + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart( this, explosion )) return explosion; -+ explosion.m_46061_(); -+ explosion.m_46075_( true ); ++ explosion.explode(); ++ explosion.finalizeExplosion( true ); + return explosion; + } + -+ public abstract String m_46464_(); ++ public abstract String gatherChunkSourceStats(); + + @Nullable -+ public BlockEntity m_7702_(BlockPos p_46716_) { ++ public BlockEntity getBlockEntity(BlockPos p_46716_) { + // CraftBukkit start - org.magmafoundation.magma.Magma - doing this is weird validate is never used so why is it here? should we remove it? + return getBlockEntity( p_46716_, true ); + } @@ -1238,91 +1238,91 @@ + return capturedTileEntities.get( p_46716_ ); + } + // CraftBukkit end -+ if (this.m_151570_( p_46716_ )) { ++ if (this.isOutsideBuildHeight( p_46716_ )) { + return null; + } else { -+ return !this.f_46443_ && Thread.currentThread() != this.f_46423_ ? null : this.m_46745_( p_46716_ ).m_5685_( p_46716_, LevelChunk.EntityCreationType.IMMEDIATE ); ++ return !this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt( p_46716_ ).getBlockEntity( p_46716_, LevelChunk.EntityCreationType.IMMEDIATE ); + } + } + -+ public void m_151523_(BlockEntity p_151524_) { -+ BlockPos blockpos = p_151524_.m_58899_(); -+ if (!this.m_151570_( blockpos )) { ++ public void setBlockEntity(BlockEntity p_151524_) { ++ BlockPos blockpos = p_151524_.getBlockPos(); ++ if (!this.isOutsideBuildHeight( blockpos )) { + // CraftBukkit start + if (captureBlockStates) { -+ capturedTileEntities.put( blockpos.m_7949_(), p_151524_ ); ++ capturedTileEntities.put( blockpos.immutable(), p_151524_ ); + return; + } + // CraftBukkit end -+ this.m_46745_( blockpos ).m_142170_( p_151524_ ); ++ this.getChunkAt( blockpos ).addAndRegisterBlockEntity( p_151524_ ); + } + } + -+ public void m_46747_(BlockPos p_46748_) { -+ if (!this.m_151570_( p_46748_ )) { -+ this.m_46745_( p_46748_ ).m_8114_( p_46748_ ); ++ public void removeBlockEntity(BlockPos p_46748_) { ++ if (!this.isOutsideBuildHeight( p_46748_ )) { ++ this.getChunkAt( p_46748_ ).removeBlockEntity( p_46748_ ); + } -+ this.m_46717_( p_46748_, m_8055_( p_46748_ ).m_60734_() ); //Notify neighbors of changes ++ this.updateNeighbourForOutputSignal( p_46748_, getBlockState( p_46748_ ).getBlock() ); //Notify neighbors of changes + } + -+ public boolean m_46749_(BlockPos p_46750_) { -+ return this.m_151570_( p_46750_ ) ? false : this.m_7726_().m_5563_( SectionPos.m_123171_( p_46750_.m_123341_() ), SectionPos.m_123171_( p_46750_.m_123343_() ) ); ++ public boolean isLoaded(BlockPos p_46750_) { ++ return this.isOutsideBuildHeight( p_46750_ ) ? false : this.getChunkSource().hasChunk( SectionPos.blockToSectionCoord( p_46750_.getX() ), SectionPos.blockToSectionCoord( p_46750_.getZ() ) ); + } + -+ public boolean m_46578_(BlockPos p_46579_, Entity p_46580_, Direction p_46581_) { -+ if (this.m_151570_( p_46579_ )) { ++ public boolean loadedAndEntityCanStandOnFace(BlockPos p_46579_, Entity p_46580_, Direction p_46581_) { ++ if (this.isOutsideBuildHeight( p_46579_ )) { + return false; + } else { -+ ChunkAccess chunkaccess = this.m_6522_( SectionPos.m_123171_( p_46579_.m_123341_() ), SectionPos.m_123171_( p_46579_.m_123343_() ), ChunkStatus.f_62326_, false ); -+ return chunkaccess == null ? false : chunkaccess.m_8055_( p_46579_ ).m_60638_( this, p_46579_, p_46580_, p_46581_ ); ++ ChunkAccess chunkaccess = this.getChunk( SectionPos.blockToSectionCoord( p_46579_.getX() ), SectionPos.blockToSectionCoord( p_46579_.getZ() ), ChunkStatus.FULL, false ); ++ return chunkaccess == null ? false : chunkaccess.getBlockState( p_46579_ ).entityCanStandOnFace( this, p_46579_, p_46580_, p_46581_ ); + } + } + -+ public boolean m_46575_(BlockPos p_46576_, Entity p_46577_) { -+ return this.m_46578_( p_46576_, p_46577_, Direction.UP ); ++ public boolean loadedAndEntityCanStandOn(BlockPos p_46576_, Entity p_46577_) { ++ return this.loadedAndEntityCanStandOnFace( p_46576_, p_46577_, Direction.UP ); + } + -+ public void m_46465_() { -+ double d0 = 1.0D - (double) (this.m_46722_( 1.0F ) * 5.0F) / 16.0D; -+ double d1 = 1.0D - (double) (this.m_46661_( 1.0F ) * 5.0F) / 16.0D; -+ double d2 = 0.5D + 2.0D * Mth.m_14008_( (double) Mth.m_14089_( this.m_46942_( 1.0F ) * ((float) Math.PI * 2F) ), -0.25D, 0.25D ); -+ this.f_46425_ = (int) ((1.0D - d2 * d0 * d1) * 11.0D); ++ public void updateSkyBrightness() { ++ double d0 = 1.0D - (double) (this.getRainLevel( 1.0F ) * 5.0F) / 16.0D; ++ double d1 = 1.0D - (double) (this.getThunderLevel( 1.0F ) * 5.0F) / 16.0D; ++ double d2 = 0.5D + 2.0D * Mth.clamp( (double) Mth.cos( this.getTimeOfDay( 1.0F ) * ((float) Math.PI * 2F) ), -0.25D, 0.25D ); ++ this.skyDarken = (int) ((1.0D - d2 * d0 * d1) * 11.0D); + } + -+ public void m_46703_(boolean p_46704_, boolean p_46705_) { -+ this.m_7726_().m_6707_( p_46704_, p_46705_ ); ++ public void setSpawnSettings(boolean p_46704_, boolean p_46705_) { ++ this.getChunkSource().setSpawnSettings( p_46704_, p_46705_ ); + } + -+ protected void m_46466_() { -+ if (this.f_46442_.m_6533_()) { -+ this.f_46438_ = 1.0F; -+ if (this.f_46442_.m_6534_()) { -+ this.f_46440_ = 1.0F; ++ protected void prepareWeather() { ++ if (this.levelData.isRaining()) { ++ this.rainLevel = 1.0F; ++ if (this.levelData.isThundering()) { ++ this.thunderLevel = 1.0F; + } + } + + } + + public void close() throws IOException { -+ this.m_7726_().close(); ++ this.getChunkSource().close(); + } + + @Nullable -+ public BlockGetter m_7925_(int p_46711_, int p_46712_) { -+ return this.m_6522_( p_46711_, p_46712_, ChunkStatus.f_62326_, false ); ++ public BlockGetter getChunkForCollisions(int p_46711_, int p_46712_) { ++ return this.getChunk( p_46711_, p_46712_, ChunkStatus.FULL, false ); + } + -+ public List m_6249_(@Nullable Entity p_46536_, AABB p_46537_, Predicate p_46538_) { -+ this.m_46473_().m_6174_( "getEntities" ); ++ public List getEntities(@Nullable Entity p_46536_, AABB p_46537_, Predicate p_46538_) { ++ this.getProfiler().incrementCounter( "getEntities" ); + List list = Lists.newArrayList(); -+ this.m_142646_().m_142232_( p_46537_, (p_151522_) -> { ++ this.getEntities().get( p_46537_, (p_151522_) -> { + if (p_151522_ != p_46536_ && p_46538_.test( p_151522_ )) { + list.add( p_151522_ ); + } + + if (false) + if (p_151522_ instanceof EnderDragon) { -+ for (EnderDragonPart enderdragonpart : ((EnderDragon) p_151522_).m_31156_()) { ++ for (EnderDragonPart enderdragonpart : ((EnderDragon) p_151522_).getSubEntities()) { + if (p_151522_ != p_46536_ && p_46538_.test( enderdragonpart )) { + list.add( enderdragonpart ); + } @@ -1331,17 +1331,17 @@ + + } ); + for (net.minecraftforge.entity.PartEntity p : this.getPartEntities()) { -+ if (p != p_46536_ && p.m_142469_().m_82381_( p_46537_ ) && p_46538_.test( p )) { ++ if (p != p_46536_ && p.getBoundingBox().intersects( p_46537_ ) && p_46538_.test( p )) { + list.add( p ); + } + } + return list; + } + -+ public List m_142425_(EntityTypeTest p_151528_, AABB p_151529_, Predicate p_151530_) { -+ this.m_46473_().m_6174_( "getEntities" ); ++ public List getEntities(EntityTypeTest p_151528_, AABB p_151529_, Predicate p_151530_) { ++ this.getProfiler().incrementCounter( "getEntities" ); + List list = Lists.newArrayList(); -+ this.m_142646_().m_142137_( p_151528_, p_151529_, (p_151539_) -> { ++ this.getEntities().get( p_151528_, p_151529_, (p_151539_) -> { + if (p_151530_.test( p_151539_ )) { + list.add( p_151539_ ); + } @@ -1351,8 +1351,8 @@ + if (p_151539_ instanceof EnderDragon) { + EnderDragon enderdragon = (EnderDragon) p_151539_; + -+ for (EnderDragonPart enderdragonpart : enderdragon.m_31156_()) { -+ T t = p_151528_.m_141992_( enderdragonpart ); ++ for (EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { ++ T t = p_151528_.tryCast( enderdragonpart ); + if (t != null && p_151530_.test( t )) { + list.add( t ); + } @@ -1361,8 +1361,8 @@ + + } ); + for (net.minecraftforge.entity.PartEntity p : this.getPartEntities()) { -+ T t = p_151528_.m_141992_( p ); -+ if (t != null && t.m_142469_().m_82381_( p_151529_ ) && p_151530_.test( t )) { ++ T t = p_151528_.tryCast( p ); ++ if (t != null && t.getBoundingBox().intersects( p_151529_ ) && p_151530_.test( t )) { + list.add( t ); + } + } @@ -1370,47 +1370,47 @@ + } + + @Nullable -+ public abstract Entity m_6815_(int p_46492_); ++ public abstract Entity getEntity(int p_46492_); + + public void blockEntityChangedWithoutNeighborUpdates(BlockPos p_151544_) { -+ if (this.m_46805_(p_151544_)) { -+ this.m_46745_(p_151544_).m_8092_(true); ++ if (this.hasChunkAt(p_151544_)) { ++ this.getChunkAt(p_151544_).setUnsaved(true); + } + } + + /** @deprecated Call {@link #blockEntityChangedWithoutNeighborUpdates(BlockPos)} instead. See #9235 for details. */ + @Deprecated -+ public void m_151543_(BlockPos p_151544_) { ++ public void blockEntityChanged(BlockPos p_151544_) { + this.blockEntityChangedWithoutNeighborUpdates(p_151544_); -+ this.m_46717_(p_151544_, m_8055_(p_151544_).m_60734_()); //Notify neighbors of changes ++ this.updateNeighbourForOutputSignal(p_151544_, getBlockState(p_151544_).getBlock()); //Notify neighbors of changes + } + -+ public int m_5736_() { ++ public int getSeaLevel() { + return 63; + } + -+ public int m_46751_(BlockPos p_46752_) { ++ public int getDirectSignalTo(BlockPos p_46752_) { + int i = 0; -+ i = Math.max( i, this.m_46852_( p_46752_.m_7495_(), Direction.DOWN ) ); ++ i = Math.max( i, this.getDirectSignal( p_46752_.below(), Direction.DOWN ) ); + if (i >= 15) { return i; - } else { -- i = Math.max(i, this.m_46852_(p_46752_.m_142127_(), Direction.NORTH)); +- i = Math.max(i, this.getDirectSignal(p_46752_.north(), Direction.NORTH)); + } else { -+ i = Math.max( i, this.m_46852_( p_46752_.m_7494_(), Direction.UP ) ); ++ i = Math.max( i, this.getDirectSignal( p_46752_.above(), Direction.UP ) ); if (i >= 15) { - return i; + return i; } else { -- i = Math.max(i, this.m_46852_(p_46752_.m_142128_(), Direction.SOUTH)); +- i = Math.max(i, this.getDirectSignal(p_46752_.south(), Direction.SOUTH)); - if (i >= 15) { - return i; - } else { -- i = Math.max(i, this.m_46852_(p_46752_.m_142125_(), Direction.WEST)); +- i = Math.max(i, this.getDirectSignal(p_46752_.west(), Direction.WEST)); - if (i >= 15) { - return i; - } else { -- i = Math.max(i, this.m_46852_(p_46752_.m_142126_(), Direction.EAST)); +- i = Math.max(i, this.getDirectSignal(p_46752_.east(), Direction.EAST)); - return i >= 15 ? i : i; - } - } @@ -1419,37 +1419,37 @@ - } - } - -- public boolean m_46616_(BlockPos p_46617_, Direction p_46618_) { -- return this.m_46681_(p_46617_, p_46618_) > 0; +- public boolean hasSignal(BlockPos p_46617_, Direction p_46618_) { +- return this.getSignal(p_46617_, p_46618_) > 0; - } - -- public int m_46681_(BlockPos p_46682_, Direction p_46683_) { -- BlockState blockstate = this.m_8055_(p_46682_); -- int i = blockstate.m_60746_(this, p_46682_, p_46683_); -- return blockstate.m_60796_(this, p_46682_) ? Math.max(i, this.m_46751_(p_46682_)) : i; +- public int getSignal(BlockPos p_46682_, Direction p_46683_) { +- BlockState blockstate = this.getBlockState(p_46682_); +- int i = blockstate.getSignal(this, p_46682_, p_46683_); +- return blockstate.isRedstoneConductor(this, p_46682_) ? Math.max(i, this.getDirectSignalTo(p_46682_)) : i; - } - -- public boolean m_46753_(BlockPos p_46754_) { -- if (this.m_46681_(p_46754_.m_7495_(), Direction.DOWN) > 0) { +- public boolean hasNeighborSignal(BlockPos p_46754_) { +- if (this.getSignal(p_46754_.below(), Direction.DOWN) > 0) { - return true; -- } else if (this.m_46681_(p_46754_.m_7494_(), Direction.UP) > 0) { +- } else if (this.getSignal(p_46754_.above(), Direction.UP) > 0) { - return true; -- } else if (this.m_46681_(p_46754_.m_142127_(), Direction.NORTH) > 0) { +- } else if (this.getSignal(p_46754_.north(), Direction.NORTH) > 0) { - return true; -- } else if (this.m_46681_(p_46754_.m_142128_(), Direction.SOUTH) > 0) { +- } else if (this.getSignal(p_46754_.south(), Direction.SOUTH) > 0) { - return true; -- } else if (this.m_46681_(p_46754_.m_142125_(), Direction.WEST) > 0) { +- } else if (this.getSignal(p_46754_.west(), Direction.WEST) > 0) { - return true; - } else { -- return this.m_46681_(p_46754_.m_142126_(), Direction.EAST) > 0; +- return this.getSignal(p_46754_.east(), Direction.EAST) > 0; - } - } - -- public int m_46755_(BlockPos p_46756_) { +- public int getBestNeighborSignal(BlockPos p_46756_) { - int i = 0; - -- for(Direction direction : f_46422_) { -- int j = this.m_46681_(p_46756_.m_142300_(direction), direction); +- for(Direction direction : DIRECTIONS) { +- int j = this.getSignal(p_46756_.relative(direction), direction); - if (j >= 15) { - return 15; - } @@ -1462,134 +1462,134 @@ - return i; - } - -- public void m_7462_() { +- public void disconnect() { - } - -- public long m_46467_() { -- return this.f_46442_.m_6793_(); +- public long getGameTime() { +- return this.levelData.getGameTime(); - } - -- public long m_46468_() { -- return this.f_46442_.m_6792_(); +- public long getDayTime() { +- return this.levelData.getDayTime(); - } - -- public boolean m_7966_(Player p_46557_, BlockPos p_46558_) { +- public boolean mayInteract(Player p_46557_, BlockPos p_46558_) { - return true; - } - -- public void m_7605_(Entity p_46509_, byte p_46510_) { +- public void broadcastEntityEvent(Entity p_46509_, byte p_46510_) { - } - -- public void m_7696_(BlockPos p_46582_, Block p_46583_, int p_46584_, int p_46585_) { -- this.m_8055_(p_46582_).m_60677_(this, p_46582_, p_46584_, p_46585_); +- public void blockEvent(BlockPos p_46582_, Block p_46583_, int p_46584_, int p_46585_) { +- this.getBlockState(p_46582_).triggerEvent(this, p_46582_, p_46584_, p_46585_); - } - -- public LevelData m_6106_() { -- return this.f_46442_; +- public LevelData getLevelData() { +- return this.levelData; - } - -- public GameRules m_46469_() { -- return this.f_46442_.m_5470_(); +- public GameRules getGameRules() { +- return this.levelData.getGameRules(); - } - -- public float m_46661_(float p_46662_) { -- return Mth.m_14179_(p_46662_, this.f_46439_, this.f_46440_) * this.m_46722_(p_46662_); +- public float getThunderLevel(float p_46662_) { +- return Mth.lerp(p_46662_, this.oThunderLevel, this.thunderLevel) * this.getRainLevel(p_46662_); - } - -- public void m_46707_(float p_46708_) { -- float f = Mth.m_14036_(p_46708_, 0.0F, 1.0F); -- this.f_46439_ = f; -- this.f_46440_ = f; +- public void setThunderLevel(float p_46708_) { +- float f = Mth.clamp(p_46708_, 0.0F, 1.0F); +- this.oThunderLevel = f; +- this.thunderLevel = f; - } - -- public float m_46722_(float p_46723_) { -- return Mth.m_14179_(p_46723_, this.f_46437_, this.f_46438_); +- public float getRainLevel(float p_46723_) { +- return Mth.lerp(p_46723_, this.oRainLevel, this.rainLevel); - } - -- public void m_46734_(float p_46735_) { -- float f = Mth.m_14036_(p_46735_, 0.0F, 1.0F); -- this.f_46437_ = f; -- this.f_46438_ = f; +- public void setRainLevel(float p_46735_) { +- float f = Mth.clamp(p_46735_, 0.0F, 1.0F); +- this.oRainLevel = f; +- this.rainLevel = f; - } - -- public boolean m_46470_() { -- if (this.m_6042_().m_63935_() && !this.m_6042_().m_63946_()) { -- return (double)this.m_46661_(1.0F) > 0.9D; +- public boolean isThundering() { +- if (this.dimensionType().hasSkyLight() && !this.dimensionType().hasCeiling()) { +- return (double)this.getThunderLevel(1.0F) > 0.9D; - } else { - return false; - } - } - -- public boolean m_46471_() { -- return (double)this.m_46722_(1.0F) > 0.2D; +- public boolean isRaining() { +- return (double)this.getRainLevel(1.0F) > 0.2D; - } - -- public boolean m_46758_(BlockPos p_46759_) { -- if (!this.m_46471_()) { +- public boolean isRainingAt(BlockPos p_46759_) { +- if (!this.isRaining()) { - return false; -- } else if (!this.m_45527_(p_46759_)) { +- } else if (!this.canSeeSky(p_46759_)) { - return false; -- } else if (this.m_5452_(Heightmap.Types.MOTION_BLOCKING, p_46759_).m_123342_() > p_46759_.m_123342_()) { +- } else if (this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_46759_).getY() > p_46759_.getY()) { - return false; - } else { -- Biome biome = this.m_204166_(p_46759_).m_203334_(); -- return biome.m_47530_() == Biome.Precipitation.RAIN && biome.m_198906_(p_46759_); +- Biome biome = this.getBiome(p_46759_).value(); +- return biome.getPrecipitation() == Biome.Precipitation.RAIN && biome.warmEnoughToRain(p_46759_); - } - } - -- public boolean m_46761_(BlockPos p_46762_) { -- Biome biome = this.m_204166_(p_46762_).m_203334_(); -- return biome.m_47533_(); +- public boolean isHumidAt(BlockPos p_46762_) { +- Biome biome = this.getBiome(p_46762_).value(); +- return biome.isHumid(); - } - - @Nullable -- public abstract MapItemSavedData m_7489_(String p_46650_); +- public abstract MapItemSavedData getMapData(String p_46650_); - -- public abstract void m_142325_(String p_151533_, MapItemSavedData p_151534_); +- public abstract void setMapData(String p_151533_, MapItemSavedData p_151534_); - -- public abstract int m_7354_(); +- public abstract int getFreeMapId(); - -- public void m_6798_(int p_46665_, BlockPos p_46666_, int p_46667_) { +- public void globalLevelEvent(int p_46665_, BlockPos p_46666_, int p_46667_) { - } - -- public CrashReportCategory m_6026_(CrashReport p_46656_) { -- CrashReportCategory crashreportcategory = p_46656_.m_127516_("Affected level", 1); -- crashreportcategory.m_128165_("All players", () -> { -- return this.m_6907_().size() + " total; " + this.m_6907_(); +- public CrashReportCategory fillReportDetails(CrashReport p_46656_) { +- CrashReportCategory crashreportcategory = p_46656_.addCategory("Affected level", 1); +- crashreportcategory.setDetail("All players", () -> { +- return this.players().size() + " total; " + this.players(); - }); -- crashreportcategory.m_128165_("Chunk stats", this.m_7726_()::m_6754_); -- crashreportcategory.m_128165_("Level dimension", () -> { -- return this.m_46472_().m_135782_().toString(); +- crashreportcategory.setDetail("Chunk stats", this.getChunkSource()::gatherStats); +- crashreportcategory.setDetail("Level dimension", () -> { +- return this.dimension().location().toString(); - }); - - try { -- this.f_46442_.m_142471_(crashreportcategory, this); +- this.levelData.fillCrashReportCategory(crashreportcategory, this); - } catch (Throwable throwable) { -- crashreportcategory.m_128162_("Level Data Unobtainable", throwable); +- crashreportcategory.setDetailError("Level Data Unobtainable", throwable); - } - - return crashreportcategory; - } - -- public abstract void m_6801_(int p_46506_, BlockPos p_46507_, int p_46508_); +- public abstract void destroyBlockProgress(int p_46506_, BlockPos p_46507_, int p_46508_); - -- public void m_7228_(double p_46475_, double p_46476_, double p_46477_, double p_46478_, double p_46479_, double p_46480_, @Nullable CompoundTag p_46481_) { +- public void createFireworks(double p_46475_, double p_46476_, double p_46477_, double p_46478_, double p_46479_, double p_46480_, @Nullable CompoundTag p_46481_) { - } - -- public abstract Scoreboard m_6188_(); +- public abstract Scoreboard getScoreboard(); - -- public void m_46717_(BlockPos p_46718_, Block p_46719_) { +- public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { - for(Direction direction : Direction.Plane.HORIZONTAL) { -- BlockPos blockpos = p_46718_.m_142300_(direction); -- if (this.m_46805_(blockpos)) { -- BlockState blockstate = this.m_8055_(blockpos); -- if (blockstate.m_60713_(Blocks.f_50328_)) { -- blockstate.m_60690_(this, blockpos, p_46719_, p_46718_, false); -- } else if (blockstate.m_60796_(this, blockpos)) { -- blockpos = blockpos.m_142300_(direction); -- blockstate = this.m_8055_(blockpos); -- if (blockstate.m_60713_(Blocks.f_50328_)) { -- blockstate.m_60690_(this, blockpos, p_46719_, p_46718_, false); +- BlockPos blockpos = p_46718_.relative(direction); +- if (this.hasChunkAt(blockpos)) { +- BlockState blockstate = this.getBlockState(blockpos); +- if (blockstate.is(Blocks.COMPARATOR)) { +- blockstate.neighborChanged(this, blockpos, p_46719_, p_46718_, false); +- } else if (blockstate.isRedstoneConductor(this, blockpos)) { +- blockpos = blockpos.relative(direction); +- blockstate = this.getBlockState(blockpos); +- if (blockstate.is(Blocks.COMPARATOR)) { +- blockstate.neighborChanged(this, blockpos, p_46719_, p_46718_, false); - } - } - } @@ -1597,100 +1597,100 @@ - - } - -- public DifficultyInstance m_6436_(BlockPos p_46730_) { +- public DifficultyInstance getCurrentDifficultyAt(BlockPos p_46730_) { - long i = 0L; - float f = 0.0F; -- if (this.m_46805_(p_46730_)) { -- f = this.m_46940_(); -- i = this.m_46745_(p_46730_).m_6319_(); +- if (this.hasChunkAt(p_46730_)) { +- f = this.getMoonBrightness(); +- i = this.getChunkAt(p_46730_).getInhabitedTime(); - } - -- return new DifficultyInstance(this.m_46791_(), this.m_46468_(), i, f); +- return new DifficultyInstance(this.getDifficulty(), this.getDayTime(), i, f); - } - -- public int m_7445_() { -- return this.f_46425_; +- public int getSkyDarken() { +- return this.skyDarken; - } - -- public void m_6580_(int p_46709_) { +- public void setSkyFlashTime(int p_46709_) { - } - -- public WorldBorder m_6857_() { -- return this.f_46447_; +- public WorldBorder getWorldBorder() { +- return this.worldBorder; - } - -- public void m_5503_(Packet p_46657_) { +- public void sendPacketToServer(Packet p_46657_) { - throw new UnsupportedOperationException("Can't send packets to server unless you're on the client."); - } - -- public DimensionType m_6042_() { -- return this.f_46445_; +- public DimensionType dimensionType() { +- return this.dimensionType; - } - -- public Holder m_204156_() { -- return this.f_204147_; +- public Holder dimensionTypeRegistration() { +- return this.dimensionTypeRegistration; - } - -- public ResourceKey m_46472_() { -- return this.f_46421_; +- public ResourceKey dimension() { +- return this.dimension; - } - -- public Random m_5822_() { -- return this.f_46441_; +- public Random getRandom() { +- return this.random; - } - -- public boolean m_7433_(BlockPos p_46620_, Predicate p_46621_) { -- return p_46621_.test(this.m_8055_(p_46620_)); +- public boolean isStateAtPosition(BlockPos p_46620_, Predicate p_46621_) { +- return p_46621_.test(this.getBlockState(p_46620_)); - } - -- public boolean m_142433_(BlockPos p_151541_, Predicate p_151542_) { -- return p_151542_.test(this.m_6425_(p_151541_)); +- public boolean isFluidAtPosition(BlockPos p_151541_, Predicate p_151542_) { +- return p_151542_.test(this.getFluidState(p_151541_)); - } - -- public abstract RecipeManager m_7465_(); +- public abstract RecipeManager getRecipeManager(); - -- public BlockPos m_46496_(int p_46497_, int p_46498_, int p_46499_, int p_46500_) { -- this.f_46435_ = this.f_46435_ * 3 + 1013904223; -- int i = this.f_46435_ >> 2; +- public BlockPos getBlockRandomPos(int p_46497_, int p_46498_, int p_46499_, int p_46500_) { +- this.randValue = this.randValue * 3 + 1013904223; +- int i = this.randValue >> 2; - return new BlockPos(p_46497_ + (i & 15), p_46498_ + (i >> 16 & p_46500_), p_46499_ + (i >> 8 & 15)); - } - -- public boolean m_7441_() { +- public boolean noSave() { - return false; - } - -- public ProfilerFiller m_46473_() { -- return this.f_46446_.get(); +- public ProfilerFiller getProfiler() { +- return this.profiler.get(); - } - -- public Supplier m_46658_() { -- return this.f_46446_; +- public Supplier getProfilerSupplier() { +- return this.profiler; - } - -- public BiomeManager m_7062_() { -- return this.f_46420_; +- public BiomeManager getBiomeManager() { +- return this.biomeManager; - } - -- public final boolean m_46659_() { -- return this.f_46424_; +- public final boolean isDebug() { +- return this.isDebug; - } - -- protected abstract LevelEntityGetter m_142646_(); +- protected abstract LevelEntityGetter getEntities(); - -- protected void m_151513_(@Nullable Entity p_151514_, GameEvent p_151515_, BlockPos p_151516_, int p_151517_) { -- int i = SectionPos.m_123171_(p_151516_.m_123341_() - p_151517_); -- int j = SectionPos.m_123171_(p_151516_.m_123343_() - p_151517_); -- int k = SectionPos.m_123171_(p_151516_.m_123341_() + p_151517_); -- int l = SectionPos.m_123171_(p_151516_.m_123343_() + p_151517_); -- int i1 = SectionPos.m_123171_(p_151516_.m_123342_() - p_151517_); -- int j1 = SectionPos.m_123171_(p_151516_.m_123342_() + p_151517_); +- protected void postGameEventInRadius(@Nullable Entity p_151514_, GameEvent p_151515_, BlockPos p_151516_, int p_151517_) { +- int i = SectionPos.blockToSectionCoord(p_151516_.getX() - p_151517_); +- int j = SectionPos.blockToSectionCoord(p_151516_.getZ() - p_151517_); +- int k = SectionPos.blockToSectionCoord(p_151516_.getX() + p_151517_); +- int l = SectionPos.blockToSectionCoord(p_151516_.getZ() + p_151517_); +- int i1 = SectionPos.blockToSectionCoord(p_151516_.getY() - p_151517_); +- int j1 = SectionPos.blockToSectionCoord(p_151516_.getY() + p_151517_); - - for(int k1 = i; k1 <= k; ++k1) { - for(int l1 = j; l1 <= l; ++l1) { -- ChunkAccess chunkaccess = this.m_7726_().m_7131_(k1, l1); +- ChunkAccess chunkaccess = this.getChunkSource().getChunkNow(k1, l1); - if (chunkaccess != null) { - for(int i2 = i1; i2 <= j1; ++i2) { -- chunkaccess.m_142336_(i2).m_142666_(p_151515_, p_151514_, p_151516_); +- chunkaccess.getEventDispatcher(i2).post(p_151515_, p_151514_, p_151516_); - } - } - } @@ -1698,22 +1698,22 @@ - - } - -- public long m_183596_() { -- return (long)(this.f_186455_++); +- public long nextSubTickCount() { +- return (long)(this.subTickCount++); - } -+ i = Math.max( i, this.m_46852_( p_46752_.m_142127_(), Direction.NORTH ) ); ++ i = Math.max( i, this.getDirectSignal( p_46752_.north(), Direction.NORTH ) ); + if (i >= 15) { + return i; + } else { -+ i = Math.max( i, this.m_46852_( p_46752_.m_142128_(), Direction.SOUTH ) ); ++ i = Math.max( i, this.getDirectSignal( p_46752_.south(), Direction.SOUTH ) ); + if (i >= 15) { + return i; + } else { -+ i = Math.max( i, this.m_46852_( p_46752_.m_142125_(), Direction.WEST ) ); ++ i = Math.max( i, this.getDirectSignal( p_46752_.west(), Direction.WEST ) ); + if (i >= 15) { + return i; + } else { -+ i = Math.max( i, this.m_46852_( p_46752_.m_142126_(), Direction.EAST ) ); ++ i = Math.max( i, this.getDirectSignal( p_46752_.east(), Direction.EAST ) ); + return i >= 15 ? i : i; + } + } @@ -1722,37 +1722,37 @@ + } + } + -+ public boolean m_46616_(BlockPos p_46617_, Direction p_46618_) { -+ return this.m_46681_( p_46617_, p_46618_ ) > 0; ++ public boolean hasSignal(BlockPos p_46617_, Direction p_46618_) { ++ return this.getSignal( p_46617_, p_46618_ ) > 0; + } + -+ public int m_46681_(BlockPos p_46682_, Direction p_46683_) { -+ BlockState blockstate = this.m_8055_( p_46682_ ); -+ int i = blockstate.m_60746_( this, p_46682_, p_46683_ ); -+ return blockstate.shouldCheckWeakPower( this, p_46682_, p_46683_ ) ? Math.max( i, this.m_46751_( p_46682_ ) ) : i; ++ public int getSignal(BlockPos p_46682_, Direction p_46683_) { ++ BlockState blockstate = this.getBlockState( p_46682_ ); ++ int i = blockstate.getSignal( this, p_46682_, p_46683_ ); ++ return blockstate.shouldCheckWeakPower( this, p_46682_, p_46683_ ) ? Math.max( i, this.getDirectSignalTo( p_46682_ ) ) : i; + } + -+ public boolean m_46753_(BlockPos p_46754_) { -+ if (this.m_46681_( p_46754_.m_7495_(), Direction.DOWN ) > 0) { ++ public boolean hasNeighborSignal(BlockPos p_46754_) { ++ if (this.getSignal( p_46754_.below(), Direction.DOWN ) > 0) { + return true; -+ } else if (this.m_46681_( p_46754_.m_7494_(), Direction.UP ) > 0) { ++ } else if (this.getSignal( p_46754_.above(), Direction.UP ) > 0) { + return true; -+ } else if (this.m_46681_( p_46754_.m_142127_(), Direction.NORTH ) > 0) { ++ } else if (this.getSignal( p_46754_.north(), Direction.NORTH ) > 0) { + return true; -+ } else if (this.m_46681_( p_46754_.m_142128_(), Direction.SOUTH ) > 0) { ++ } else if (this.getSignal( p_46754_.south(), Direction.SOUTH ) > 0) { + return true; -+ } else if (this.m_46681_( p_46754_.m_142125_(), Direction.WEST ) > 0) { ++ } else if (this.getSignal( p_46754_.west(), Direction.WEST ) > 0) { + return true; + } else { -+ return this.m_46681_( p_46754_.m_142126_(), Direction.EAST ) > 0; ++ return this.getSignal( p_46754_.east(), Direction.EAST ) > 0; + } + } + -+ public int m_46755_(BlockPos p_46756_) { ++ public int getBestNeighborSignal(BlockPos p_46756_) { + int i = 0; + -+ for (Direction direction : f_46422_) { -+ int j = this.m_46681_( p_46756_.m_142300_( direction ), direction ); ++ for (Direction direction : DIRECTIONS) { ++ int j = this.getSignal( p_46756_.relative( direction ), direction ); + if (j >= 15) { + return 15; + } @@ -1765,136 +1765,136 @@ + return i; + } + -+ public void m_7462_() { ++ public void disconnect() { + } + -+ public long m_46467_() { -+ return this.f_46442_.m_6793_(); ++ public long getGameTime() { ++ return this.levelData.getGameTime(); + } + -+ public long m_46468_() { -+ return this.f_46442_.m_6792_(); ++ public long getDayTime() { ++ return this.levelData.getDayTime(); + } + -+ public boolean m_7966_(Player p_46557_, BlockPos p_46558_) { ++ public boolean mayInteract(Player p_46557_, BlockPos p_46558_) { + return true; + } + -+ public void m_7605_(Entity p_46509_, byte p_46510_) { ++ public void broadcastEntityEvent(Entity p_46509_, byte p_46510_) { + } + -+ public void m_7696_(BlockPos p_46582_, Block p_46583_, int p_46584_, int p_46585_) { -+ this.m_8055_( p_46582_ ).m_60677_( this, p_46582_, p_46584_, p_46585_ ); ++ public void blockEvent(BlockPos p_46582_, Block p_46583_, int p_46584_, int p_46585_) { ++ this.getBlockState( p_46582_ ).triggerEvent( this, p_46582_, p_46584_, p_46585_ ); + } + -+ public LevelData m_6106_() { -+ return this.f_46442_; ++ public LevelData getLevelData() { ++ return this.levelData; + } + -+ public GameRules m_46469_() { -+ return this.f_46442_.m_5470_(); ++ public GameRules getGameRules() { ++ return this.levelData.getGameRules(); + } + -+ public float m_46661_(float p_46662_) { -+ return Mth.m_14179_( p_46662_, this.f_46439_, this.f_46440_ ) * this.m_46722_( p_46662_ ); ++ public float getThunderLevel(float p_46662_) { ++ return Mth.lerp( p_46662_, this.oThunderLevel, this.thunderLevel ) * this.getRainLevel( p_46662_ ); + } + -+ public void m_46707_(float p_46708_) { -+ float f = Mth.m_14036_( p_46708_, 0.0F, 1.0F ); -+ this.f_46439_ = f; -+ this.f_46440_ = f; ++ public void setThunderLevel(float p_46708_) { ++ float f = Mth.clamp( p_46708_, 0.0F, 1.0F ); ++ this.oThunderLevel = f; ++ this.thunderLevel = f; + } + -+ public float m_46722_(float p_46723_) { -+ return Mth.m_14179_( p_46723_, this.f_46437_, this.f_46438_ ); ++ public float getRainLevel(float p_46723_) { ++ return Mth.lerp( p_46723_, this.oRainLevel, this.rainLevel ); + } + -+ public void m_46734_(float p_46735_) { -+ float f = Mth.m_14036_( p_46735_, 0.0F, 1.0F ); -+ this.f_46437_ = f; -+ this.f_46438_ = f; ++ public void setRainLevel(float p_46735_) { ++ float f = Mth.clamp( p_46735_, 0.0F, 1.0F ); ++ this.oRainLevel = f; ++ this.rainLevel = f; + } + -+ public boolean m_46470_() { -+ if (this.m_6042_().m_63935_() && !this.m_6042_().m_63946_()) { -+ return (double) this.m_46661_( 1.0F ) > 0.9D; ++ public boolean isThundering() { ++ if (this.dimensionType().hasSkyLight() && !this.dimensionType().hasCeiling()) { ++ return (double) this.getThunderLevel( 1.0F ) > 0.9D; + } else { + return false; + } + } + -+ public boolean m_46471_() { -+ return (double) this.m_46722_( 1.0F ) > 0.2D; ++ public boolean isRaining() { ++ return (double) this.getRainLevel( 1.0F ) > 0.2D; + } + -+ public boolean m_46758_(BlockPos p_46759_) { -+ if (!this.m_46471_()) { ++ public boolean isRainingAt(BlockPos p_46759_) { ++ if (!this.isRaining()) { + return false; -+ } else if (!this.m_45527_( p_46759_ )) { ++ } else if (!this.canSeeSky( p_46759_ )) { + return false; -+ } else if (this.m_5452_( Heightmap.Types.MOTION_BLOCKING, p_46759_ ).m_123342_() > p_46759_.m_123342_()) { ++ } else if (this.getHeightmapPos( Heightmap.Types.MOTION_BLOCKING, p_46759_ ).getY() > p_46759_.getY()) { + return false; + } else { -+ Biome biome = this.m_204166_( p_46759_ ).m_203334_(); -+ return biome.m_47530_() == Biome.Precipitation.RAIN && biome.m_198906_( p_46759_ ); ++ Biome biome = this.getBiome( p_46759_ ).value(); ++ return biome.getPrecipitation() == Biome.Precipitation.RAIN && biome.warmEnoughToRain( p_46759_ ); + } + } + -+ public boolean m_46761_(BlockPos p_46762_) { -+ Biome biome = this.m_204166_( p_46762_ ).m_203334_(); -+ return biome.m_47533_(); ++ public boolean isHumidAt(BlockPos p_46762_) { ++ Biome biome = this.getBiome( p_46762_ ).value(); ++ return biome.isHumid(); + } + + @Nullable -+ public abstract MapItemSavedData m_7489_(String p_46650_); ++ public abstract MapItemSavedData getMapData(String p_46650_); + -+ public abstract void m_142325_(String p_151533_, MapItemSavedData p_151534_); ++ public abstract void setMapData(String p_151533_, MapItemSavedData p_151534_); + -+ public abstract int m_7354_(); ++ public abstract int getFreeMapId(); + -+ public void m_6798_(int p_46665_, BlockPos p_46666_, int p_46667_) { ++ public void globalLevelEvent(int p_46665_, BlockPos p_46666_, int p_46667_) { + } + -+ public CrashReportCategory m_6026_(CrashReport p_46656_) { -+ CrashReportCategory crashreportcategory = p_46656_.m_127516_( "Affected level", 1 ); -+ crashreportcategory.m_128165_( "All players", () -> { -+ return this.m_6907_().size() + " total; " + this.m_6907_(); ++ public CrashReportCategory fillReportDetails(CrashReport p_46656_) { ++ CrashReportCategory crashreportcategory = p_46656_.addCategory( "Affected level", 1 ); ++ crashreportcategory.setDetail( "All players", () -> { ++ return this.players().size() + " total; " + this.players(); + } ); -+ crashreportcategory.m_128165_( "Chunk stats", this.m_7726_()::m_6754_ ); -+ crashreportcategory.m_128165_( "Level dimension", () -> { -+ return this.m_46472_().m_135782_().toString(); ++ crashreportcategory.setDetail( "Chunk stats", this.getChunkSource()::gatherStats ); ++ crashreportcategory.setDetail( "Level dimension", () -> { ++ return this.dimension().location().toString(); + } ); + + try { -+ this.f_46442_.m_142471_( crashreportcategory, this ); ++ this.levelData.fillCrashReportCategory( crashreportcategory, this ); + } catch (Throwable throwable) { -+ crashreportcategory.m_128162_( "Level Data Unobtainable", throwable ); ++ crashreportcategory.setDetailError( "Level Data Unobtainable", throwable ); + } + + return crashreportcategory; + } + -+ public abstract void m_6801_(int p_46506_, BlockPos p_46507_, int p_46508_); ++ public abstract void destroyBlockProgress(int p_46506_, BlockPos p_46507_, int p_46508_); + -+ public void m_7228_(double p_46475_, double p_46476_, double p_46477_, double p_46478_, double p_46479_, double p_46480_, @Nullable CompoundTag p_46481_) { ++ public void createFireworks(double p_46475_, double p_46476_, double p_46477_, double p_46478_, double p_46479_, double p_46480_, @Nullable CompoundTag p_46481_) { + } + -+ public abstract Scoreboard m_6188_(); ++ public abstract Scoreboard getScoreboard(); + -+ public void m_46717_(BlockPos p_46718_, Block p_46719_) { ++ public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { + for (Direction direction : Direction.values()) { -+ BlockPos blockpos = p_46718_.m_142300_( direction ); -+ if (this.m_46805_( blockpos )) { -+ BlockState blockstate = this.m_8055_( blockpos ); ++ BlockPos blockpos = p_46718_.relative( direction ); ++ if (this.hasChunkAt( blockpos )) { ++ BlockState blockstate = this.getBlockState( blockpos ); + blockstate.onNeighborChange( this, blockpos, p_46718_ ); -+ if (blockstate.m_60796_( this, blockpos )) { -+ blockpos = blockpos.m_142300_( direction ); -+ blockstate = this.m_8055_( blockpos ); ++ if (blockstate.isRedstoneConductor( this, blockpos )) { ++ blockpos = blockpos.relative( direction ); ++ blockstate = this.getBlockState( blockpos ); + if (blockstate.getWeakChanges( this, blockpos )) { + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) + this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); + else -+ blockstate.m_60690_( this, blockpos, p_46719_, p_46718_, false ); ++ blockstate.neighborChanged( this, blockpos, p_46719_, p_46718_, false ); + } + } + } @@ -1902,78 +1902,78 @@ + + } + -+ public DifficultyInstance m_6436_(BlockPos p_46730_) { ++ public DifficultyInstance getCurrentDifficultyAt(BlockPos p_46730_) { + long i = 0L; + float f = 0.0F; -+ if (this.m_46805_( p_46730_ )) { -+ f = this.m_46940_(); -+ i = this.m_46745_( p_46730_ ).m_6319_(); ++ if (this.hasChunkAt( p_46730_ )) { ++ f = this.getMoonBrightness(); ++ i = this.getChunkAt( p_46730_ ).getInhabitedTime(); + } + -+ return new DifficultyInstance( this.m_46791_(), this.m_46468_(), i, f ); ++ return new DifficultyInstance( this.getDifficulty(), this.getDayTime(), i, f ); + } + -+ public int m_7445_() { -+ return this.f_46425_; ++ public int getSkyDarken() { ++ return this.skyDarken; + } + -+ public void m_6580_(int p_46709_) { ++ public void setSkyFlashTime(int p_46709_) { + } + -+ public WorldBorder m_6857_() { -+ return this.f_46447_; ++ public WorldBorder getWorldBorder() { ++ return this.worldBorder; + } + -+ public void m_5503_(Packet p_46657_) { ++ public void sendPacketToServer(Packet p_46657_) { + throw new UnsupportedOperationException( "Can't send packets to server unless you're on the client." ); + } + -+ public DimensionType m_6042_() { -+ return this.f_46445_; ++ public DimensionType dimensionType() { ++ return this.dimensionType; + } + -+ public Holder m_204156_() { -+ return this.f_204147_; ++ public Holder dimensionTypeRegistration() { ++ return this.dimensionTypeRegistration; + } + -+ public ResourceKey m_46472_() { -+ return this.f_46421_; ++ public ResourceKey dimension() { ++ return this.dimension; + } + -+ public Random m_5822_() { -+ return this.f_46441_; ++ public Random getRandom() { ++ return this.random; + } + -+ public boolean m_7433_(BlockPos p_46620_, Predicate p_46621_) { -+ return p_46621_.test( this.m_8055_( p_46620_ ) ); ++ public boolean isStateAtPosition(BlockPos p_46620_, Predicate p_46621_) { ++ return p_46621_.test( this.getBlockState( p_46620_ ) ); + } + -+ public boolean m_142433_(BlockPos p_151541_, Predicate p_151542_) { -+ return p_151542_.test( this.m_6425_( p_151541_ ) ); ++ public boolean isFluidAtPosition(BlockPos p_151541_, Predicate p_151542_) { ++ return p_151542_.test( this.getFluidState( p_151541_ ) ); + } + -+ public abstract RecipeManager m_7465_(); ++ public abstract RecipeManager getRecipeManager(); + -+ public BlockPos m_46496_(int p_46497_, int p_46498_, int p_46499_, int p_46500_) { -+ this.f_46435_ = this.f_46435_ * 3 + 1013904223; -+ int i = this.f_46435_ >> 2; ++ public BlockPos getBlockRandomPos(int p_46497_, int p_46498_, int p_46499_, int p_46500_) { ++ this.randValue = this.randValue * 3 + 1013904223; ++ int i = this.randValue >> 2; + return new BlockPos( p_46497_ + (i & 15), p_46498_ + (i >> 16 & p_46500_), p_46499_ + (i >> 8 & 15) ); + } + -+ public boolean m_7441_() { ++ public boolean noSave() { + return false; + } + -+ public ProfilerFiller m_46473_() { -+ return this.f_46446_.get(); ++ public ProfilerFiller getProfiler() { ++ return this.profiler.get(); + } + -+ public Supplier m_46658_() { -+ return this.f_46446_; ++ public Supplier getProfilerSupplier() { ++ return this.profiler; + } + -+ public BiomeManager m_7062_() { -+ return this.f_46420_; ++ public BiomeManager getBiomeManager() { ++ return this.biomeManager; + } + + private double maxEntityRadius = 2.0D; @@ -1990,34 +1990,34 @@ + return maxEntityRadius; + } + -+ public final boolean m_46659_() { -+ return this.f_46424_; ++ public final boolean isDebug() { ++ return this.isDebug; + } + -+ public abstract LevelEntityGetter m_142646_(); ++ public abstract LevelEntityGetter getEntities(); + -+ protected void m_151513_(@Nullable Entity p_151514_, GameEvent p_151515_, BlockPos p_151516_, int p_151517_) { ++ protected void postGameEventInRadius(@Nullable Entity p_151514_, GameEvent p_151515_, BlockPos p_151516_, int p_151517_) { + // CraftBukkit start -+ org.bukkit.event.world.GenericGameEvent event = new org.bukkit.event.world.GenericGameEvent( org.bukkit.GameEvent.getByKey( org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft( Registry.f_175412_.m_7981_( p_151515_ ) ) ), new org.bukkit.Location( this.getWorld(), p_151516_.m_123341_(), p_151516_.m_123342_(), p_151516_.m_123343_() ), (p_151514_ == null) ? null : p_151514_.getBukkitEntity(), p_151517_ ); ++ org.bukkit.event.world.GenericGameEvent event = new org.bukkit.event.world.GenericGameEvent( org.bukkit.GameEvent.getByKey( org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft( Registry.GAME_EVENT.getKey( p_151515_ ) ) ), new org.bukkit.Location( this.getWorld(), p_151516_.getX(), p_151516_.getY(), p_151516_.getZ() ), (p_151514_ == null) ? null : p_151514_.getBukkitEntity(), p_151517_ ); + getCraftServer().getPluginManager().callEvent( event ); + if (event.isCancelled()) { + return; + } + p_151517_ = event.getRadius(); + // CraftBukkit end -+ int i = SectionPos.m_123171_( p_151516_.m_123341_() - p_151517_ ); -+ int j = SectionPos.m_123171_( p_151516_.m_123343_() - p_151517_ ); -+ int k = SectionPos.m_123171_( p_151516_.m_123341_() + p_151517_ ); -+ int l = SectionPos.m_123171_( p_151516_.m_123343_() + p_151517_ ); -+ int i1 = SectionPos.m_123171_( p_151516_.m_123342_() - p_151517_ ); -+ int j1 = SectionPos.m_123171_( p_151516_.m_123342_() + p_151517_ ); ++ int i = SectionPos.blockToSectionCoord( p_151516_.getX() - p_151517_ ); ++ int j = SectionPos.blockToSectionCoord( p_151516_.getZ() - p_151517_ ); ++ int k = SectionPos.blockToSectionCoord( p_151516_.getX() + p_151517_ ); ++ int l = SectionPos.blockToSectionCoord( p_151516_.getZ() + p_151517_ ); ++ int i1 = SectionPos.blockToSectionCoord( p_151516_.getY() - p_151517_ ); ++ int j1 = SectionPos.blockToSectionCoord( p_151516_.getY() + p_151517_ ); + + for (int k1 = i; k1 <= k; ++k1) { + for (int l1 = j; l1 <= l; ++l1) { -+ ChunkAccess chunkaccess = this.m_7726_().m_7131_( k1, l1 ); ++ ChunkAccess chunkaccess = this.getChunkSource().getChunkNow( k1, l1 ); + if (chunkaccess != null) { + for (int i2 = i1; i2 <= j1; ++i2) { -+ chunkaccess.m_142336_( i2 ).m_142666_( p_151515_, p_151514_, p_151516_ ); ++ chunkaccess.getEventDispatcher( i2 ).post( p_151515_, p_151514_, p_151516_ ); + } + } + } @@ -2025,8 +2025,8 @@ + + } + -+ public long m_183596_() { -+ return (long) (this.f_186455_++); ++ public long nextSubTickCount() { ++ return (long) (this.subTickCount++); + } + + // org.magmafoundation.magma.Magma Stub diff --git a/patches/minecraft/net/minecraft/world/level/LevelAccessor.java.patch b/patches/minecraft/net/minecraft/world/level/LevelAccessor.java.patch index 57ec5c54..270b5cf4 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelAccessor.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelAccessor.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java @@ -77,6 +_,10 @@ - default void m_6289_(BlockPos p_46781_, Block p_46782_) { + default void blockUpdated(BlockPos p_46781_, Block p_46782_) { } + default void neighborShapeChanged(net.minecraft.core.Direction p_220411_, net.minecraft.world.level.block.state.BlockState p_220412_, BlockPos p_220413_, BlockPos p_220414_, int p_220415_, int p_220416_) { + org.magmafoundation.magma.mcpatch.updatesuppression.NeighborUpdater.executeShapeUpdate(this, p_220411_, p_220412_, p_220413_, p_220414_, p_220415_, p_220416_ - 1); + } + - void m_5594_(@Nullable Player p_46775_, BlockPos p_46776_, SoundEvent p_46777_, SoundSource p_46778_, float p_46779_, float p_46780_); + void playSound(@Nullable Player p_46775_, BlockPos p_46776_, SoundEvent p_46777_, SoundSource p_46778_, float p_46779_, float p_46780_); - void m_7106_(ParticleOptions p_46783_, double p_46784_, double p_46785_, double p_46786_, double p_46787_, double p_46788_, double p_46789_); + void addParticle(ParticleOptions p_46783_, double p_46784_, double p_46785_, double p_46786_, double p_46787_, double p_46788_, double p_46789_); @@ -100,4 +_,6 @@ - default void m_151545_(@Nullable Entity p_151546_, GameEvent p_151547_, Entity p_151548_) { - this.m_142346_(p_151546_, p_151547_, p_151548_.m_142538_()); + default void gameEvent(@Nullable Entity p_151546_, GameEvent p_151547_, Entity p_151548_) { + this.gameEvent(p_151546_, p_151547_, p_151548_.blockPosition()); } + + net.minecraft.server.level.ServerLevel getMinecraftWorld(); // CraftBukkit diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch index 8a07965c..f04ab383 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch @@ -5,9 +5,9 @@ /** @deprecated */ + default boolean isAreaLoaded(BlockPos center, int range) { -+ return this.m_46832_(center.m_142082_(-range, -range, -range), center.m_142082_(range, range, range)); ++ return this.hasChunksAt(center.offset(-range, -range, -range), center.offset(range, range, range)); + } + @Deprecated - default boolean m_46832_(BlockPos p_46833_, BlockPos p_46834_) { - return this.m_46812_(p_46833_.m_123341_(), p_46833_.m_123342_(), p_46833_.m_123343_(), p_46834_.m_123341_(), p_46834_.m_123342_(), p_46834_.m_123343_()); + default boolean hasChunksAt(BlockPos p_46833_, BlockPos p_46834_) { + return this.hasChunksAt(p_46833_.getX(), p_46833_.getY(), p_46833_.getZ(), p_46834_.getX(), p_46834_.getY(), p_46834_.getZ()); diff --git a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch index 680d23f8..53161a6c 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch @@ -1,59 +1,59 @@ --- a/net/minecraft/world/level/LevelSettings.java +++ b/net/minecraft/world/level/LevelSettings.java @@ -11,8 +_,12 @@ - private final boolean f_46906_; - private final GameRules f_46907_; - private final DataPackConfig f_46908_; + private final boolean allowCommands; + private final GameRules gameRules; + private final DataPackConfig dataPackConfig; + private final com.mojang.serialization.Lifecycle lifecycle; public LevelSettings(String p_46910_, GameType p_46911_, boolean p_46912_, Difficulty p_46913_, boolean p_46914_, GameRules p_46915_, DataPackConfig p_46916_) { + this(p_46910_, p_46911_, p_46912_, p_46913_, p_46914_, p_46915_, p_46916_, com.mojang.serialization.Lifecycle.stable()); + } + public LevelSettings(String p_46910_, GameType p_46911_, boolean p_46912_, Difficulty p_46913_, boolean p_46914_, GameRules p_46915_, DataPackConfig p_46916_, com.mojang.serialization.Lifecycle lifecycle) { - this.f_46902_ = p_46910_; - this.f_46903_ = p_46911_; - this.f_46904_ = p_46912_; + this.levelName = p_46910_; + this.gameType = p_46911_; + this.hardcore = p_46912_; @@ -20,13 +_,14 @@ - this.f_46906_ = p_46914_; - this.f_46907_ = p_46915_; - this.f_46908_ = p_46916_; + this.allowCommands = p_46914_; + this.gameRules = p_46915_; + this.dataPackConfig = p_46916_; + this.lifecycle = lifecycle; } - public static LevelSettings m_46924_(Dynamic p_46925_, DataPackConfig p_46926_) { - GameType gametype = GameType.m_46393_(p_46925_.get("GameType").asInt(0)); + public static LevelSettings parse(Dynamic p_46925_, DataPackConfig p_46926_) { + GameType gametype = GameType.byId(p_46925_.get("GameType").asInt(0)); return new LevelSettings(p_46925_.get("LevelName").asString(""), gametype, p_46925_.get("hardcore").asBoolean(false), p_46925_.get("Difficulty").asNumber().map((p_46928_) -> { - return Difficulty.m_19029_(p_46928_.byteValue()); + return Difficulty.byId(p_46928_.byteValue()); - }).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), new GameRules(p_46925_.get("GameRules")), p_46926_); + }).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), new GameRules(p_46925_.get("GameRules")), p_46926_, net.minecraftforge.common.ForgeHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable"))); } - public String m_46917_() { + public String levelName() { @@ -58,18 +_,25 @@ } - public LevelSettings m_46922_(GameType p_46923_) { -- return new LevelSettings(this.f_46902_, p_46923_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_46908_); -+ return new LevelSettings(this.f_46902_, p_46923_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_46908_, this.lifecycle); + public LevelSettings withGameType(GameType p_46923_) { +- return new LevelSettings(this.levelName, p_46923_, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, this.dataPackConfig); ++ return new LevelSettings(this.levelName, p_46923_, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, this.dataPackConfig, this.lifecycle); } - public LevelSettings m_46918_(Difficulty p_46919_) { -- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_46908_); -+ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_46919_, this.f_46905_); -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_46908_, this.lifecycle); + public LevelSettings withDifficulty(Difficulty p_46919_) { +- return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataPackConfig); ++ net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_46919_, this.difficulty); ++ return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataPackConfig, this.lifecycle); } - public LevelSettings m_46920_(DataPackConfig p_46921_) { -- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, p_46921_); -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, p_46921_, this.lifecycle); + public LevelSettings withDataPackConfig(DataPackConfig p_46921_) { +- return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_46921_); ++ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_46921_, this.lifecycle); } - public LevelSettings m_46935_() { -- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_46908_); -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_46908_, this.lifecycle); + public LevelSettings copy() { +- return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataPackConfig); ++ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataPackConfig, this.lifecycle); + } + public LevelSettings withLifecycle(com.mojang.serialization.Lifecycle lifecycle) { -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_46908_, lifecycle); ++ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataPackConfig, lifecycle); + } + public com.mojang.serialization.Lifecycle getLifecycle() { + return this.lifecycle; diff --git a/patches/minecraft/net/minecraft/world/level/LevelWriter.java.patch b/patches/minecraft/net/minecraft/world/level/LevelWriter.java.patch index 57eb9d1a..11fdad7f 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelWriter.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelWriter.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/LevelWriter.java @@ -24,7 +_,17 @@ - boolean m_7740_(BlockPos p_46957_, boolean p_46958_, @Nullable Entity p_46959_, int p_46960_); + boolean destroyBlock(BlockPos p_46957_, boolean p_46958_, @Nullable Entity p_46959_, int p_46960_); + default void prepareEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + entity.spawnReason = (spawnReason != null ? spawnReason : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + - default boolean m_7967_(Entity p_46964_) { + default boolean addFreshEntity(Entity p_46964_) { return false; } + diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index 9c3e653f..af410ace 100644 --- a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -2,29 +2,29 @@ +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -83,7 +_,7 @@ mob = (Mob)entity; - } while(mob.m_21532_() || mob.m_8023_()); + } while(mob.isPersistenceRequired() || mob.requiresCustomPersistence()); -- MobCategory mobcategory = entity.m_6095_().m_20674_(); +- MobCategory mobcategory = entity.getType().getCategory(); + MobCategory mobcategory = entity.getClassification(true); if (mobcategory != MobCategory.MISC) { Entity entity_f = entity; - BlockPos blockpos = entity.m_142538_(); + BlockPos blockpos = entity.blockPosition(); @@ -109,13 +_,31 @@ - public static void m_47029_(ServerLevel p_47030_, LevelChunk p_47031_, NaturalSpawner.SpawnState p_47032_, boolean p_47033_, boolean p_47034_, boolean p_47035_) { - p_47030_.m_46473_().m_6180_("spawner"); + public static void spawnForChunk(ServerLevel p_47030_, LevelChunk p_47031_, NaturalSpawner.SpawnState p_47032_, boolean p_47033_, boolean p_47034_, boolean p_47035_) { + p_47030_.getProfiler().push("spawner"); + p_47030_.timings.mobSpawn.startTiming(); // Spigot + -+ net.minecraft.world.level.storage.LevelData worlddata = p_47030_.m_6106_(); // CraftBukkit - Other mob type spawn tick rate ++ net.minecraft.world.level.storage.LevelData worlddata = p_47030_.getLevelData(); // CraftBukkit - Other mob type spawn tick rate - for(MobCategory mobcategory : f_46979_) { -- if ((p_47033_ || !mobcategory.m_21609_()) && (p_47034_ || mobcategory.m_21609_()) && (p_47035_ || !mobcategory.m_21610_()) && p_47032_.m_186548_(mobcategory, p_47031_.m_7697_())) { + for(MobCategory mobcategory : SPAWNING_CATEGORIES) { +- if ((p_47033_ || !mobcategory.isFriendly()) && (p_47034_ || mobcategory.isFriendly()) && (p_47035_ || !mobcategory.isPersistent()) && p_47032_.canSpawnForCategory(mobcategory, p_47031_.getPos())) { + // CraftBukkit start - Use per-world spawn limits + boolean spawnThisTick = true; -+ int limit = mobcategory.m_21608_(); ++ int limit = mobcategory.getMaxInstancesPerChunk(); + org.bukkit.entity.SpawnCategory spawnCategory = org.bukkit.craftbukkit.v1_18_R2.util.CraftSpawnCategory.toBukkit(mobcategory); + if (org.bukkit.craftbukkit.v1_18_R2.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) { -+ spawnThisTick = p_47030_.ticksPerSpawnCategory.getLong(spawnCategory) != 0 && worlddata.m_6793_() % p_47030_.ticksPerSpawnCategory.getLong(spawnCategory) == 0; ++ spawnThisTick = p_47030_.ticksPerSpawnCategory.getLong(spawnCategory) != 0 && worlddata.getGameTime() % p_47030_.ticksPerSpawnCategory.getLong(spawnCategory) == 0; + limit = p_47030_.getWorld().getSpawnLimit(spawnCategory); + } + @@ -32,38 +32,38 @@ + if (!spawnThisTick || limit == 0) { + continue; + } -+ if ((p_47033_ || !mobcategory.m_21609_()) && (p_47034_ || mobcategory.m_21609_()) && (p_47035_ || !mobcategory.m_21610_()) && p_47032_.canSpawnForCategory(mobcategory, p_47031_.m_7697_(), limit)) { ++ if ((p_47033_ || !mobcategory.isFriendly()) && (p_47034_ || mobcategory.isFriendly()) && (p_47035_ || !mobcategory.isPersistent()) && p_47032_.canSpawnForCategory(mobcategory, p_47031_.getPos(), limit)) { + // CraftBukkit end - m_47045_(mobcategory, p_47030_, p_47031_, p_47032_::m_47127_, p_47032_::m_47131_); + spawnCategoryForChunk(mobcategory, p_47030_, p_47031_, p_47032_::canSpawn, p_47032_::afterSpawn); } } + p_47030_.timings.mobSpawn.stopTiming(); // Spigot - p_47030_.m_46473_().m_7238_(); + p_47030_.getProfiler().pop(); } @@ -179,13 +_,22 @@ } - mob.m_7678_(d0, (double)i, d1, p_47040_.f_46441_.nextFloat() * 360.0F, 0.0F); -- if (m_46991_(p_47040_, mob, d2)) { + mob.moveTo(d0, (double)i, d1, p_47040_.random.nextFloat() * 360.0F, 0.0F); +- if (isValidPositionForMob(p_47040_, mob, d2)) { + int canSpawn = net.minecraftforge.common.ForgeHooks.canEntitySpawn(mob, p_47040_, d0, i, d1, null, MobSpawnType.NATURAL); -+ if (canSpawn != -1 && (canSpawn == 1 || m_46991_(p_47040_, mob, d2))) { ++ if (canSpawn != -1 && (canSpawn == 1 || isValidPositionForMob(p_47040_, mob, d2))) { + if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, (LevelAccessor) p_47040_, (float)d0, (float)i, (float)d1, null, MobSpawnType.NATURAL)) - spawngroupdata = mob.m_6518_(p_47040_, p_47040_.m_6436_(mob.m_142538_()), MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); + spawngroupdata = mob.finalizeSpawn(p_47040_, p_47040_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); - ++j; - ++l1; + // CraftBukkit start + //Magma start - set the spawn reason in the entity class instead of here + p_47040_.prepareEntity(mob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); - p_47040_.m_47205_(mob); -- p_47044_.m_47100_(mob, p_47041_); -- if (j >= mob.m_5792_()) { + p_47040_.addFreshEntityWithPassengers(mob); +- p_47044_.run(mob, p_47041_); +- if (j >= mob.getMaxSpawnClusterSize()) { + //Magma end -+ if (!mob.m_146910_()) { ++ if (!mob.isRemoved()) { + ++j; + ++l1; -+ p_47044_.m_47100_(mob, p_47041_); ++ p_47044_.run(mob, p_47041_); + } + // CraftBukkit end + if (j >= net.minecraftforge.event.ForgeEventFactory.getMaxSpawnPackSize(mob)) { @@ -73,16 +73,16 @@ @@ -265,7 +_,7 @@ } - private static WeightedRandomList m_204168_(ServerLevel p_204169_, StructureFeatureManager p_204170_, ChunkGenerator p_204171_, MobCategory p_204172_, BlockPos p_204173_, @Nullable Holder p_204174_) { -- return m_186529_(p_204173_, p_204169_, p_204172_, p_204170_) ? NetherFortressFeature.f_66381_ : p_204171_.m_203315_(p_204174_ != null ? p_204174_ : p_204169_.m_204166_(p_204173_), p_204170_, p_204172_, p_204173_); -+ return net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(p_204169_, p_204172_, p_204173_, m_186529_(p_204173_, p_204169_, p_204172_, p_204170_) ? NetherFortressFeature.f_66381_ : p_204171_.m_203315_(p_204174_ != null ? p_204174_ : p_204169_.m_204166_(p_204173_), p_204170_, p_204172_, p_204173_)); + private static WeightedRandomList mobsAt(ServerLevel p_204169_, StructureFeatureManager p_204170_, ChunkGenerator p_204171_, MobCategory p_204172_, BlockPos p_204173_, @Nullable Holder p_204174_) { +- return isInNetherFortressBounds(p_204173_, p_204169_, p_204172_, p_204170_) ? NetherFortressFeature.FORTRESS_ENEMIES : p_204171_.getMobsAt(p_204174_ != null ? p_204174_ : p_204169_.getBiome(p_204173_), p_204170_, p_204172_, p_204173_); ++ return net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(p_204169_, p_204172_, p_204173_, isInNetherFortressBounds(p_204173_, p_204169_, p_204172_, p_204170_) ? NetherFortressFeature.FORTRESS_ENEMIES : p_204171_.getMobsAt(p_204174_ != null ? p_204174_ : p_204169_.getBiome(p_204173_), p_204170_, p_204172_, p_204173_)); } - public static boolean m_186529_(BlockPos p_186530_, ServerLevel p_186531_, MobCategory p_186532_, StructureFeatureManager p_186533_) { + public static boolean isInNetherFortressBounds(BlockPos p_186530_, ServerLevel p_186531_, MobCategory p_186532_, StructureFeatureManager p_186533_) { @@ -304,6 +_,13 @@ if (p_47052_ == SpawnPlacements.Type.NO_RESTRICTIONS) { return true; - } else if (p_47055_ != null && p_47053_.m_6857_().m_61937_(p_47054_)) { + } else if (p_47055_ != null && p_47053_.getWorldBorder().isWithinBounds(p_47054_)) { + return p_47052_.canSpawnAt(p_47053_, p_47054_, p_47055_); + } + return false; @@ -90,18 +90,18 @@ + + public static boolean canSpawnAtBody(SpawnPlacements.Type p_47052_, LevelReader p_47053_, BlockPos p_47054_, @Nullable EntityType p_47055_) { + { - BlockState blockstate = p_47053_.m_8055_(p_47054_); - FluidState fluidstate = p_47053_.m_6425_(p_47054_); - BlockPos blockpos = p_47054_.m_7494_(); + BlockState blockstate = p_47053_.getBlockState(p_47054_); + FluidState fluidstate = p_47053_.getFluidState(p_47054_); + BlockPos blockpos = p_47054_.above(); @@ -316,14 +_,12 @@ case ON_GROUND: default: - BlockState blockstate1 = p_47053_.m_8055_(blockpos1); -- if (!blockstate1.m_60643_(p_47053_, blockpos1, p_47055_)) { + BlockState blockstate1 = p_47053_.getBlockState(blockpos1); +- if (!blockstate1.isValidSpawn(p_47053_, blockpos1, p_47055_)) { + if (!blockstate1.isValidSpawn(p_47053_, blockpos1, p_47052_, p_47055_)) { return false; } else { - return m_47056_(p_47053_, p_47054_, blockstate, fluidstate, p_47055_) && m_47056_(p_47053_, blockpos, p_47053_.m_8055_(blockpos), p_47053_.m_6425_(blockpos), p_47055_); + return isValidEmptySpawnBlock(p_47053_, p_47054_, blockstate, fluidstate, p_47055_) && isValidEmptySpawnBlock(p_47053_, blockpos, p_47053_.getBlockState(blockpos), p_47053_.getFluidState(blockpos), p_47055_); } } - } else { @@ -110,35 +110,35 @@ } @@ -369,8 +_,10 @@ - entity.m_7678_(d0, (double)blockpos.m_123342_(), d1, p_204179_.nextFloat() * 360.0F, 0.0F); + entity.moveTo(d0, (double)blockpos.getY(), d1, p_204179_.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob) { Mob mob = (Mob)entity; -+ if (net.minecraftforge.common.ForgeHooks.canEntitySpawn(mob, p_204176_, d0, blockpos.m_123342_(), d1, null, MobSpawnType.CHUNK_GENERATION) == -1) continue; - if (mob.m_5545_(p_204176_, MobSpawnType.CHUNK_GENERATION) && mob.m_6914_(p_204176_)) { - spawngroupdata = mob.m_6518_(p_204176_, p_204176_.m_6436_(mob.m_142538_()), MobSpawnType.CHUNK_GENERATION, spawngroupdata, (CompoundTag)null); ++ if (net.minecraftforge.common.ForgeHooks.canEntitySpawn(mob, p_204176_, d0, blockpos.getY(), d1, null, MobSpawnType.CHUNK_GENERATION) == -1) continue; + if (mob.checkSpawnRules(p_204176_, MobSpawnType.CHUNK_GENERATION) && mob.checkSpawnObstruction(p_204176_)) { + spawngroupdata = mob.finalizeSpawn(p_204176_, p_204176_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.CHUNK_GENERATION, spawngroupdata, (CompoundTag)null); + p_204176_.prepareEntity(mob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); //Magma - add spawn reason - p_204176_.m_47205_(mob); + p_204176_.addFreshEntityWithPassengers(mob); flag = true; } @@ -492,8 +_,21 @@ - return this.f_47113_; + return this.unmodifiableMobCategoryCounts; } + //Magma - add original canSpawnForCategory method for mods that implement this - boolean m_186548_(MobCategory p_186549_, ChunkPos p_186550_) { - int i = p_186549_.m_21608_() * this.f_47110_ / NaturalSpawner.f_46978_; -+ if (this.f_47111_.getInt(p_186549_) >= i) { + boolean canSpawnForCategory(MobCategory p_186549_, ChunkPos p_186550_) { + int i = p_186549_.getMaxInstancesPerChunk() * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER; ++ if (this.mobCategoryCounts.getInt(p_186549_) >= i) { + return false; + } else { -+ return this.f_186542_.m_186504_(p_186549_, p_186550_); ++ return this.localMobCapCalculator.canSpawn(p_186549_, p_186550_); + } + } + //Magma - end + // CraftBukkit start + boolean canSpawnForCategory(MobCategory p_186549_, ChunkPos p_186550_, int limit) { -+ int i = limit * this.f_47110_ / NaturalSpawner.f_46978_; ++ int i = limit * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER; + // CraftBukkit end + - if (this.f_47111_.getInt(p_186549_) >= i) { + if (this.mobCategoryCounts.getInt(p_186549_) >= i) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/level/ServerLevelAccessor.java.patch b/patches/minecraft/net/minecraft/world/level/ServerLevelAccessor.java.patch index f58ead44..3a14a5fb 100644 --- a/patches/minecraft/net/minecraft/world/level/ServerLevelAccessor.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ServerLevelAccessor.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/world/level/ServerLevelAccessor.java @@ -6,7 +_,23 @@ public interface ServerLevelAccessor extends LevelAccessor { - ServerLevel m_6018_(); + ServerLevel getLevel(); + default void prepareEntity(Entity entity, @org.jetbrains.annotations.Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + entity.spawnReason = (spawnReason != null ? spawnReason : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + - default void m_47205_(Entity p_47206_) { -- p_47206_.m_142428_().forEach(this::m_7967_); + default void addFreshEntityWithPassengers(Entity p_47206_) { +- p_47206_.getSelfAndPassengers().forEach(this::addFreshEntity); - } + // CraftBukkit start + //Magma - move spawn reason to the entity class @@ -17,12 +17,12 @@ + } + + default void addFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { -+ entity.m_142428_().forEach((e) -> this.addFreshEntity(e, reason)); ++ entity.getSelfAndPassengers().forEach((e) -> this.addFreshEntity(e, reason)); + } + + @Override + default ServerLevel getMinecraftWorld() { -+ return m_6018_(); ++ return getLevel(); + } + // CraftBukkit end } 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 6e93b0ec..323b431b 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch @@ -6,17 +6,17 @@ -public final class Biome { +public final class Biome extends net.minecraftforge.registries.ForgeRegistryEntry.UncheckedRegistryEntry { - public static final Codec f_47429_ = RecordCodecBuilder.create((p_186636_) -> { - return p_186636_.group(Biome.ClimateSettings.f_47679_.forGetter((p_151717_) -> { - return p_151717_.f_47437_; + public static final Codec DIRECT_CODEC = RecordCodecBuilder.create((p_186636_) -> { + return p_186636_.group(Biome.ClimateSettings.CODEC.forGetter((p_151717_) -> { + return p_151717_.climateSettings; @@ -46,7 +_,9 @@ - return p_186642_.f_47438_; - }), MobSpawnSettings.f_48327_.forGetter((p_186640_) -> { - return p_186640_.f_47439_; + return p_186642_.generationSettings; + }), MobSpawnSettings.CODEC.forGetter((p_186640_) -> { + return p_186640_.mobSettings; - })).apply(p_186636_, Biome::new); -+ }), net.minecraft.resources.ResourceLocation.f_135803_.optionalFieldOf("forge:registry_name").forGetter(b -> Optional.ofNullable(b.getRegistryName()))) ++ }), net.minecraft.resources.ResourceLocation.CODEC.optionalFieldOf("forge:registry_name").forGetter(b -> Optional.ofNullable(b.getRegistryName()))) + .apply(p_186636_, (climate, category, effects, gen, spawns, name) -> + net.minecraftforge.common.ForgeHooks.enhanceBiome(name.orElse(null), climate, category, effects, gen, spawns, p_186636_, Biome::new)); }); - public static final Codec f_47430_ = RecordCodecBuilder.create((p_186632_) -> { - return p_186632_.group(Biome.ClimateSettings.f_47679_.forGetter((p_186638_) -> { + public static final Codec NETWORK_CODEC = RecordCodecBuilder.create((p_186632_) -> { + return p_186632_.group(Biome.ClimateSettings.CODEC.forGetter((p_186638_) -> { 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 92028737..6f1d3e33 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch @@ -3,24 +3,24 @@ @@ -38,6 +_,7 @@ })).apply(p_186655_, BiomeGenerationSettings::new); }); - private final Map>> f_47780_; + private final Map>> carvers; + private final java.util.Set carversView; - private final List> f_47781_; - private final Supplier>> f_47783_; - private final Supplier> f_186648_; + private final List> features; + private final Supplier>> flowerFeatures; + private final Supplier> featureSet; @@ -53,10 +_,15 @@ - this.f_186648_ = Suppliers.memoize(() -> { - return p_186651_.stream().flatMap(HolderSet::m_203614_).map(Holder::m_203334_).collect(Collectors.toSet()); + this.featureSet = Suppliers.memoize(() -> { + return p_186651_.stream().flatMap(HolderSet::stream).map(Holder::value).collect(Collectors.toSet()); }); -+ this.carversView = java.util.Collections.unmodifiableSet(f_47780_.keySet()); ++ this.carversView = java.util.Collections.unmodifiableSet(carvers.keySet()); } - public Iterable>> m_204187_(GenerationStep.Carving p_204188_) { - return Objects.requireNonNullElseGet(this.f_47780_.get(p_204188_), List::of); + public Iterable>> getCarvers(GenerationStep.Carving p_204188_) { + return Objects.requireNonNullElseGet(this.carvers.get(p_204188_), List::of); + } + + public java.util.Set getCarvingStages() { + return this.carversView; } - public List> m_47815_() { + public List> getFlowerFeatures() { diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch index 737db24c..dac21f40 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch @@ -7,25 +7,25 @@ - public static enum GrassColorModifier implements StringRepresentable { + public static enum GrassColorModifier implements StringRepresentable, net.minecraftforge.common.IExtensibleEnum { NONE("none") { - public int m_6583_(double p_48081_, double p_48082_, int p_48083_) { + public int modifyColor(double p_48081_, double p_48082_, int p_48083_) { return p_48083_; @@ -222,17 +_,35 @@ }; - private final String f_48051_; -- public static final Codec f_48050_ = StringRepresentable.m_14350_(BiomeSpecialEffects.GrassColorModifier::values, BiomeSpecialEffects.GrassColorModifier::m_48070_); -+ public static final Codec f_48050_ = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(BiomeSpecialEffects.GrassColorModifier::values, BiomeSpecialEffects.GrassColorModifier::m_48070_); - private static final Map f_48052_ = Arrays.stream(values()).collect(Collectors.toMap(BiomeSpecialEffects.GrassColorModifier::m_48072_, (p_48069_) -> { + private final String name; +- public static final Codec CODEC = StringRepresentable.fromEnum(BiomeSpecialEffects.GrassColorModifier::values, BiomeSpecialEffects.GrassColorModifier::byName); ++ public static final Codec CODEC = net.minecraftforge.common.IExtensibleEnum.createCodecForExtensibleEnum(BiomeSpecialEffects.GrassColorModifier::values, BiomeSpecialEffects.GrassColorModifier::byName); + private static final Map BY_NAME = Arrays.stream(values()).collect(Collectors.toMap(BiomeSpecialEffects.GrassColorModifier::getName, (p_48069_) -> { return p_48069_; })); -- public abstract int m_6583_(double p_48065_, double p_48066_, int p_48067_); -+ public int m_6583_(double p_48065_, double p_48066_, int p_48067_) { +- public abstract int modifyColor(double p_48065_, double p_48066_, int p_48067_); ++ public int modifyColor(double p_48065_, double p_48066_, int p_48067_) { + return delegate.modifyGrassColor(p_48065_, p_48066_, p_48067_); + } GrassColorModifier(String p_48058_) { - this.f_48051_ = p_48058_; + this.name = p_48058_; } + private ColorModifier delegate; @@ -38,12 +38,12 @@ + } + @Override + public void init() { -+ f_48052_.put(this.m_48072_(), this); ++ BY_NAME.put(this.getName(), this); + } + @FunctionalInterface + public interface ColorModifier { + int modifyGrassColor(double x, double z, int color); + } - public String m_48072_() { - return this.f_48051_; + public String getName() { + return this.name; } diff --git a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index 20ac1d73..cbd3d498 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/net/minecraft/world/level/biome/MobSpawnSettings.java @@ -39,20 +_,32 @@ - private final float f_48328_; - private final Map> f_48329_; - private final Map, MobSpawnSettings.MobSpawnCost> f_48330_; + private final float creatureGenerationProbability; + private final Map> spawners; + private final Map, MobSpawnSettings.MobSpawnCost> mobSpawnCosts; + private final java.util.Set typesView; + private final java.util.Set> costView; MobSpawnSettings(float p_196689_, Map> p_196690_, Map, MobSpawnSettings.MobSpawnCost> p_196691_) { - this.f_48328_ = p_196689_; - this.f_48329_ = ImmutableMap.copyOf(p_196690_); - this.f_48330_ = ImmutableMap.copyOf(p_196691_); -+ this.typesView = java.util.Collections.unmodifiableSet(this.f_48329_.keySet()); -+ this.costView = java.util.Collections.unmodifiableSet(this.f_48330_.keySet()); + this.creatureGenerationProbability = p_196689_; + this.spawners = ImmutableMap.copyOf(p_196690_); + this.mobSpawnCosts = ImmutableMap.copyOf(p_196691_); ++ this.typesView = java.util.Collections.unmodifiableSet(this.spawners.keySet()); ++ this.costView = java.util.Collections.unmodifiableSet(this.mobSpawnCosts.keySet()); } - public WeightedRandomList m_151798_(MobCategory p_151799_) { - return this.f_48329_.getOrDefault(p_151799_, f_151796_); + public WeightedRandomList getMobs(MobCategory p_151799_) { + return this.spawners.getOrDefault(p_151799_, EMPTY_MOB_LIST); } + public java.util.Set getSpawnerTypes() { @@ -24,12 +24,12 @@ + } + @Nullable - public MobSpawnSettings.MobSpawnCost m_48345_(EntityType p_48346_) { - return this.f_48330_.get(p_48346_); + public MobSpawnSettings.MobSpawnCost getMobSpawnCost(EntityType p_48346_) { + return this.mobSpawnCosts.get(p_48346_); + } + + public java.util.Set> getEntityTypes() { + return this.costView; } - public float m_48344_() { + public float getCreatureProbability() { diff --git a/patches/minecraft/net/minecraft/world/level/block/AbstractCandleBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/AbstractCandleBlock.java.patch index 4e62da0f..0dd2d0a7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/AbstractCandleBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/AbstractCandleBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/AbstractCandleBlock.java @@ -35,6 +_,11 @@ - public void m_5581_(Level p_151905_, BlockState p_151906_, BlockHitResult p_151907_, Projectile p_151908_) { - if (!p_151905_.f_46443_ && p_151908_.m_6060_() && this.m_142595_(p_151906_)) { + public void onProjectileHit(Level p_151905_, BlockState p_151906_, BlockHitResult p_151907_, Projectile p_151908_) { + if (!p_151905_.isClientSide && p_151908_.isOnFire() && this.canBeLit(p_151906_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(p_151905_, p_151907_.m_82425_(), p_151908_).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(p_151905_, p_151907_.getBlockPos(), p_151908_).isCancelled()) { + return; + } + // CraftBukkit end - m_151918_(p_151905_, p_151906_, p_151907_.m_82425_(), true); + setLit(p_151905_, p_151906_, p_151907_.getBlockPos(), true); } diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch index f4bdae63..8198c673 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch @@ -6,54 +6,54 @@ -public class BambooBlock extends Block implements BonemealableBlock { +public class BambooBlock extends Block implements BonemealableBlock, net.minecraftforge.common.IPlantable { - protected static final float f_152092_ = 3.0F; - protected static final float f_152093_ = 5.0F; - protected static final float f_152094_ = 1.5F; + protected static final float SMALL_LEAVES_AABB_OFFSET = 3.0F; + protected static final float LARGE_LEAVES_AABB_OFFSET = 5.0F; + protected static final float COLLISION_AABB_OFFSET = 1.5F; @@ -114,10 +_,11 @@ - public void m_7455_(BlockState p_48936_, ServerLevel p_48937_, BlockPos p_48938_, Random p_48939_) { - if (p_48936_.m_61143_(f_48871_) == 0) { -- if (p_48939_.nextInt(3) == 0 && p_48937_.m_46859_(p_48938_.m_7494_()) && p_48937_.m_45524_(p_48938_.m_7494_(), 0) >= 9) { -+ if (p_48937_.m_46859_(p_48938_.m_7494_()) && p_48937_.m_45524_(p_48938_.m_7494_(), 0) >= 9) { - int i = this.m_48932_(p_48937_, p_48938_) + 1; + public void randomTick(BlockState p_48936_, ServerLevel p_48937_, BlockPos p_48938_, Random p_48939_) { + if (p_48936_.getValue(STAGE) == 0) { +- if (p_48939_.nextInt(3) == 0 && p_48937_.isEmptyBlock(p_48938_.above()) && p_48937_.getRawBrightness(p_48938_.above(), 0) >= 9) { ++ if (p_48937_.isEmptyBlock(p_48938_.above()) && p_48937_.getRawBrightness(p_48938_.above(), 0) >= 9) { + int i = this.getHeightBelowUpToMax(p_48937_, p_48938_) + 1; - if (i < 16) { + if (i < 16 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_48937_, p_48938_, p_48936_, p_48939_.nextInt(Math.max(1, (int) (100.0F / p_48937_.spigotConfig.bambooModifier) * 3)) == 0)) { // Spigot - this.m_48910_(p_48936_, p_48937_, p_48938_, p_48939_, i); + this.growBamboo(p_48936_, p_48937_, p_48938_, p_48939_, i); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_48937_, p_48938_, p_48936_); } } @@ -159,7 +_,7 @@ for(int i1 = 0; i1 < l; ++i1) { - BlockPos blockpos = p_48878_.m_6630_(i); - BlockState blockstate = p_48876_.m_8055_(blockpos); -- if (k >= 16 || blockstate.m_61143_(f_48871_) == 1 || !p_48876_.m_46859_(blockpos.m_7494_())) { -+ if (k >= 16 || !blockstate.m_60713_(Blocks.f_50571_) || blockstate.m_61143_(f_48871_) == 1 || !p_48876_.m_46859_(blockpos.m_7494_())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here + BlockPos blockpos = p_48878_.above(i); + BlockState blockstate = p_48876_.getBlockState(blockpos); +- if (k >= 16 || blockstate.getValue(STAGE) == 1 || !p_48876_.isEmptyBlock(blockpos.above())) { ++ if (k >= 16 || !blockstate.is(Blocks.BAMBOO) || blockstate.getValue(STAGE) == 1 || !p_48876_.isEmptyBlock(blockpos.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here return; } @@ -171,7 +_,7 @@ } - public float m_5880_(BlockState p_48901_, Player p_48902_, BlockGetter p_48903_, BlockPos p_48904_) { -- return p_48902_.m_21205_().m_41720_() instanceof SwordItem ? 1.0F : super.m_5880_(p_48901_, p_48902_, p_48903_, p_48904_); -+ return p_48902_.m_21205_().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.m_5880_(p_48901_, p_48902_, p_48903_, p_48904_); + public float getDestroyProgress(BlockState p_48901_, Player p_48902_, BlockGetter p_48903_, BlockPos p_48904_) { +- return p_48902_.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(p_48901_, p_48902_, p_48903_, p_48904_); ++ return p_48902_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_48901_, p_48902_, p_48903_, p_48904_); } - protected void m_48910_(BlockState p_48911_, Level p_48912_, BlockPos p_48913_, Random p_48914_, int p_48915_) { + protected void growBamboo(BlockState p_48911_, Level p_48912_, BlockPos p_48913_, Random p_48914_, int p_48915_) { @@ -179,13 +_,18 @@ - BlockPos blockpos = p_48913_.m_6625_(2); - BlockState blockstate1 = p_48912_.m_8055_(blockpos); + BlockPos blockpos = p_48913_.below(2); + BlockState blockstate1 = p_48912_.getBlockState(blockpos); BambooLeaves bambooleaves = BambooLeaves.NONE; + boolean shouldUpdateOthers = false; // CraftBukkit + if (p_48915_ >= 1) { - if (blockstate.m_60713_(Blocks.f_50571_) && blockstate.m_61143_(f_48870_) != BambooLeaves.NONE) { - if (blockstate.m_60713_(Blocks.f_50571_) && blockstate.m_61143_(f_48870_) != BambooLeaves.NONE) { + if (blockstate.is(Blocks.BAMBOO) && blockstate.getValue(LEAVES) != BambooLeaves.NONE) { + if (blockstate.is(Blocks.BAMBOO) && blockstate.getValue(LEAVES) != BambooLeaves.NONE) { bambooleaves = BambooLeaves.LARGE; - if (blockstate1.m_60713_(Blocks.f_50571_)) { -- p_48912_.m_7731_(p_48913_.m_7495_(), blockstate.m_61124_(f_48870_, BambooLeaves.SMALL), 3); -- p_48912_.m_7731_(blockpos, blockstate1.m_61124_(f_48870_, BambooLeaves.NONE), 3); + if (blockstate1.is(Blocks.BAMBOO)) { +- p_48912_.setBlock(p_48913_.below(), blockstate.setValue(LEAVES, BambooLeaves.SMALL), 3); +- p_48912_.setBlock(blockpos, blockstate1.setValue(LEAVES, BambooLeaves.NONE), 3); + // CraftBukkit start - moved down + // p_48912_.setBlock(p_48913_.below(), blockstate.setValue(LEAVES, BambooLeaves.SMALL), 3); + // p_48912_.setBlock(blockpos, blockstate1.setValue(LEAVES, BambooLeaves.NONE), 3); @@ -66,25 +66,25 @@ } } -- int i = p_48911_.m_61143_(f_48869_) != 1 && !blockstate1.m_60713_(Blocks.f_50571_) ? 0 : 1; +- int i = p_48911_.getValue(AGE) != 1 && !blockstate1.is(Blocks.BAMBOO) ? 0 : 1; - int j = (p_48915_ < 11 || !(p_48914_.nextFloat() < 0.25F)) && p_48915_ != 15 ? 0 : 1; -- p_48912_.m_7731_(p_48913_.m_7494_(), this.m_49966_().m_61124_(f_48869_, Integer.valueOf(i)).m_61124_(f_48870_, bambooleaves).m_61124_(f_48871_, Integer.valueOf(j)), 3); +- p_48912_.setBlock(p_48913_.above(), this.defaultBlockState().setValue(AGE, Integer.valueOf(i)).setValue(LEAVES, bambooleaves).setValue(STAGE, Integer.valueOf(j)), 3); + //Magma start - fix bamboo growing into the ground -+ int j = (Integer) p_48911_.m_61143_(f_48869_) != 1 && !blockstate1.m_60713_(Blocks.f_50571_) ? 0 : 1; ++ int j = (Integer) p_48911_.getValue(AGE) != 1 && !blockstate1.is(Blocks.BAMBOO) ? 0 : 1; + int k = (p_48915_ < 11 || p_48914_.nextFloat() >= 0.25F) && p_48915_ != 15 ? 0 : 1; + + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_48912_, p_48913_, p_48913_.m_7494_(), (BlockState) ((BlockState) ((BlockState) this.m_49966_().m_61124_(f_48869_, j)).m_61124_(f_48870_, bambooleaves)).m_61124_(f_48871_, k), 3)) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_48912_, p_48913_, p_48913_.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(AGE, j)).setValue(LEAVES, bambooleaves)).setValue(STAGE, k), 3)) { + if (shouldUpdateOthers) { -+ p_48912_.m_7731_(p_48913_.m_7495_(), blockstate.m_61124_(f_48870_, BambooLeaves.SMALL), 3); -+ p_48912_.m_7731_(blockpos, blockstate1.m_61124_(f_48870_, BambooLeaves.NONE), 3); ++ p_48912_.setBlock(p_48913_.below(), blockstate.setValue(LEAVES, BambooLeaves.SMALL), 3); ++ p_48912_.setBlock(blockpos, blockstate1.setValue(LEAVES, BambooLeaves.NONE), 3); + } + } + // CraftBukkit end + //Magma end } - protected int m_48882_(BlockGetter p_48883_, BlockPos p_48884_) { + protected int getHeightAboveUpToMax(BlockGetter p_48883_, BlockPos p_48884_) { @@ -212,5 +_,12 @@ } @@ -93,8 +93,8 @@ + + @Override + public BlockState getPlant(BlockGetter world, BlockPos pos) { -+ BlockState state = world.m_8055_(pos); -+ if (state.m_60734_() != this) return m_49966_(); ++ BlockState state = world.getBlockState(pos); ++ if (state.getBlock() != this) return defaultBlockState(); + return state; } } 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 21980100..332481e3 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -3,13 +3,13 @@ @@ -77,10 +_,10 @@ } - public float m_5880_(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { -- return p_48982_.m_21205_().m_41720_() instanceof SwordItem ? 1.0F : super.m_5880_(p_48981_, p_48982_, p_48983_, p_48984_); -+ return p_48982_.m_21205_().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.m_5880_(p_48981_, p_48982_, p_48983_, p_48984_); + public float getDestroyProgress(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { +- return p_48982_.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); ++ return p_48982_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); } - protected void m_48972_(Level p_48973_, BlockPos p_48974_) { -- p_48973_.m_7731_(p_48974_.m_7494_(), Blocks.f_50571_.m_49966_().m_61124_(BambooBlock.f_48870_, BambooLeaves.SMALL), 3); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_48973_, p_48974_, p_48974_.m_7494_(), (BlockState) Blocks.f_50571_.m_49966_().m_61124_(BambooBlock.f_48870_, BambooLeaves.SMALL), 3); // CraftBukkit - BlockSpreadEvent + protected void growBamboo(Level p_48973_, BlockPos p_48974_) { +- p_48973_.setBlock(p_48974_.above(), Blocks.BAMBOO.defaultBlockState().setValue(BambooBlock.LEAVES, BambooLeaves.SMALL), 3); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_48973_, p_48974_, p_48974_.above(), (BlockState) Blocks.BAMBOO.defaultBlockState().setValue(BambooBlock.LEAVES, BambooLeaves.SMALL), 3); // CraftBukkit - BlockSpreadEvent } } 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 80aa8781..79d52b5a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java @@ -113,7 +_,13 @@ - if (!p_49263_.m_5825_()) { - p_49263_.m_7311_(p_49263_.m_20094_() + 1); - if (p_49263_.m_20094_() == 0) { -- p_49263_.m_20254_(8); + if (!p_49263_.fireImmune()) { + p_49263_.setRemainingFireTicks(p_49263_.getRemainingFireTicks() + 1); + if (p_49263_.getRemainingFireTicks() == 0) { +- p_49263_.setSecondsOnFire(8); + // CraftBukkit start + org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_49261_, p_49262_), p_49263_.getBukkitEntity(), 8); + p_49261_.getCraftServer().getPluginManager().callEvent(event); @@ -14,20 +14,20 @@ + // CraftBukkit end } - p_49263_.m_6469_(DamageSource.f_19305_, this.f_49238_); + p_49263_.hurt(DamageSource.IN_FIRE, this.fireDamage); @@ -126,6 +_,7 @@ - if (!p_49282_.m_60713_(p_49279_.m_60734_())) { - if (m_49248_(p_49280_)) { - Optional optional = PortalShape.m_77708_(p_49280_, p_49281_, Direction.Axis.X); + 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().m_77743_(); + optional.get().createPortalBlocks(); return; @@ -133,7 +_,7 @@ } - if (!p_49279_.m_60710_(p_49280_, p_49281_)) { -- p_49280_.m_7471_(p_49281_, false); + if (!p_49279_.canSurvive(p_49280_, p_49281_)) { +- p_49280_.removeBlock(p_49281_, false); + fireExtinguished(p_49280_, p_49281_); // CraftBukkit - fuel block broke } @@ -39,8 +39,8 @@ + + // CraftBukkit start + protected void fireExtinguished(net.minecraft.world.level.LevelAccessor world, BlockPos position) { -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ world.m_7471_(position, false); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ world.removeBlock(position, false); + } + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch index 3e7c3edd..c45ad450 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java @@ -70,6 +_,20 @@ - int i = this.m_6693_(p_152145_, p_152146_); + int i = this.getSignalStrength(p_152145_, p_152146_); boolean flag = p_152148_ > 0; boolean flag1 = i > 0; + @@ -10,7 +10,7 @@ + org.bukkit.plugin.PluginManager manager = p_152145_.getCraftServer().getPluginManager(); + + if (flag != flag1) { -+ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bworld.getBlockAt(p_152146_.m_123341_(), p_152146_.m_123342_(), p_152146_.m_123343_()), p_152148_, i); ++ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bworld.getBlockAt(p_152146_.getX(), p_152146_.getY(), p_152146_.getZ()), p_152148_, i); + manager.callEvent(eventRedstone); + + flag1 = eventRedstone.getNewCurrent() > 0; @@ -19,5 +19,5 @@ + // CraftBukkit end + if (p_152148_ != i) { - BlockState blockstate = this.m_7422_(p_152147_, i); - p_152145_.m_7731_(p_152146_, blockstate, 2); + BlockState blockstate = this.setSignalForState(p_152147_, i); + p_152145_.setBlock(p_152146_, blockstate, 2); 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 6836fbdf..b38db456 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -6,49 +6,49 @@ -public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock { +public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock, net.minecraftforge.common.extensions.IForgeBaseRailBlock { - protected static final VoxelShape f_49355_ = Block.m_49796_(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); - protected static final VoxelShape f_49356_ = Block.m_49796_(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); - public static final BooleanProperty f_152149_ = BlockStateProperties.f_61362_; + protected static final VoxelShape FLAT_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); + protected static final VoxelShape HALF_BLOCK_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; @@ -45,6 +_,7 @@ - public VoxelShape m_5940_(BlockState p_49403_, BlockGetter p_49404_, BlockPos p_49405_, CollisionContext p_49406_) { - RailShape railshape = p_49403_.m_60713_(this) ? p_49403_.m_61143_(this.m_7978_()) : null; -+ RailShape railShape2 = p_49403_.m_60713_(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; - return railshape != null && railshape.m_61745_() ? f_49356_ : f_49355_; + public 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; + return railshape != null && railshape.isAscending() ? HALF_BLOCK_AABB : FLAT_AABB; } @@ -61,7 +_,10 @@ - protected BlockState m_49389_(BlockState p_49390_, Level p_49391_, BlockPos p_49392_, boolean p_49393_) { - p_49390_ = this.m_49367_(p_49391_, p_49392_, p_49390_, true); - if (this.f_49357_) { -- p_49390_.m_60690_(p_49391_, p_49392_, this, p_49392_, p_49393_); + protected BlockState updateState(BlockState p_49390_, Level p_49391_, BlockPos p_49392_, boolean p_49393_) { + p_49390_ = this.updateDir(p_49391_, p_49392_, p_49390_, true); + if (this.isStraight) { +- p_49390_.neighborChanged(p_49391_, p_49392_, this, p_49392_, p_49393_); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) + p_49391_.neighborChanged(p_49390_, p_49392_, this, p_49392_, p_49393_); + else -+ p_49390_.m_60690_(p_49391_, p_49392_, this, p_49392_, p_49393_); ++ p_49390_.neighborChanged(p_49391_, p_49392_, this, p_49392_, p_49393_); } return p_49390_; @@ -69,7 +_,7 @@ - public void m_6861_(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, boolean p_49382_) { - if (!p_49378_.f_46443_ && p_49378_.m_8055_(p_49379_).m_60713_(this)) { -- RailShape railshape = p_49377_.m_61143_(this.m_7978_()); + public void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, 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 (m_49398_(p_49379_, p_49378_, railshape)) { - m_49950_(p_49377_, p_49378_, p_49379_); - p_49378_.m_7471_(p_49379_, p_49382_); + if (shouldBeRemoved(p_49379_, p_49378_, railshape)) { + dropResources(p_49377_, p_49378_, p_49379_); + p_49378_.removeBlock(p_49379_, p_49382_); @@ -118,7 +_,7 @@ - public void m_6810_(BlockState p_49384_, Level p_49385_, BlockPos p_49386_, BlockState p_49387_, boolean p_49388_) { + public void onRemove(BlockState p_49384_, Level p_49385_, BlockPos p_49386_, BlockState p_49387_, boolean p_49388_) { if (!p_49388_) { - super.m_6810_(p_49384_, p_49385_, p_49386_, p_49387_, p_49388_); -- if (p_49384_.m_61143_(this.m_7978_()).m_61745_()) { -+ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).m_61745_()) { - p_49385_.m_46672_(p_49386_.m_7494_(), this); + 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()) { + p_49385_.updateNeighborsAt(p_49386_.above(), this); } @@ -139,6 +_,11 @@ - return blockstate.m_61124_(this.m_7978_(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).m_61124_(f_152149_, Boolean.valueOf(flag)); + return blockstate.setValue(this.getShapeProperty(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(WATERLOGGED, Boolean.valueOf(flag)); } + /** @@ -56,22 +56,22 @@ + * If you do change this property be aware that other functions in this/subclasses may break as they can make assumptions about this property + */ + @Deprecated - public abstract Property m_7978_(); + public abstract Property getShapeProperty(); - public BlockState m_7417_(BlockState p_152151_, Direction p_152152_, BlockState p_152153_, LevelAccessor p_152154_, BlockPos p_152155_, BlockPos p_152156_) { + public BlockState updateShape(BlockState p_152151_, Direction p_152152_, BlockState p_152153_, LevelAccessor p_152154_, BlockPos p_152155_, BlockPos p_152156_) { @@ -151,5 +_,15 @@ - public FluidState m_5888_(BlockState p_152158_) { - return p_152158_.m_61143_(f_152149_) ? Fluids.f_76193_.m_76068_(false) : super.m_5888_(p_152158_); + public FluidState getFluidState(BlockState p_152158_) { + return p_152158_.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(p_152158_); + } + + @Override + public boolean isFlexibleRail(BlockState state, BlockGetter world, BlockPos pos) { -+ return !this.f_49357_; ++ return !this.isStraight; + } + + @Override + public RailShape getRailDirection(BlockState state, BlockGetter world, BlockPos pos, @javax.annotation.Nullable net.minecraft.world.entity.vehicle.AbstractMinecart cart) { -+ return state.m_61143_(m_7978_()); ++ return state.getValue(getShapeProperty()); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/BedBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BedBlock.java.patch index d9a8501f..9ba23f80 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BedBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BedBlock.java.patch @@ -4,12 +4,12 @@ } } -- if (!m_49488_(p_49516_)) { +- if (!canSetSpawn(p_49516_)) { + // CraftBukkit - moved world and biome check into EntityHuman -+ if (false && !m_49488_(p_49516_)) { - p_49516_.m_7471_(p_49517_, false); - BlockPos blockpos = p_49517_.m_142300_(p_49515_.m_61143_(f_54117_).m_122424_()); - if (p_49516_.m_8055_(blockpos).m_60713_(this)) { ++ if (false && !canSetSpawn(p_49516_)) { + p_49516_.removeBlock(p_49517_, false); + BlockPos blockpos = p_49517_.relative(p_49515_.getValue(FACING).getOpposite()); + if (p_49516_.getBlockState(blockpos).is(this)) { @@ -100,7 +_,16 @@ return InteractionResult.SUCCESS; @@ -18,14 +18,14 @@ + BlockState finaliblockdata = p_49515_; + BlockPos finalblockposition = p_49517_; + // CraftBukkit end - p_49518_.m_7720_(p_49517_).ifLeft((p_49477_) -> { + p_49518_.startSleepInBed(p_49517_).ifLeft((p_49477_) -> { + // CraftBukkit start - handling bed explosion from below here -+ if (!p_49516_.m_6042_().m_63961_()) { ++ if (!p_49516_.dimensionType().bedWorks()) { + this.explodeBed(finaliblockdata, p_49516_, finalblockposition); + } else + // CraftBukkit end if (p_49477_ != null) { - p_49518_.m_5661_(p_49477_.m_36423_(), true); + p_49518_.displayClientMessage(p_49477_.getMessage(), true); } @@ -111,8 +_,21 @@ } @@ -33,20 +33,20 @@ + // CraftBukkit start + private InteractionResult explodeBed(BlockState iblockdata, Level world, BlockPos blockposition) { -+ world.m_7471_(blockposition, false); -+ BlockPos blockposition1 = blockposition.m_142300_(((Direction) iblockdata.m_61143_(f_54117_)).m_122424_()); -+ if (world.m_8055_(blockposition1).m_60734_() == this) { -+ world.m_7471_(blockposition1, false); ++ world.removeBlock(blockposition, false); ++ BlockPos blockposition1 = blockposition.relative(((Direction) iblockdata.getValue(FACING)).getOpposite()); ++ if (world.getBlockState(blockposition1).getBlock() == this) { ++ world.removeBlock(blockposition1, false); + } -+ world.m_7703_((Entity) null, DamageSource.m_19334_(), (ExplosionDamageCalculator) null, (double) blockposition.m_123341_() + 0.5D, (double) blockposition.m_123342_() + 0.5D, (double) blockposition.m_123343_() + 0.5D, 5.0F, true, Explosion.BlockInteraction.DESTROY); ++ world.explode((Entity) null, DamageSource.badRespawnPointExplosion(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.BlockInteraction.DESTROY); + return InteractionResult.SUCCESS; + } +// CraftBukkit end + - public static boolean m_49488_(Level p_49489_) { -- return p_49489_.m_6042_().m_63961_(); + public static boolean canSetSpawn(Level p_49489_) { +- return p_49489_.dimensionType().bedWorks(); + // CraftBukkit - moved world and biome check into EntityHuman -+ return true || p_49489_.m_6042_().m_63961_(); ++ return true || p_49489_.dimensionType().bedWorks(); } - private boolean m_49490_(Level p_49491_, BlockPos p_49492_) { + private boolean kickVillagerOutOfBed(Level p_49491_, BlockPos p_49492_) { 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 d4d0a457..b1204af2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java @@ -70,6 +_,9 @@ - public int m_6782_(BlockState p_49620_, Level p_49621_, BlockPos p_49622_) { - return p_49620_.m_61143_(f_49564_); + public int getAnalogOutputSignal(BlockState p_49620_, Level p_49621_, BlockPos p_49622_) { + return p_49620_.getValue(HONEY_LEVEL); } + // Forge: Fixed MC-227255 Beehives and bee nests do not rotate/mirror correctly in structure blocks -+ @Override public BlockState m_6843_(BlockState blockState, net.minecraft.world.level.block.Rotation rotation) { return blockState.m_61124_(f_49563_, rotation.m_55954_(blockState.m_61143_(f_49563_))); } -+ @Override public BlockState m_6943_(BlockState blockState, net.minecraft.world.level.block.Mirror mirror) { return blockState.m_60717_(mirror.m_54846_(blockState.m_61143_(f_49563_))); } ++ @Override public BlockState rotate(BlockState blockState, net.minecraft.world.level.block.Rotation rotation) { return blockState.setValue(FACING, rotation.rotate(blockState.getValue(FACING))); } ++ @Override public BlockState mirror(BlockState blockState, net.minecraft.world.level.block.Mirror mirror) { return blockState.rotate(mirror.getRotation(blockState.getValue(FACING))); } - public void m_6240_(Level p_49584_, Player p_49585_, BlockPos p_49586_, BlockState p_49587_, @Nullable BlockEntity p_49588_, ItemStack p_49589_) { - super.m_6240_(p_49584_, p_49585_, p_49586_, p_49587_, p_49588_, p_49589_); + public void playerDestroy(Level p_49584_, Player p_49585_, BlockPos p_49586_, BlockState p_49587_, @Nullable BlockEntity p_49588_, ItemStack p_49589_) { + super.playerDestroy(p_49584_, p_49585_, p_49586_, p_49587_, p_49588_, p_49589_); @@ -90,11 +_,12 @@ - List list = p_49650_.m_45976_(Bee.class, (new AABB(p_49651_)).m_82377_(8.0D, 6.0D, 8.0D)); + List list = p_49650_.getEntitiesOfClass(Bee.class, (new AABB(p_49651_)).inflate(8.0D, 6.0D, 8.0D)); if (!list.isEmpty()) { - List list1 = p_49650_.m_45976_(Player.class, (new AABB(p_49651_)).m_82377_(8.0D, 6.0D, 8.0D)); + List list1 = p_49650_.getEntitiesOfClass(Player.class, (new AABB(p_49651_)).inflate(8.0D, 6.0D, 8.0D)); + if (list1.isEmpty()) return; //Forge: Prevent Error when no players are around. int i = list1.size(); for(Bee bee : list) { - if (bee.m_5448_() == null) { -- bee.m_6710_(list1.get(p_49650_.f_46441_.nextInt(i))); -+ bee.setTarget(list1.get(p_49650_.f_46441_.nextInt(i)), org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit + if (bee.getTarget() == null) { +- bee.setTarget(list1.get(p_49650_.random.nextInt(i))); ++ bee.setTarget(list1.get(p_49650_.random.nextInt(i)), org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit } } } @@ -111,7 +_,7 @@ boolean flag = false; if (i >= 5) { - Item item = itemstack.m_41720_(); -- if (itemstack.m_150930_(Items.f_42574_)) { + Item item = itemstack.getItem(); +- if (itemstack.is(Items.SHEARS)) { + if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST)) { - p_49625_.m_6263_(p_49627_, p_49627_.m_20185_(), p_49627_.m_20186_(), p_49627_.m_20189_(), SoundEvents.f_11697_, SoundSource.NEUTRAL, 1.0F, 1.0F); - m_49600_(p_49625_, p_49626_); - itemstack.m_41622_(1, p_49627_, (p_49571_) -> { + p_49625_.playSound(p_49627_, p_49627_.getX(), p_49627_.getY(), p_49627_.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.NEUTRAL, 1.0F, 1.0F); + dropHoneycomb(p_49625_, p_49626_); + itemstack.hurtAndBreak(1, p_49627_, (p_49571_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BigDripleafBlock.java.patch index 37ddc414..28c788cb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -3,23 +3,23 @@ @@ -104,7 +_,7 @@ } - public void m_5581_(Level p_152228_, BlockState p_152229_, BlockHitResult p_152230_, Projectile p_152231_) { -- this.m_152282_(p_152229_, p_152228_, p_152230_.m_82425_(), Tilt.FULL, SoundEvents.f_144131_); -+ this.setTiltAndScheduleTick(p_152229_, p_152228_, p_152230_.m_82425_(), Tilt.FULL, SoundEvents.f_144131_, p_152231_); // CraftBukkit + public void onProjectileHit(Level p_152228_, BlockState p_152229_, BlockHitResult p_152230_, Projectile p_152231_) { +- this.setTiltAndScheduleTick(p_152229_, p_152228_, p_152230_.getBlockPos(), Tilt.FULL, SoundEvents.BIG_DRIPLEAF_TILT_DOWN); ++ this.setTiltAndScheduleTick(p_152229_, p_152228_, p_152230_.getBlockPos(), Tilt.FULL, SoundEvents.BIG_DRIPLEAF_TILT_DOWN, p_152231_); // CraftBukkit } - public FluidState m_5888_(BlockState p_152312_) { + public FluidState getFluidState(BlockState p_152312_) { @@ -152,7 +_,19 @@ - public void m_7892_(BlockState p_152266_, Level p_152267_, BlockPos p_152268_, Entity p_152269_) { - if (!p_152267_.f_46443_) { - if (p_152266_.m_61143_(f_152201_) == Tilt.NONE && m_152301_(p_152268_, p_152269_) && !p_152267_.m_46753_(p_152268_)) { -- this.m_152282_(p_152266_, p_152267_, p_152268_, Tilt.UNSTABLE, (SoundEvent)null); + public void entityInside(BlockState p_152266_, Level p_152267_, BlockPos p_152268_, Entity p_152269_) { + if (!p_152267_.isClientSide) { + if (p_152266_.getValue(TILT) == Tilt.NONE && canEntityTilt(p_152268_, p_152269_) && !p_152267_.hasNeighborSignal(p_152268_)) { +- this.setTiltAndScheduleTick(p_152266_, p_152267_, p_152268_, Tilt.UNSTABLE, (SoundEvent)null); + // CraftBukkit start - tilt dripleaf + org.bukkit.event.Cancellable cancellable; + if (p_152269_ instanceof Player) { + cancellable = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent((Player) p_152269_, org.bukkit.event.block.Action.PHYSICAL, p_152268_, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(p_152269_.getBukkitEntity(), p_152267_.getWorld().getBlockAt(p_152268_.m_123341_(), p_152268_.m_123342_(), p_152268_.m_123343_())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(p_152269_.getBukkitEntity(), p_152267_.getWorld().getBlockAt(p_152268_.getX(), p_152268_.getY(), p_152268_.getZ())); + p_152267_.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + if (cancellable.isCancelled()) { @@ -32,56 +32,56 @@ } @@ -164,9 +_,9 @@ } else { - Tilt tilt = p_152256_.m_61143_(f_152201_); + Tilt tilt = p_152256_.getValue(TILT); if (tilt == Tilt.UNSTABLE) { -- this.m_152282_(p_152256_, p_152257_, p_152258_, Tilt.PARTIAL, SoundEvents.f_144131_); -+ this.setTiltAndScheduleTick(p_152256_, p_152257_, p_152258_, Tilt.PARTIAL, SoundEvents.f_144131_, null); // CraftBukkit +- this.setTiltAndScheduleTick(p_152256_, p_152257_, p_152258_, Tilt.PARTIAL, SoundEvents.BIG_DRIPLEAF_TILT_DOWN); ++ this.setTiltAndScheduleTick(p_152256_, p_152257_, p_152258_, Tilt.PARTIAL, SoundEvents.BIG_DRIPLEAF_TILT_DOWN, null); // CraftBukkit } else if (tilt == Tilt.PARTIAL) { -- this.m_152282_(p_152256_, p_152257_, p_152258_, Tilt.FULL, SoundEvents.f_144131_); -+ this.setTiltAndScheduleTick(p_152256_, p_152257_, p_152258_, Tilt.FULL, SoundEvents.f_144131_, null); // CraftBukkit +- this.setTiltAndScheduleTick(p_152256_, p_152257_, p_152258_, Tilt.FULL, SoundEvents.BIG_DRIPLEAF_TILT_DOWN); ++ this.setTiltAndScheduleTick(p_152256_, p_152257_, p_152258_, Tilt.FULL, SoundEvents.BIG_DRIPLEAF_TILT_DOWN, null); // CraftBukkit } else if (tilt == Tilt.FULL) { - m_152313_(p_152256_, p_152257_, p_152258_); + resetTilt(p_152256_, p_152257_, p_152258_); } @@ -190,8 +_,10 @@ - return p_152303_.m_20096_() && p_152303_.m_20182_().f_82480_ > (double)((float)p_152302_.m_123342_() + 0.6875F); + return p_152303_.isOnGround() && p_152303_.position().y > (double)((float)p_152302_.getY() + 0.6875F); } -- private void m_152282_(BlockState p_152283_, Level p_152284_, BlockPos p_152285_, Tilt p_152286_, @Nullable SoundEvent p_152287_) { -- m_152277_(p_152283_, p_152284_, p_152285_, p_152286_); +- private void setTiltAndScheduleTick(BlockState p_152283_, Level p_152284_, BlockPos p_152285_, Tilt p_152286_, @Nullable SoundEvent p_152287_) { +- setTilt(p_152283_, p_152284_, p_152285_, p_152286_); + // CraftBukkit start + private void setTiltAndScheduleTick(BlockState p_152283_, Level p_152284_, BlockPos p_152285_, Tilt p_152286_, @Nullable SoundEvent p_152287_, @Nullable Entity entity) { + if(!setTilt(p_152283_, p_152284_, p_152285_, p_152286_, entity)) return; + // CraftBukkit end if (p_152287_ != null) { - m_152232_(p_152284_, p_152285_, p_152287_); + playTiltSound(p_152284_, p_152285_, p_152287_); } @@ -204,19 +_,27 @@ } - private static void m_152313_(BlockState p_152314_, Level p_152315_, BlockPos p_152316_) { -- m_152277_(p_152314_, p_152315_, p_152316_, Tilt.NONE); + private static void resetTilt(BlockState p_152314_, Level p_152315_, BlockPos p_152316_) { +- setTilt(p_152314_, p_152315_, p_152316_, Tilt.NONE); + setTilt(p_152314_, p_152315_, p_152316_, Tilt.NONE, null); // CraftBukkit - if (p_152314_.m_61143_(f_152201_) != Tilt.NONE) { - m_152232_(p_152315_, p_152316_, SoundEvents.f_144132_); + if (p_152314_.getValue(TILT) != Tilt.NONE) { + playTiltSound(p_152315_, p_152316_, SoundEvents.BIG_DRIPLEAF_TILT_UP); } } -- private static void m_152277_(BlockState p_152278_, Level p_152279_, BlockPos p_152280_, Tilt p_152281_) { +- private static void setTilt(BlockState p_152278_, Level p_152279_, BlockPos p_152280_, Tilt p_152281_) { + // CraftBukkit start + private static boolean setTilt(BlockState p_152278_, Level p_152279_, BlockPos p_152280_, Tilt p_152281_, @Nullable Entity entity) { + if (entity != null) { -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_152280_, p_152278_.m_61124_(BigDripleafBlock.f_152201_, p_152281_)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_152280_, p_152278_.setValue(BigDripleafBlock.TILT, p_152281_)).isCancelled()) { + return false; + } + } + // CraftBukkit end - p_152279_.m_7731_(p_152280_, p_152278_.m_61124_(f_152201_, p_152281_), 2); - if (p_152281_.m_156084_()) { - p_152279_.m_151555_(GameEvent.f_157792_, p_152280_); + p_152279_.setBlock(p_152280_, p_152278_.setValue(TILT, p_152281_), 2); + if (p_152281_.causesVibration()) { + p_152279_.gameEvent(GameEvent.BLOCK_CHANGE, p_152280_); } + return true; // CraftBukkit } - public VoxelShape m_5939_(BlockState p_152307_, BlockGetter p_152308_, BlockPos p_152309_, CollisionContext p_152310_) { + public VoxelShape getCollisionShape(BlockState p_152307_, BlockGetter p_152308_, BlockPos p_152309_, CollisionContext p_152310_) { 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 c78f654b..260847c4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -6,18 +6,18 @@ -public class Block extends BlockBehaviour implements ItemLike { +public class Block extends BlockBehaviour implements ItemLike, net.minecraftforge.common.extensions.IForgeBlock { - private static final Logger f_49790_ = LogUtils.getLogger(); - private final Holder.Reference f_204296_ = Registry.f_122824_.m_203693_(this); -- public static final IdMapper f_49791_ = new IdMapper<>(); + private static final Logger LOGGER = LogUtils.getLogger(); + private final Holder.Reference builtInRegistryHolder = Registry.BLOCK.createIntrusiveHolder(this); +- public static final IdMapper BLOCK_STATE_REGISTRY = new IdMapper<>(); + @Deprecated //Forge: Do not use, use GameRegistry -+ public static final IdMapper f_49791_ = net.minecraftforge.registries.GameData.getBlockStateIDMap(); - private static final LoadingCache f_49785_ = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { ++ public static final IdMapper BLOCK_STATE_REGISTRY = net.minecraftforge.registries.GameData.getBlockStateIDMap(); + private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { public Boolean load(VoxelShape p_49972_) { - return !Shapes.m_83157_(Shapes.m_83144_(), p_49972_, BooleanOp.f_82687_); + return !Shapes.joinIsNotEmpty(Shapes.block(), p_49972_, BooleanOp.NOT_SAME); @@ -87,6 +_,15 @@ - public static final int f_152391_ = 512; - protected final StateDefinition f_49792_; - private BlockState f_49786_; + public static final int UPDATE_LIMIT = 512; + protected final StateDefinition stateDefinition; + private BlockState defaultBlockState; + // Paper start + public co.aikar.timings.Timing timing; + public co.aikar.timings.Timing getTiming() { @@ -28,112 +28,112 @@ + } + // Paper end @Nullable - private String f_49787_; + private String descriptionId; @Nullable @@ -178,7 +_,7 @@ - f_49790_.error("Block classes should end with Block and {} doesn't.", (Object)s); + LOGGER.error("Block classes should end with Block and {} doesn't.", (Object)s); } } - + initClient(); } - public static boolean m_152463_(BlockState p_152464_) { + public static boolean isExceptionForConnection(BlockState p_152464_) { @@ -193,6 +_,8 @@ - BlockState blockstate = p_152446_.m_8055_(p_152449_); - if (p_152445_.m_60719_(blockstate, p_152448_)) { + BlockState blockstate = p_152446_.getBlockState(p_152449_); + if (p_152445_.skipRendering(blockstate, p_152448_)) { return false; -+ } else if(p_152445_.supportsExternalFaceHiding() && blockstate.hidesNeighborFace(p_152446_, p_152449_, p_152445_, p_152448_.m_122424_())){ ++ } else if(p_152445_.supportsExternalFaceHiding() && blockstate.hidesNeighborFace(p_152446_, p_152449_, p_152445_, p_152448_.getOpposite())){ + return false; - } else if (blockstate.m_60815_()) { + } else if (blockstate.canOcclude()) { Block.BlockStatePairKey block$blockstatepairkey = new Block.BlockStatePairKey(p_152445_, blockstate, p_152448_); - Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = f_49789_.get(); + Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = OCCLUSION_CACHE.get(); @@ -324,20 +_,27 @@ } - private static void m_152440_(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { -- if (!p_152441_.f_46443_ && !p_152443_.m_41619_() && p_152441_.m_46469_().m_46207_(GameRules.f_46136_)) { -+ if (!p_152441_.f_46443_ && !p_152443_.m_41619_() && p_152441_.m_46469_().m_46207_(GameRules.f_46136_) && !p_152441_.restoringBlockSnapshots) { + 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) { ItemEntity itementity = p_152442_.get(); - itementity.m_32060_(); -- p_152441_.m_7967_(itementity); + itementity.setDefaultPickUpDelay(); +- p_152441_.addFreshEntity(itementity); + // CraftBukkit start + if (p_152441_.captureDrops != null) { + p_152441_.captureDrops.add(itementity); + } else { -+ p_152441_.m_7967_(itementity); ++ p_152441_.addFreshEntity(itementity); + } + // CraftBukkit end } } - public void m_49805_(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { -- if (p_49806_.m_46469_().m_46207_(GameRules.f_46136_)) { -+ if (p_49806_.m_46469_().m_46207_(GameRules.f_46136_) && !p_49806_.restoringBlockSnapshots) { - ExperienceOrb.m_147082_(p_49806_, Vec3.m_82512_(p_49807_), p_49808_); + public void popExperience(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { +- if (p_49806_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ++ if (p_49806_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_49806_.restoringBlockSnapshots) { + ExperienceOrb.award(p_49806_, Vec3.atCenterOf(p_49807_), p_49808_); } } + @Deprecated //Forge: Use more sensitive version - public float m_7325_() { - return this.f_60444_; + public float getExplosionResistance() { + return this.explosionResistance; } @@ -355,6 +_,7 @@ - public void m_6240_(Level p_49827_, Player p_49828_, BlockPos p_49829_, BlockState p_49830_, @Nullable BlockEntity p_49831_, ItemStack p_49832_) { - p_49828_.m_36246_(Stats.f_12949_.m_12902_(this)); + 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_.setExhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); - p_49828_.m_36399_(0.005F); - m_49881_(p_49830_, p_49827_, p_49829_, p_49831_, p_49828_, p_49832_); + p_49828_.causeFoodExhaustion(0.005F); + dropResources(p_49830_, p_49827_, p_49829_, p_49831_, p_49828_, p_49832_); } @@ -384,8 +_,10 @@ - public void m_5548_(BlockGetter p_49821_, Entity p_49822_) { - p_49822_.m_20256_(p_49822_.m_20184_().m_82542_(1.0D, 0.0D, 1.0D)); -+ p_49822_.m_20256_(p_49822_.m_20184_().m_82542_(1.0D, 0.0D, 1.0D)); + public void updateEntityAfterFallOn(BlockGetter p_49821_, Entity p_49822_) { + p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); ++ p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); } + @Deprecated //Forge: Use more sensitive version - public ItemStack m_7397_(BlockGetter p_49823_, BlockPos p_49824_, BlockState p_49825_) { + public ItemStack getCloneItemStack(BlockGetter p_49823_, BlockPos p_49824_, BlockState p_49825_) { return new ItemStack(this); } @@ -422,6 +_,7 @@ - public void m_141997_(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { + public void handlePrecipitation(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { } + @Deprecated //Forge: Use more sensitive version - public boolean m_6903_(Explosion p_49826_) { + public boolean dropFromExplosion(Explosion p_49826_) { return true; } @@ -457,6 +_,7 @@ - return p_152456_.m_61124_(p_152457_, p_152455_.m_61143_(p_152457_)); + return p_152456_.setValue(p_152457_, p_152455_.getValue(p_152457_)); } + @Deprecated //Forge: Use more sensitive version {@link IForgeBlockState#getSoundType(IWorldReader, BlockPos, Entity) } - public SoundType m_49962_(BlockState p_49963_) { - return this.f_60446_; + public SoundType getSoundType(BlockState p_49963_) { + return this.soundType; } @@ -466,7 +_,7 @@ - this.f_49788_ = Item.m_41439_(this); + this.item = Item.byBlock(this); } -- return this.f_49788_; -+ return this.f_49788_.delegate.get(); //Forge: Vanilla caches the items, update with registry replacements. +- return this.item; ++ return this.item.delegate.get(); //Forge: Vanilla caches the items, update with registry replacements. } - public boolean m_49967_() { + public boolean hasDynamicShape() { @@ -474,7 +_,7 @@ } public String toString() { -- return "Block{" + Registry.f_122824_.m_7981_(this) + "}"; +- return "Block{" + Registry.BLOCK.getKey(this) + "}"; + return "Block{" + getRegistryName() + "}"; } - public void m_5871_(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List p_49818_, TooltipFlag p_49819_) { + public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List p_49818_, TooltipFlag p_49819_) { @@ -488,11 +_,99 @@ - return this.f_49792_.m_61056_().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); + return this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); } + /* ======================================== FORGE START =====================================*/ @@ -164,38 +164,38 @@ + + @Override + public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, net.minecraftforge.common.IPlantable plantable) { -+ BlockState plant = plantable.getPlant(world, pos.m_142300_(facing)); -+ net.minecraftforge.common.PlantType type = plantable.getPlantType(world, pos.m_142300_(facing)); ++ BlockState plant = plantable.getPlant(world, pos.relative(facing)); ++ net.minecraftforge.common.PlantType type = plantable.getPlantType(world, pos.relative(facing)); + -+ if (plant.m_60734_() == Blocks.f_50128_) -+ return state.m_60713_(Blocks.f_50128_) || state.m_60713_(Blocks.f_49992_) || state.m_60713_(Blocks.f_49993_); ++ if (plant.getBlock() == Blocks.CACTUS) ++ return state.is(Blocks.CACTUS) || state.is(Blocks.SAND) || state.is(Blocks.RED_SAND); + -+ if (plant.m_60734_() == Blocks.f_50130_ && this == Blocks.f_50130_) ++ if (plant.getBlock() == Blocks.SUGAR_CANE && this == Blocks.SUGAR_CANE) + return true; + -+ if (plantable instanceof BushBlock && ((BushBlock)plantable).m_6266_(state, world, pos)) ++ if (plantable instanceof BushBlock && ((BushBlock)plantable).mayPlaceOn(state, world, pos)) + return true; + + if (net.minecraftforge.common.PlantType.DESERT.equals(type)) { -+ return this == Blocks.f_49992_ || this == Blocks.f_50352_ || this instanceof GlazedTerracottaBlock; ++ return this == Blocks.SAND || this == Blocks.TERRACOTTA || this instanceof GlazedTerracottaBlock; + } else if (net.minecraftforge.common.PlantType.NETHER.equals(type)) { -+ return this == Blocks.f_50135_; ++ return this == Blocks.SOUL_SAND; + } else if (net.minecraftforge.common.PlantType.CROP.equals(type)) { -+ return state.m_60713_(Blocks.f_50093_); ++ return state.is(Blocks.FARMLAND); + } else if (net.minecraftforge.common.PlantType.CAVE.equals(type)) { -+ return state.m_60783_(world, pos, Direction.UP); ++ return state.isFaceSturdy(world, pos, Direction.UP); + } else if (net.minecraftforge.common.PlantType.PLAINS.equals(type)) { -+ return this == Blocks.f_50440_ || this.m_49966_().m_204336_(BlockTags.f_144274_) || this == Blocks.f_50093_; ++ return this == Blocks.GRASS_BLOCK || this.defaultBlockState().is(BlockTags.DIRT) || this == Blocks.FARMLAND; + } else if (net.minecraftforge.common.PlantType.WATER.equals(type)) { -+ return state.m_60767_() == net.minecraft.world.level.material.Material.f_76305_; //&& state.getValue(BlockLiquidWrapper) ++ return state.getMaterial() == net.minecraft.world.level.material.Material.WATER; //&& state.getValue(BlockLiquidWrapper) + } else if (net.minecraftforge.common.PlantType.BEACH.equals(type)) { -+ boolean isBeach = state.m_60713_(Blocks.f_50440_) || this.m_49966_().m_204336_(BlockTags.f_144274_) || state.m_60713_(Blocks.f_49992_) || state.m_60713_(Blocks.f_49993_); ++ boolean isBeach = state.is(Blocks.GRASS_BLOCK) || this.defaultBlockState().is(BlockTags.DIRT) || state.is(Blocks.SAND) || state.is(Blocks.RED_SAND); + boolean hasWater = false; + for (Direction face : Direction.Plane.HORIZONTAL) { -+ BlockState blockState = world.m_8055_(pos.m_142300_(face)); -+ net.minecraft.world.level.material.FluidState fluidState = world.m_6425_(pos.m_142300_(face)); -+ hasWater |= blockState.m_60713_(Blocks.f_50449_); -+ hasWater |= fluidState.m_205070_(net.minecraft.tags.FluidTags.f_13131_); ++ BlockState blockState = world.getBlockState(pos.relative(face)); ++ net.minecraft.world.level.material.FluidState fluidState = world.getFluidState(pos.relative(face)); ++ hasWater |= blockState.is(Blocks.FROSTED_ICE); ++ hasWater |= fluidState.is(net.minecraft.tags.FluidTags.WATER); + if (hasWater) + break; //No point continuing. + } @@ -208,13 +208,13 @@ + /** @deprecated */ @Deprecated - public Holder.Reference m_204297_() { - return this.f_204296_; + public Holder.Reference builtInRegistryHolder() { + return this.builtInRegistryHolder; } + + // CraftBukkit start //Magma - default to forge if not overridden + public int getExpDrop(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, ItemStack itemstack) { -+ return this.getExpDrop(blockState, serverLevel, blockPos, net.minecraft.world.item.enchantment.EnchantmentHelper.m_44843_(net.minecraft.world.item.enchantment.Enchantments.f_44987_, itemstack), net.minecraft.world.item.enchantment.EnchantmentHelper.m_44843_(net.minecraft.world.item.enchantment.Enchantments.f_44985_, itemstack)); ++ return this.getExpDrop(blockState, serverLevel, blockPos, net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_FORTUNE, itemstack), net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.SILK_TOUCH, itemstack)); + } + // CraftBukkit end + @@ -231,4 +231,4 @@ + // Spigot end public static final class BlockStatePairKey { - private final BlockState f_49980_; + private final BlockState first; 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 3fc1f4c9..66a9a2fc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -6,30 +6,30 @@ +@net.minecraftforge.registries.ObjectHolder("minecraft") public class Blocks { - public static final Block f_50016_ = m_50795_("air", new AirBlock(BlockBehaviour.Properties.m_60939_(Material.f_76296_).m_60910_().m_60993_().m_60996_())); - public static final Block f_50069_ = m_50795_("stone", new Block(BlockBehaviour.Properties.m_60944_(Material.f_76278_, MaterialColor.f_76409_).m_60999_().m_60913_(1.5F, 6.0F))); + public static final Block AIR = register("air", new AirBlock(BlockBehaviour.Properties.of(Material.AIR).noCollission().noDrops().air())); + public static final Block STONE = register("stone", new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE).requiresCorrectToolForDrops().strength(1.5F, 6.0F))); @@ -135,7 +_,7 @@ - public static final Block f_50027_ = m_50795_("green_bed", m_50764_(DyeColor.GREEN)); - public static final Block f_50028_ = m_50795_("red_bed", m_50764_(DyeColor.RED)); - public static final Block f_50029_ = m_50795_("black_bed", m_50764_(DyeColor.BLACK)); -- public static final Block f_50030_ = m_50795_("powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_))); -+ public static final Block f_50030_ = m_50795_("powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_), true)); - public static final Block f_50031_ = m_50795_("detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_))); - public static final Block f_50032_ = m_50795_("sticky_piston", m_50798_(true)); - public static final Block f_50033_ = m_50795_("cobweb", new WebBlock(BlockBehaviour.Properties.m_60939_(Material.f_76311_).m_60910_().m_60999_().m_60978_(4.0F))); + public static final Block GREEN_BED = register("green_bed", bed(DyeColor.GREEN)); + 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(Material.DECORATION).noCollission().strength(0.7F).sound(SoundType.METAL))); ++ public static final Block POWERED_RAIL = register("powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of(Material.DECORATION).noCollission().strength(0.7F).sound(SoundType.METAL), true)); + public static final Block DETECTOR_RAIL = register("detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.of(Material.DECORATION).noCollission().strength(0.7F).sound(SoundType.METAL))); + public static final Block STICKY_PISTON = register("sticky_piston", pistonBase(true)); + public static final Block COBWEB = register("cobweb", new WebBlock(BlockBehaviour.Properties.of(Material.WEB).noCollission().requiresCorrectToolForDrops().strength(4.0F))); @@ -1111,16 +_,5 @@ - public static void m_50758_() { - Block.f_49791_.forEach(BlockBehaviour.BlockStateBase::m_60611_); + public static void rebuildCache() { + Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache); - } - - static { -- for(Block block : Registry.f_122824_) { -- for(BlockState blockstate : block.m_49965_().m_61056_()) { -- Block.f_49791_.m_122667_(blockstate); +- for(Block block : Registry.BLOCK) { +- for(BlockState blockstate : block.getStateDefinition().getPossibleStates()) { +- Block.BLOCK_STATE_REGISTRY.add(blockstate); - } - -- block.m_60589_(); +- block.getLootTable(); - } - } diff --git a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch index 0ba83dd2..ea5ced1c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch @@ -6,8 +6,8 @@ -public interface BucketPickup { +public interface BucketPickup extends net.minecraftforge.common.extensions.IForgeBucketPickup { - ItemStack m_142598_(LevelAccessor p_152719_, BlockPos p_152720_, BlockState p_152721_); + ItemStack pickupBlock(LevelAccessor p_152719_, BlockPos p_152720_, BlockState p_152721_); + @Deprecated//Forge: Use state sensitive variant instead - Optional m_142298_(); + Optional getPickupSound(); } diff --git a/patches/minecraft/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch index 6ba33920..4b87cbab 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch @@ -3,10 +3,10 @@ @@ -39,7 +_,8 @@ if (block != null) { - BlockState blockstate1 = block.m_49966_().m_61124_(AmethystClusterBlock.f_152006_, direction).m_61124_(AmethystClusterBlock.f_152005_, Boolean.valueOf(blockstate.m_60819_().m_76152_() == Fluids.f_76193_)); -- p_152729_.m_46597_(blockpos, blockstate1); + BlockState blockstate1 = block.defaultBlockState().setValue(AmethystClusterBlock.FACING, direction).setValue(AmethystClusterBlock.WATERLOGGED, Boolean.valueOf(blockstate.getFluidState().getType() == Fluids.WATER)); +- p_152729_.setBlockAndUpdate(blockpos, blockstate1); + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_152729_, p_152730_, blockpos, blockstate1)) -+ p_152729_.m_46597_(blockpos, blockstate1); ++ p_152729_.setBlockAndUpdate(blockpos, blockstate1); } } 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 5615b4ee..35980ea1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch @@ -12,35 +12,35 @@ @@ -20,11 +_,20 @@ } - public BlockState m_7417_(BlockState p_51032_, Direction p_51033_, BlockState p_51034_, LevelAccessor p_51035_, BlockPos p_51036_, BlockPos p_51037_) { -- return !p_51032_.m_60710_(p_51035_, p_51036_) ? Blocks.f_50016_.m_49966_() : super.m_7417_(p_51032_, p_51033_, p_51034_, p_51035_, p_51036_, p_51037_); + public BlockState updateShape(BlockState p_51032_, Direction p_51033_, BlockState p_51034_, LevelAccessor p_51035_, BlockPos p_51036_, BlockPos p_51037_) { +- return !p_51032_.canSurvive(p_51035_, p_51036_) ? Blocks.AIR.defaultBlockState() : super.updateShape(p_51032_, p_51033_, p_51034_, p_51035_, p_51036_, p_51037_); + // CraftBukkit start -+ if (!p_51032_.m_60710_(p_51035_, p_51036_)) { ++ if (!p_51032_.canSurvive(p_51035_, p_51036_)) { + if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockPhysicsEvent(p_51035_, p_51036_).isCancelled()) { -+ return Blocks.f_50016_.m_49966_(); ++ return Blocks.AIR.defaultBlockState(); + } + } -+ return super.m_7417_(p_51032_, p_51033_, p_51034_, p_51035_, p_51036_, p_51037_); ++ return super.updateShape(p_51032_, p_51033_, p_51034_, p_51035_, p_51036_, p_51037_); + // CraftBukkit end } - public boolean m_7898_(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { - BlockPos blockpos = p_51030_.m_7495_(); -+ if (p_51028_.m_60734_() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. -+ return p_51029_.m_8055_(blockpos).canSustainPlant(p_51029_, blockpos, Direction.UP, this); - return this.m_6266_(p_51029_.m_8055_(blockpos), p_51029_, blockpos); + public boolean canSurvive(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { + BlockPos blockpos = p_51030_.below(); ++ if (p_51028_.getBlock() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. ++ return p_51029_.getBlockState(blockpos).canSustainPlant(p_51029_, blockpos, Direction.UP, this); + return this.mayPlaceOn(p_51029_.getBlockState(blockpos), p_51029_, blockpos); } @@ -34,5 +_,12 @@ - public boolean m_7357_(BlockState p_51023_, BlockGetter p_51024_, BlockPos p_51025_, PathComputationType p_51026_) { - return p_51026_ == PathComputationType.AIR && !this.f_60443_ ? true : super.m_7357_(p_51023_, p_51024_, p_51025_, p_51026_); + public boolean isPathfindable(BlockState p_51023_, BlockGetter p_51024_, BlockPos p_51025_, PathComputationType p_51026_) { + return p_51026_ == PathComputationType.AIR && !this.hasCollision ? true : super.isPathfindable(p_51023_, p_51024_, p_51025_, p_51026_); + } + + @Override + public BlockState getPlant(BlockGetter world, BlockPos pos) { -+ BlockState state = world.m_8055_(pos); -+ if (state.m_60734_() != this) return m_49966_(); ++ BlockState state = world.getBlockState(pos); ++ if (state.getBlock() != this) return defaultBlockState(); + return state; } } diff --git a/patches/minecraft/net/minecraft/world/level/block/ButtonBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ButtonBlock.java.patch index 4c64acd1..f8cc452a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ButtonBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ButtonBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/ButtonBlock.java +++ b/net/minecraft/world/level/block/ButtonBlock.java @@ -97,6 +_,19 @@ - if (p_51088_.m_61143_(f_51045_)) { + if (p_51088_.getValue(POWERED)) { return InteractionResult.CONSUME; } else { + // CraftBukkit start -+ boolean powered = ((Boolean) p_51088_.m_61143_(f_51045_)); -+ org.bukkit.block.Block block = p_51089_.getWorld().getBlockAt(p_51090_.m_123341_(), p_51090_.m_123342_(), p_51090_.m_123343_()); ++ boolean powered = ((Boolean) p_51088_.getValue(POWERED)); ++ org.bukkit.block.Block block = p_51089_.getWorld().getBlockAt(p_51090_.getX(), p_51090_.getY(), p_51090_.getZ()); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -17,15 +17,15 @@ + return InteractionResult.SUCCESS; + } + // CraftBukkit end - this.m_51116_(p_51088_, p_51089_, p_51090_); - this.m_51067_(p_51091_, p_51089_, p_51090_, true); - p_51089_.m_142346_(p_51091_, GameEvent.f_157798_, p_51090_); + this.press(p_51088_, p_51089_, p_51090_); + this.playSound(p_51091_, p_51089_, p_51090_, true); + p_51089_.gameEvent(p_51091_, GameEvent.BLOCK_PRESS, p_51090_); @@ -143,6 +_,16 @@ - if (this.f_51062_) { - this.m_51120_(p_51073_, p_51074_, p_51075_); + if (this.sensitive) { + this.checkPressed(p_51073_, p_51074_, p_51075_); } else { + // CraftBukkit start -+ org.bukkit.block.Block block = p_51074_.getWorld().getBlockAt(p_51075_.m_123341_(), p_51075_.m_123342_(), p_51075_.m_123343_()); ++ org.bukkit.block.Block block = p_51074_.getWorld().getBlockAt(p_51075_.getX(), p_51075_.getY(), p_51075_.getZ()); + + org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(block, 15, 0); + p_51074_.getCraftServer().getPluginManager().callEvent(eventRedstone); @@ -34,17 +34,17 @@ + return; + } + // CraftBukkit end - p_51074_.m_7731_(p_51075_, p_51073_.m_61124_(f_51045_, Boolean.valueOf(false)), 3); - this.m_51124_(p_51073_, p_51074_, p_51075_); - this.m_51067_((Player)null, p_51074_, p_51075_, false); + p_51074_.setBlock(p_51075_, p_51073_.setValue(POWERED, Boolean.valueOf(false)), 3); + this.updateNeighbours(p_51073_, p_51074_, p_51075_); + this.playSound((Player)null, p_51074_, p_51075_, false); @@ -162,7 +_,42 @@ - List list = p_51122_.m_45976_(AbstractArrow.class, p_51121_.m_60808_(p_51122_, p_51123_).m_83215_().m_82338_(p_51123_)); + List list = p_51122_.getEntitiesOfClass(AbstractArrow.class, p_51121_.getShape(p_51122_, p_51123_).bounds().move(p_51123_)); boolean flag = !list.isEmpty(); - boolean flag1 = p_51121_.m_61143_(f_51045_); + boolean flag1 = p_51121_.getValue(POWERED); + + // CraftBukkit start - Call interact event when arrows turn on wooden buttons + if (flag1 != flag && flag) { -+ org.bukkit.block.Block block = p_51122_.getWorld().getBlockAt(p_51123_.m_123341_(), p_51123_.m_123342_(), p_51123_.m_123343_()); ++ org.bukkit.block.Block block = p_51122_.getWorld().getBlockAt(p_51123_.getX(), p_51123_.getY(), p_51123_.getZ()); + boolean allowed = false; + // If all of the events are cancelled block the button press, else allow + for (Object object : list) { @@ -66,7 +66,7 @@ if (flag != flag1) { + // CraftBukkit start + boolean powered = flag1; -+ org.bukkit.block.Block block = p_51122_.getWorld().getBlockAt(p_51123_.m_123341_(), p_51123_.m_123342_(), p_51123_.m_123343_()); ++ org.bukkit.block.Block block = p_51122_.getWorld().getBlockAt(p_51123_.getX(), p_51123_.getY(), p_51123_.getZ()); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -77,6 +77,6 @@ + return; + } + // CraftBukkit end - p_51122_.m_7731_(p_51123_, p_51121_.m_61124_(f_51045_, Boolean.valueOf(flag)), 3); - this.m_51124_(p_51121_, p_51122_, p_51123_); - this.m_51067_((Player)null, p_51122_, p_51123_, flag); + p_51122_.setBlock(p_51123_, p_51121_.setValue(POWERED, Boolean.valueOf(flag)), 3); + this.updateNeighbours(p_51121_, p_51122_, p_51123_); + this.playSound((Player)null, p_51122_, p_51123_, flag); 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 9f9b406b..10db35ed 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch @@ -6,35 +6,35 @@ -public class CactusBlock extends Block { +public class CactusBlock extends Block implements net.minecraftforge.common.IPlantable { - public static final IntegerProperty f_51131_ = BlockStateProperties.f_61410_; - public static final int f_152740_ = 15; - protected static final int f_152741_ = 1; + public static final IntegerProperty AGE = BlockStateProperties.AGE_15; + public static final int MAX_AGE = 15; + protected static final int AABB_OFFSET = 1; @@ -34,6 +_,7 @@ } - public void m_7458_(BlockState p_51138_, ServerLevel p_51139_, BlockPos p_51140_, Random p_51141_) { + public void tick(BlockState p_51138_, ServerLevel p_51139_, BlockPos p_51140_, Random p_51141_) { + if (!p_51139_.isAreaLoaded(p_51140_, 1)) return; // Forge: prevent growing cactus from loading unloaded chunks with block update - if (!p_51138_.m_60710_(p_51139_, p_51140_)) { - p_51139_.m_46961_(p_51140_, true); + if (!p_51138_.canSurvive(p_51139_, p_51140_)) { + p_51139_.destroyBlock(p_51140_, true); } @@ -49,15 +_,20 @@ if (i < 3) { - int j = p_51166_.m_61143_(f_51131_); + int j = p_51166_.getValue(AGE); - if (j == 15) { -- p_51167_.m_46597_(blockpos, this.m_49966_()); +- p_51167_.setBlockAndUpdate(blockpos, this.defaultBlockState()); + if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51167_, blockpos, p_51166_, true)) { + if (j >= (byte) range(3, ((100.0F / p_51167_.spigotConfig.cactusModifier) * 15) + 0.5F, 15)) { // Spigot -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51167_, blockpos, this.m_49966_()); // CraftBukkit - BlockState blockstate = p_51166_.m_61124_(f_51131_, Integer.valueOf(0)); - p_51167_.m_7731_(p_51168_, blockstate, 4); -- blockstate.m_60690_(p_51167_, blockpos, this, p_51168_, false); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51167_, blockpos, this.defaultBlockState()); // CraftBukkit + BlockState blockstate = p_51166_.setValue(AGE, Integer.valueOf(0)); + p_51167_.setBlock(p_51168_, blockstate, 4); +- blockstate.neighborChanged(p_51167_, blockpos, this, p_51168_, false); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) + p_51167_.neighborChanged(blockstate, blockpos, this, p_51168_, false); + else -+ blockstate.m_60690_(p_51167_, blockpos, this, p_51168_, false); ++ blockstate.neighborChanged(p_51167_, blockpos, this, p_51168_, false); } else { - p_51167_.m_7731_(p_51168_, p_51166_.m_61124_(f_51131_, Integer.valueOf(j + 1)), 4); + p_51167_.setBlock(p_51168_, p_51166_.setValue(AGE, Integer.valueOf(j + 1)), 4); } - + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_51167_, p_51168_, p_51166_); @@ -45,21 +45,21 @@ @@ -88,11 +_,13 @@ } - BlockState blockstate1 = p_51154_.m_8055_(p_51155_.m_7495_()); -- return (blockstate1.m_60713_(Blocks.f_50128_) || blockstate1.m_60713_(Blocks.f_49992_) || blockstate1.m_60713_(Blocks.f_49993_)) && !p_51154_.m_8055_(p_51155_.m_7494_()).m_60767_().m_76332_(); -+ return blockstate1.canSustainPlant(p_51154_, p_51155_, Direction.UP, this) && !p_51154_.m_8055_(p_51155_.m_7494_()).m_60767_().m_76332_(); + BlockState blockstate1 = p_51154_.getBlockState(p_51155_.below()); +- return (blockstate1.is(Blocks.CACTUS) || blockstate1.is(Blocks.SAND) || blockstate1.is(Blocks.RED_SAND)) && !p_51154_.getBlockState(p_51155_.above()).getMaterial().isLiquid(); ++ return blockstate1.canSustainPlant(p_51154_, p_51155_, Direction.UP, this) && !p_51154_.getBlockState(p_51155_.above()).getMaterial().isLiquid(); } - public void m_7892_(BlockState p_51148_, Level p_51149_, BlockPos p_51150_, Entity p_51151_) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = p_51149_.getWorld().getBlockAt(p_51150_.m_123341_(), p_51150_.m_123342_(), p_51150_.m_123343_()); // CraftBukkit - p_51151_.m_6469_(DamageSource.f_19314_, 1.0F); + public void entityInside(BlockState p_51148_, Level p_51149_, BlockPos p_51150_, Entity p_51151_) { ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = p_51149_.getWorld().getBlockAt(p_51150_.getX(), p_51150_.getY(), p_51150_.getZ()); // CraftBukkit + p_51151_.hurt(DamageSource.CACTUS, 1.0F); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; // CraftBukkit } - protected void m_7926_(StateDefinition.Builder p_51164_) { + protected void createBlockStateDefinition(StateDefinition.Builder p_51164_) { @@ -101,5 +_,15 @@ - public boolean m_7357_(BlockState p_51143_, BlockGetter p_51144_, BlockPos p_51145_, PathComputationType p_51146_) { + public boolean isPathfindable(BlockState p_51143_, BlockGetter p_51144_, BlockPos p_51145_, PathComputationType p_51146_) { return false; + } + @@ -70,6 +70,6 @@ + + @Override + public BlockState getPlant(BlockGetter world, BlockPos pos) { -+ return m_49966_(); ++ return defaultBlockState(); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/CakeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CakeBlock.java.patch index 942639bc..bb7209f8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CakeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CakeBlock.java.patch @@ -3,16 +3,16 @@ @@ -79,7 +_,14 @@ return InteractionResult.PASS; } else { - p_51189_.m_36220_(Stats.f_12942_); -- p_51189_.m_36324_().m_38707_(2, 0.1F); + p_51189_.awardStat(Stats.EAT_CAKE_SLICE); +- p_51189_.getFoodData().eat(2, 0.1F); + // CraftBukkit start -+ int oldFoodLevel = p_51189_.m_36324_().f_38696_; ++ int oldFoodLevel = p_51189_.getFoodData().foodLevel; + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFoodLevelChangeEvent(p_51189_, 2 + oldFoodLevel); + if (!event.isCancelled()) { -+ p_51189_.m_36324_().m_38707_(event.getFoodLevel() - oldFoodLevel, 0.1F); ++ p_51189_.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F); + } + ((net.minecraft.server.level.ServerPlayer) p_51189_).getBukkitEntity().sendHealthUpdate(); + // CraftBukkit end - int i = p_51188_.m_61143_(f_51180_); - p_51186_.m_142346_(p_51189_, GameEvent.f_157806_, p_51187_); + int i = p_51188_.getValue(BITES); + p_51186_.gameEvent(p_51189_, GameEvent.EAT, p_51187_); if (i < 6) { 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 3c68746c..e2954177 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -2,32 +2,32 @@ +++ b/net/minecraft/world/level/block/CampfireBlock.java @@ -85,7 +_,9 @@ - public void m_7892_(BlockState p_51269_, Level p_51270_, BlockPos p_51271_, Entity p_51272_) { - if (!p_51272_.m_5825_() && p_51269_.m_61143_(f_51227_) && p_51272_ instanceof LivingEntity && !EnchantmentHelper.m_44938_((LivingEntity)p_51272_)) { + public void entityInside(BlockState p_51269_, Level p_51270_, BlockPos p_51271_, Entity p_51272_) { + if (!p_51272_.fireImmune() && p_51269_.getValue(LIT) && p_51272_ instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)p_51272_)) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_51270_, p_51271_); // CraftBukkit - p_51272_.m_6469_(DamageSource.f_19305_, (float)this.f_51233_); + p_51272_.hurt(DamageSource.IN_FIRE, (float)this.fireDamage); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; // CraftBukkit } - super.m_7892_(p_51269_, p_51270_, p_51271_, p_51272_); + super.entityInside(p_51269_, p_51270_, p_51271_, p_51272_); @@ -182,6 +_,11 @@ - public void m_5581_(Level p_51244_, BlockState p_51245_, BlockHitResult p_51246_, Projectile p_51247_) { - BlockPos blockpos = p_51246_.m_82425_(); - if (!p_51244_.f_46443_ && p_51247_.m_6060_() && p_51247_.m_142265_(p_51244_, blockpos) && !p_51245_.m_61143_(f_51227_) && !p_51245_.m_61143_(f_51229_)) { + public void onProjectileHit(Level p_51244_, BlockState p_51245_, BlockHitResult p_51246_, Projectile p_51247_) { + BlockPos blockpos = p_51246_.getBlockPos(); + if (!p_51244_.isClientSide && p_51247_.isOnFire() && p_51247_.mayInteract(p_51244_, blockpos) && !p_51245_.getValue(LIT) && !p_51245_.getValue(WATERLOGGED)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(p_51244_, blockpos, p_51247_).isCancelled()) { + return; + } + // CraftBukkit end - p_51244_.m_7731_(blockpos, p_51245_.m_61124_(BlockStateProperties.f_61443_, Boolean.valueOf(true)), 11); + p_51244_.setBlock(blockpos, p_51245_.setValue(BlockStateProperties.LIT, Boolean.valueOf(true)), 11); } @@ -205,7 +_,7 @@ return true; } -- boolean flag = Shapes.m_83157_(f_51231_, blockstate.m_60742_(p_51249_, p_51250_, CollisionContext.m_82749_()), BooleanOp.f_82689_); -+ boolean flag = Shapes.m_83157_(f_51231_, blockstate.m_60742_(p_51249_, blockpos, CollisionContext.m_82749_()), BooleanOp.f_82689_);//Forge fix: MC-201374 +- boolean flag = Shapes.joinIsNotEmpty(VIRTUAL_FENCE_POST, blockstate.getCollisionShape(p_51249_, p_51250_, CollisionContext.empty()), BooleanOp.AND); ++ boolean flag = Shapes.joinIsNotEmpty(VIRTUAL_FENCE_POST, blockstate.getCollisionShape(p_51249_, blockpos, CollisionContext.empty()), BooleanOp.AND);//Forge fix: MC-201374 if (flag) { - BlockState blockstate1 = p_51249_.m_8055_(blockpos.m_7495_()); - return m_51319_(blockstate1); + BlockState blockstate1 = p_51249_.getBlockState(blockpos.below()); + return isLitCampfire(blockstate1); diff --git a/patches/minecraft/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch index cc7fdbb7..808396af 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch @@ -2,60 +2,60 @@ +++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java @@ -55,17 +_,28 @@ - private void m_51378_(Level p_51379_, BlockPos p_51380_) { - BlockPattern.BlockPatternMatch blockpattern$blockpatternmatch = this.m_51393_().m_61184_(p_51379_, p_51380_); + private void trySpawnGolem(Level p_51379_, BlockPos p_51380_) { + BlockPattern.BlockPatternMatch blockpattern$blockpatternmatch = this.getOrCreateSnowGolemFull().find(p_51379_, p_51380_); + org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator(p_51379_); // CraftBukkit - Use BlockStateListPopulator if (blockpattern$blockpatternmatch != null) { - for(int i = 0; i < this.m_51393_().m_61202_(); ++i) { - BlockInWorld blockinworld = blockpattern$blockpatternmatch.m_61229_(0, i, 0); -- p_51379_.m_7731_(blockinworld.m_61176_(), Blocks.f_50016_.m_49966_(), 2); -- p_51379_.m_46796_(2001, blockinworld.m_61176_(), Block.m_49956_(blockinworld.m_61168_())); -+ blockList.m_7731_(blockinworld.m_61176_(), Blocks.f_50016_.m_49966_(), 2); // CraftBukkit + for(int i = 0; i < this.getOrCreateSnowGolemFull().getHeight(); ++i) { + BlockInWorld blockinworld = blockpattern$blockpatternmatch.getBlock(0, i, 0); +- p_51379_.setBlock(blockinworld.getPos(), Blocks.AIR.defaultBlockState(), 2); +- p_51379_.levelEvent(2001, blockinworld.getPos(), Block.getId(blockinworld.getState())); ++ blockList.setBlock(blockinworld.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit + //p_51379_.levelEvent(2001, blockinworld.getPos(), Block.getId(blockinworld.getState())); } - SnowGolem snowgolem = EntityType.f_20528_.m_20615_(p_51379_); - BlockPos blockpos1 = blockpattern$blockpatternmatch.m_61229_(0, 2, 0).m_61176_(); - snowgolem.m_7678_((double)blockpos1.m_123341_() + 0.5D, (double)blockpos1.m_123342_() + 0.05D, (double)blockpos1.m_123343_() + 0.5D, 0.0F, 0.0F); -- p_51379_.m_7967_(snowgolem); + SnowGolem snowgolem = EntityType.SNOW_GOLEM.create(p_51379_); + BlockPos blockpos1 = blockpattern$blockpatternmatch.getBlock(0, 2, 0).getPos(); + snowgolem.moveTo((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.05D, (double)blockpos1.getZ() + 0.5D, 0.0F, 0.0F); +- p_51379_.addFreshEntity(snowgolem); + + // CraftBukkit start + p_51379_.prepareEntity(snowgolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_SNOWMAN); -+ if (!p_51379_.m_7967_(snowgolem)) { ++ if (!p_51379_.addFreshEntity(snowgolem)) { + return; + } + for (BlockPos pos : blockList.getBlocks()) { -+ p_51379_.m_46796_(2001, pos, Block.m_49956_(p_51379_.m_8055_(pos))); ++ p_51379_.levelEvent(2001, pos, Block.getId(p_51379_.getBlockState(pos))); + } + blockList.updateList(); + // CraftBukkit end - for(ServerPlayer serverplayer : p_51379_.m_45976_(ServerPlayer.class, snowgolem.m_142469_().m_82400_(5.0D))) { - CriteriaTriggers.f_10580_.m_68256_(serverplayer, snowgolem); + for(ServerPlayer serverplayer : p_51379_.getEntitiesOfClass(ServerPlayer.class, snowgolem.getBoundingBox().inflate(5.0D))) { + CriteriaTriggers.SUMMONED_ENTITY.trigger(serverplayer, snowgolem); @@ -81,8 +_,8 @@ - for(int j = 0; j < this.m_51397_().m_61203_(); ++j) { - for(int k = 0; k < this.m_51397_().m_61202_(); ++k) { - BlockInWorld blockinworld2 = blockpattern$blockpatternmatch.m_61229_(j, k, 0); -- p_51379_.m_7731_(blockinworld2.m_61176_(), Blocks.f_50016_.m_49966_(), 2); -- p_51379_.m_46796_(2001, blockinworld2.m_61176_(), Block.m_49956_(blockinworld2.m_61168_())); -+ blockList.m_7731_(blockinworld2.m_61176_(), Blocks.f_50016_.m_49966_(), 2); // CraftBukkit + for(int j = 0; j < this.getOrCreateIronGolemFull().getWidth(); ++j) { + for(int k = 0; k < this.getOrCreateIronGolemFull().getHeight(); ++k) { + BlockInWorld blockinworld2 = blockpattern$blockpatternmatch.getBlock(j, k, 0); +- p_51379_.setBlock(blockinworld2.getPos(), Blocks.AIR.defaultBlockState(), 2); +- p_51379_.levelEvent(2001, blockinworld2.getPos(), Block.getId(blockinworld2.getState())); ++ blockList.setBlock(blockinworld2.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit + //p_51379_.levelEvent(2001, blockinworld2.getPos(), Block.getId(blockinworld2.getState())); } } @@ -90,7 +_,14 @@ - IronGolem irongolem = EntityType.f_20460_.m_20615_(p_51379_); - irongolem.m_28887_(true); - irongolem.m_7678_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.05D, (double)blockpos.m_123343_() + 0.5D, 0.0F, 0.0F); -- p_51379_.m_7967_(irongolem); + IronGolem irongolem = EntityType.IRON_GOLEM.create(p_51379_); + irongolem.setPlayerCreated(true); + irongolem.moveTo((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.05D, (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F); +- p_51379_.addFreshEntity(irongolem); + // CraftBukkit start + p_51379_.prepareEntity(irongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_IRONGOLEM); //Magma - add spawn reason -+ if (!p_51379_.m_7967_(irongolem)) { ++ if (!p_51379_.addFreshEntity(irongolem)) { + return; + } -+ blockList.getBlocks().forEach(pos -> p_51379_.m_46796_(2001, pos, Block.m_49956_(p_51379_.m_8055_(pos)))); ++ blockList.getBlocks().forEach(pos -> p_51379_.levelEvent(2001, pos, Block.getId(p_51379_.getBlockState(pos)))); + blockList.updateList(); + // CraftBukkit end - for(ServerPlayer serverplayer1 : p_51379_.m_45976_(ServerPlayer.class, irongolem.m_142469_().m_82400_(5.0D))) { - CriteriaTriggers.f_10580_.m_68256_(serverplayer1, irongolem); + for(ServerPlayer serverplayer1 : p_51379_.getEntitiesOfClass(ServerPlayer.class, irongolem.getBoundingBox().inflate(5.0D))) { + CriteriaTriggers.SUMMONED_ENTITY.trigger(serverplayer1, irongolem); diff --git a/patches/minecraft/net/minecraft/world/level/block/CauldronBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CauldronBlock.java.patch index 0b7f2538..8e8cc413 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CauldronBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CauldronBlock.java.patch @@ -2,15 +2,15 @@ +++ b/net/minecraft/world/level/block/CauldronBlock.java @@ -52,11 +_,11 @@ - protected void m_142310_(BlockState p_152940_, Level p_152941_, BlockPos p_152942_, Fluid p_152943_) { - if (p_152943_ == Fluids.f_76193_) { -- p_152941_.m_46597_(p_152942_, Blocks.f_152476_.m_49966_()); -+ LayeredCauldronBlock.changeLevel(p_152940_, p_152941_, p_152942_, Blocks.f_152476_.m_49966_(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit - p_152941_.m_46796_(1047, p_152942_, 0); - p_152941_.m_142346_((Entity)null, GameEvent.f_157769_, p_152942_); - } else if (p_152943_ == Fluids.f_76195_) { -- p_152941_.m_46597_(p_152942_, Blocks.f_152477_.m_49966_()); -+ LayeredCauldronBlock.changeLevel(p_152940_, p_152941_, p_152942_, Blocks.f_152477_.m_49966_(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit - p_152941_.m_46796_(1046, p_152942_, 0); - p_152941_.m_142346_((Entity)null, GameEvent.f_157769_, p_152942_); + protected void receiveStalactiteDrip(BlockState p_152940_, Level p_152941_, BlockPos p_152942_, Fluid p_152943_) { + if (p_152943_ == Fluids.WATER) { +- p_152941_.setBlockAndUpdate(p_152942_, Blocks.WATER_CAULDRON.defaultBlockState()); ++ LayeredCauldronBlock.changeLevel(p_152940_, p_152941_, p_152942_, Blocks.WATER_CAULDRON.defaultBlockState(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + p_152941_.levelEvent(1047, p_152942_, 0); + p_152941_.gameEvent((Entity)null, GameEvent.FLUID_PLACE, p_152942_); + } else if (p_152943_ == Fluids.LAVA) { +- p_152941_.setBlockAndUpdate(p_152942_, Blocks.LAVA_CAULDRON.defaultBlockState()); ++ LayeredCauldronBlock.changeLevel(p_152940_, p_152941_, p_152942_, Blocks.LAVA_CAULDRON.defaultBlockState(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + p_152941_.levelEvent(1046, p_152942_, 0); + p_152941_.gameEvent((Entity)null, GameEvent.FLUID_PLACE, p_152942_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CaveVines.java.patch b/patches/minecraft/net/minecraft/world/level/block/CaveVines.java.patch index 5d41cb95..0400d558 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CaveVines.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CaveVines.java.patch @@ -1,34 +1,34 @@ --- a/net/minecraft/world/level/block/CaveVines.java +++ b/net/minecraft/world/level/block/CaveVines.java @@ -20,11 +_,29 @@ - BooleanProperty f_152949_ = BlockStateProperties.f_155977_; + BooleanProperty BERRIES = BlockStateProperties.BERRIES; - static InteractionResult m_152953_(BlockState p_152954_, Level p_152955_, BlockPos p_152956_) { + static InteractionResult use(BlockState p_152954_, Level p_152955_, BlockPos p_152956_) { + net.minecraft.world.entity.Entity entity = org.magmafoundation.magma.helpers.InterfaceHelper.tempNMSEntity.getAndSet(null); - if (p_152954_.m_61143_(f_152949_)) { -- Block.m_49840_(p_152955_, p_152956_, new ItemStack(Items.f_151079_, 1)); + if (p_152954_.getValue(BERRIES)) { +- Block.popResource(p_152955_, p_152956_, new ItemStack(Items.GLOW_BERRIES, 1)); + // CraftBukkit start + //Magma - add null check -+ if (entity != null && org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_152956_, (BlockState) p_152954_.m_61124_(CaveVines.f_152949_, false)).isCancelled()) { ++ if (entity != null && org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_152956_, (BlockState) p_152954_.setValue(CaveVines.BERRIES, false)).isCancelled()) { + return InteractionResult.SUCCESS; + } + + if (entity instanceof Player) { -+ org.bukkit.event.player.PlayerHarvestBlockEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerHarvestBlockEvent(p_152955_, p_152956_, (Player) entity, java.util.Collections.singletonList(new ItemStack(Items.f_151079_, 1))); ++ org.bukkit.event.player.PlayerHarvestBlockEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerHarvestBlockEvent(p_152955_, p_152956_, (Player) entity, java.util.Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1))); + if (event.isCancelled()) { + return InteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block + } + for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) { -+ Block.m_49840_(p_152955_, p_152956_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(itemStack)); ++ Block.popResource(p_152955_, p_152956_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(itemStack)); + } + } else { -+ Block.m_49840_(p_152955_, p_152956_, new ItemStack(Items.f_151079_, 1)); ++ Block.popResource(p_152955_, p_152956_, new ItemStack(Items.GLOW_BERRIES, 1)); + } + // CraftBukkit end - float f = Mth.m_144924_(p_152955_.f_46441_, 0.8F, 1.2F); - p_152955_.m_5594_((Player)null, p_152956_, SoundEvents.f_144088_, SoundSource.BLOCKS, 1.0F, f); -- p_152955_.m_7731_(p_152956_, p_152954_.m_61124_(f_152949_, Boolean.valueOf(false)), 2); -+ p_152955_.m_7731_(p_152956_, p_152954_.m_61124_(f_152949_, false), 2); - return InteractionResult.m_19078_(p_152955_.f_46443_); + float f = Mth.randomBetween(p_152955_.random, 0.8F, 1.2F); + p_152955_.playSound((Player)null, p_152956_, SoundEvents.CAVE_VINES_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, f); +- p_152955_.setBlock(p_152956_, p_152954_.setValue(BERRIES, Boolean.valueOf(false)), 2); ++ p_152955_.setBlock(p_152956_, p_152954_.setValue(BERRIES, false), 2); + return InteractionResult.sidedSuccess(p_152955_.isClientSide); } else { return InteractionResult.PASS; diff --git a/patches/minecraft/net/minecraft/world/level/block/CaveVinesBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CaveVinesBlock.java.patch index 0408cdd2..bf1df6a1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CaveVinesBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CaveVinesBlock.java.patch @@ -3,8 +3,8 @@ @@ -49,6 +_,7 @@ } - public InteractionResult m_6227_(BlockState p_152980_, Level p_152981_, BlockPos p_152982_, Player p_152983_, InteractionHand p_152984_, BlockHitResult p_152985_) { + public InteractionResult use(BlockState p_152980_, Level p_152981_, BlockPos p_152982_, Player p_152983_, InteractionHand p_152984_, BlockHitResult p_152985_) { + org.magmafoundation.magma.helpers.InterfaceHelper.tempNMSEntity.set(p_152983_); //Magma - set the entity to be used by the event - return CaveVines.m_152953_(p_152980_, p_152981_, p_152982_); + return CaveVines.use(p_152980_, p_152981_, p_152982_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CaveVinesPlantBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CaveVinesPlantBlock.java.patch index 051da804..c8e83bdd 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CaveVinesPlantBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CaveVinesPlantBlock.java.patch @@ -3,8 +3,8 @@ @@ -35,6 +_,7 @@ } - public InteractionResult m_6227_(BlockState p_153021_, Level p_153022_, BlockPos p_153023_, Player p_153024_, InteractionHand p_153025_, BlockHitResult p_153026_) { + public InteractionResult use(BlockState p_153021_, Level p_153022_, BlockPos p_153023_, Player p_153024_, InteractionHand p_153025_, BlockHitResult p_153026_) { + org.magmafoundation.magma.helpers.InterfaceHelper.tempNMSEntity.set(p_153024_); //Magma - set the entity to be used by the event - return CaveVines.m_152953_(p_153021_, p_153022_, p_153023_); + return CaveVines.use(p_153021_, p_153022_, p_153023_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch index 65fd8682..374b7505 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/ChangeOverTimeBlock.java +++ b/net/minecraft/world/level/block/ChangeOverTimeBlock.java @@ -59,7 +_,7 @@ - float f1 = f * f * this.m_142377_(); + float f1 = f * f * this.getChanceModifier(); if (p_153050_.nextFloat() < f1) { - this.m_142123_(p_153047_).ifPresent((p_153039_) -> { -- p_153048_.m_46597_(p_153049_, p_153039_); + this.getNext(p_153047_).ifPresent((p_153039_) -> { +- p_153048_.setBlockAndUpdate(p_153049_, p_153039_); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_153048_, p_153049_, p_153039_); }); } 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 fb1ddf26..12fc8aab 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch @@ -2,26 +2,26 @@ +++ b/net/minecraft/world/level/block/ChestBlock.java @@ -81,27 +_,8 @@ }; - private static final DoubleBlockCombiner.Combiner> f_51487_ = new DoubleBlockCombiner.Combiner>() { - public Optional m_6959_(final ChestBlockEntity p_51604_, final ChestBlockEntity p_51605_) { + private static final DoubleBlockCombiner.Combiner> MENU_PROVIDER_COMBINER = new DoubleBlockCombiner.Combiner>() { + public Optional acceptDouble(final ChestBlockEntity p_51604_, final ChestBlockEntity p_51605_) { - final Container container = new CompoundContainer(p_51604_, p_51605_); - return Optional.of(new MenuProvider() { - @Nullable -- public AbstractContainerMenu m_7208_(int p_51622_, Inventory p_51623_, Player p_51624_) { -- if (p_51604_.m_7525_(p_51624_) && p_51605_.m_7525_(p_51624_)) { -- p_51604_.m_59640_(p_51623_.f_35978_); -- p_51605_.m_59640_(p_51623_.f_35978_); -- return ChestMenu.m_39246_(p_51622_, p_51623_, container); +- public AbstractContainerMenu createMenu(int p_51622_, Inventory p_51623_, Player p_51624_) { +- if (p_51604_.canOpen(p_51624_) && p_51605_.canOpen(p_51624_)) { +- p_51604_.unpackLootTable(p_51623_.player); +- p_51605_.unpackLootTable(p_51623_.player); +- return ChestMenu.sixRows(p_51622_, p_51623_, container); - } else { - return null; - } - } - -- public Component m_5446_() { -- if (p_51604_.m_8077_()) { -- return p_51604_.m_5446_(); +- public Component getDisplayName() { +- if (p_51604_.hasCustomName()) { +- return p_51604_.getDisplayName(); - } else { -- return (Component)(p_51605_.m_8077_() ? p_51605_.m_5446_() : new TranslatableComponent("container.chestDouble")); +- return (Component)(p_51605_.hasCustomName() ? p_51605_.getDisplayName() : new TranslatableComponent("container.chestDouble")); - } - } - }); @@ -29,7 +29,7 @@ + return Optional.of(new DoubleInventory(p_51604_, p_51605_, container)); // CraftBukkit } - public Optional m_7693_(ChestBlockEntity p_51602_) { + public Optional acceptSingle(ChestBlockEntity p_51602_) { @@ -113,6 +_,37 @@ } }; @@ -48,48 +48,48 @@ + + @Nullable + @Override -+ public AbstractContainerMenu m_7208_(int i, Inventory playerinventory, Player entityhuman) { -+ if (tileentitychest.m_7525_(entityhuman) && tileentitychest1.m_7525_(entityhuman)) { -+ tileentitychest.m_59640_(playerinventory.f_35978_); -+ tileentitychest1.m_59640_(playerinventory.f_35978_); -+ return ChestMenu.m_39246_(i, playerinventory, inventorylargechest); ++ public AbstractContainerMenu createMenu(int i, Inventory playerinventory, Player entityhuman) { ++ if (tileentitychest.canOpen(entityhuman) && tileentitychest1.canOpen(entityhuman)) { ++ tileentitychest.unpackLootTable(playerinventory.player); ++ tileentitychest1.unpackLootTable(playerinventory.player); ++ return ChestMenu.sixRows(i, playerinventory, inventorylargechest); + } else { + return null; + } + } + + @Override -+ public Component m_5446_() { -+ return (Component) (tileentitychest.m_8077_() ? tileentitychest.m_5446_() : (tileentitychest1.m_8077_() ? tileentitychest1.m_5446_() : new TranslatableComponent("container.chestDouble"))); ++ public Component getDisplayName() { ++ return (Component) (tileentitychest.hasCustomName() ? tileentitychest.getDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getDisplayName() : new TranslatableComponent("container.chestDouble"))); + } + }; + // CraftBukkit end + public ChestBlock(BlockBehaviour.Properties p_51490_, Supplier> p_51491_) { super(p_51490_, p_51491_); - this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_51478_, Direction.NORTH).m_61124_(f_51479_, ChestType.SINGLE).m_61124_(f_51480_, Boolean.valueOf(false))); + this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(TYPE, ChestType.SINGLE).setValue(WATERLOGGED, Boolean.valueOf(false))); @@ -271,7 +_,13 @@ @Nullable - public MenuProvider m_7246_(BlockState p_51574_, Level p_51575_, BlockPos p_51576_) { -- return this.m_5641_(p_51574_, p_51575_, p_51576_, false).>m_5649_(f_51487_).orElse((MenuProvider)null); + public MenuProvider getMenuProvider(BlockState p_51574_, Level p_51575_, BlockPos p_51576_) { +- return this.combine(p_51574_, p_51575_, p_51576_, false).>apply(MENU_PROVIDER_COMBINER).orElse((MenuProvider)null); + // CraftBukkit start + return getMenuProvider(p_51574_, p_51575_, p_51576_, false); + } + @Nullable + public MenuProvider getMenuProvider(BlockState blockState, Level level, BlockPos blockposition, boolean ignoreObstructions) { -+ return (MenuProvider) ((Optional) this.m_5641_(blockState, level, blockposition, ignoreObstructions).m_5649_(f_51487_)).orElse((Object) null); ++ return (MenuProvider) ((Optional) this.combine(blockState, level, blockposition, ignoreObstructions).apply(MENU_PROVIDER_COMBINER)).orElse((Object) null); + // CraftBukkit end } - public static DoubleBlockCombiner.Combiner m_51517_(final LidBlockEntity p_51518_) { + public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity p_51518_) { @@ -336,7 +_,8 @@ } - public BlockState m_6943_(BlockState p_51549_, Mirror p_51550_) { -- return p_51549_.m_60717_(p_51550_.m_54846_(p_51549_.m_61143_(f_51478_))); -+ BlockState rotated = p_51549_.m_60717_(p_51550_.m_54846_(p_51549_.m_61143_(f_51478_))); -+ return p_51550_ == Mirror.NONE ? rotated : rotated.m_61124_(f_51479_, rotated.m_61143_(f_51479_).m_61486_()); // Forge: Fixed MC-134110 Structure mirroring breaking apart double chests + public BlockState mirror(BlockState p_51549_, Mirror p_51550_) { +- return p_51549_.rotate(p_51550_.getRotation(p_51549_.getValue(FACING))); ++ BlockState rotated = p_51549_.rotate(p_51550_.getRotation(p_51549_.getValue(FACING))); ++ return p_51550_ == Mirror.NONE ? rotated : rotated.setValue(TYPE, rotated.getValue(TYPE).getOpposite()); // Forge: Fixed MC-134110 Structure mirroring breaking apart double chests } - protected void m_7926_(StateDefinition.Builder p_51562_) { + protected void createBlockStateDefinition(StateDefinition.Builder p_51562_) { 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 edaa9244..dcaab862 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java @@ -43,7 +_,7 @@ - BlockPos blockpos = p_51704_.m_7494_(); - if (p_51703_.m_46859_(blockpos) && blockpos.m_123342_() < p_51703_.m_151558_()) { - int i = p_51702_.m_61143_(f_51647_); + BlockPos blockpos = p_51704_.above(); + if (p_51703_.isEmptyBlock(blockpos) && blockpos.getY() < p_51703_.getMaxBuildHeight()) { + int i = p_51702_.getValue(AGE); - if (i < 5) { + if (i < 5 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51703_, blockpos, p_51702_, true)) { boolean flag = false; boolean flag1 = false; - BlockState blockstate = p_51703_.m_8055_(p_51704_.m_7495_()); + BlockState blockstate = p_51703_.getBlockState(p_51704_.below()); @@ -72,8 +_,13 @@ } - if (flag && m_51697_(p_51703_, blockpos, (Direction)null) && p_51703_.m_46859_(p_51704_.m_6630_(2))) { -- p_51703_.m_7731_(p_51704_, this.f_51648_.m_51710_(p_51703_, p_51704_), 2); -- this.m_51661_(p_51703_, blockpos, i); + if (flag && allNeighborsEmpty(p_51703_, blockpos, (Direction)null) && p_51703_.isEmptyBlock(p_51704_.above(2))) { +- p_51703_.setBlock(p_51704_, this.plant.getStateForPlacement(p_51703_, p_51704_), 2); +- this.placeGrownFlower(p_51703_, blockpos, i); + // CraftBukkit start - add event -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_51703_, p_51704_, blockpos, this.m_49966_().m_61124_(f_51647_, Integer.valueOf(i)), 2)) { -+ p_51703_.m_7731_(p_51704_, this.f_51648_.m_51710_(p_51703_, p_51704_), 2); -+ this.m_51661_(p_51703_, blockpos, i); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_51703_, p_51704_, blockpos, this.defaultBlockState().setValue(AGE, Integer.valueOf(i)), 2)) { ++ p_51703_.setBlock(p_51704_, this.plant.getStateForPlacement(p_51703_, p_51704_), 2); ++ this.placeGrownFlower(p_51703_, blockpos, i); + } + // CraftBukkit end + @@ -26,14 +26,14 @@ int l = p_51705_.nextInt(4); if (flag1) { @@ -86,20 +_,33 @@ - Direction direction = Direction.Plane.HORIZONTAL.m_122560_(p_51705_); - BlockPos blockpos1 = p_51704_.m_142300_(direction); - if (p_51703_.m_46859_(blockpos1) && p_51703_.m_46859_(blockpos1.m_7495_()) && m_51697_(p_51703_, blockpos1, direction.m_122424_())) { -- this.m_51661_(p_51703_, blockpos1, i + 1); + Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(p_51705_); + BlockPos blockpos1 = p_51704_.relative(direction); + if (p_51703_.isEmptyBlock(blockpos1) && p_51703_.isEmptyBlock(blockpos1.below()) && allNeighborsEmpty(p_51703_, blockpos1, direction.getOpposite())) { +- this.placeGrownFlower(p_51703_, blockpos1, i + 1); - flag2 = true; + // CraftBukkit start - add event -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_51703_, p_51704_, blockpos1, this.m_49966_().m_61124_(f_51647_, Integer.valueOf(i + 1)), 2)) { -+ this.m_51661_(p_51703_, blockpos1, i + 1); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_51703_, p_51704_, blockpos1, this.defaultBlockState().setValue(AGE, Integer.valueOf(i + 1)), 2)) { ++ this.placeGrownFlower(p_51703_, blockpos1, i + 1); + flag2 = true; + } + // CraftBukkit end @@ -41,22 +41,22 @@ } if (flag2) { - p_51703_.m_7731_(p_51704_, this.f_51648_.m_51710_(p_51703_, p_51704_), 2); + p_51703_.setBlock(p_51704_, this.plant.getStateForPlacement(p_51703_, p_51704_), 2); } else { -- this.m_51658_(p_51703_, p_51704_); +- this.placeDeadFlower(p_51703_, p_51704_); + // CraftBukkit - add event -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51703_, p_51704_, this.m_49966_().m_61124_(f_51647_, Integer.valueOf(5)), 2)) { -+ this.m_51658_(p_51703_, p_51704_); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51703_, p_51704_, this.defaultBlockState().setValue(AGE, Integer.valueOf(5)), 2)) { ++ this.placeDeadFlower(p_51703_, p_51704_); + } + // CraftBukkit end } } else { + // CraftBukkit - add event -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51703_, p_51704_, this.m_49966_().m_61124_(f_51647_, Integer.valueOf(5)), 2)) { -+ this.m_51658_(p_51703_, p_51704_); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51703_, p_51704_, this.defaultBlockState().setValue(AGE, Integer.valueOf(5)), 2)) { ++ this.placeDeadFlower(p_51703_, p_51704_); + } + // CraftBukkit end - this.m_51658_(p_51703_, p_51704_); + this.placeDeadFlower(p_51703_, p_51704_); } - + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_51703_, p_51704_, p_51702_); @@ -64,14 +64,14 @@ } } @@ -214,6 +_,11 @@ - public void m_5581_(Level p_51654_, BlockState p_51655_, BlockHitResult p_51656_, Projectile p_51657_) { - BlockPos blockpos = p_51656_.m_82425_(); - if (!p_51654_.f_46443_ && p_51657_.m_142265_(p_51654_, blockpos) && p_51657_.m_6095_().m_204039_(EntityTypeTags.f_13124_)) { + public void onProjectileHit(Level p_51654_, BlockState p_51655_, BlockHitResult p_51656_, Projectile p_51657_) { + BlockPos blockpos = p_51656_.getBlockPos(); + if (!p_51654_.isClientSide && p_51657_.mayInteract(p_51654_, blockpos) && p_51657_.getType().is(EntityTypeTags.IMPACT_PROJECTILES)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_51657_, blockpos, Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_51657_, blockpos, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - p_51654_.m_46953_(blockpos, true, p_51657_); + p_51654_.destroyBlock(blockpos, true, p_51657_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch index d0148fa5..05d4a948 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -3,14 +3,14 @@ @@ -47,10 +_,11 @@ } - public void m_7455_(BlockState p_51782_, ServerLevel p_51783_, BlockPos p_51784_, Random p_51785_) { -- if (p_51783_.f_46441_.nextInt(5) == 0) { + public void randomTick(BlockState p_51782_, ServerLevel p_51783_, BlockPos p_51784_, Random p_51785_) { +- if (p_51783_.random.nextInt(5) == 0) { + if (true) { - int i = p_51782_.m_61143_(f_51736_); + int i = p_51782_.getValue(AGE); - if (i < 2) { -- p_51783_.m_7731_(p_51784_, p_51782_.m_61124_(f_51736_, Integer.valueOf(i + 1)), 2); -+ if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51783_, p_51784_, p_51782_, p_51783_.f_46441_.nextInt(Math.max(1, (int) (100.0F / p_51783_.spigotConfig.cocoaModifier) * 5)) == 0)) { // Spigot -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51783_, p_51784_, (BlockState) p_51782_.m_61124_(f_51736_, i + 1), 2); // CraftBukkkit +- p_51783_.setBlock(p_51784_, p_51782_.setValue(AGE, Integer.valueOf(i + 1)), 2); ++ if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_51783_, p_51784_, p_51782_, p_51783_.random.nextInt(Math.max(1, (int) (100.0F / p_51783_.spigotConfig.cocoaModifier) * 5)) == 0)) { // Spigot ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51783_, p_51784_, (BlockState) p_51782_.setValue(AGE, i + 1), 2); // CraftBukkkit + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_51783_, p_51784_, p_51782_); } } @@ -18,9 +18,9 @@ @@ -107,7 +_,7 @@ } - public void m_7719_(ServerLevel p_51745_, Random p_51746_, BlockPos p_51747_, BlockState p_51748_) { -- p_51745_.m_7731_(p_51747_, p_51748_.m_61124_(f_51736_, Integer.valueOf(p_51748_.m_61143_(f_51736_) + 1)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51745_, p_51747_, (BlockState) p_51748_.m_61124_(f_51736_, (Integer) p_51748_.m_61143_(f_51736_) + 1), 2); // CraftBukkit + public void performBonemeal(ServerLevel p_51745_, Random p_51746_, BlockPos p_51747_, BlockState p_51748_) { +- p_51745_.setBlock(p_51747_, p_51748_.setValue(AGE, Integer.valueOf(p_51748_.getValue(AGE) + 1)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_51745_, p_51747_, (BlockState) p_51748_.setValue(AGE, (Integer) p_51748_.getValue(AGE) + 1), 2); // CraftBukkit } - protected void m_7926_(StateDefinition.Builder p_51778_) { + protected void createBlockStateDefinition(StateDefinition.Builder p_51778_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/CommandBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CommandBlock.java.patch index f343ed9b..54b38457 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CommandBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CommandBlock.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/level/block/CommandBlock.java @@ -52,6 +_,17 @@ CommandBlockEntity commandblockentity = (CommandBlockEntity)blockentity; - boolean flag = p_51839_.m_46753_(p_51840_); - boolean flag1 = commandblockentity.m_59142_(); + boolean flag = p_51839_.hasNeighborSignal(p_51840_); + boolean flag1 = commandblockentity.isPowered(); + + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = p_51839_.getWorld().getBlockAt(p_51840_.m_123341_(), p_51840_.m_123342_(), p_51840_.m_123343_()); ++ org.bukkit.block.Block bukkitBlock = p_51839_.getWorld().getBlockAt(p_51840_.getX(), p_51840_.getY(), p_51840_.getZ()); + int old = flag1 ? 15 : 0; + int current = flag ? 15 : 0; + @@ -15,6 +15,6 @@ + flag = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end + - commandblockentity.m_59135_(flag); - if (!flag1 && !commandblockentity.m_59143_() && commandblockentity.m_59148_() != CommandBlockEntity.Mode.SEQUENCE) { + commandblockentity.setPowered(flag); + if (!flag1 && !commandblockentity.isAutomatic() && commandblockentity.getMode() != CommandBlockEntity.Mode.SEQUENCE) { if (flag) { 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 0a14ddfc..032af77a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,39 +1,39 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java @@ -139,8 +_,18 @@ - boolean flag1 = this.m_7320_(p_51908_, p_51909_, p_51910_); - boolean flag = p_51910_.m_61143_(f_52496_); + boolean flag1 = this.shouldTurnOn(p_51908_, p_51909_, p_51910_); + boolean flag = p_51910_.getValue(POWERED); if (flag && !flag1) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_51908_, p_51909_, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - p_51908_.m_7731_(p_51909_, p_51910_.m_61124_(f_52496_, Boolean.valueOf(false)), 2); + p_51908_.setBlock(p_51909_, p_51910_.setValue(POWERED, Boolean.valueOf(false)), 2); } else if (!flag && flag1) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_51908_, p_51909_, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - p_51908_.m_7731_(p_51909_, p_51910_.m_61124_(f_52496_, Boolean.valueOf(true)), 2); + p_51908_.setBlock(p_51909_, p_51910_.setValue(POWERED, Boolean.valueOf(true)), 2); } @@ -165,5 +_,17 @@ - protected void m_7926_(StateDefinition.Builder p_51887_) { - p_51887_.m_61104_(f_54117_, f_51854_, f_52496_); + protected void createBlockStateDefinition(StateDefinition.Builder p_51887_) { + p_51887_.add(FACING, MODE, POWERED); + } + + @Override + public boolean getWeakChanges(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos) { -+ return state.m_60713_(Blocks.f_50328_); ++ return state.is(Blocks.COMPARATOR); + } + + @Override + public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, BlockPos neighbor) { -+ if (pos.m_123342_() == neighbor.m_123342_() && world instanceof Level && !((Level)world).m_5776_()) { -+ state.m_60690_((Level)world, pos, world.m_8055_(neighbor).m_60734_(), neighbor, false); ++ if (pos.getY() == neighbor.getY() && world instanceof Level && !((Level)world).isClientSide()) { ++ state.neighborChanged((Level)world, pos, world.getBlockState(neighbor).getBlock(), neighbor, false); + } } } diff --git a/patches/minecraft/net/minecraft/world/level/block/ComposterBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ComposterBlock.java.patch index 691e2d56..9781aa88 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -4,89 +4,89 @@ public ComposterBlock(BlockBehaviour.Properties p_51919_) { super(p_51919_); -- this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_51913_, Integer.valueOf(0))); -+ this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_51913_, 0)); +- this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0))); ++ this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, 0)); } - public static void m_51923_(Level p_51924_, BlockPos p_51925_, boolean p_51926_) { + public static void handleFill(Level p_51924_, BlockPos p_51925_, boolean p_51926_) { @@ -213,17 +_,24 @@ - return InteractionResult.m_19078_(p_51950_.f_46443_); + return InteractionResult.sidedSuccess(p_51950_.isClientSide); } else if (i == 8) { -- m_51998_(p_51949_, p_51950_, p_51951_); +- extractProduce(p_51949_, p_51950_, p_51951_); + extractProduce(p_51949_, p_51950_, p_51951_, (net.minecraft.world.entity.Entity) null); // CraftBukkit - no event for players - return InteractionResult.m_19078_(p_51950_.f_46443_); + return InteractionResult.sidedSuccess(p_51950_.isClientSide); } else { return InteractionResult.PASS; } } -- public static BlockState m_51929_(BlockState p_51930_, ServerLevel p_51931_, ItemStack p_51932_, BlockPos p_51933_) { +- public static BlockState insertItem(BlockState p_51930_, ServerLevel p_51931_, ItemStack p_51932_, BlockPos p_51933_) { + public static BlockState insertItem(BlockState p_51930_, ServerLevel p_51931_, ItemStack p_51932_, BlockPos p_51933_, net.minecraft.world.entity.Entity entity) { // CraftBukkit - int i = p_51930_.m_61143_(f_51913_); - if (i < 7 && f_51914_.containsKey(p_51932_.m_41720_())) { -- BlockState blockstate = m_51983_(p_51930_, p_51931_, p_51933_, p_51932_); + int i = p_51930_.getValue(LEVEL); + if (i < 7 && COMPOSTABLES.containsKey(p_51932_.getItem())) { +- BlockState blockstate = addItem(p_51930_, p_51931_, p_51933_, p_51932_); + // CraftBukkit start -+ double rand = p_51931_.m_5822_().nextDouble(); ++ double rand = p_51931_.getRandom().nextDouble(); + BlockState blockstate = addItem(p_51930_, org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, p_51933_, p_51932_, rand); + if (p_51930_ == blockstate || org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_51933_, blockstate).isCancelled()) { + return p_51930_; + } + blockstate = addItem(p_51930_, p_51931_, p_51933_, p_51932_, rand); + // CraftBukkit end - p_51932_.m_41774_(1); + p_51932_.shrink(1); return blockstate; } else { @@ -231,7 +_,16 @@ } } -- public static BlockState m_51998_(BlockState p_51999_, Level p_52000_, BlockPos p_52001_) { +- public static BlockState extractProduce(BlockState p_51999_, Level p_52000_, BlockPos p_52001_) { + + // CraftBukkit start + public static BlockState extractProduce(BlockState p_51999_, Level p_52000_, BlockPos p_52001_, net.minecraft.world.entity.Entity entity) { + if (entity != null) { -+ BlockState iblockdata1 = m_52002_(p_51999_, org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, p_52001_); ++ BlockState iblockdata1 = empty(p_51999_, org.bukkit.craftbukkit.v1_18_R2.util.DummyGeneratorAccess.INSTANCE, p_52001_); + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_52001_, iblockdata1).isCancelled()) { + return p_51999_; + } + } + // CraftBukkit end - if (!p_52000_.f_46443_) { + if (!p_52000_.isClientSide) { float f = 0.7F; - double d0 = (double)(p_52000_.f_46441_.nextFloat() * 0.7F) + (double)0.15F; + double d0 = (double)(p_52000_.random.nextFloat() * 0.7F) + (double)0.15F; @@ -248,19 +_,25 @@ } - static BlockState m_52002_(BlockState p_52003_, LevelAccessor p_52004_, BlockPos p_52005_) { -- BlockState blockstate = p_52003_.m_61124_(f_51913_, Integer.valueOf(0)); -+ BlockState blockstate = p_52003_.m_61124_(f_51913_, 0); - p_52004_.m_7731_(p_52005_, blockstate, 3); + static BlockState empty(BlockState p_52003_, LevelAccessor p_52004_, BlockPos p_52005_) { +- BlockState blockstate = p_52003_.setValue(LEVEL, Integer.valueOf(0)); ++ BlockState blockstate = p_52003_.setValue(LEVEL, 0); + p_52004_.setBlock(p_52005_, blockstate, 3); return blockstate; } - static BlockState m_51983_(BlockState p_51984_, LevelAccessor p_51985_, BlockPos p_51986_, ItemStack p_51987_) { + static BlockState addItem(BlockState p_51984_, LevelAccessor p_51985_, BlockPos p_51986_, ItemStack p_51987_) { + // CraftBukkit start -+ return addItem(p_51984_, p_51985_, p_51986_, p_51987_, p_51985_.m_5822_().nextDouble()); //Magma - replace dummy level accessor with real one ++ return addItem(p_51984_, p_51985_, p_51986_, p_51987_, p_51985_.getRandom().nextDouble()); //Magma - replace dummy level accessor with real one + } + + static BlockState addItem(BlockState p_51984_, LevelAccessor p_51985_, BlockPos p_51986_, ItemStack p_51987_, double rand) { + // CraftBukkit end - int i = p_51984_.m_61143_(f_51913_); - float f = f_51914_.getFloat(p_51987_.m_41720_()); -- if ((i != 0 || !(f > 0.0F)) && !(p_51985_.m_5822_().nextDouble() < (double)f)) { + int i = p_51984_.getValue(LEVEL); + float f = COMPOSTABLES.getFloat(p_51987_.getItem()); +- if ((i != 0 || !(f > 0.0F)) && !(p_51985_.getRandom().nextDouble() < (double)f)) { + if ((i != 0 || !(f > 0.0F)) && !(rand < (double)f)) { //Magma - revert to original code return p_51984_; } else { int j = i + 1; -- BlockState blockstate = p_51984_.m_61124_(f_51913_, Integer.valueOf(j)); -+ BlockState blockstate = p_51984_.m_61124_(f_51913_, j); - p_51985_.m_7731_(p_51986_, blockstate, 3); +- BlockState blockstate = p_51984_.setValue(LEVEL, Integer.valueOf(j)); ++ BlockState blockstate = p_51984_.setValue(LEVEL, j); + p_51985_.setBlock(p_51986_, blockstate, 3); if (j == 7) { - p_51985_.m_186460_(p_51986_, p_51984_.m_60734_(), 20); + p_51985_.scheduleTick(p_51986_, p_51984_.getBlock(), 20); @@ -299,13 +_,14 @@ if (i == 8) { - return new ComposterBlock.OutputContainer(p_51956_, p_51957_, p_51958_, new ItemStack(Items.f_42499_)); + return new ComposterBlock.OutputContainer(p_51956_, p_51957_, p_51958_, new ItemStack(Items.BONE_MEAL)); } else { - return (WorldlyContainer)(i < 7 ? new ComposterBlock.InputContainer(p_51956_, p_51957_, p_51958_) : new ComposterBlock.EmptyContainer()); + return (WorldlyContainer)(i < 7 ? new ComposterBlock.InputContainer(p_51956_, p_51957_, p_51958_) : new ComposterBlock.EmptyContainer(p_51957_, p_51958_)); @@ -100,36 +100,36 @@ + this.bukkitOwner = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlockInventoryHolder(p_52023_, p_52024_, this); // CraftBukkit } - public int[] m_7071_(Direction p_52012_) { + public int[] getSlotsForFace(Direction p_52012_) { @@ -332,6 +_,7 @@ - this.f_52017_ = p_52022_; - this.f_52018_ = p_52023_; - this.f_52019_ = p_52024_; + this.state = p_52022_; + this.level = p_52023_; + this.pos = p_52024_; + this.bukkitOwner = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlockInventoryHolder(p_52023_, p_52024_, this); // CraftBukkit } - public int m_6893_() { + public int getMaxStackSize() { @@ -373,6 +_,7 @@ - this.f_52037_ = p_52042_; - this.f_52038_ = p_52043_; - this.f_52039_ = p_52044_; + this.state = p_52042_; + this.level = p_52043_; + this.pos = p_52044_; + this.bukkitOwner = new org.bukkit.craftbukkit.v1_18_R2.inventory.CraftBlockInventoryHolder(p_52043_, p_52044_, this); // CraftBukkit } - public int m_6893_() { + public int getMaxStackSize() { @@ -392,8 +_,16 @@ } - public void m_6596_() { -- ComposterBlock.m_52002_(this.f_52037_, this.f_52038_, this.f_52039_); -- this.f_52040_ = true; + public void setChanged() { +- ComposterBlock.empty(this.state, this.level, this.pos); +- this.changed = true; + // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent) -+ if (this.m_7983_()) { -+ ComposterBlock.m_52002_(this.f_52037_, this.f_52038_, this.f_52039_); -+ this.f_52040_ = true; ++ if (this.isEmpty()) { ++ ComposterBlock.empty(this.state, this.level, this.pos); ++ this.changed = true; + } else { -+ this.f_52038_.m_7731_(this.f_52039_, this.f_52037_, 3); -+ this.f_52040_ = false; ++ this.level.setBlock(this.pos, this.state, 3); ++ this.changed = false; + } + // CraftBukkit end + 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 5e04179a..c4146d57 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ConcretePowderBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ConcretePowderBlock.java.patch @@ -2,52 +2,52 @@ +++ b/net/minecraft/world/level/block/ConcretePowderBlock.java @@ -21,7 +_,7 @@ - public void m_142216_(Level p_52068_, BlockPos p_52069_, BlockState p_52070_, BlockState p_52071_, FallingBlockEntity p_52072_) { - if (m_52080_(p_52068_, p_52069_, p_52071_)) { -- p_52068_.m_7731_(p_52069_, this.f_52058_, 3); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_52068_, p_52069_, this.f_52058_, 3); // CraftBukkit + public void onLand(Level p_52068_, BlockPos p_52069_, BlockState p_52070_, BlockState p_52071_, FallingBlockEntity p_52072_) { + if (shouldSolidify(p_52068_, p_52069_, p_52071_)) { +- p_52068_.setBlock(p_52069_, this.concrete, 3); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_52068_, p_52069_, this.concrete, 3); // CraftBukkit } } @@ -30,7 +_,23 @@ - BlockGetter blockgetter = p_52063_.m_43725_(); - BlockPos blockpos = p_52063_.m_8083_(); - BlockState blockstate = blockgetter.m_8055_(blockpos); -- return m_52080_(blockgetter, blockpos, blockstate) ? this.f_52058_ : super.m_5573_(p_52063_); + BlockGetter blockgetter = p_52063_.getLevel(); + BlockPos blockpos = p_52063_.getClickedPos(); + BlockState blockstate = blockgetter.getBlockState(blockpos); +- return shouldSolidify(blockgetter, blockpos, blockstate) ? this.concrete : super.getStateForPlacement(p_52063_); + // CraftBukkit start -+ if (!m_52080_(blockgetter, blockpos, blockstate)) { -+ return super.m_5573_(p_52063_); ++ if (!shouldSolidify(blockgetter, blockpos, blockstate)) { ++ return super.getStateForPlacement(p_52063_); + } + + // TODO: 30/08/2020 Magma We should be able to make a factory for this -+ org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState blockState = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockStates.getBlockState(p_52063_.m_43725_(), blockpos); -+ blockState.setData(this.f_52058_); ++ org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState blockState = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockStates.getBlockState(p_52063_.getLevel(), blockpos); ++ blockState.setData(this.concrete); + + org.bukkit.event.block.BlockFormEvent event = new org.bukkit.event.block.BlockFormEvent(blockState.getBlock(), blockState); -+ p_52063_.m_43725_().getCraftServer().getPluginManager().callEvent(event); ++ p_52063_.getLevel().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); + } -+ return super.m_5573_(p_52063_); ++ return super.getStateForPlacement(p_52063_); + // CraftBukkit end } - private static boolean m_52080_(BlockGetter p_52081_, BlockPos p_52082_, BlockState p_52083_) { + private static boolean shouldSolidify(BlockGetter p_52081_, BlockPos p_52082_, BlockState p_52083_) { @@ -61,7 +_,25 @@ } - public BlockState m_7417_(BlockState p_52074_, Direction p_52075_, BlockState p_52076_, LevelAccessor p_52077_, BlockPos p_52078_, BlockPos p_52079_) { -- return m_52064_(p_52077_, p_52078_) ? this.f_52058_ : super.m_7417_(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); + public 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 : super.updateShape(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); + + // CraftBukkit start -+ if (m_52064_(p_52077_, p_52078_)) { ++ if (touchesLiquid(p_52077_, p_52078_)) { + // Suppress during worldgen + if (!(p_52077_ instanceof Level)) { -+ return this.f_52058_; ++ return this.concrete; + } + org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState blockState = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockStates.getBlockState(p_52077_, p_52078_); -+ blockState.setData(this.f_52058_); ++ blockState.setData(this.concrete); + + org.bukkit.event.block.BlockFormEvent event = new org.bukkit.event.block.BlockFormEvent(blockState.getBlock(), blockState); + ((Level) p_52077_).getCraftServer().getPluginManager().callEvent(event); @@ -56,8 +56,8 @@ + return blockState.getHandle(); + } + } -+ return super.m_7417_(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); ++ return super.updateShape(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); + // CraftBukkit end } - public int m_6248_(BlockState p_52085_, BlockGetter p_52086_, BlockPos p_52087_) { + public int getDustColor(BlockState p_52085_, BlockGetter p_52086_, BlockPos p_52087_) { 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 f32cfd06..5e52e1c5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CoralBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CoralBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/CoralBlock.java @@ -23,6 +_,11 @@ - public void m_7458_(BlockState p_52138_, ServerLevel p_52139_, BlockPos p_52140_, Random p_52141_) { - if (!this.m_52134_(p_52139_, p_52140_)) { + public void tick(BlockState p_52138_, ServerLevel p_52139_, BlockPos p_52140_, Random p_52141_) { + if (!this.scanForWater(p_52139_, p_52140_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52139_, p_52140_, this.f_52128_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52139_, p_52140_, this.deadBlock.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - p_52139_.m_7731_(p_52140_, this.f_52128_.m_49966_(), 2); + p_52139_.setBlock(p_52140_, this.deadBlock.defaultBlockState(), 2); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CoralFanBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CoralFanBlock.java.patch index b28b1a4f..646b51d7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CoralFanBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CoralFanBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/CoralFanBlock.java @@ -24,6 +_,11 @@ - public void m_7458_(BlockState p_52154_, ServerLevel p_52155_, BlockPos p_52156_, Random p_52157_) { - if (!m_49186_(p_52154_, p_52155_, p_52156_)) { + public void tick(BlockState p_52154_, ServerLevel p_52155_, BlockPos p_52156_, Random p_52157_) { + if (!scanForWater(p_52154_, p_52155_, p_52156_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52155_, p_52156_, this.f_52149_.m_49966_().m_61124_(CoralFanBlock.f_49158_, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52155_, p_52156_, this.deadBlock.defaultBlockState().setValue(CoralFanBlock.WATERLOGGED, false)).isCancelled()) { + return; + } + // CraftBukkit end - p_52155_.m_7731_(p_52156_, this.f_52149_.m_49966_().m_61124_(f_49158_, Boolean.valueOf(false)), 2); + p_52155_.setBlock(p_52156_, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(false)), 2); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CoralPlantBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CoralPlantBlock.java.patch index c4a59d7d..d931fbba 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CoralPlantBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CoralPlantBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/CoralPlantBlock.java @@ -29,6 +_,11 @@ - public void m_7458_(BlockState p_52178_, ServerLevel p_52179_, BlockPos p_52180_, Random p_52181_) { - if (!m_49186_(p_52178_, p_52179_, p_52180_)) { + public void tick(BlockState p_52178_, ServerLevel p_52179_, BlockPos p_52180_, Random p_52181_) { + if (!scanForWater(p_52178_, p_52179_, p_52180_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52179_, p_52180_, this.f_52172_.m_49966_().m_61124_(CoralPlantBlock.f_49158_, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52179_, p_52180_, this.deadBlock.defaultBlockState().setValue(CoralPlantBlock.WATERLOGGED, false)).isCancelled()) { + return; + } + // CraftBukkit end - p_52179_.m_7731_(p_52180_, this.f_52172_.m_49966_().m_61124_(f_49158_, Boolean.valueOf(false)), 2); + p_52179_.setBlock(p_52180_, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(false)), 2); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CoralWallFanBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CoralWallFanBlock.java.patch index 631679ad..cbe136c7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CoralWallFanBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CoralWallFanBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/CoralWallFanBlock.java @@ -24,6 +_,11 @@ - public void m_7458_(BlockState p_52205_, ServerLevel p_52206_, BlockPos p_52207_, Random p_52208_) { - if (!m_49186_(p_52205_, p_52206_, p_52207_)) { + public void tick(BlockState p_52205_, ServerLevel p_52206_, BlockPos p_52207_, Random p_52208_) { + if (!scanForWater(p_52205_, p_52206_, p_52207_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52206_, p_52207_, this.f_52200_.m_49966_().m_61124_(CoralWallFanBlock.f_49158_, false).m_61124_(CoralWallFanBlock.f_49192_, p_52205_.m_61143_(CoralWallFanBlock.f_49192_))).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_52206_, p_52207_, this.deadBlock.defaultBlockState().setValue(CoralWallFanBlock.WATERLOGGED, false).setValue(CoralWallFanBlock.FACING, p_52205_.getValue(CoralWallFanBlock.FACING))).isCancelled()) { + return; + } + // CraftBukkit end - p_52206_.m_7731_(p_52207_, this.f_52200_.m_49966_().m_61124_(f_49158_, Boolean.valueOf(false)).m_61124_(f_49192_, p_52205_.m_61143_(f_49192_)), 2); + p_52206_.setBlock(p_52207_, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(false)).setValue(FACING, p_52205_.getValue(FACING)), 2); } 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 344a0997..030ccdb8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch @@ -3,29 +3,29 @@ @@ -64,12 +_,27 @@ } - public void m_7455_(BlockState p_52292_, ServerLevel p_52293_, BlockPos p_52294_, Random p_52295_) { + public void randomTick(BlockState p_52292_, ServerLevel p_52293_, BlockPos p_52294_, Random p_52295_) { + if (!p_52293_.isAreaLoaded(p_52294_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light - if (p_52293_.m_45524_(p_52294_, 0) >= 9) { - int i = this.m_52305_(p_52292_); - if (i < this.m_7419_()) { - float f = m_52272_(this, p_52293_, p_52294_); + if (p_52293_.getRawBrightness(p_52294_, 0) >= 9) { + int i = this.getAge(p_52292_); + if (i < this.getMaxAge()) { + float f = getGrowthSpeed(this, p_52293_, p_52294_); - if (p_52295_.nextInt((int)(25.0F / f) + 1) == 0) { -- p_52293_.m_7731_(p_52294_, this.m_52289_(i + 1), 2); +- p_52293_.setBlock(p_52294_, this.getStateForAge(i + 1), 2); + + // Spigot start + int modifier; -+ if (this == Blocks.f_50444_) { ++ if (this == Blocks.BEETROOTS) { + modifier = p_52293_.spigotConfig.beetrootModifier; -+ } else if (this == Blocks.f_50249_) { ++ } else if (this == Blocks.CARROTS) { + modifier = p_52293_.spigotConfig.carrotModifier; -+ } else if (this == Blocks.f_50250_) { ++ } else if (this == Blocks.POTATOES) { + modifier = p_52293_.spigotConfig.potatoModifier; + } else { + modifier = p_52293_.spigotConfig.wheatModifier; + } + + if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_52293_, p_52294_, p_52292_, p_52295_.nextInt((int) ((100.0F / modifier) * (25.0F / f)) + 1) == 0)) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_52293_, p_52294_, this.m_52289_(i + 1), 2); // CraftBukkit ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_52293_, p_52294_, this.getStateForAge(i + 1), 2); // CraftBukkit + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_52293_, p_52294_, p_52292_); } } @@ -34,29 +34,29 @@ i = j; } -- p_52264_.m_7731_(p_52265_, this.m_52289_(i), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_52264_, p_52265_, this.m_52289_(i), 2); // CraftBukkit +- p_52264_.setBlock(p_52265_, this.getStateForAge(i), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_52264_, p_52265_, this.getStateForAge(i), 2); // CraftBukkit } - protected int m_7125_(Level p_52262_) { + protected int getBonemealAgeIncrease(Level p_52262_) { @@ -98,9 +_,9 @@ for(int j = -1; j <= 1; ++j) { float f1 = 0.0F; - BlockState blockstate = p_52274_.m_8055_(blockpos.m_142082_(i, 0, j)); -- if (blockstate.m_60713_(Blocks.f_50093_)) { -+ if (blockstate.canSustainPlant(p_52274_, blockpos.m_142082_(i, 0, j), net.minecraft.core.Direction.UP, (net.minecraftforge.common.IPlantable) p_52273_)) { + BlockState blockstate = p_52274_.getBlockState(blockpos.offset(i, 0, j)); +- if (blockstate.is(Blocks.FARMLAND)) { ++ if (blockstate.canSustainPlant(p_52274_, blockpos.offset(i, 0, j), net.minecraft.core.Direction.UP, (net.minecraftforge.common.IPlantable) p_52273_)) { f1 = 1.0F; -- if (blockstate.m_61143_(FarmBlock.f_53243_) > 0) { -+ if (blockstate.isFertile(p_52274_, p_52275_.m_142082_(i, 0, j))) { +- if (blockstate.getValue(FarmBlock.MOISTURE) > 0) { ++ if (blockstate.isFertile(p_52274_, p_52275_.offset(i, 0, j))) { f1 = 3.0F; } } @@ -136,7 +_,7 @@ } - public void m_7892_(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { -- if (p_52280_ instanceof Ravager && p_52278_.m_46469_().m_46207_(GameRules.f_46132_)) { -+ if (p_52280_ instanceof Ravager && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_52278_, p_52280_) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_52280_, p_52279_, Blocks.f_50016_.m_49966_(), !p_52278_.m_46469_().m_46207_(GameRules.f_46132_)).isCancelled()) { // CraftBukkit - p_52278_.m_46953_(p_52279_, true, p_52280_); + public 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_) && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_52280_, p_52279_, Blocks.AIR.defaultBlockState(), !p_52278_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { // CraftBukkit + p_52278_.destroyBlock(p_52279_, true, p_52280_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch index 435b479e..e1054984 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/world/level/block/DaylightDetectorBlock.java @@ -60,6 +_,7 @@ - i = Mth.m_14045_(i, 0, 15); - if (p_52411_.m_61143_(f_52377_) != i) { -+ i = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_52412_, p_52413_, ((Integer) p_52411_.m_61143_(f_52377_)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent - p_52412_.m_7731_(p_52413_, p_52411_.m_61124_(f_52377_, Integer.valueOf(i)), 3); + i = Mth.clamp(i, 0, 15); + if (p_52411_.getValue(POWER) != i) { ++ i = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_52412_, p_52413_, ((Integer) p_52411_.getValue(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent + p_52412_.setBlock(p_52413_, p_52411_.setValue(POWER, Integer.valueOf(i)), 3); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch index 30d0c903..d49074a4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch @@ -6,6 +6,6 @@ -public class DeadBushBlock extends BushBlock { +public class DeadBushBlock extends BushBlock implements net.minecraftforge.common.IForgeShearable { - protected static final float f_153120_ = 6.0F; - protected static final VoxelShape f_52414_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); + protected static final float AABB_OFFSET = 6.0F; + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); diff --git a/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch index fe0d9c27..8cd0b9c0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -8,7 +8,7 @@ + } + + protected void registerDefaultState() { - this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_52428_, Boolean.valueOf(false)).m_61124_(f_52427_, RailShape.NORTH_SOUTH).m_61124_(f_152149_, Boolean.valueOf(false))); + this.registerDefaultState(this.stateDefinition.any().setValue(POWERED, Boolean.valueOf(false)).setValue(SHAPE, RailShape.NORTH_SOUTH).setValue(WATERLOGGED, Boolean.valueOf(false))); } @@ -75,6 +_,17 @@ @@ -17,7 +17,7 @@ + // CraftBukkit start + if (flag != flag1) { -+ org.bukkit.block.Block block = p_52433_.getWorld().getBlockAt(p_52434_.m_123341_(), p_52434_.m_123342_(), p_52434_.m_123343_()); ++ org.bukkit.block.Block block = p_52433_.getWorld().getBlockAt(p_52434_.getX(), p_52434_.getY(), p_52434_.getZ()); + + org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0); + p_52433_.getCraftServer().getPluginManager().callEvent(eventRedstone); @@ -27,36 +27,36 @@ + // CraftBukkit end + if (flag1 && !flag) { - BlockState blockstate = p_52435_.m_61124_(f_52428_, Boolean.valueOf(true)); - p_52433_.m_7731_(p_52434_, blockstate, 3); + BlockState blockstate = p_52435_.setValue(POWERED, Boolean.valueOf(true)); + p_52433_.setBlock(p_52434_, blockstate, 3); @@ -106,7 +_,10 @@ - for(BlockPos blockpos : railstate.m_55424_()) { - BlockState blockstate = p_52473_.m_8055_(blockpos); -- blockstate.m_60690_(p_52473_, blockpos, blockstate.m_60734_(), p_52474_, false); + for(BlockPos blockpos : railstate.getConnections()) { + BlockState blockstate = p_52473_.getBlockState(blockpos); +- blockstate.neighborChanged(p_52473_, blockpos, blockstate.getBlock(), p_52474_, false); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) -+ p_52473_.neighborChanged(blockstate, blockpos, blockstate.m_60734_(), p_52474_, false); ++ p_52473_.neighborChanged(blockstate, blockpos, blockstate.getBlock(), p_52474_, false); + else -+ blockstate.m_60690_(p_52473_, blockpos, blockstate.m_60734_(), p_52474_, false); ++ blockstate.neighborChanged(p_52473_, blockpos, blockstate.getBlock(), p_52474_, false); } } @@ -135,7 +_,9 @@ - return list.get(0).m_38534_().m_45436_(); + return list.get(0).getCommandBlock().getSuccessCount(); } -- List list1 = this.m_52436_(p_52455_, p_52456_, AbstractMinecart.class, EntitySelector.f_20405_); -+ List carts = this.m_52436_(p_52455_, p_52456_, AbstractMinecart.class, e -> e.m_6084_()); +- List list1 = this.getInteractingMinecartOfType(p_52455_, p_52456_, AbstractMinecart.class, EntitySelector.CONTAINER_ENTITY_SELECTOR); ++ List carts = this.getInteractingMinecartOfType(p_52455_, p_52456_, AbstractMinecart.class, e -> e.isAlive()); + if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1) return carts.get(0).getComparatorLevel(); -+ List list1 = carts.stream().filter(EntitySelector.f_20405_).collect(java.util.stream.Collectors.toList()); ++ List list1 = carts.stream().filter(EntitySelector.CONTAINER_ENTITY_SELECTOR).collect(java.util.stream.Collectors.toList()); if (!list1.isEmpty()) { - return AbstractContainerMenu.m_38938_((Container)list1.get(0)); + return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)list1.get(0)); } @@ -270,6 +_,6 @@ } - protected void m_7926_(StateDefinition.Builder p_52469_) { -- p_52469_.m_61104_(f_52427_, f_52428_, f_152149_); -+ p_52469_.m_61104_(m_7978_(), f_52428_, f_152149_); + protected void createBlockStateDefinition(StateDefinition.Builder p_52469_) { +- p_52469_.add(SHAPE, POWERED, WATERLOGGED); ++ p_52469_.add(getShapeProperty(), POWERED, WATERLOGGED); } } 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 6960ab6a..9b937290 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java @@ -40,8 +_,18 @@ - boolean flag = p_52515_.m_61143_(f_52496_); - boolean flag1 = this.m_7320_(p_52516_, p_52517_, p_52515_); + boolean flag = p_52515_.getValue(POWERED); + boolean flag1 = this.shouldTurnOn(p_52516_, p_52517_, p_52515_); if (flag && !flag1) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_52516_, p_52517_, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - p_52516_.m_7731_(p_52517_, p_52515_.m_61124_(f_52496_, Boolean.valueOf(false)), 2); + p_52516_.setBlock(p_52517_, p_52515_.setValue(POWERED, Boolean.valueOf(false)), 2); } else if (!flag) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_52516_, p_52517_, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - p_52516_.m_7731_(p_52517_, p_52515_.m_61124_(f_52496_, Boolean.valueOf(true)), 2); + p_52516_.setBlock(p_52517_, p_52515_.setValue(POWERED, Boolean.valueOf(true)), 2); if (!flag1) { - p_52516_.m_186464_(p_52517_, this, this.m_6112_(p_52515_), TickPriority.VERY_HIGH); + p_52516_.scheduleTick(p_52517_, this, this.getDelay(p_52515_), TickPriority.VERY_HIGH); @@ -165,6 +_,8 @@ - protected void m_52580_(Level p_52581_, BlockPos p_52582_, BlockState p_52583_) { - Direction direction = p_52583_.m_61143_(f_54117_); - BlockPos blockpos = p_52582_.m_142300_(direction.m_122424_()); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(p_52581_, p_52582_, p_52581_.m_8055_(p_52582_), java.util.EnumSet.of(direction.m_122424_()), false).isCanceled()) + protected void updateNeighborsInFront(Level p_52581_, BlockPos p_52582_, BlockState p_52583_) { + 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()) + return; - p_52581_.m_46586_(blockpos, this, p_52582_); - p_52581_.m_46590_(blockpos, this, direction); + p_52581_.neighborChanged(blockpos, this, p_52582_); + p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DirtPathBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DirtPathBlock.java.patch index 63dc031d..169159fc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DirtPathBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DirtPathBlock.java.patch @@ -3,12 +3,12 @@ @@ -38,6 +_,11 @@ } - public void m_7458_(BlockState p_153133_, ServerLevel p_153134_, BlockPos p_153135_, Random p_153136_) { + public void tick(BlockState p_153133_, ServerLevel p_153134_, BlockPos p_153135_, Random p_153136_) { + // CraftBukkit start - do not fade if the block is valid here -+ if (p_153133_.m_60710_(p_153134_, p_153135_)) { ++ if (p_153133_.canSurvive(p_153134_, p_153135_)) { + return; + } + // CraftBukkit end - FarmBlock.m_53296_(p_153133_, p_153134_, p_153135_); + FarmBlock.turnToDirt(p_153133_, p_153134_, p_153135_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DispenserBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DispenserBlock.java.patch index c28d56c1..8a9f248b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DispenserBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DispenserBlock.java.patch @@ -3,16 +3,16 @@ @@ -44,6 +_,7 @@ p_52723_.defaultReturnValue(new DefaultDispenseItemBehavior()); }); - private static final int f_153160_ = 4; + private static final int TRIGGER_DURATION = 4; + public static boolean eventFired = false; // CraftBukkit - public static void m_52672_(ItemLike p_52673_, DispenseItemBehavior p_52674_) { - f_52661_.put(p_52673_.m_5456_(), p_52674_); + public static void registerBehavior(ItemLike p_52673_, DispenseItemBehavior p_52674_) { + DISPENSER_REGISTRY.put(p_52673_.asItem(), p_52674_); @@ -83,6 +_,7 @@ - ItemStack itemstack = dispenserblockentity.m_8020_(i); - DispenseItemBehavior dispenseitembehavior = this.m_7216_(itemstack); - if (dispenseitembehavior != DispenseItemBehavior.f_123393_) { + ItemStack itemstack = dispenserblockentity.getItem(i); + DispenseItemBehavior dispenseitembehavior = this.getDispenseMethod(itemstack); + if (dispenseitembehavior != DispenseItemBehavior.NOOP) { + eventFired = false; // CraftBukkit - reset event status - dispenserblockentity.m_6836_(i, dispenseitembehavior.m_6115_(blocksourceimpl, itemstack)); + dispenserblockentity.setItem(i, dispenseitembehavior.dispense(blocksourceimpl, itemstack)); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DoorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DoorBlock.java.patch index 02be48b5..b39377bc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DoorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DoorBlock.java.patch @@ -3,20 +3,20 @@ @@ -180,8 +_,24 @@ } - public void m_6861_(BlockState p_52776_, Level p_52777_, BlockPos p_52778_, Block p_52779_, BlockPos p_52780_, boolean p_52781_) { -- boolean flag = p_52777_.m_46753_(p_52778_) || p_52777_.m_46753_(p_52778_.m_142300_(p_52776_.m_61143_(f_52730_) == DoubleBlockHalf.LOWER ? Direction.UP : Direction.DOWN)); -- if (!this.m_49966_().m_60713_(p_52779_) && flag != p_52776_.m_61143_(f_52729_)) { + public void neighborChanged(BlockState p_52776_, Level p_52777_, BlockPos p_52778_, Block p_52779_, BlockPos p_52780_, boolean p_52781_) { +- boolean flag = p_52777_.hasNeighborSignal(p_52778_) || p_52777_.hasNeighborSignal(p_52778_.relative(p_52776_.getValue(HALF) == DoubleBlockHalf.LOWER ? Direction.UP : Direction.DOWN)); +- if (!this.defaultBlockState().is(p_52779_) && flag != p_52776_.getValue(POWERED)) { + // CraftBukkit start -+ BlockPos otherHalf = p_52778_.m_142300_(p_52776_.m_61143_(DoorBlock.f_52730_) == DoubleBlockHalf.LOWER ? Direction.UP : Direction.DOWN); ++ BlockPos otherHalf = p_52778_.relative(p_52776_.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? Direction.UP : Direction.DOWN); + + org.bukkit.World bworld = p_52777_.getWorld(); -+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(p_52778_.m_123341_(), p_52778_.m_123342_(), p_52778_.m_123343_()); -+ org.bukkit.block.Block blockTop = bworld.getBlockAt(otherHalf.m_123341_(), otherHalf.m_123342_(), otherHalf.m_123343_()); ++ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(p_52778_.getX(), p_52778_.getY(), p_52778_.getZ()); ++ org.bukkit.block.Block blockTop = bworld.getBlockAt(otherHalf.getX(), otherHalf.getY(), otherHalf.getZ()); + + int power = bukkitBlock.getBlockPower(); + int powerTop = blockTop.getBlockPower(); + if (powerTop > power) power = powerTop; -+ int oldPower = (Boolean) p_52776_.m_61143_(DoorBlock.f_52729_) ? 15 : 0; ++ int oldPower = (Boolean) p_52776_.getValue(DoorBlock.POWERED) ? 15 : 0; + + if (oldPower == 0 ^ power == 0) { + org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bukkitBlock, oldPower, power); @@ -24,6 +24,6 @@ + + boolean flag = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end - if (flag != p_52776_.m_61143_(f_52727_)) { - this.m_52759_(p_52777_, p_52778_, flag); - p_52777_.m_151555_(flag ? GameEvent.f_157796_ : GameEvent.f_157793_, p_52778_); + if (flag != p_52776_.getValue(OPEN)) { + this.playSound(p_52777_, p_52778_, flag); + p_52777_.gameEvent(flag ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, p_52778_); 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 ff70944d..31667e9f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java @@ -53,6 +_,7 @@ - return super.m_7898_(p_52887_, p_52888_, p_52889_); + return super.canSurvive(p_52887_, p_52888_, p_52889_); } else { - BlockState blockstate = p_52888_.m_8055_(p_52889_.m_7495_()); -+ if (p_52887_.m_60734_() != this) return super.m_7898_(p_52887_, p_52888_, p_52889_); //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. - return blockstate.m_60713_(this) && blockstate.m_61143_(f_52858_) == DoubleBlockHalf.LOWER; + BlockState blockstate = p_52888_.getBlockState(p_52889_.below()); ++ if (p_52887_.getBlock() != this) return super.canSurvive(p_52887_, p_52888_, p_52889_); //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. + return blockstate.is(this) && blockstate.getValue(HALF) == DoubleBlockHalf.LOWER; } } @@ -84,6 +_,11 @@ } - protected static void m_52903_(Level p_52904_, BlockPos p_52905_, BlockState p_52906_, Player p_52907_) { + protected static void preventCreativeDropFromBottomPart(Level p_52904_, BlockPos p_52905_, BlockState p_52906_, Player p_52907_) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockPhysicsEvent(p_52904_, p_52905_).isCancelled()) { + return; + } + // CraftBukkit end - DoubleBlockHalf doubleblockhalf = p_52906_.m_61143_(f_52858_); + DoubleBlockHalf doubleblockhalf = p_52906_.getValue(HALF); if (doubleblockhalf == DoubleBlockHalf.UPPER) { - BlockPos blockpos = p_52905_.m_7495_(); + BlockPos blockpos = p_52905_.below(); diff --git a/patches/minecraft/net/minecraft/world/level/block/DragonEggBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DragonEggBlock.java.patch index 846cb4ed..3580e4c7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DragonEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DragonEggBlock.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/level/block/DragonEggBlock.java @@ -42,6 +_,18 @@ for(int i = 0; i < 1000; ++i) { - BlockPos blockpos = p_52938_.m_142082_(p_52937_.f_46441_.nextInt(16) - p_52937_.f_46441_.nextInt(16), p_52937_.f_46441_.nextInt(8) - p_52937_.f_46441_.nextInt(8), p_52937_.f_46441_.nextInt(16) - p_52937_.f_46441_.nextInt(16)); - if (p_52937_.m_8055_(blockpos).m_60795_() && worldborder.m_61937_(blockpos)) { + BlockPos blockpos = p_52938_.offset(p_52937_.random.nextInt(16) - p_52937_.random.nextInt(16), p_52937_.random.nextInt(8) - p_52937_.random.nextInt(8), p_52937_.random.nextInt(16) - p_52937_.random.nextInt(16)); + if (p_52937_.getBlockState(blockpos).isAir() && worldborder.isWithinBounds(blockpos)) { + // CraftBukkit start -+ org.bukkit.block.Block from = p_52937_.getWorld().getBlockAt(p_52938_.m_123341_(), p_52938_.m_123342_(), p_52938_.m_123343_()); -+ org.bukkit.block.Block to = p_52937_.getWorld().getBlockAt(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); ++ org.bukkit.block.Block from = p_52937_.getWorld().getBlockAt(p_52938_.getX(), p_52938_.getY(), p_52938_.getZ()); ++ org.bukkit.block.Block to = p_52937_.getWorld().getBlockAt(blockpos.getX(), blockpos.getY(), blockpos.getZ()); + org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(from, to); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + @@ -16,6 +16,6 @@ + + blockpos = new BlockPos(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ()); + // CraftBukkit end - if (p_52937_.f_46443_) { + if (p_52937_.isClientSide) { for(int j = 0; j < 128; ++j) { - double d0 = p_52937_.f_46441_.nextDouble(); + double d0 = p_52937_.random.nextDouble(); diff --git a/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch index 46190ae3..bfe8d27b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch @@ -4,27 +4,27 @@ import net.minecraft.world.level.block.state.BlockState; public class DropperBlock extends DispenserBlock { -- private static final DispenseItemBehavior f_52939_ = new DefaultDispenseItemBehavior(); -+ private static final DispenseItemBehavior f_52939_ = new DefaultDispenseItemBehavior(true); +- private static final DispenseItemBehavior DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(); ++ private static final DispenseItemBehavior DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(true); public DropperBlock(BlockBehaviour.Properties p_52942_) { super(p_52942_); @@ -38,15 +_,32 @@ - p_52944_.m_46796_(1001, p_52945_, 0); + p_52944_.levelEvent(1001, p_52945_, 0); } else { - ItemStack itemstack = dispenserblockentity.m_8020_(i); -- if (!itemstack.m_41619_()) { -+ if (!itemstack.m_41619_() && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(p_52944_, p_52945_, dispenserblockentity, i, itemstack)) { - Direction direction = p_52944_.m_8055_(p_52945_).m_61143_(f_52659_); - Container container = HopperBlockEntity.m_59390_(p_52944_, p_52945_.m_142300_(direction)); + ItemStack itemstack = dispenserblockentity.getItem(i); +- if (!itemstack.isEmpty()) { ++ if (!itemstack.isEmpty() && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(p_52944_, p_52945_, dispenserblockentity, i, itemstack)) { + Direction direction = p_52944_.getBlockState(p_52945_).getValue(FACING); + Container container = HopperBlockEntity.getContainerAt(p_52944_, p_52945_.relative(direction)); ItemStack itemstack1; if (container == null) { - itemstack1 = f_52939_.m_6115_(blocksourceimpl, itemstack); + itemstack1 = DISPENSE_BEHAVIOUR.dispense(blocksourceimpl, itemstack); } else { -- itemstack1 = HopperBlockEntity.m_59326_(dispenserblockentity, container, itemstack.m_41777_().m_41620_(1), direction.m_122424_()); -- if (itemstack1.m_41619_()) { +- itemstack1 = HopperBlockEntity.addItem(dispenserblockentity, container, itemstack.copy().split(1), direction.getOpposite()); +- if (itemstack1.isEmpty()) { + // CraftBukkit start - Fire event when pushing items into other inventories -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack.m_41777_().m_41620_(1)); ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack.copy().split(1)); + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly @@ -39,9 +39,9 @@ + if (event.isCancelled()) { + return; + } -+ itemstack1 = HopperBlockEntity.m_59326_(dispenserblockentity, container, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction.m_122424_()); -+ if (event.getItem().equals(oitemstack) && itemstack1.m_41619_()) { ++ itemstack1 = HopperBlockEntity.addItem(dispenserblockentity, container, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction.getOpposite()); ++ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) { + // CraftBukkit end - itemstack1 = itemstack.m_41777_(); - itemstack1.m_41774_(1); + itemstack1 = itemstack.copy(); + itemstack1.shrink(1); } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch index ba1af134..5622a588 100644 --- a/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/EnchantmentTableBlock.java.patch @@ -3,9 +3,9 @@ @@ -40,7 +_,7 @@ } - public static boolean m_207909_(Level p_207910_, BlockPos p_207911_, BlockPos p_207912_) { -- return p_207910_.m_8055_(p_207911_.m_141952_(p_207912_)).m_60713_(Blocks.f_50078_) && p_207910_.m_46859_(p_207911_.m_142082_(p_207912_.m_123341_() / 2, p_207912_.m_123342_(), p_207912_.m_123343_() / 2)); -+ return p_207910_.m_8055_(p_207911_.m_141952_(p_207912_)).getEnchantPowerBonus(p_207910_, p_207911_.m_141952_(p_207912_)) != 0 && p_207910_.m_46859_(p_207911_.m_142082_(p_207912_.m_123341_() / 2, p_207912_.m_123342_(), p_207912_.m_123343_() / 2)); + public static boolean isValidBookShelf(Level p_207910_, BlockPos p_207911_, BlockPos p_207912_) { +- return p_207910_.getBlockState(p_207911_.offset(p_207912_)).is(Blocks.BOOKSHELF) && p_207910_.isEmptyBlock(p_207911_.offset(p_207912_.getX() / 2, p_207912_.getY(), p_207912_.getZ() / 2)); ++ return p_207910_.getBlockState(p_207911_.offset(p_207912_)).getEnchantPowerBonus(p_207910_, p_207911_.offset(p_207912_)) != 0 && p_207910_.isEmptyBlock(p_207911_.offset(p_207912_.getX() / 2, p_207912_.getY(), p_207912_.getZ() / 2)); } - public boolean m_7923_(BlockState p_52997_) { + public boolean useShapeForLightOcclusion(BlockState p_52997_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/EndPortalBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/EndPortalBlock.java.patch index 92bc7776..f7e1954b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/EndPortalBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/EndPortalBlock.java.patch @@ -2,25 +2,25 @@ +++ b/net/minecraft/world/level/block/EndPortalBlock.java @@ -36,12 +_,21 @@ - public void m_7892_(BlockState p_53025_, Level p_53026_, BlockPos p_53027_, Entity p_53028_) { - if (p_53026_ instanceof ServerLevel && !p_53028_.m_20159_() && !p_53028_.m_20160_() && p_53028_.m_6072_() && Shapes.m_83157_(Shapes.m_83064_(p_53028_.m_142469_().m_82386_((double)(-p_53027_.m_123341_()), (double)(-p_53027_.m_123342_()), (double)(-p_53027_.m_123343_()))), p_53025_.m_60808_(p_53026_, p_53027_), BooleanOp.f_82689_)) { -- ResourceKey resourcekey = p_53026_.m_46472_() == Level.f_46430_ ? Level.f_46428_ : Level.f_46430_; -+ ResourceKey resourcekey = p_53026_.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.f_63973_ ? Level.f_46428_ : Level.f_46430_; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends - ServerLevel serverlevel = ((ServerLevel)p_53026_).m_142572_().m_129880_(resourcekey); + public void entityInside(BlockState p_53025_, Level p_53026_, BlockPos p_53027_, Entity p_53028_) { + if (p_53026_ instanceof ServerLevel && !p_53028_.isPassenger() && !p_53028_.isVehicle() && p_53028_.canChangeDimensions() && Shapes.joinIsNotEmpty(Shapes.create(p_53028_.getBoundingBox().move((double)(-p_53027_.getX()), (double)(-p_53027_.getY()), (double)(-p_53027_.getZ()))), p_53025_.getShape(p_53026_, p_53027_), BooleanOp.AND)) { +- ResourceKey resourcekey = p_53026_.dimension() == Level.END ? Level.OVERWORLD : Level.END; ++ ResourceKey resourcekey = p_53026_.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends + ServerLevel serverlevel = ((ServerLevel)p_53026_).getServer().getLevel(resourcekey); if (serverlevel == null) { + // return; // CraftBukkit - always fire event in case plugins wish to change it + } + + // CraftBukkit start - Entity in portal -+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(p_53028_.getBukkitEntity(), new org.bukkit.Location(p_53026_.getWorld(), p_53027_.m_123341_(), p_53027_.m_123342_(), p_53027_.m_123343_())); ++ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(p_53028_.getBukkitEntity(), new org.bukkit.Location(p_53026_.getWorld(), p_53027_.getX(), p_53027_.getY(), p_53027_.getZ())); + p_53026_.getCraftServer().getPluginManager().callEvent(event); + + if (p_53028_ instanceof net.minecraft.server.level.ServerPlayer) { -+ ((net.minecraft.server.level.ServerPlayer) p_53028_).changeDimension(serverlevel, serverlevel.m_8871_() , org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ ((net.minecraft.server.level.ServerPlayer) p_53028_).changeDimension(serverlevel, serverlevel.getPortalForcer() , org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL); return; } - + // CraftBukkit end - p_53028_.m_5489_(serverlevel); + p_53028_.changeDimension(serverlevel); } 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 8b063218..b5f3ef67 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/world/level/block/FarmBlock.java +++ b/net/minecraft/world/level/block/FarmBlock.java @@ -70,31 +_,55 @@ - int i = p_53285_.m_61143_(f_53243_); - if (!m_53258_(p_53286_, p_53287_) && !p_53286_.m_46758_(p_53287_.m_7494_())) { + int i = p_53285_.getValue(MOISTURE); + if (!isNearWater(p_53286_, p_53287_) && !p_53286_.isRainingAt(p_53287_.above())) { if (i > 0) { -- p_53286_.m_7731_(p_53287_, p_53285_.m_61124_(f_53243_, Integer.valueOf(i - 1)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleMoistureChangeEvent(p_53286_, p_53287_, p_53285_.m_61124_(f_53243_, Integer.valueOf(i - 1)), 2); // CraftBukkit - } else if (!m_53250_(p_53286_, p_53287_)) { - m_53296_(p_53285_, p_53286_, p_53287_); +- p_53286_.setBlock(p_53287_, p_53285_.setValue(MOISTURE, Integer.valueOf(i - 1)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleMoistureChangeEvent(p_53286_, p_53287_, p_53285_.setValue(MOISTURE, Integer.valueOf(i - 1)), 2); // CraftBukkit + } else if (!isUnderCrops(p_53286_, p_53287_)) { + turnToDirt(p_53285_, p_53286_, p_53287_); } } else if (i < 7) { -- p_53286_.m_7731_(p_53287_, p_53285_.m_61124_(f_53243_, Integer.valueOf(7)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleMoistureChangeEvent(p_53286_, p_53287_, p_53285_.m_61124_(f_53243_, Integer.valueOf(7)), 2); // CraftBukkit +- p_53286_.setBlock(p_53287_, p_53285_.setValue(MOISTURE, Integer.valueOf(7)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleMoistureChangeEvent(p_53286_, p_53287_, p_53285_.setValue(MOISTURE, Integer.valueOf(7)), 2); // CraftBukkit } } - public void m_142072_(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { -- if (!p_153227_.f_46443_ && p_153227_.f_46441_.nextFloat() < p_153231_ - 0.5F && p_153230_ instanceof LivingEntity && (p_153230_ instanceof Player || p_153227_.m_46469_().m_46207_(GameRules.f_46132_)) && p_153230_.m_20205_() * p_153230_.m_20205_() * p_153230_.m_20206_() > 0.512F) { -+ super.m_142072_(p_153227_, p_153228_, p_153229_, p_153230_, p_153231_); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage -+ if (!p_153227_.f_46443_ && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(p_153227_, p_153229_, Blocks.f_50493_.m_49966_(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample + public void fallOn(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { +- if (!p_153227_.isClientSide && 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_.getBbWidth() * p_153230_.getBbWidth() * p_153230_.getBbHeight() > 0.512F) { ++ super.fallOn(p_153227_, p_153228_, p_153229_, p_153230_, p_153231_); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage ++ if (!p_153227_.isClientSide && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(p_153227_, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; + if (p_153230_ instanceof Player) { + cancellable = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent((Player) p_153230_, org.bukkit.event.block.Action.PHYSICAL, p_153229_, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(p_153230_.getBukkitEntity(), p_153227_.getWorld().getBlockAt(p_153229_.m_123341_(), p_153229_.m_123342_(), p_153229_.m_123343_())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(p_153230_.getBukkitEntity(), p_153227_.getWorld().getBlockAt(p_153229_.getX(), p_153229_.getY(), p_153229_.getZ())); + p_153227_.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + @@ -33,35 +33,35 @@ + return; + } + -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_153230_, p_153229_, Blocks.f_50493_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_153230_, p_153229_, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - m_53296_(p_153228_, p_153227_, p_153229_); + turnToDirt(p_153228_, p_153227_, p_153229_); } -- super.m_142072_(p_153227_, p_153228_, p_153229_, p_153230_, p_153231_); +- super.fallOn(p_153227_, p_153228_, p_153229_, p_153230_, p_153231_); + // super.fallOn(p_153227_, p_153228_, p_153229_, p_153230_, p_153231_); // CraftBukkit - moved up } - public static void m_53296_(BlockState p_53297_, Level p_53298_, BlockPos p_53299_) { + public static void turnToDirt(BlockState p_53297_, Level p_53298_, BlockPos p_53299_) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53298_, p_53299_, Blocks.f_50493_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53298_, p_53299_, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - p_53298_.m_46597_(p_53299_, m_49897_(p_53297_, Blocks.f_50493_.m_49966_(), p_53298_, p_53299_)); + p_53298_.setBlockAndUpdate(p_53299_, pushEntitiesUp(p_53297_, Blocks.DIRT.defaultBlockState(), p_53298_, p_53299_)); } - private static boolean m_53250_(BlockGetter p_53251_, BlockPos p_53252_) { -- Block block = p_53251_.m_8055_(p_53252_.m_7494_()).m_60734_(); + private static boolean isUnderCrops(BlockGetter p_53251_, BlockPos p_53252_) { +- Block block = p_53251_.getBlockState(p_53252_.above()).getBlock(); - return block instanceof CropBlock || block instanceof StemBlock || block instanceof AttachedStemBlock; -+ BlockState plant = p_53251_.m_8055_(p_53252_.m_7494_()); -+ BlockState state = p_53251_.m_8055_(p_53252_); -+ return plant.m_60734_() instanceof net.minecraftforge.common.IPlantable && state.canSustainPlant(p_53251_, p_53252_, Direction.UP, (net.minecraftforge.common.IPlantable)plant.m_60734_()); ++ BlockState plant = p_53251_.getBlockState(p_53252_.above()); ++ BlockState state = p_53251_.getBlockState(p_53252_); ++ return plant.getBlock() instanceof net.minecraftforge.common.IPlantable && state.canSustainPlant(p_53251_, p_53252_, Direction.UP, (net.minecraftforge.common.IPlantable)plant.getBlock()); } - private static boolean m_53258_(LevelReader p_53259_, BlockPos p_53260_) { + private static boolean isNearWater(LevelReader p_53259_, BlockPos p_53260_) { @@ -104,7 +_,7 @@ } } @@ -70,4 +70,4 @@ + return net.minecraftforge.common.FarmlandWaterManager.hasBlockWaterTicket(p_53259_, p_53260_); } - protected void m_7926_(StateDefinition.Builder p_53283_) { + protected void createBlockStateDefinition(StateDefinition.Builder p_53283_) { 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 16c1e998..b095e0c4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java @@ -126,6 +_,18 @@ - public void m_6861_(BlockState p_53372_, Level p_53373_, BlockPos p_53374_, Block p_53375_, BlockPos p_53376_, boolean p_53377_) { - if (!p_53373_.f_46443_) { - boolean flag = p_53373_.m_46753_(p_53374_); + public void neighborChanged(BlockState p_53372_, Level p_53373_, BlockPos p_53374_, Block p_53375_, BlockPos p_53376_, boolean p_53377_) { + if (!p_53373_.isClientSide) { + boolean flag = p_53373_.hasNeighborSignal(p_53374_); + // CraftBukkit start -+ boolean oldPowered = p_53372_.m_61143_(f_53342_); ++ boolean oldPowered = p_53372_.getValue(POWERED); + if (oldPowered != flag) { + int newPower = flag ? 15 : 0; + int oldPower = oldPowered ? 15 : 0; @@ -16,6 +16,6 @@ + } + // CraftBukkit end + - if (p_53372_.m_61143_(f_53342_) != flag) { - p_53373_.m_7731_(p_53374_, p_53372_.m_61124_(f_53342_, Boolean.valueOf(flag)).m_61124_(f_53341_, Boolean.valueOf(flag)), 2); - if (p_53372_.m_61143_(f_53341_) != flag) { + if (p_53372_.getValue(POWERED) != flag) { + p_53373_.setBlock(p_53374_, p_53372_.setValue(POWERED, Boolean.valueOf(flag)).setValue(OPEN, Boolean.valueOf(flag)), 2); + if (p_53372_.getValue(OPEN) != flag) { 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 29435048..29b45e95 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch @@ -3,136 +3,136 @@ @@ -89,7 +_,23 @@ } - public BlockState m_7417_(BlockState p_53458_, Direction p_53459_, BlockState p_53460_, LevelAccessor p_53461_, BlockPos p_53462_, BlockPos p_53463_) { -- return this.m_7898_(p_53458_, p_53461_, p_53462_) ? this.m_53437_(p_53461_, p_53462_, p_53458_.m_61143_(f_53408_)) : Blocks.f_50016_.m_49966_(); + public BlockState updateShape(BlockState p_53458_, Direction p_53459_, BlockState p_53460_, LevelAccessor p_53461_, BlockPos p_53462_, BlockPos p_53463_) { +- return this.canSurvive(p_53458_, p_53461_, p_53462_) ? this.getStateWithAge(p_53461_, p_53462_, p_53458_.getValue(AGE)) : Blocks.AIR.defaultBlockState(); + // CraftBukkit start -+ if (!this.m_7898_(p_53458_, p_53461_, p_53462_)) { ++ if (!this.canSurvive(p_53458_, p_53461_, p_53462_)) { + // Suppress during worldgen + if (!(p_53461_ instanceof Level)) { -+ return Blocks.f_50016_.m_49966_(); ++ return Blocks.AIR.defaultBlockState(); + } + org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState blockState = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockStates.getBlockState(p_53461_, p_53462_); -+ blockState.setData(Blocks.f_50016_.m_49966_()); ++ blockState.setData(Blocks.AIR.defaultBlockState()); + org.bukkit.event.block.BlockFadeEvent event = new org.bukkit.event.block.BlockFadeEvent(blockState.getBlock(), blockState); + ((Level) p_53461_).getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + return blockState.getHandle(); + } + } -+ return this.m_53437_(p_53461_, p_53462_, (Integer) p_53458_.m_61143_(f_53408_)); ++ return this.getStateWithAge(p_53461_, p_53462_, (Integer) p_53458_.getValue(AGE)); + // CraftBukkit end + } - public VoxelShape m_5940_(BlockState p_53474_, BlockGetter p_53475_, BlockPos p_53476_, CollisionContext p_53477_) { + public VoxelShape getShape(BlockState p_53474_, BlockGetter p_53475_, BlockPos p_53476_, CollisionContext p_53477_) { @@ -103,13 +_,13 @@ - protected BlockState m_53470_(BlockGetter p_53471_, BlockPos p_53472_) { - BlockPos blockpos = p_53472_.m_7495_(); - BlockState blockstate = p_53471_.m_8055_(blockpos); -- if (!this.m_7599_(blockstate) && !blockstate.m_60783_(p_53471_, blockpos, Direction.UP)) { -+ if (!this.canCatchFire(p_53471_, p_53472_, Direction.UP) && !blockstate.m_60783_(p_53471_, blockpos, Direction.UP)) { - BlockState blockstate1 = this.m_49966_(); + protected BlockState getStateForPlacement(BlockGetter p_53471_, BlockPos p_53472_) { + BlockPos blockpos = p_53472_.below(); + BlockState blockstate = p_53471_.getBlockState(blockpos); +- if (!this.canBurn(blockstate) && !blockstate.isFaceSturdy(p_53471_, blockpos, Direction.UP)) { ++ if (!this.canCatchFire(p_53471_, p_53472_, Direction.UP) && !blockstate.isFaceSturdy(p_53471_, blockpos, Direction.UP)) { + BlockState blockstate1 = this.defaultBlockState(); for(Direction direction : Direction.values()) { - BooleanProperty booleanproperty = f_53414_.get(direction); + BooleanProperty booleanproperty = PROPERTY_BY_DIRECTION.get(direction); if (booleanproperty != null) { -- blockstate1 = blockstate1.m_61124_(booleanproperty, Boolean.valueOf(this.m_7599_(p_53471_.m_8055_(p_53472_.m_142300_(direction))))); -+ blockstate1 = blockstate1.m_61124_(booleanproperty, Boolean.valueOf(this.canCatchFire(p_53471_, p_53472_.m_142300_(direction), direction.m_122424_()))); +- blockstate1 = blockstate1.setValue(booleanproperty, Boolean.valueOf(this.canBurn(p_53471_.getBlockState(p_53472_.relative(direction))))); ++ blockstate1 = blockstate1.setValue(booleanproperty, Boolean.valueOf(this.canCatchFire(p_53471_, p_53472_.relative(direction), direction.getOpposite()))); } } @@ -128,14 +_,18 @@ - p_53450_.m_186460_(p_53451_, this, m_53468_(p_53450_.f_46441_)); - if (p_53450_.m_46469_().m_46207_(GameRules.f_46131_)) { - if (!p_53449_.m_60710_(p_53450_, p_53451_)) { -- p_53450_.m_7471_(p_53451_, false); -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ p_53450_.m_7471_(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + p_53450_.scheduleTick(p_53451_, this, getFireTickDelay(p_53450_.random)); + if (p_53450_.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { + if (!p_53449_.canSurvive(p_53450_, p_53451_)) { +- p_53450_.removeBlock(p_53451_, false); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ p_53450_.removeBlock(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + } } - BlockState blockstate = p_53450_.m_8055_(p_53451_.m_7495_()); -- boolean flag = blockstate.m_204336_(p_53450_.m_6042_().m_204517_()); + BlockState blockstate = p_53450_.getBlockState(p_53451_.below()); +- boolean flag = blockstate.is(p_53450_.dimensionType().infiniburn()); + boolean flag = blockstate.isFireSource(p_53450_, p_53451_, Direction.UP); - int i = p_53449_.m_61143_(f_53408_); - if (!flag && p_53450_.m_46471_() && this.m_53428_(p_53450_, p_53451_) && p_53452_.nextFloat() < 0.2F + (float)i * 0.03F) { -- p_53450_.m_7471_(p_53451_, false); -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ p_53450_.m_7471_(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + int i = p_53449_.getValue(AGE); + if (!flag && p_53450_.isRaining() && this.isNearRain(p_53450_, p_53451_) && p_53452_.nextFloat() < 0.2F + (float)i * 0.03F) { +- p_53450_.removeBlock(p_53451_, false); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ p_53450_.removeBlock(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + } } else { int j = Math.min(15, i + p_53452_.nextInt(3) / 2); if (i != j) { @@ -147,26 +_,32 @@ - if (!this.m_53485_(p_53450_, p_53451_)) { - BlockPos blockpos = p_53451_.m_7495_(); - if (!p_53450_.m_8055_(blockpos).m_60783_(p_53450_, blockpos, Direction.UP) || i > 3) { -- p_53450_.m_7471_(p_53451_, false); -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ p_53450_.m_7471_(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + if (!this.isValidFireLocation(p_53450_, p_53451_)) { + BlockPos blockpos = p_53451_.below(); + if (!p_53450_.getBlockState(blockpos).isFaceSturdy(p_53450_, blockpos, Direction.UP) || i > 3) { +- p_53450_.removeBlock(p_53451_, false); ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ p_53450_.removeBlock(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + } } return; } -- if (i == 15 && p_53452_.nextInt(4) == 0 && !this.m_7599_(p_53450_.m_8055_(p_53451_.m_7495_()))) { -- p_53450_.m_7471_(p_53451_, false); -+ if (i == 15 && p_53452_.nextInt(4) == 0 && !this.canCatchFire(p_53450_, p_53451_.m_7495_(), Direction.UP)) { -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.f_50016_.m_49966_()).isCancelled()) { -+ p_53450_.m_7471_(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) +- if (i == 15 && p_53452_.nextInt(4) == 0 && !this.canBurn(p_53450_.getBlockState(p_53451_.below()))) { +- p_53450_.removeBlock(p_53451_, false); ++ if (i == 15 && p_53452_.nextInt(4) == 0 && !this.canCatchFire(p_53450_, p_53451_.below(), Direction.UP)) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_53450_, p_53451_, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ p_53450_.removeBlock(p_53451_, false); //Magma - directly implement removeBlock here to prevent a mixin inject error (look at this.fireExtinguished) + } return; } } - boolean flag1 = p_53450_.m_46761_(p_53451_); + boolean flag1 = p_53450_.isHumidAt(p_53451_); int k = flag1 ? -50 : 0; -- this.m_53431_(p_53450_, p_53451_.m_142126_(), 300 + k, p_53452_, i); -- this.m_53431_(p_53450_, p_53451_.m_142125_(), 300 + k, p_53452_, i); -- this.m_53431_(p_53450_, p_53451_.m_7495_(), 250 + k, p_53452_, i); -- this.m_53431_(p_53450_, p_53451_.m_7494_(), 250 + k, p_53452_, i); -- this.m_53431_(p_53450_, p_53451_.m_142127_(), 300 + k, p_53452_, i); -- this.m_53431_(p_53450_, p_53451_.m_142128_(), 300 + k, p_53452_, i); +- this.checkBurnOut(p_53450_, p_53451_.east(), 300 + k, p_53452_, i); +- this.checkBurnOut(p_53450_, p_53451_.west(), 300 + k, p_53452_, i); +- this.checkBurnOut(p_53450_, p_53451_.below(), 250 + k, p_53452_, i); +- this.checkBurnOut(p_53450_, p_53451_.above(), 250 + k, p_53452_, i); +- this.checkBurnOut(p_53450_, p_53451_.north(), 300 + k, p_53452_, i); +- this.checkBurnOut(p_53450_, p_53451_.south(), 300 + k, p_53452_, i); + // CraftBukkit start - add source blockposition to burn calls -+ this.tryCatchFire(p_53450_, p_53451_.m_142126_(), 300 + k, p_53452_, i, Direction.WEST, p_53451_); -+ this.tryCatchFire(p_53450_, p_53451_.m_142125_(), 300 + k, p_53452_, i, Direction.EAST, p_53451_); -+ this.tryCatchFire(p_53450_, p_53451_.m_7495_(), 250 + k, p_53452_, i, Direction.UP, p_53451_); -+ this.tryCatchFire(p_53450_, p_53451_.m_7494_(), 250 + k, p_53452_, i, Direction.DOWN, p_53451_); -+ this.tryCatchFire(p_53450_, p_53451_.m_142127_(), 300 + k, p_53452_, i, Direction.SOUTH, p_53451_); -+ this.tryCatchFire(p_53450_, p_53451_.m_142128_(), 300 + k, p_53452_, i, Direction.NORTH, p_53451_); ++ this.tryCatchFire(p_53450_, p_53451_.east(), 300 + k, p_53452_, i, Direction.WEST, p_53451_); ++ this.tryCatchFire(p_53450_, p_53451_.west(), 300 + k, p_53452_, i, Direction.EAST, p_53451_); ++ this.tryCatchFire(p_53450_, p_53451_.below(), 250 + k, p_53452_, i, Direction.UP, p_53451_); ++ this.tryCatchFire(p_53450_, p_53451_.above(), 250 + k, p_53452_, i, Direction.DOWN, p_53451_); ++ this.tryCatchFire(p_53450_, p_53451_.north(), 300 + k, p_53452_, i, Direction.SOUTH, p_53451_); ++ this.tryCatchFire(p_53450_, p_53451_.south(), 300 + k, p_53452_, i, Direction.NORTH, p_53451_); + // CraftBukkit end BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for(int l = -1; l <= 1; ++l) { @@ -188,7 +_,14 @@ - if (i2 > 0 && p_53452_.nextInt(k1) <= i2 && (!p_53450_.m_46471_() || !this.m_53428_(p_53450_, blockpos$mutableblockpos))) { + if (i2 > 0 && p_53452_.nextInt(k1) <= i2 && (!p_53450_.isRaining() || !this.isNearRain(p_53450_, blockpos$mutableblockpos))) { int j2 = Math.min(15, i + p_53452_.nextInt(5) / 4); -- p_53450_.m_7731_(blockpos$mutableblockpos, this.m_53437_(p_53450_, blockpos$mutableblockpos, j2), 3); +- p_53450_.setBlock(blockpos$mutableblockpos, this.getStateWithAge(p_53450_, blockpos$mutableblockpos, j2), 3); + // CraftBukkit start - Call to stop spread of fire -+ if (p_53450_.m_8055_(blockpos$mutableblockpos).m_60734_() != Blocks.f_50083_) { ++ if (p_53450_.getBlockState(blockpos$mutableblockpos).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(p_53450_, blockpos$mutableblockpos, p_53451_).isCancelled()) { + continue; + } -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_53450_, p_53451_, blockpos$mutableblockpos, this.m_53437_(p_53450_, blockpos$mutableblockpos, j2), 3); // CraftBukkit ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_53450_, p_53451_, blockpos$mutableblockpos, this.getStateWithAge(p_53450_, blockpos$mutableblockpos, j2), 3); // CraftBukkit + } + // CraftBukkit end } } } @@ -204,14 +_,87 @@ - return p_53429_.m_46758_(p_53430_) || p_53429_.m_46758_(p_53430_.m_142125_()) || p_53429_.m_46758_(p_53430_.m_142126_()) || p_53429_.m_46758_(p_53430_.m_142127_()) || p_53429_.m_46758_(p_53430_.m_142128_()); + return p_53429_.isRainingAt(p_53430_) || p_53429_.isRainingAt(p_53430_.west()) || p_53429_.isRainingAt(p_53430_.east()) || p_53429_.isRainingAt(p_53430_.north()) || p_53429_.isRainingAt(p_53430_.south()); } + @Deprecated //Forge: Use IForgeBlockState.getFlammability, Public for default implementation only. - public int m_53492_(BlockState p_53493_) { - return p_53493_.m_61138_(BlockStateProperties.f_61362_) && p_53493_.m_61143_(BlockStateProperties.f_61362_) ? 0 : this.f_53422_.getInt(p_53493_.m_60734_()); + public int getBurnOdd(BlockState p_53493_) { + return p_53493_.hasProperty(BlockStateProperties.WATERLOGGED) && p_53493_.getValue(BlockStateProperties.WATERLOGGED) ? 0 : this.burnOdds.getInt(p_53493_.getBlock()); } + @Deprecated //Forge: Use IForgeBlockState.getFireSpreadSpeed - public int m_53494_(BlockState p_53495_) { - return p_53495_.m_61138_(BlockStateProperties.f_61362_) && p_53495_.m_61143_(BlockStateProperties.f_61362_) ? 0 : this.f_53421_.getInt(p_53495_.m_60734_()); + public int getFlameOdds(BlockState p_53495_) { + return p_53495_.hasProperty(BlockStateProperties.WATERLOGGED) && p_53495_.getValue(BlockStateProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(p_53495_.getBlock()); } + //Magma - add constructor without source block position @@ -174,14 +174,14 @@ + BlockPos source = tryCatchFire_source; + //unset + tryCatchFire_source = null; -+ int i = p_53432_.m_8055_(p_53433_).getFlammability(p_53432_, p_53433_, face); ++ int i = p_53432_.getBlockState(p_53433_).getFlammability(p_53432_, p_53433_, face); + if (p_53435_.nextInt(p_53434_) < i) { -+ BlockState blockstate = p_53432_.m_8055_(p_53433_); ++ BlockState blockstate = p_53432_.getBlockState(p_53433_); + + // CraftBukkit start -+ org.bukkit.block.Block theBlock = p_53432_.getWorld().getBlockAt(p_53433_.m_123341_(), p_53433_.m_123342_(), p_53433_.m_123343_()); ++ org.bukkit.block.Block theBlock = p_53432_.getWorld().getBlockAt(p_53433_.getX(), p_53433_.getY(), p_53433_.getZ()); + //Magma - had to add a null check to the source, this could be a potential problem for plugins interacting with mods but there was no other way -+ org.bukkit.block.Block sourceBlock = source == null ? null : p_53432_.getWorld().getBlockAt(source.m_123341_(), source.m_123342_(), source.m_123343_()); ++ org.bukkit.block.Block sourceBlock = source == null ? null : p_53432_.getWorld().getBlockAt(source.getX(), source.getY(), source.getZ()); + org.bukkit.event.block.BlockBurnEvent event = new org.bukkit.event.block.BlockBurnEvent(theBlock, sourceBlock); + p_53432_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { @@ -189,11 +189,11 @@ + } + // CraftBukkit end + -+ if (p_53435_.nextInt(p_53436_ + 10) < 5 && !p_53432_.m_46758_(p_53433_)) { ++ if (p_53435_.nextInt(p_53436_ + 10) < 5 && !p_53432_.isRainingAt(p_53433_)) { + int j = Math.min(p_53436_ + p_53435_.nextInt(5) / 4, 15); -+ p_53432_.m_7731_(p_53433_, this.m_53437_(p_53432_, p_53433_, j), 3); ++ p_53432_.setBlock(p_53433_, this.getStateWithAge(p_53432_, p_53433_, j), 3); + } else { -+ p_53432_.m_7471_(p_53433_, false); ++ p_53432_.removeBlock(p_53433_, false); + } + + blockstate.onCaughtFire(p_53432_, p_53433_, face, null); @@ -206,24 +206,24 @@ + } + //Magma end + - private void m_53431_(Level p_53432_, BlockPos p_53433_, int p_53434_, Random p_53435_, int p_53436_) { - int i = this.m_53492_(p_53432_.m_8055_(p_53433_)); + private void checkBurnOut(Level p_53432_, BlockPos p_53433_, int p_53434_, Random p_53435_, int p_53436_) { + int i = this.getBurnOdd(p_53432_.getBlockState(p_53433_)); if (p_53435_.nextInt(p_53434_) < i) { @@ -239,7 +_,7 @@ - private boolean m_53485_(BlockGetter p_53486_, BlockPos p_53487_) { + private boolean isValidFireLocation(BlockGetter p_53486_, BlockPos p_53487_) { for(Direction direction : Direction.values()) { -- if (this.m_7599_(p_53486_.m_8055_(p_53487_.m_142300_(direction)))) { -+ if (this.canCatchFire(p_53486_, p_53487_.m_142300_(direction), direction.m_122424_())) { +- if (this.canBurn(p_53486_.getBlockState(p_53487_.relative(direction)))) { ++ if (this.canCatchFire(p_53486_, p_53487_.relative(direction), direction.getOpposite())) { return true; } } @@ -255,13 +_,14 @@ for(Direction direction : Direction.values()) { - BlockState blockstate = p_53442_.m_8055_(p_53443_.m_142300_(direction)); -- i = Math.max(this.m_53494_(blockstate), i); -+ i = Math.max(blockstate.getFireSpreadSpeed(p_53442_, p_53443_.m_142300_(direction), direction.m_122424_()), i); + BlockState blockstate = p_53442_.getBlockState(p_53443_.relative(direction)); +- i = Math.max(this.getFlameOdds(blockstate), i); ++ i = Math.max(blockstate.getFireSpreadSpeed(p_53442_, p_53443_.relative(direction), direction.getOpposite()), i); } return i; @@ -231,16 +231,16 @@ } + @Deprecated //Forge: Use canCatchFire with more context - protected boolean m_7599_(BlockState p_53489_) { - return this.m_53494_(p_53489_) > 0; + protected boolean canBurn(BlockState p_53489_) { + return this.getFlameOdds(p_53489_) > 0; } @@ -280,8 +_,21 @@ } - private void m_53444_(Block p_53445_, int p_53446_, int p_53447_) { -+ if (p_53445_ == Blocks.f_50016_) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); - this.f_53421_.put(p_53445_, p_53446_); - this.f_53422_.put(p_53445_, p_53447_); + private void setFlammable(Block p_53445_, int p_53446_, int p_53447_) { ++ if (p_53445_ == Blocks.AIR) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + this.flameOdds.put(p_53445_, p_53446_); + this.burnOdds.put(p_53445_, p_53447_); + } + + /** @@ -252,7 +252,7 @@ + * @return True if the face can catch fire. + */ + public boolean canCatchFire(BlockGetter world, BlockPos pos, Direction face) { -+ return world.m_8055_(pos).isFlammable(world, pos, face); ++ return world.getBlockState(pos).isFlammable(world, pos, face); } - public static void m_53484_() { + public static void bootStrap() { diff --git a/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch index d38589fa..f2edcaad 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/level/block/FlowerBlock.java +++ b/net/minecraft/world/level/block/FlowerBlock.java @@ -15,6 +_,17 @@ - private final MobEffect f_53508_; - private final int f_53509_; + private final MobEffect suspiciousStewEffect; + private final int effectDuration; + private final java.util.function.Supplier suspiciousStewEffectSupplier; + + public FlowerBlock(java.util.function.Supplier effectSupplier, int p_53513_, BlockBehaviour.Properties p_53514_) { + super(p_53514_); -+ this.f_53508_ = null; ++ this.suspiciousStewEffect = null; + this.suspiciousStewEffectSupplier = effectSupplier; -+ this.f_53509_ = p_53513_; ++ this.effectDuration = p_53513_; + } + + /** @deprecated FORGE: Use supplier version instead */ + @Deprecated public FlowerBlock(MobEffect p_53512_, int p_53513_, BlockBehaviour.Properties p_53514_) { super(p_53514_); - this.f_53508_ = p_53512_; + this.suspiciousStewEffect = p_53512_; @@ -23,6 +_,7 @@ } else { - this.f_53509_ = p_53513_ * 20; + this.effectDuration = p_53513_ * 20; } + this.suspiciousStewEffectSupplier = net.minecraftforge.registries.RegistryObject.create(p_53512_.getRegistryName(), net.minecraftforge.registries.ForgeRegistries.MOB_EFFECTS); @@ -29,13 +29,13 @@ @@ -36,10 +_,12 @@ } - public MobEffect m_53521_() { + public MobEffect getSuspiciousStewEffect() { + if (true) return this.suspiciousStewEffectSupplier.get(); - return this.f_53508_; + return this.suspiciousStewEffect; } - public int m_53522_() { -+ if (!this.suspiciousStewEffectSupplier.get().m_8093_()) return this.f_53509_ * 20; - return this.f_53509_; + public int getEffectDuration() { ++ if (!this.suspiciousStewEffectSupplier.get().isInstantenous()) return this.effectDuration * 20; + return this.effectDuration; } } 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 910de9bc..5341fcb5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java @@ -28,10 +_,33 @@ - protected static final VoxelShape f_53523_ = Block.m_49796_(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); - private final Block f_53525_; + protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); + private final Block content; + @Deprecated // Mods should use the constructor below public FlowerPotBlock(Block p_53528_, BlockBehaviour.Properties p_53529_) { - super(p_53529_); -- this.f_53525_ = p_53528_; -- f_53524_.put(p_53528_, this); -+ this(Blocks.f_50276_ == null ? null : () -> (FlowerPotBlock) Blocks.f_50276_.delegate.get(), () -> p_53528_.delegate.get(), p_53529_); -+ if (Blocks.f_50276_ != null) { -+ ((FlowerPotBlock)Blocks.f_50276_).addPlant(p_53528_.getRegistryName(), () -> this); +- this.content = p_53528_; +- POTTED_BY_CONTENT.put(p_53528_, this); ++ this(Blocks.FLOWER_POT == null ? null : () -> (FlowerPotBlock) Blocks.FLOWER_POT.delegate.get(), () -> p_53528_.delegate.get(), p_53529_); ++ if (Blocks.FLOWER_POT != null) { ++ ((FlowerPotBlock)Blocks.FLOWER_POT).addPlant(p_53528_.getRegistryName(), () -> this); + } + } + @@ -25,7 +25,7 @@ + */ + public FlowerPotBlock(@javax.annotation.Nullable java.util.function.Supplier emptyPot, java.util.function.Supplier p_53528_, BlockBehaviour.Properties properties) { + super(properties); -+ this.f_53525_ = null; // Unused, redirected by coremod ++ this.content = null; // Unused, redirected by coremod + this.flowerDelegate = p_53528_; + if (emptyPot == null) { + this.fullPots = Maps.newHashMap(); @@ -36,34 +36,34 @@ + } } - public VoxelShape m_5940_(BlockState p_53556_, BlockGetter p_53557_, BlockPos p_53558_, CollisionContext p_53559_) { + public VoxelShape getShape(BlockState p_53556_, BlockGetter p_53557_, BlockPos p_53558_, CollisionContext p_53559_) { @@ -45,7 +_,7 @@ - public InteractionResult m_6227_(BlockState p_53540_, Level p_53541_, BlockPos p_53542_, Player p_53543_, InteractionHand p_53544_, BlockHitResult p_53545_) { - ItemStack itemstack = p_53543_.m_21120_(p_53544_); - Item item = itemstack.m_41720_(); -- BlockState blockstate = (item instanceof BlockItem ? f_53524_.getOrDefault(((BlockItem)item).m_40614_(), Blocks.f_50016_) : Blocks.f_50016_).m_49966_(); -+ BlockState blockstate = (item instanceof BlockItem ? getEmptyPot().fullPots.getOrDefault(((BlockItem)item).m_40614_().getRegistryName(), Blocks.f_50016_.delegate).get() : Blocks.f_50016_).m_49966_(); - boolean flag = blockstate.m_60713_(Blocks.f_50016_); - boolean flag1 = this.m_153267_(); + public InteractionResult use(BlockState p_53540_, Level p_53541_, BlockPos p_53542_, Player p_53543_, InteractionHand p_53544_, BlockHitResult p_53545_) { + ItemStack itemstack = p_53543_.getItemInHand(p_53544_); + Item item = itemstack.getItem(); +- BlockState blockstate = (item instanceof BlockItem ? POTTED_BY_CONTENT.getOrDefault(((BlockItem)item).getBlock(), Blocks.AIR) : Blocks.AIR).defaultBlockState(); ++ BlockState blockstate = (item instanceof BlockItem ? getEmptyPot().fullPots.getOrDefault(((BlockItem)item).getBlock().getRegistryName(), Blocks.AIR.delegate).get() : Blocks.AIR).defaultBlockState(); + boolean flag = blockstate.is(Blocks.AIR); + boolean flag1 = this.isEmpty(); if (flag != flag1) { @@ -63,7 +_,7 @@ - p_53543_.m_36176_(itemstack1, false); + p_53543_.drop(itemstack1, false); } -- p_53541_.m_7731_(p_53542_, Blocks.f_50276_.m_49966_(), 3); -+ p_53541_.m_7731_(p_53542_, getEmptyPot().m_49966_(), 3); +- p_53541_.setBlock(p_53542_, Blocks.FLOWER_POT.defaultBlockState(), 3); ++ p_53541_.setBlock(p_53542_, getEmptyPot().defaultBlockState(), 3); } - p_53541_.m_142346_(p_53543_, GameEvent.f_157792_, p_53542_); + p_53541_.gameEvent(p_53543_, GameEvent.BLOCK_CHANGE, p_53542_); @@ -86,10 +_,31 @@ } - public Block m_53560_() { -- return this.f_53525_; + public Block getContent() { +- return this.content; + return flowerDelegate.get(); } - public boolean m_7357_(BlockState p_53535_, BlockGetter p_53536_, BlockPos p_53537_, PathComputationType p_53538_) { + public boolean isPathfindable(BlockState p_53535_, BlockGetter p_53536_, BlockPos p_53537_, PathComputationType p_53538_) { return false; } + diff --git a/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch index 4b4a3703..bdaea43b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch @@ -3,17 +3,17 @@ @@ -44,6 +_,16 @@ } - public void m_7719_(ServerLevel p_53603_, Random p_53604_, BlockPos p_53605_, BlockState p_53606_) { + public void performBonemeal(ServerLevel p_53603_, Random p_53604_, BlockPos p_53605_, BlockState p_53606_) { + // CraftBukkit start -+ if (this == Blocks.f_50691_) { ++ if (this == Blocks.WARPED_FUNGUS) { + SaplingBlock.treeType = org.bukkit.TreeType.WARPED_FUNGUS; -+ } else if (this == Blocks.f_50700_) { ++ } else if (this == Blocks.CRIMSON_FUNGUS) { + SaplingBlock.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; + } + // CraftBukkit end - this.f_53597_.get().m_203334_().m_65385_(p_53603_, p_53603_.m_7726_().m_8481_(), p_53604_, p_53605_); -+ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_53603_, p_53604_, p_53605_, this.f_53597_.get()); + this.feature.get().value().place(p_53603_, p_53603_.getChunkSource().getGenerator(), p_53604_, p_53605_); ++ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_53603_, p_53604_, p_53605_, this.feature.get()); + if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return; -+ event.getFeature().m_203334_().m_65385_(p_53603_, p_53603_.m_7726_().m_8481_(), p_53604_, p_53605_); ++ event.getFeature().value().place(p_53603_, p_53603_.getChunkSource().getGenerator(), p_53604_, p_53605_); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch index 026e5713..53689e5e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch @@ -3,14 +3,14 @@ @@ -35,10 +_,11 @@ } - public void m_7455_(BlockState p_53963_, ServerLevel p_53964_, BlockPos p_53965_, Random p_53966_) { -- if (p_53963_.m_61143_(f_53924_) < 25 && p_53966_.nextDouble() < this.f_53925_) { -+ if (p_53963_.m_61143_(f_53924_) < 25 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_53964_, p_53965_.m_142300_(this.f_53859_), p_53964_.m_8055_(p_53965_.m_142300_(this.f_53859_)),p_53966_.nextDouble() < (100.0D / p_53964_.spigotConfig.kelpModifier) * this.f_53925_)) { // Spigot - BlockPos blockpos = p_53965_.m_142300_(this.f_53859_); - if (this.m_5971_(p_53964_.m_8055_(blockpos))) { -- p_53964_.m_46597_(blockpos, this.m_142452_(p_53963_, p_53964_.f_46441_)); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_53964_, p_53965_, blockpos, this.m_142452_(p_53963_, p_53964_.f_46441_)); // CraftBukkit -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_53964_, blockpos, p_53964_.m_8055_(blockpos)); + public void randomTick(BlockState p_53963_, ServerLevel p_53964_, BlockPos p_53965_, Random p_53966_) { +- if (p_53963_.getValue(AGE) < 25 && p_53966_.nextDouble() < this.growPerTickProbability) { ++ if (p_53963_.getValue(AGE) < 25 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_53964_, p_53965_.relative(this.growthDirection), p_53964_.getBlockState(p_53965_.relative(this.growthDirection)),p_53966_.nextDouble() < (100.0D / p_53964_.spigotConfig.kelpModifier) * this.growPerTickProbability)) { // Spigot + BlockPos blockpos = p_53965_.relative(this.growthDirection); + if (this.canGrowInto(p_53964_.getBlockState(blockpos))) { +- p_53964_.setBlockAndUpdate(blockpos, this.getGrowIntoState(p_53963_, p_53964_.random)); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_53964_, p_53965_, blockpos, this.getGrowIntoState(p_53963_, p_53964_.random)); // CraftBukkit ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_53964_, blockpos, p_53964_.getBlockState(blockpos)); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/IceBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/IceBlock.java.patch index 9d6167a9..8be099d5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/IceBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/IceBlock.java.patch @@ -3,12 +3,12 @@ @@ -45,6 +_,11 @@ } - protected void m_54168_(BlockState p_54169_, Level p_54170_, BlockPos p_54171_) { + protected void melt(BlockState p_54169_, Level p_54170_, BlockPos p_54171_) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_54170_, p_54171_, p_54170_.m_6042_().m_63951_() ? Blocks.f_50016_.m_49966_() : Blocks.f_49990_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_54170_, p_54171_, p_54170_.dimensionType().ultraWarm() ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - if (p_54170_.m_6042_().m_63951_()) { - p_54170_.m_7471_(p_54171_, false); + if (p_54170_.dimensionType().ultraWarm()) { + p_54170_.removeBlock(p_54171_, false); } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/InfestedBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/InfestedBlock.java.patch index d33688a9..50ef38d3 100644 --- a/patches/minecraft/net/minecraft/world/level/block/InfestedBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/InfestedBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/InfestedBlock.java +++ b/net/minecraft/world/level/block/InfestedBlock.java @@ -40,6 +_,7 @@ - private void m_54180_(ServerLevel p_54181_, BlockPos p_54182_) { - Silverfish silverfish = EntityType.f_20523_.m_20615_(p_54181_); - silverfish.m_7678_((double)p_54182_.m_123341_() + 0.5D, (double)p_54182_.m_123342_(), (double)p_54182_.m_123343_() + 0.5D, 0.0F, 0.0F); + private void spawnInfestation(ServerLevel p_54181_, BlockPos p_54182_) { + Silverfish silverfish = EntityType.SILVERFISH.create(p_54181_); + silverfish.moveTo((double)p_54182_.getX() + 0.5D, (double)p_54182_.getY(), (double)p_54182_.getZ() + 0.5D, 0.0F, 0.0F); + p_54181_.prepareEntity(silverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SILVERFISH_BLOCK); //Magma - add spawn reason - p_54181_.m_7967_(silverfish); - silverfish.m_21373_(); + p_54181_.addFreshEntity(silverfish); + silverfish.spawnAnim(); } diff --git a/patches/minecraft/net/minecraft/world/level/block/JukeboxBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/JukeboxBlock.java.patch index 69b317c9..f81a6505 100644 --- a/patches/minecraft/net/minecraft/world/level/block/JukeboxBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/JukeboxBlock.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/block/JukeboxBlock.java +++ b/net/minecraft/world/level/block/JukeboxBlock.java @@ -54,7 +_,13 @@ - public void m_54269_(LevelAccessor p_54270_, BlockPos p_54271_, BlockState p_54272_, ItemStack p_54273_) { - BlockEntity blockentity = p_54270_.m_7702_(p_54271_); + public void setRecord(LevelAccessor p_54270_, BlockPos p_54271_, BlockState p_54272_, ItemStack p_54273_) { + BlockEntity blockentity = p_54270_.getBlockEntity(p_54271_); if (blockentity instanceof JukeboxBlockEntity) { -- ((JukeboxBlockEntity)blockentity).m_59517_(p_54273_.m_41777_()); +- ((JukeboxBlockEntity)blockentity).setRecord(p_54273_.copy()); + // CraftBukkit start - There can only be one -+ p_54273_ = p_54273_.m_41777_(); -+ if (!p_54273_.m_41619_()) { -+ p_54273_.m_41764_(1); ++ p_54273_ = p_54273_.copy(); ++ if (!p_54273_.isEmpty()) { ++ p_54273_.setCount(1); + } -+ ((JukeboxBlockEntity) blockentity).m_59517_(p_54273_); ++ ((JukeboxBlockEntity) blockentity).setRecord(p_54273_); + // CraftBukkit end - p_54270_.m_7731_(p_54271_, p_54272_.m_61124_(f_54254_, Boolean.valueOf(true)), 2); + p_54270_.setBlock(p_54271_, p_54272_.setValue(HAS_RECORD, Boolean.valueOf(true)), 2); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch index 46ff6cf6..42b0a6b9 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch @@ -4,133 +4,133 @@ import net.minecraft.world.level.material.Fluids; public class LayeredCauldronBlock extends AbstractCauldronBlock { -- public static final int f_153512_ = 1; -- public static final int f_153513_ = 3; -- public static final IntegerProperty f_153514_ = BlockStateProperties.f_61418_; -- private static final int f_153517_ = 6; -- private static final double f_153518_ = 3.0D; -- public static final Predicate f_153515_ = (p_153553_) -> { +- public static final int MIN_FILL_LEVEL = 1; +- public static final int MAX_FILL_LEVEL = 3; +- public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_CAULDRON; +- private static final int BASE_CONTENT_HEIGHT = 6; +- private static final double HEIGHT_PER_LEVEL = 3.0D; +- public static final Predicate RAIN = (p_153553_) -> { - return p_153553_ == Biome.Precipitation.RAIN; - }; -- public static final Predicate f_153516_ = (p_153526_) -> { +- public static final Predicate SNOW = (p_153526_) -> { - return p_153526_ == Biome.Precipitation.SNOW; - }; -- private final Predicate f_153519_; +- private final Predicate fillPredicate; - - public LayeredCauldronBlock(BlockBehaviour.Properties p_153522_, Predicate p_153523_, Map p_153524_) { - super(p_153522_, p_153524_); -- this.f_153519_ = p_153523_; -- this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_153514_, Integer.valueOf(1))); +- this.fillPredicate = p_153523_; +- this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(1))); - } - -- public boolean m_142596_(BlockState p_153555_) { -- return p_153555_.m_61143_(f_153514_) == 3; +- public boolean isFull(BlockState p_153555_) { +- return p_153555_.getValue(LEVEL) == 3; - } - -- protected boolean m_142087_(Fluid p_153551_) { -- return p_153551_ == Fluids.f_76193_ && this.f_153519_ == f_153515_; +- protected boolean canReceiveStalactiteDrip(Fluid p_153551_) { +- return p_153551_ == Fluids.WATER && this.fillPredicate == RAIN; - } - -- protected double m_142446_(BlockState p_153528_) { -- return (6.0D + (double)p_153528_.m_61143_(f_153514_).intValue() * 3.0D) / 16.0D; +- protected double getContentHeight(BlockState p_153528_) { +- return (6.0D + (double)p_153528_.getValue(LEVEL).intValue() * 3.0D) / 16.0D; - } - -- public void m_7892_(BlockState p_153534_, Level p_153535_, BlockPos p_153536_, Entity p_153537_) { -- if (!p_153535_.f_46443_ && p_153537_.m_6060_() && this.m_151979_(p_153534_, p_153536_, p_153537_)) { -- p_153537_.m_20095_(); -- if (p_153537_.m_142265_(p_153535_, p_153536_)) { -- this.m_142266_(p_153534_, p_153535_, p_153536_); +- public void entityInside(BlockState p_153534_, Level p_153535_, BlockPos p_153536_, Entity p_153537_) { +- if (!p_153535_.isClientSide && p_153537_.isOnFire() && this.isEntityInsideContent(p_153534_, p_153536_, p_153537_)) { +- p_153537_.clearFire(); +- if (p_153537_.mayInteract(p_153535_, p_153536_)) { +- this.handleEntityOnFireInside(p_153534_, p_153535_, p_153536_); - } - } - - } - -- protected void m_142266_(BlockState p_153556_, Level p_153557_, BlockPos p_153558_) { -- m_153559_(p_153556_, p_153557_, p_153558_); +- protected void handleEntityOnFireInside(BlockState p_153556_, Level p_153557_, BlockPos p_153558_) { +- lowerFillLevel(p_153556_, p_153557_, p_153558_); - } - -- public static void m_153559_(BlockState p_153560_, Level p_153561_, BlockPos p_153562_) { -- int i = p_153560_.m_61143_(f_153514_) - 1; -- p_153561_.m_46597_(p_153562_, i == 0 ? Blocks.f_50256_.m_49966_() : p_153560_.m_61124_(f_153514_, Integer.valueOf(i))); +- public static void lowerFillLevel(BlockState p_153560_, Level p_153561_, BlockPos p_153562_) { +- int i = p_153560_.getValue(LEVEL) - 1; +- p_153561_.setBlockAndUpdate(p_153562_, i == 0 ? Blocks.CAULDRON.defaultBlockState() : p_153560_.setValue(LEVEL, Integer.valueOf(i))); - } - -- public void m_141997_(BlockState p_153539_, Level p_153540_, BlockPos p_153541_, Biome.Precipitation p_153542_) { -- if (CauldronBlock.m_182450_(p_153540_, p_153542_) && p_153539_.m_61143_(f_153514_) != 3 && this.f_153519_.test(p_153542_)) { -- p_153540_.m_46597_(p_153541_, p_153539_.m_61122_(f_153514_)); +- public void handlePrecipitation(BlockState p_153539_, Level p_153540_, BlockPos p_153541_, Biome.Precipitation p_153542_) { +- if (CauldronBlock.shouldHandlePrecipitation(p_153540_, p_153542_) && p_153539_.getValue(LEVEL) != 3 && this.fillPredicate.test(p_153542_)) { +- p_153540_.setBlockAndUpdate(p_153541_, p_153539_.cycle(LEVEL)); - } - } - -- public int m_6782_(BlockState p_153530_, Level p_153531_, BlockPos p_153532_) { -- return p_153530_.m_61143_(f_153514_); +- public int getAnalogOutputSignal(BlockState p_153530_, Level p_153531_, BlockPos p_153532_) { +- return p_153530_.getValue(LEVEL); - } - -- protected void m_7926_(StateDefinition.Builder p_153549_) { -- p_153549_.m_61104_(f_153514_); +- protected void createBlockStateDefinition(StateDefinition.Builder p_153549_) { +- p_153549_.add(LEVEL); - } - -- protected void m_142310_(BlockState p_153544_, Level p_153545_, BlockPos p_153546_, Fluid p_153547_) { -- if (!this.m_142596_(p_153544_)) { -- p_153545_.m_46597_(p_153546_, p_153544_.m_61124_(f_153514_, Integer.valueOf(p_153544_.m_61143_(f_153514_) + 1))); -- p_153545_.m_46796_(1047, p_153546_, 0); +- protected void receiveStalactiteDrip(BlockState p_153544_, Level p_153545_, BlockPos p_153546_, Fluid p_153547_) { +- if (!this.isFull(p_153544_)) { +- p_153545_.setBlockAndUpdate(p_153546_, p_153544_.setValue(LEVEL, Integer.valueOf(p_153544_.getValue(LEVEL) + 1))); +- p_153545_.levelEvent(1047, p_153546_, 0); - } - } -+ public static final int f_153512_ = 1; -+ public static final int f_153513_ = 3; -+ public static final IntegerProperty f_153514_ = BlockStateProperties.f_61418_; -+ private static final int f_153517_ = 6; -+ private static final double f_153518_ = 3.0D; -+ public static final Predicate f_153515_ = (p_153553_) -> { ++ public static final int MIN_FILL_LEVEL = 1; ++ public static final int MAX_FILL_LEVEL = 3; ++ public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_CAULDRON; ++ private static final int BASE_CONTENT_HEIGHT = 6; ++ private static final double HEIGHT_PER_LEVEL = 3.0D; ++ public static final Predicate RAIN = (p_153553_) -> { + return p_153553_ == Biome.Precipitation.RAIN; + }; -+ public static final Predicate f_153516_ = (p_153526_) -> { ++ public static final Predicate SNOW = (p_153526_) -> { + return p_153526_ == Biome.Precipitation.SNOW; + }; -+ private final Predicate f_153519_; ++ private final Predicate fillPredicate; + + public LayeredCauldronBlock(BlockBehaviour.Properties p_153522_, Predicate p_153523_, Map p_153524_) { + super(p_153522_, p_153524_); -+ this.f_153519_ = p_153523_; -+ this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_153514_, Integer.valueOf(1))); ++ this.fillPredicate = p_153523_; ++ this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(1))); + } + -+ public boolean m_142596_(BlockState p_153555_) { -+ return p_153555_.m_61143_(f_153514_) == 3; ++ public boolean isFull(BlockState p_153555_) { ++ return p_153555_.getValue(LEVEL) == 3; + } + -+ protected boolean m_142087_(Fluid p_153551_) { -+ return p_153551_ == Fluids.f_76193_ && this.f_153519_ == f_153515_; ++ protected boolean canReceiveStalactiteDrip(Fluid p_153551_) { ++ return p_153551_ == Fluids.WATER && this.fillPredicate == RAIN; + } + -+ protected double m_142446_(BlockState p_153528_) { -+ return (6.0D + (double) p_153528_.m_61143_(f_153514_).intValue() * 3.0D) / 16.0D; ++ protected double getContentHeight(BlockState p_153528_) { ++ return (6.0D + (double) p_153528_.getValue(LEVEL).intValue() * 3.0D) / 16.0D; + } + -+ public void m_7892_(BlockState p_153534_, Level p_153535_, BlockPos p_153536_, Entity p_153537_) { -+ if (!p_153535_.f_46443_ && p_153537_.m_6060_() && this.m_151979_(p_153534_, p_153536_, p_153537_)) { ++ public void entityInside(BlockState p_153534_, Level p_153535_, BlockPos p_153536_, Entity p_153537_) { ++ if (!p_153535_.isClientSide && p_153537_.isOnFire() && this.isEntityInsideContent(p_153534_, p_153536_, p_153537_)) { + // CraftBukkit start -+ if (p_153537_.m_142265_(p_153535_, p_153536_)) { ++ if (p_153537_.mayInteract(p_153535_, p_153536_)) { + if (!lowerFillLevel(p_153534_, p_153535_, p_153536_, p_153537_, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { + return; + } + } -+ p_153537_.m_20095_(); ++ p_153537_.clearFire(); + // CraftBukkit end + } + + } + -+ protected void m_142266_(BlockState p_153556_, Level p_153557_, BlockPos p_153558_) { -+ m_153559_(p_153556_, p_153557_, p_153558_); ++ protected void handleEntityOnFireInside(BlockState p_153556_, Level p_153557_, BlockPos p_153558_) { ++ lowerFillLevel(p_153556_, p_153557_, p_153558_); + } + -+ public static void m_153559_(BlockState p_153560_, Level p_153561_, BlockPos p_153562_) { ++ public static void lowerFillLevel(BlockState p_153560_, Level p_153561_, BlockPos p_153562_) { + // CraftBukkit start + lowerFillLevel(p_153560_, p_153561_, p_153562_, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.UNKNOWN); + } + + public static boolean lowerFillLevel(BlockState p_153560_, Level p_153561_, BlockPos p_153562_, Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { -+ int i = p_153560_.m_61143_(f_153514_) - 1; -+ return changeLevel(p_153560_, p_153561_, p_153562_, i == 0 ? Blocks.f_50256_.m_49966_() : p_153560_.m_61124_(LayeredCauldronBlock.f_153514_, i), entity, reason); ++ int i = p_153560_.getValue(LEVEL) - 1; ++ return changeLevel(p_153560_, p_153561_, p_153562_, i == 0 ? Blocks.CAULDRON.defaultBlockState() : p_153560_.setValue(LayeredCauldronBlock.LEVEL, i), entity, reason); + } + + // CraftBukkit start @@ -139,7 +139,7 @@ + newState.setData(newBlock); + + org.bukkit.event.block.CauldronLevelChangeEvent event = new org.bukkit.event.block.CauldronLevelChangeEvent( -+ world.getWorld().getBlockAt(blockposition.m_123341_(), blockposition.m_123342_(), blockposition.m_123343_()), ++ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), + (entity == null) ? null : entity.getBukkitEntity(), reason, newState + ); + world.getCraftServer().getPluginManager().callEvent(event); @@ -152,28 +152,28 @@ + // CraftBukkit end + + -+ public void m_141997_(BlockState p_153539_, Level p_153540_, BlockPos p_153541_, Biome.Precipitation p_153542_) { -+ if (CauldronBlock.m_182450_(p_153540_, p_153542_) && p_153539_.m_61143_(f_153514_) != 3 && this.f_153519_.test(p_153542_)) { -+ changeLevel(p_153539_, p_153540_, p_153541_, (BlockState) p_153539_.m_61122_(LayeredCauldronBlock.f_153514_), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit ++ public void handlePrecipitation(BlockState p_153539_, Level p_153540_, BlockPos p_153541_, Biome.Precipitation p_153542_) { ++ if (CauldronBlock.shouldHandlePrecipitation(p_153540_, p_153542_) && p_153539_.getValue(LEVEL) != 3 && this.fillPredicate.test(p_153542_)) { ++ changeLevel(p_153539_, p_153540_, p_153541_, (BlockState) p_153539_.cycle(LayeredCauldronBlock.LEVEL), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + } + } + -+ public int m_6782_(BlockState p_153530_, Level p_153531_, BlockPos p_153532_) { -+ return p_153530_.m_61143_(f_153514_); ++ public int getAnalogOutputSignal(BlockState p_153530_, Level p_153531_, BlockPos p_153532_) { ++ return p_153530_.getValue(LEVEL); + } + -+ protected void m_7926_(StateDefinition.Builder p_153549_) { -+ p_153549_.m_61104_(f_153514_); ++ protected void createBlockStateDefinition(StateDefinition.Builder p_153549_) { ++ p_153549_.add(LEVEL); + } + -+ protected void m_142310_(BlockState p_153544_, Level p_153545_, BlockPos p_153546_, Fluid p_153547_) { -+ if (!this.m_142596_(p_153544_)) { ++ protected void receiveStalactiteDrip(BlockState p_153544_, Level p_153545_, BlockPos p_153546_, Fluid p_153547_) { ++ if (!this.isFull(p_153544_)) { + // CraftBukkit start -+ if (!changeLevel(p_153544_, p_153545_, p_153546_, (BlockState) p_153544_.m_61124_(LayeredCauldronBlock.f_153514_, (Integer) p_153544_.m_61143_(LayeredCauldronBlock.f_153514_) + 1), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { ++ if (!changeLevel(p_153544_, p_153545_, p_153546_, (BlockState) p_153544_.setValue(LayeredCauldronBlock.LEVEL, (Integer) p_153544_.getValue(LayeredCauldronBlock.LEVEL) + 1), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { + return; + } + // CraftBukkit end -+ p_153545_.m_46796_(1047, p_153546_, 0); ++ p_153545_.levelEvent(1047, p_153546_, 0); + } + } } 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 78ada0a6..f0c2cdc7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -6,21 +6,21 @@ -public class LeavesBlock extends Block { +public class LeavesBlock extends Block implements net.minecraftforge.common.IForgeShearable { - public static final int f_153563_ = 7; - public static final IntegerProperty f_54418_ = BlockStateProperties.f_61414_; - public static final BooleanProperty f_54419_ = BlockStateProperties.f_61447_; + public static final int DECAY_DISTANCE = 7; + public static final IntegerProperty DISTANCE = BlockStateProperties.DISTANCE; + public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT; @@ -40,6 +_,14 @@ - public void m_7455_(BlockState p_54451_, ServerLevel p_54452_, BlockPos p_54453_, Random p_54454_) { - if (!p_54451_.m_61143_(f_54419_) && p_54451_.m_61143_(f_54418_) == 7) { + public void randomTick(BlockState p_54451_, ServerLevel p_54452_, BlockPos p_54453_, Random p_54454_) { + if (!p_54451_.getValue(PERSISTENT) && p_54451_.getValue(DISTANCE) == 7) { + // CraftBukkit start -+ org.bukkit.event.block.LeavesDecayEvent event = new org.bukkit.event.block.LeavesDecayEvent(p_54452_.getWorld().getBlockAt(p_54453_.m_123341_(), p_54453_.m_123342_(), p_54453_.m_123343_())); ++ org.bukkit.event.block.LeavesDecayEvent event = new org.bukkit.event.block.LeavesDecayEvent(p_54452_.getWorld().getBlockAt(p_54453_.getX(), p_54453_.getY(), p_54453_.getZ())); + p_54452_.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled() || p_54452_.m_8055_(p_54453_).m_60734_() != this) { ++ if (event.isCancelled() || p_54452_.getBlockState(p_54453_).getBlock() != this) { + return; + } + // CraftBukkit end - m_49950_(p_54451_, p_54452_, p_54453_); - p_54452_.m_7471_(p_54453_, false); + dropResources(p_54451_, p_54452_, p_54453_); + p_54452_.removeBlock(p_54453_, false); } diff --git a/patches/minecraft/net/minecraft/world/level/block/LecternBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LecternBlock.java.patch index eb1027f5..6eb30de1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LecternBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LecternBlock.java.patch @@ -3,14 +3,14 @@ @@ -180,11 +_,12 @@ } - private void m_54587_(BlockState p_54588_, Level p_54589_, BlockPos p_54590_) { -- BlockEntity blockentity = p_54589_.m_7702_(p_54590_); + private void popBook(BlockState p_54588_, Level p_54589_, BlockPos p_54590_) { +- BlockEntity blockentity = p_54589_.getBlockEntity(p_54590_); + BlockEntity blockentity = p_54589_.getBlockEntity(p_54590_, false); // CraftBukkit - don't validate, type may be changed already if (blockentity instanceof LecternBlockEntity) { LecternBlockEntity lecternblockentity = (LecternBlockEntity)blockentity; - Direction direction = p_54588_.m_61143_(f_54465_); - ItemStack itemstack = lecternblockentity.m_59566_().m_41777_(); -+ if (itemstack.m_41619_()) return; // CraftBukkit - SPIGOT-5500 - float f = 0.25F * (float)direction.m_122429_(); - float f1 = 0.25F * (float)direction.m_122431_(); - ItemEntity itementity = new ItemEntity(p_54589_, (double)p_54590_.m_123341_() + 0.5D + (double)f, (double)(p_54590_.m_123342_() + 1), (double)p_54590_.m_123343_() + 0.5D + (double)f1, itemstack); + Direction direction = p_54588_.getValue(FACING); + ItemStack itemstack = lecternblockentity.getBook().copy(); ++ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500 + float f = 0.25F * (float)direction.getStepX(); + float f1 = 0.25F * (float)direction.getStepZ(); + ItemEntity itementity = new ItemEntity(p_54589_, (double)p_54590_.getX() + 0.5D + (double)f, (double)(p_54590_.getY() + 1), (double)p_54590_.getZ() + 0.5D + (double)f1, itemstack); diff --git a/patches/minecraft/net/minecraft/world/level/block/LeverBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LeverBlock.java.patch index 5007292f..013cd047 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LeverBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LeverBlock.java.patch @@ -5,8 +5,8 @@ return InteractionResult.SUCCESS; } else { + // CraftBukkit start - Interact Lever -+ boolean powered = p_54640_.m_61143_(f_54622_); // Old powered state -+ org.bukkit.block.Block block = p_54641_.getWorld().getBlockAt(p_54642_.m_123341_(), p_54642_.m_123342_(), p_54642_.m_123343_()); ++ boolean powered = p_54640_.getValue(POWERED); // Old powered state ++ org.bukkit.block.Block block = p_54641_.getWorld().getBlockAt(p_54642_.getX(), p_54642_.getY(), p_54642_.getZ()); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -17,6 +17,6 @@ + return InteractionResult.SUCCESS; + } + // CraftBukkit end - BlockState blockstate = this.m_54676_(p_54640_, p_54641_, p_54642_); - float f = blockstate.m_61143_(f_54622_) ? 0.6F : 0.5F; - p_54641_.m_5594_((Player)null, p_54642_, SoundEvents.f_12088_, SoundSource.BLOCKS, 0.3F, f); + BlockState blockstate = this.pull(p_54640_, p_54641_, p_54642_); + float f = blockstate.getValue(POWERED) ? 0.6F : 0.5F; + p_54641_.playSound((Player)null, p_54642_, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, f); diff --git a/patches/minecraft/net/minecraft/world/level/block/LightningRodBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LightningRodBlock.java.patch index a4f38cc7..f1da80ec 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LightningRodBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LightningRodBlock.java.patch @@ -3,9 +3,9 @@ @@ -70,6 +_,18 @@ } - public void m_153760_(BlockState p_153761_, Level p_153762_, BlockPos p_153763_) { + public void onLightningStrike(BlockState p_153761_, Level p_153762_, BlockPos p_153763_) { + // CraftBukkit start -+ boolean powered = p_153761_.m_61143_(LightningRodBlock.f_153703_); ++ boolean powered = p_153761_.getValue(LightningRodBlock.POWERED); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -16,15 +16,15 @@ + return; + } + // CraftBukkit end - p_153762_.m_7731_(p_153763_, p_153761_.m_61124_(f_153703_, Boolean.valueOf(true)), 3); - this.m_153764_(p_153761_, p_153762_, p_153763_); - p_153762_.m_186460_(p_153763_, this, 8); + p_153762_.setBlock(p_153763_, p_153761_.setValue(POWERED, Boolean.valueOf(true)), 3); + this.updateNeighbours(p_153761_, p_153762_, p_153763_); + p_153762_.scheduleTick(p_153763_, this, 8); @@ -118,7 +_,7 @@ - lightningbolt.m_20219_(Vec3.m_82539_(blockpos.m_7494_())); - Entity entity = p_153716_.m_37282_(); - lightningbolt.m_20879_(entity instanceof ServerPlayer ? (ServerPlayer)entity : null); -- p_153713_.m_7967_(lightningbolt); + lightningbolt.moveTo(Vec3.atBottomCenterOf(blockpos.above())); + Entity entity = p_153716_.getOwner(); + lightningbolt.setCause(entity instanceof ServerPlayer ? (ServerPlayer)entity : null); +- p_153713_.addFreshEntity(lightningbolt); + ((ServerLevel) p_153713_).strikeLightning(lightningbolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit - p_153713_.m_5594_((Player)null, blockpos, SoundEvents.f_12521_, SoundSource.WEATHER, 5.0F, 1.0F); + p_153713_.playSound((Player)null, blockpos, SoundEvents.TRIDENT_THUNDER, SoundSource.WEATHER, 5.0F, 1.0F); } } 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 8c523195..f71809d7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -3,22 +3,22 @@ @@ -30,11 +_,13 @@ public class LiquidBlock extends Block implements BucketPickup { - public static final IntegerProperty f_54688_ = BlockStateProperties.f_61422_; -- protected final FlowingFluid f_54689_; + public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL; +- protected final FlowingFluid fluid; + @Deprecated // Use getFluid -+ private final FlowingFluid f_54689_; - private final List f_54691_; - public static final VoxelShape f_54690_ = Block.m_49796_(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); - public static final ImmutableList f_181233_ = ImmutableList.of(Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST); ++ private final FlowingFluid fluid; + private final List stateCache; + public static final VoxelShape STABLE_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); + public static final ImmutableList POSSIBLE_FLOW_DIRECTIONS = ImmutableList.of(Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST); + @Deprecated // Forge: Use the constructor that takes a supplier public LiquidBlock(FlowingFluid p_54694_, BlockBehaviour.Properties p_54695_) { super(p_54695_); - this.f_54689_ = p_54694_; + this.fluid = p_54694_; @@ -47,6 +_,19 @@ - this.f_54691_.add(p_54694_.m_75953_(8, true)); - this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_54688_, Integer.valueOf(0))); + this.stateCache.add(p_54694_.getFlowing(8, true)); + this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0))); + fluidStateCacheInitialized = true; + supplier = p_54694_.delegate; + } @@ -28,50 +28,50 @@ + */ + public LiquidBlock(java.util.function.Supplier p_54694_, BlockBehaviour.Properties p_54695_) { + super(p_54695_); -+ this.f_54689_ = null; -+ this.f_54691_ = Lists.newArrayList(); -+ this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_54688_, Integer.valueOf(0))); ++ this.fluid = null; ++ this.stateCache = Lists.newArrayList(); ++ this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0))); + this.supplier = p_54694_; } - public VoxelShape m_5939_(BlockState p_54760_, BlockGetter p_54761_, BlockPos p_54762_, CollisionContext p_54763_) { + public VoxelShape getCollisionShape(BlockState p_54760_, BlockGetter p_54761_, BlockPos p_54762_, CollisionContext p_54763_) { @@ -71,6 +_,7 @@ - public FluidState m_5888_(BlockState p_54765_) { - int i = p_54765_.m_61143_(f_54688_); + public FluidState getFluidState(BlockState p_54765_) { + int i = p_54765_.getValue(LEVEL); + if (!fluidStateCacheInitialized) initFluidStateCache(); - return this.f_54691_.get(Math.min(i, 8)); + return this.stateCache.get(Math.min(i, 8)); } @@ -120,14 +_,20 @@ - BlockPos blockpos = p_54698_.m_142300_(direction.m_122424_()); - if (p_54697_.m_6425_(blockpos).m_205070_(FluidTags.f_13131_)) { - Block block = p_54697_.m_6425_(p_54698_).m_76170_() ? Blocks.f_50080_ : Blocks.f_50652_; -- p_54697_.m_46597_(p_54698_, block.m_49966_()); -- this.m_54700_(p_54697_, p_54698_); + BlockPos blockpos = p_54698_.relative(direction.getOpposite()); + if (p_54697_.getFluidState(blockpos).is(FluidTags.WATER)) { + Block block = p_54697_.getFluidState(p_54698_).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; +- p_54697_.setBlockAndUpdate(p_54698_, block.defaultBlockState()); +- this.fizz(p_54697_, p_54698_); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_54697_, p_54698_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_54697_, p_54698_, p_54698_, block.m_49966_()))) { -+ this.m_54700_(p_54697_, p_54698_); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_54697_, p_54698_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_54697_, p_54698_, p_54698_, block.defaultBlockState()))) { ++ this.fizz(p_54697_, p_54698_); + } + // CraftBukkit end return false; } - if (flag && p_54697_.m_8055_(blockpos).m_60713_(Blocks.f_50568_)) { -- p_54697_.m_46597_(p_54698_, Blocks.f_50137_.m_49966_()); -- this.m_54700_(p_54697_, p_54698_); + if (flag && p_54697_.getBlockState(blockpos).is(Blocks.BLUE_ICE)) { +- p_54697_.setBlockAndUpdate(p_54698_, Blocks.BASALT.defaultBlockState()); +- this.fizz(p_54697_, p_54698_); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_54697_, p_54698_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_54697_, p_54698_, p_54698_, Blocks.f_50137_.m_49966_()))) { -+ this.m_54700_(p_54697_, p_54698_); ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_54697_, p_54698_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_54697_, p_54698_, p_54698_, Blocks.BASALT.defaultBlockState()))) { ++ this.fizz(p_54697_, p_54698_); + } + // CraftBukkit end return false; } } @@ -150,6 +_,25 @@ - return new ItemStack(this.f_54689_.m_6859_()); + return new ItemStack(this.fluid.getBucket()); } else { - return ItemStack.f_41583_; + return ItemStack.EMPTY; + } + } + @@ -84,12 +84,12 @@ + private boolean fluidStateCacheInitialized = false; + protected synchronized void initFluidStateCache() { + if (fluidStateCacheInitialized == false) { -+ this.f_54691_.add(getFluid().m_76068_(false)); ++ this.stateCache.add(getFluid().getSource(false)); + + for (int i = 1; i < 8; ++i) -+ this.f_54691_.add(getFluid().m_75953_(8 - i, false)); ++ this.stateCache.add(getFluid().getFlowing(8 - i, false)); + -+ this.f_54691_.add(getFluid().m_75953_(8, true)); ++ this.stateCache.add(getFluid().getFlowing(8, true)); + fluidStateCacheInitialized = true; } } diff --git a/patches/minecraft/net/minecraft/world/level/block/MagmaBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/MagmaBlock.java.patch index 17281443..45fcda0e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/MagmaBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/MagmaBlock.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/level/block/MagmaBlock.java @@ -27,7 +_,9 @@ - public void m_141947_(Level p_153777_, BlockPos p_153778_, BlockState p_153779_, Entity p_153780_) { - if (!p_153780_.m_5825_() && p_153780_ instanceof LivingEntity && !EnchantmentHelper.m_44938_((LivingEntity)p_153780_)) { -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = p_153777_.getWorld().getBlockAt(p_153778_.m_123341_(), p_153778_.m_123342_(), p_153778_.m_123343_()); // CraftBukkit - p_153780_.m_6469_(DamageSource.f_19309_, 1.0F); + public void stepOn(Level p_153777_, BlockPos p_153778_, BlockState p_153779_, Entity p_153780_) { + if (!p_153780_.fireImmune() && p_153780_ instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)p_153780_)) { ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = p_153777_.getWorld().getBlockAt(p_153778_.getX(), p_153778_.getY(), p_153778_.getZ()); // CraftBukkit + p_153780_.hurt(DamageSource.HOT_FLOOR, 1.0F); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; // CraftBukkit } - super.m_141947_(p_153777_, p_153778_, p_153779_, p_153780_); + super.stepOn(p_153777_, p_153778_, p_153779_, p_153780_); diff --git a/patches/minecraft/net/minecraft/world/level/block/MultifaceBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/MultifaceBlock.java.patch index 4ee1a5c8..f01d29c4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/MultifaceBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/MultifaceBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/MultifaceBlock.java +++ b/net/minecraft/world/level/block/MultifaceBlock.java @@ -190,7 +_,7 @@ - Optional> optional = this.m_153855_(p_153867_, p_153868_, p_153869_, p_153870_, p_153871_); + Optional> optional = this.getSpreadFromFaceTowardDirection(p_153867_, p_153868_, p_153869_, p_153870_, p_153871_); if (optional.isPresent()) { Pair pair = optional.get(); -- return this.m_153834_(p_153868_, pair.getFirst(), pair.getSecond(), p_153872_); +- return this.spreadToFace(p_153868_, pair.getFirst(), pair.getSecond(), p_153872_); + return this.spreadToFace(p_153868_, pair.getFirst(), pair.getSecond(), p_153872_, p_153869_); // CraftBukkit } else { return false; @@ -13,16 +13,16 @@ } } -- private boolean m_153834_(LevelAccessor p_153835_, BlockPos p_153836_, Direction p_153837_, boolean p_153838_) { +- private boolean spreadToFace(LevelAccessor p_153835_, BlockPos p_153836_, Direction p_153837_, boolean p_153838_) { + private boolean spreadToFace(LevelAccessor p_153835_, BlockPos p_153836_, Direction p_153837_, boolean p_153838_, BlockPos source) { // CraftBukkit - BlockState blockstate = p_153835_.m_8055_(p_153836_); - BlockState blockstate1 = this.m_153940_(blockstate, p_153835_, p_153836_, p_153837_); + BlockState blockstate = p_153835_.getBlockState(p_153836_); + BlockState blockstate1 = this.getStateForPlacement(blockstate, p_153835_, p_153836_, p_153837_); if (blockstate1 != null) { @@ -239,7 +_,7 @@ - p_153835_.m_46865_(p_153836_).m_8113_(p_153836_); + p_153835_.getChunk(p_153836_).markPosForPostprocessing(p_153836_); } -- return p_153835_.m_7731_(p_153836_, blockstate1, 2); +- return p_153835_.setBlock(p_153836_, blockstate1, 2); + return org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_153835_, source, p_153836_, blockstate1, 2); } else { return false; diff --git a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch index d427bc98..13f653ca 100644 --- a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -3,7 +3,7 @@ @@ -30,7 +_,7 @@ } - public void m_7455_(BlockState p_54884_, ServerLevel p_54885_, BlockPos p_54886_, Random p_54887_) { + public void randomTick(BlockState p_54884_, ServerLevel p_54885_, BlockPos p_54886_, Random p_54887_) { - if (p_54887_.nextInt(25) == 0) { + if (p_54887_.nextInt(Math.max(1, (int) (100.0F / p_54885_.spigotConfig.mushroomModifier) * 25)) == 0) { // Spigot int i = 5; @@ -12,28 +12,28 @@ @@ -54,7 +_,7 @@ } - if (p_54885_.m_46859_(blockpos1) && p_54884_.m_60710_(p_54885_, blockpos1)) { -- p_54885_.m_7731_(blockpos1, p_54884_, 2); + if (p_54885_.isEmptyBlock(blockpos1) && p_54884_.canSurvive(p_54885_, blockpos1)) { +- p_54885_.setBlock(blockpos1, p_54884_, 2); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_54885_, p_54886_, blockpos1, p_54884_, 2); // CraftBukkit } } @@ -70,13 +_,16 @@ - if (blockstate.m_204336_(BlockTags.f_13057_)) { + if (blockstate.is(BlockTags.MUSHROOM_GROW_BLOCK)) { return true; } else { -- return p_54881_.m_45524_(p_54882_, 0) < 13 && this.m_6266_(blockstate, p_54881_, blockpos); -+ return p_54881_.m_45524_(p_54882_, 0) < 13 && blockstate.canSustainPlant(p_54881_, blockpos, net.minecraft.core.Direction.UP, this); +- return p_54881_.getRawBrightness(p_54882_, 0) < 13 && this.mayPlaceOn(blockstate, p_54881_, blockpos); ++ return p_54881_.getRawBrightness(p_54882_, 0) < 13 && blockstate.canSustainPlant(p_54881_, blockpos, net.minecraft.core.Direction.UP, this); } } - public boolean m_54859_(ServerLevel p_54860_, BlockPos p_54861_, BlockState p_54862_, Random p_54863_) { -+ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_54860_, p_54863_, p_54861_, this.f_153981_.get()); + public boolean growMushroom(ServerLevel p_54860_, BlockPos p_54861_, BlockState p_54862_, Random p_54863_) { ++ net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_54860_, p_54863_, p_54861_, this.featureSupplier.get()); + if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return false; - p_54860_.m_7471_(p_54861_, false); -- if (this.f_153981_.get().m_203334_().m_65385_(p_54860_, p_54860_.m_7726_().m_8481_(), p_54863_, p_54861_)) { -+ SaplingBlock.treeType = (this == Blocks.f_50072_) ? org.bukkit.TreeType.BROWN_MUSHROOM : org.bukkit.TreeType.BROWN_MUSHROOM; // CraftBukkit -+ if (event.getFeature().m_203334_().m_65385_(p_54860_, p_54860_.m_7726_().m_8481_(), p_54863_, p_54861_)) { + p_54860_.removeBlock(p_54861_, false); +- if (this.featureSupplier.get().value().place(p_54860_, p_54860_.getChunkSource().getGenerator(), p_54863_, p_54861_)) { ++ SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? org.bukkit.TreeType.BROWN_MUSHROOM : org.bukkit.TreeType.BROWN_MUSHROOM; // CraftBukkit ++ if (event.getFeature().value().place(p_54860_, p_54860_.getChunkSource().getGenerator(), p_54863_, p_54861_)) { return true; } else { - p_54860_.m_7731_(p_54861_, p_54862_, 3); + p_54860_.setBlock(p_54861_, p_54862_, 3); diff --git a/patches/minecraft/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NetherPortalBlock.java.patch index 79b23296..dfd7a26c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -3,26 +3,26 @@ @@ -49,12 +_,13 @@ } - public void m_7455_(BlockState p_54937_, ServerLevel p_54938_, BlockPos p_54939_, Random p_54940_) { -- if (p_54938_.m_6042_().m_63956_() && p_54938_.m_46469_().m_46207_(GameRules.f_46134_) && p_54940_.nextInt(2000) < p_54938_.m_46791_().m_19028_()) { -+ if (p_54938_.spigotConfig.enableZombiePigmenPortalSpawns && p_54938_.m_6042_().m_63956_() && p_54938_.m_46469_().m_46207_(GameRules.f_46134_) && p_54940_.nextInt(2000) < p_54938_.m_46791_().m_19028_()) { // Spigot - while(p_54938_.m_8055_(p_54939_).m_60713_(this)) { - p_54939_ = p_54939_.m_7495_(); + public void randomTick(BlockState p_54937_, ServerLevel p_54938_, BlockPos p_54939_, Random p_54940_) { +- if (p_54938_.dimensionType().natural() && p_54938_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && p_54940_.nextInt(2000) < p_54938_.getDifficulty().getId()) { ++ if (p_54938_.spigotConfig.enableZombiePigmenPortalSpawns && p_54938_.dimensionType().natural() && p_54938_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && p_54940_.nextInt(2000) < p_54938_.getDifficulty().getId()) { // Spigot + while(p_54938_.getBlockState(p_54939_).is(this)) { + p_54939_ = p_54939_.below(); } - if (p_54938_.m_8055_(p_54939_).m_60643_(p_54938_, p_54939_, EntityType.f_20531_)) { -+ EntityType.f_20531_.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); //Magma - spawn reason - Entity entity = EntityType.f_20531_.m_20600_(p_54938_, (CompoundTag)null, (Component)null, (Player)null, p_54939_.m_7494_(), MobSpawnType.STRUCTURE, false, false); + if (p_54938_.getBlockState(p_54939_).isValidSpawn(p_54938_, p_54939_, EntityType.ZOMBIFIED_PIGLIN)) { ++ EntityType.ZOMBIFIED_PIGLIN.prepareSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); //Magma - spawn reason + Entity entity = EntityType.ZOMBIFIED_PIGLIN.spawn(p_54938_, (CompoundTag)null, (Component)null, (Player)null, p_54939_.above(), MobSpawnType.STRUCTURE, false, false); if (entity != null) { - entity.m_20091_(); + entity.setPortalCooldown(); @@ -73,6 +_,10 @@ - public void m_7892_(BlockState p_54915_, Level p_54916_, BlockPos p_54917_, Entity p_54918_) { - if (!p_54918_.m_20159_() && !p_54918_.m_20160_() && p_54918_.m_6072_()) { + public void entityInside(BlockState p_54915_, Level p_54916_, BlockPos p_54917_, Entity p_54918_) { + if (!p_54918_.isPassenger() && !p_54918_.isVehicle() && p_54918_.canChangeDimensions()) { + // CraftBukkit start - Entity in portal -+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(p_54918_.getBukkitEntity(), new org.bukkit.Location(p_54916_.getWorld(), p_54917_.m_123341_(), p_54917_.m_123342_(), p_54917_.m_123343_())); ++ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(p_54918_.getBukkitEntity(), new org.bukkit.Location(p_54916_.getWorld(), p_54917_.getX(), p_54917_.getY(), p_54917_.getZ())); + p_54916_.getCraftServer().getPluginManager().callEvent(event); + // CraftBukkit end - p_54918_.m_20221_(p_54917_); + p_54918_.handleInsidePortal(p_54917_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch index 510fd1e1..c9f0fe4f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch @@ -2,12 +2,12 @@ +++ b/net/minecraft/world/level/block/NetherWartBlock.java @@ -38,9 +_,10 @@ - public void m_7455_(BlockState p_54981_, ServerLevel p_54982_, BlockPos p_54983_, Random p_54984_) { - int i = p_54981_.m_61143_(f_54967_); + public void randomTick(BlockState p_54981_, ServerLevel p_54982_, BlockPos p_54983_, Random p_54984_) { + int i = p_54981_.getValue(AGE); - if (i < 3 && p_54984_.nextInt(10) == 0) { + if (i < 3 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_54982_, p_54983_, p_54981_, p_54984_.nextInt(Math.max(1, (int) (100.0F / p_54982_.spigotConfig.wartModifier) * 10)) == 0)) { // Spigot - p_54981_ = p_54981_.m_61124_(f_54967_, Integer.valueOf(i + 1)); -- p_54982_.m_7731_(p_54983_, p_54981_, 2); + p_54981_ = p_54981_.setValue(AGE, Integer.valueOf(i + 1)); +- p_54982_.setBlock(p_54983_, p_54981_, 2); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_54982_, p_54983_, p_54981_, 2); // CraftBukkit + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_54982_, p_54983_, p_54981_); } 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 33676d3c..9b0abfb2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java @@ -43,7 +_,9 @@ - boolean flag = p_55042_.m_46753_(p_55043_); - if (flag != p_55041_.m_61143_(f_55012_)) { + boolean flag = p_55042_.hasNeighborSignal(p_55043_); + if (flag != p_55041_.getValue(POWERED)) { if (flag) { + this.prepareNoteData(p_55041_); - this.m_55019_(p_55042_, p_55043_); -+ p_55041_ = p_55042_.m_8055_(p_55043_); // CraftBukkit - SPIGOT-5617: update in case changed in event + this.playNote(p_55042_, p_55043_); ++ p_55041_ = p_55042_.getBlockState(p_55043_); // CraftBukkit - SPIGOT-5617: update in case changed in event } - p_55042_.m_7731_(p_55043_, p_55041_.m_61124_(f_55012_, Boolean.valueOf(flag)), 3); + p_55042_.setBlock(p_55043_, p_55041_.setValue(POWERED, Boolean.valueOf(flag)), 3); @@ -51,19 +_,37 @@ } @@ -20,16 +20,16 @@ + this.playNote_data = p_55041_; + } + - private void m_55019_(Level p_55020_, BlockPos p_55021_) { + private void playNote(Level p_55020_, BlockPos p_55021_) { + if (playNote_data == null) + throw new IllegalStateException("playNote_data is null"); + - if (p_55020_.m_8055_(p_55021_.m_7494_()).m_60795_()) { -- p_55020_.m_7696_(p_55021_, this, 0, 0); + if (p_55020_.getBlockState(p_55021_.above()).isAir()) { +- p_55020_.blockEvent(p_55021_, this, 0, 0); + // CraftBukkit start -+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callNotePlayEvent(p_55020_, p_55021_, playNote_data.m_61143_(f_55011_), playNote_data.m_61143_(f_55013_)); ++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callNotePlayEvent(p_55020_, p_55021_, playNote_data.getValue(INSTRUMENT), playNote_data.getValue(NOTE)); + if (!event.isCancelled()) { -+ p_55020_.m_7696_(p_55021_, this, 0, 0); ++ p_55020_.blockEvent(p_55021_, this, 0, 0); + } + // CraftBukkit end } @@ -38,33 +38,33 @@ } + //Magma - end - public InteractionResult m_6227_(BlockState p_55034_, Level p_55035_, BlockPos p_55036_, Player p_55037_, InteractionHand p_55038_, BlockHitResult p_55039_) { - if (p_55035_.f_46443_) { + public InteractionResult use(BlockState p_55034_, Level p_55035_, BlockPos p_55036_, Player p_55037_, InteractionHand p_55038_, BlockHitResult p_55039_) { + if (p_55035_.isClientSide) { return InteractionResult.SUCCESS; } else { -- p_55034_ = p_55034_.m_61122_(f_55013_); -+ int _new = net.minecraftforge.common.ForgeHooks.onNoteChange(p_55035_, p_55036_, p_55034_, p_55034_.m_61143_(f_55013_), p_55034_.m_61122_(f_55013_).m_61143_(f_55013_)); +- p_55034_ = p_55034_.cycle(NOTE); ++ int _new = net.minecraftforge.common.ForgeHooks.onNoteChange(p_55035_, p_55036_, p_55034_, p_55034_.getValue(NOTE), p_55034_.cycle(NOTE).getValue(NOTE)); + if (_new == -1) return InteractionResult.FAIL; -+ p_55034_ = p_55034_.m_61124_(f_55013_, _new); - p_55035_.m_7731_(p_55036_, p_55034_, 3); ++ p_55034_ = p_55034_.setValue(NOTE, _new); + p_55035_.setBlock(p_55036_, p_55034_, 3); + this.prepareNoteData(p_55034_); - this.m_55019_(p_55035_, p_55036_); - p_55037_.m_36220_(Stats.f_12960_); + this.playNote(p_55035_, p_55036_); + p_55037_.awardStat(Stats.TUNE_NOTEBLOCK); return InteractionResult.CONSUME; @@ -72,12 +_,16 @@ - public void m_6256_(BlockState p_55029_, Level p_55030_, BlockPos p_55031_, Player p_55032_) { - if (!p_55030_.f_46443_) { + public void attack(BlockState p_55029_, Level p_55030_, BlockPos p_55031_, Player p_55032_) { + if (!p_55030_.isClientSide) { + this.prepareNoteData(p_55029_); - this.m_55019_(p_55030_, p_55031_); - p_55032_.m_36220_(Stats.f_12959_); + this.playNote(p_55030_, p_55031_); + p_55032_.awardStat(Stats.PLAY_NOTEBLOCK); } } - public boolean m_8133_(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { -+ net.minecraftforge.event.world.NoteBlockEvent.Play e = new net.minecraftforge.event.world.NoteBlockEvent.Play(p_55024_, p_55025_, p_55023_, p_55023_.m_61143_(f_55013_), p_55023_.m_61143_(f_55011_)); + public boolean triggerEvent(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { ++ net.minecraftforge.event.world.NoteBlockEvent.Play e = new net.minecraftforge.event.world.NoteBlockEvent.Play(p_55024_, p_55025_, p_55023_, p_55023_.getValue(NOTE), p_55023_.getValue(INSTRUMENT)); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e)) return false; -+ p_55023_ = p_55023_.m_61124_(f_55013_, e.getVanillaNoteId()).m_61124_(f_55011_, e.getInstrument()); - int i = p_55023_.m_61143_(f_55013_); ++ p_55023_ = p_55023_.setValue(NOTE, e.getVanillaNoteId()).setValue(INSTRUMENT, e.getInstrument()); + int i = p_55023_.getValue(NOTE); float f = (float)Math.pow(2.0D, (double)(i - 12) / 12.0D); - p_55024_.m_5594_((Player)null, p_55025_, p_55023_.m_61143_(f_55011_).m_61668_(), SoundSource.RECORDS, 3.0F, f); + p_55024_.playSound((Player)null, p_55025_, p_55023_.getValue(INSTRUMENT).getSoundEvent(), SoundSource.RECORDS, 3.0F, f); diff --git a/patches/minecraft/net/minecraft/world/level/block/NyliumBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NyliumBlock.java.patch index 10d4e1e5..b28c49c5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NyliumBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NyliumBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/NyliumBlock.java @@ -27,6 +_,11 @@ - public void m_7455_(BlockState p_55074_, ServerLevel p_55075_, BlockPos p_55076_, Random p_55077_) { - if (!m_55078_(p_55074_, p_55075_, p_55076_)) { + public void randomTick(BlockState p_55074_, ServerLevel p_55075_, BlockPos p_55076_, Random p_55077_) { + if (!canBeNylium(p_55074_, p_55075_, p_55076_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_55075_, p_55076_, Blocks.f_50134_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_55075_, p_55076_, Blocks.NETHERRACK.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - p_55075_.m_46597_(p_55076_, Blocks.f_50134_.m_49966_()); + p_55075_.setBlockAndUpdate(p_55076_, Blocks.NETHERRACK.defaultBlockState()); } diff --git a/patches/minecraft/net/minecraft/world/level/block/ObserverBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ObserverBlock.java.patch index 31da3e91..1d50e5a4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ObserverBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ObserverBlock.java.patch @@ -2,20 +2,20 @@ +++ b/net/minecraft/world/level/block/ObserverBlock.java @@ -36,8 +_,18 @@ - public void m_7458_(BlockState p_55096_, ServerLevel p_55097_, BlockPos p_55098_, Random p_55099_) { - if (p_55096_.m_61143_(f_55082_)) { + public void tick(BlockState p_55096_, ServerLevel p_55097_, BlockPos p_55098_, Random p_55099_) { + if (p_55096_.getValue(POWERED)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_55097_, p_55098_, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - p_55097_.m_7731_(p_55098_, p_55096_.m_61124_(f_55082_, Boolean.valueOf(false)), 2); + p_55097_.setBlock(p_55098_, p_55096_.setValue(POWERED, Boolean.valueOf(false)), 2); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_55097_, p_55098_, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - p_55097_.m_7731_(p_55098_, p_55096_.m_61124_(f_55082_, Boolean.valueOf(true)), 2); - p_55097_.m_186460_(p_55098_, this, 2); + p_55097_.setBlock(p_55098_, p_55096_.setValue(POWERED, Boolean.valueOf(true)), 2); + p_55097_.scheduleTick(p_55098_, this, 2); } diff --git a/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch index e51ed4fc..fd6f81a2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/OreBlock.java.patch @@ -2,18 +2,18 @@ +++ b/net/minecraft/world/level/block/OreBlock.java @@ -23,12 +_,10 @@ - public void m_8101_(BlockState p_55142_, ServerLevel p_55143_, BlockPos p_55144_, ItemStack p_55145_) { - super.m_8101_(p_55142_, p_55143_, p_55144_, p_55145_); -- if (EnchantmentHelper.m_44843_(Enchantments.f_44985_, p_55145_) == 0) { -- int i = this.f_153990_.m_142270_(p_55143_.f_46441_); + public void spawnAfterBreak(BlockState p_55142_, ServerLevel p_55143_, BlockPos p_55144_, ItemStack p_55145_) { + super.spawnAfterBreak(p_55142_, p_55143_, p_55144_, p_55145_); +- if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, p_55145_) == 0) { +- int i = this.xpRange.sample(p_55143_.random); - if (i > 0) { -- this.m_49805_(p_55143_, p_55144_, i); +- this.popExperience(p_55143_, p_55144_, i); - } - } + } + @Override + public int getExpDrop(BlockState state, net.minecraft.world.level.LevelReader reader, BlockPos pos, int fortune, int silktouch) { -+ return silktouch == 0 ? this.f_153990_.m_142270_(RANDOM) : 0; ++ return silktouch == 0 ? this.xpRange.sample(RANDOM) : 0; } } diff --git a/patches/minecraft/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 568db980..159f4232 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,53 +1,53 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java @@ -117,6 +_,11 @@ - public void m_5581_(Level p_154042_, BlockState p_154043_, BlockHitResult p_154044_, Projectile p_154045_) { - BlockPos blockpos = p_154044_.m_82425_(); - if (!p_154042_.f_46443_ && p_154045_.m_142265_(p_154042_, blockpos) && p_154045_ instanceof ThrownTrident && p_154045_.m_20184_().m_82553_() > 0.6D) { + public void onProjectileHit(Level p_154042_, BlockState p_154043_, BlockHitResult p_154044_, Projectile p_154045_) { + BlockPos blockpos = p_154044_.getBlockPos(); + if (!p_154042_.isClientSide && p_154045_.mayInteract(p_154042_, blockpos) && p_154045_ instanceof ThrownTrident && p_154045_.getDeltaMovement().length() > 0.6D) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_154045_, blockpos, Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_154045_, blockpos, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - p_154042_.m_46961_(blockpos, true); + p_154042_.destroyBlock(blockpos, true); } @@ -124,7 +_,9 @@ - public void m_142072_(Level p_154047_, BlockState p_154048_, BlockPos p_154049_, Entity p_154050_, float p_154051_) { - if (p_154048_.m_61143_(f_154009_) == Direction.UP && p_154048_.m_61143_(f_154010_) == DripstoneThickness.TIP) { + public void fallOn(Level p_154047_, BlockState p_154048_, BlockPos p_154049_, Entity p_154050_, float p_154051_) { + if (p_154048_.getValue(TIP_DIRECTION) == Direction.UP && p_154048_.getValue(THICKNESS) == DripstoneThickness.TIP) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154047_, p_154049_); // CraftBukkit - p_154050_.m_142535_(p_154051_ + 2.0F, 2.0F, DamageSource.f_146703_); + p_154050_.causeFallDamage(p_154051_ + 2.0F, 2.0F, DamageSource.STALAGMITE); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; // CraftBukkit } else { - super.m_142072_(p_154047_, p_154048_, p_154049_, p_154050_, p_154051_); + super.fallOn(p_154047_, p_154048_, p_154049_, p_154050_, p_154051_); } @@ -341,14 +_,14 @@ - if (m_154143_(blockstate, p_154038_.m_122424_())) { - m_154230_(blockstate, p_154036_, blockpos); - } else if (blockstate.m_60795_() || blockstate.m_60713_(Blocks.f_49990_)) { -- m_154087_(p_154036_, blockpos, p_154038_, DripstoneThickness.TIP); + if (isUnmergedTipWithDirection(blockstate, p_154038_.getOpposite())) { + createMergedTips(blockstate, p_154036_, blockpos); + } else if (blockstate.isAir() || blockstate.is(Blocks.WATER)) { +- createDripstone(p_154036_, blockpos, p_154038_, DripstoneThickness.TIP); + createDripstone(p_154036_, blockpos, p_154038_, DripstoneThickness.TIP, p_154037_); // CraftBukkit } } -- private static void m_154087_(LevelAccessor p_154088_, BlockPos p_154089_, Direction p_154090_, DripstoneThickness p_154091_) { +- private static void createDripstone(LevelAccessor p_154088_, BlockPos p_154089_, Direction p_154090_, DripstoneThickness p_154091_) { + private static void createDripstone(LevelAccessor p_154088_, BlockPos p_154089_, Direction p_154090_, DripstoneThickness p_154091_, BlockPos source) { // CraftBukkit - BlockState blockstate = Blocks.f_152588_.m_49966_().m_61124_(f_154009_, p_154090_).m_61124_(f_154010_, p_154091_).m_61124_(f_154011_, Boolean.valueOf(p_154088_.m_6425_(p_154089_).m_76152_() == Fluids.f_76193_)); -- p_154088_.m_7731_(p_154089_, blockstate, 3); + BlockState blockstate = Blocks.POINTED_DRIPSTONE.defaultBlockState().setValue(TIP_DIRECTION, p_154090_).setValue(THICKNESS, p_154091_).setValue(WATERLOGGED, Boolean.valueOf(p_154088_.getFluidState(p_154089_).getType() == Fluids.WATER)); +- p_154088_.setBlock(p_154089_, blockstate, 3); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_154088_, source, p_154089_, blockstate, 3); // CraftBukkit } - private static void m_154230_(BlockState p_154231_, LevelAccessor p_154232_, BlockPos p_154233_) { + private static void createMergedTips(BlockState p_154231_, LevelAccessor p_154232_, BlockPos p_154233_) { @@ -362,8 +_,8 @@ - blockpos1 = p_154233_.m_7495_(); + blockpos1 = p_154233_.below(); } -- m_154087_(p_154232_, blockpos, Direction.DOWN, DripstoneThickness.TIP_MERGE); -- m_154087_(p_154232_, blockpos1, Direction.UP, DripstoneThickness.TIP_MERGE); +- createDripstone(p_154232_, blockpos, Direction.DOWN, DripstoneThickness.TIP_MERGE); +- createDripstone(p_154232_, blockpos1, Direction.UP, DripstoneThickness.TIP_MERGE); + createDripstone(p_154232_, blockpos, Direction.DOWN, DripstoneThickness.TIP_MERGE, p_154233_); // CraftBukkit + createDripstone(p_154232_, blockpos1, Direction.UP, DripstoneThickness.TIP_MERGE, p_154233_); // CraftBukkit } - public static void m_154062_(Level p_154063_, BlockPos p_154064_, BlockState p_154065_) { + public static void spawnDripParticle(Level p_154063_, BlockPos p_154064_, BlockState p_154065_) { 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 b283785b..e0c112f5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -2,24 +2,24 @@ +++ b/net/minecraft/world/level/block/PowderSnowBlock.java @@ -64,7 +_,12 @@ - p_154266_.m_146924_(true); - if (!p_154264_.f_46443_) { -- if (p_154266_.m_6060_() && (p_154264_.m_46469_().m_46207_(GameRules.f_46132_) || p_154266_ instanceof Player) && p_154266_.m_142265_(p_154264_, p_154265_)) { + p_154266_.setIsInPowderSnow(true); + if (!p_154264_.isClientSide) { +- if (p_154266_.isOnFire() && (p_154264_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || p_154266_ instanceof Player) && p_154266_.mayInteract(p_154264_, p_154265_)) { + // CraftBukkit start -+ if (p_154266_.m_6060_() && p_154266_.m_142265_(p_154264_, p_154265_)) { -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_154266_, p_154265_, Blocks.f_50016_.m_49966_(), !(p_154264_.m_46469_().m_46207_(GameRules.f_46132_) || p_154266_ instanceof Player)).isCancelled()) { ++ if (p_154266_.isOnFire() && p_154266_.mayInteract(p_154264_, p_154265_)) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_154266_, p_154265_, Blocks.AIR.defaultBlockState(), !(p_154264_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || p_154266_ instanceof Player)).isCancelled()) { + return; + } + // CraftBukkit end - p_154264_.m_46961_(p_154265_, false); + p_154264_.destroyBlock(p_154265_, false); } @@ -109,7 +_,7 @@ - if (p_154256_.m_6095_().m_204039_(EntityTypeTags.f_144291_)) { + if (p_154256_.getType().is(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS)) { return true; } else { -- return p_154256_ instanceof LivingEntity ? ((LivingEntity)p_154256_).m_6844_(EquipmentSlot.FEET).m_150930_(Items.f_42463_) : false; -+ return p_154256_ instanceof LivingEntity && ((LivingEntity) p_154256_).m_6844_(EquipmentSlot.FEET).canWalkOnPowderedSnow((LivingEntity) p_154256_); +- return p_154256_ instanceof LivingEntity ? ((LivingEntity)p_154256_).getItemBySlot(EquipmentSlot.FEET).is(Items.LEATHER_BOOTS) : false; ++ return p_154256_ instanceof LivingEntity && ((LivingEntity) p_154256_).getItemBySlot(EquipmentSlot.FEET).canWalkOnPowderedSnow((LivingEntity) p_154256_); } } 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 62786626..09074b4e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/world/level/block/PoweredRailBlock.java @@ -14,9 +_,19 @@ public class PoweredRailBlock extends BaseRailBlock { - public static final EnumProperty f_55214_ = BlockStateProperties.f_61404_; - public static final BooleanProperty f_55215_ = BlockStateProperties.f_61448_; + public static final EnumProperty SHAPE = BlockStateProperties.RAIL_SHAPE_STRAIGHT; + public static final BooleanProperty POWERED = BlockStateProperties.POWERED; + private final boolean isActivator; // TRUE for an Activator Rail, FALSE for Powered Rail public PoweredRailBlock(BlockBehaviour.Properties p_55218_) { @@ -17,40 +17,40 @@ + } + + protected void registerDefaultState() { - this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_55214_, RailShape.NORTH_SOUTH).m_61124_(f_55215_, Boolean.valueOf(false)).m_61124_(f_152149_, Boolean.valueOf(false))); + this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, RailShape.NORTH_SOUTH).setValue(POWERED, Boolean.valueOf(false)).setValue(WATERLOGGED, Boolean.valueOf(false))); } @@ -28,7 +_,7 @@ - int j = p_55221_.m_123342_(); - int k = p_55221_.m_123343_(); + int j = p_55221_.getY(); + int k = p_55221_.getZ(); boolean flag = true; -- RailShape railshape = p_55222_.m_61143_(f_55214_); -+ RailShape railshape = p_55222_.m_61143_(m_7978_()); +- RailShape railshape = p_55222_.getValue(SHAPE); ++ RailShape railshape = p_55222_.getValue(getShapeProperty()); switch(railshape) { case NORTH_SOUTH: if (p_55223_) { @@ -99,14 +_,14 @@ - protected boolean m_55225_(Level p_55226_, BlockPos p_55227_, boolean p_55228_, int p_55229_, RailShape p_55230_) { - BlockState blockstate = p_55226_.m_8055_(p_55227_); -- if (!blockstate.m_60713_(this)) { -+ if (!(blockstate.m_60734_() instanceof PoweredRailBlock other)) { + protected boolean isSameRailWithPower(Level p_55226_, BlockPos p_55227_, boolean p_55228_, int p_55229_, RailShape p_55230_) { + BlockState blockstate = p_55226_.getBlockState(p_55227_); +- if (!blockstate.is(this)) { ++ if (!(blockstate.getBlock() instanceof PoweredRailBlock other)) { return false; } else { -- RailShape railshape = blockstate.m_61143_(f_55214_); +- RailShape railshape = blockstate.getValue(SHAPE); + RailShape railshape = other.getRailDirection(blockstate, p_55226_, p_55227_, null); if (p_55230_ != RailShape.EAST_WEST || railshape != RailShape.NORTH_SOUTH && railshape != RailShape.ASCENDING_NORTH && railshape != RailShape.ASCENDING_SOUTH) { if (p_55230_ != RailShape.NORTH_SOUTH || railshape != RailShape.EAST_WEST && railshape != RailShape.ASCENDING_EAST && railshape != RailShape.ASCENDING_WEST) { -- if (blockstate.m_61143_(f_55215_)) { -- return p_55226_.m_46753_(p_55227_) ? true : this.m_55219_(p_55226_, p_55227_, blockstate, p_55228_, p_55229_ + 1); +- if (blockstate.getValue(POWERED)) { +- return p_55226_.hasNeighborSignal(p_55227_) ? true : this.findPoweredRailSignal(p_55226_, p_55227_, blockstate, p_55228_, p_55229_ + 1); + if (isActivatorRail() == other.isActivatorRail()) { -+ return p_55226_.m_46753_(p_55227_) ? true : other.m_55219_(p_55226_, p_55227_, blockstate, p_55228_, p_55229_ + 1); ++ return p_55226_.hasNeighborSignal(p_55227_) ? true : other.findPoweredRailSignal(p_55226_, p_55227_, blockstate, p_55228_, p_55229_ + 1); } else { return false; } @@ -123,9 +_,16 @@ - boolean flag = p_55232_.m_61143_(f_55215_); - boolean flag1 = p_55233_.m_46753_(p_55234_) || this.m_55219_(p_55233_, p_55234_, p_55232_, true, 0) || this.m_55219_(p_55233_, p_55234_, p_55232_, false, 0); + boolean flag = p_55232_.getValue(POWERED); + boolean flag1 = p_55233_.hasNeighborSignal(p_55234_) || this.findPoweredRailSignal(p_55233_, p_55234_, p_55232_, true, 0) || this.findPoweredRailSignal(p_55233_, p_55234_, p_55232_, false, 0); if (flag1 != flag) { + // CraftBukkit start + int power = flag ? 15 : 0; @@ -59,29 +59,29 @@ + return; + } + // CraftBukkit end - p_55233_.m_7731_(p_55234_, p_55232_.m_61124_(f_55215_, Boolean.valueOf(flag1)), 3); - p_55233_.m_46672_(p_55234_.m_7495_(), this); -- if (p_55232_.m_61143_(f_55214_).m_61745_()) { -+ if (p_55232_.m_61143_(m_7978_()).m_61745_()) { - p_55233_.m_46672_(p_55234_.m_7494_(), this); + 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()) { + p_55233_.updateNeighborsAt(p_55234_.above(), this); } } @@ -156,6 +_,9 @@ - return p_55240_.m_61124_(f_55214_, RailShape.SOUTH_EAST); + return p_55240_.setValue(SHAPE, RailShape.SOUTH_EAST); case NORTH_EAST: - return p_55240_.m_61124_(f_55214_, RailShape.SOUTH_WEST); + return p_55240_.setValue(SHAPE, RailShape.SOUTH_WEST); + case NORTH_SOUTH: //Forge fix: MC-196102 + case EAST_WEST: + return p_55240_; } case COUNTERCLOCKWISE_90: - switch((RailShape)p_55240_.m_61143_(f_55214_)) { + switch((RailShape)p_55240_.getValue(SHAPE)) { @@ -253,6 +_,10 @@ } - protected void m_7926_(StateDefinition.Builder p_55243_) { -- p_55243_.m_61104_(f_55214_, f_55215_, f_152149_); -+ p_55243_.m_61104_(m_7978_(), f_55215_, f_152149_); + protected void createBlockStateDefinition(StateDefinition.Builder p_55243_) { +- p_55243_.add(SHAPE, POWERED, WATERLOGGED); ++ p_55243_.add(getShapeProperty(), POWERED, WATERLOGGED); + } + + public boolean isActivatorRail() { diff --git a/patches/minecraft/net/minecraft/world/level/block/PressurePlateBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PressurePlateBlock.java.patch index f11ca3ba..2269bada 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PressurePlateBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PressurePlateBlock.java.patch @@ -6,7 +6,7 @@ for(Entity entity : list) { + + // CraftBukkit start - Call interact event when turning on a pressure plate -+ if (this.m_6016_(p_55264_.m_8055_(p_55265_)) == 0) { ++ if (this.getSignalForState(p_55264_.getBlockState(p_55265_)) == 0) { + org.bukkit.World bworld = p_55264_.getWorld(); + org.bukkit.plugin.PluginManager manager = p_55264_.getCraftServer().getPluginManager(); + org.bukkit.event.Cancellable cancellable; @@ -14,7 +14,7 @@ + if (entity instanceof Player) { + cancellable = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, p_55265_, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(p_55265_.m_123341_(), p_55265_.m_123342_(), p_55265_.m_123343_())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(p_55265_.getX(), p_55265_.getY(), p_55265_.getZ())); + manager.callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + @@ -25,6 +25,6 @@ + } + // CraftBukkit end + - if (!entity.m_6090_()) { + if (!entity.isIgnoringBlockTriggers()) { return 15; } 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 63418c6e..65897564 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/level/block/PumpkinBlock.java @@ -24,7 +_,7 @@ - public InteractionResult m_6227_(BlockState p_55289_, Level p_55290_, BlockPos p_55291_, Player p_55292_, InteractionHand p_55293_, BlockHitResult p_55294_) { - ItemStack itemstack = p_55292_.m_21120_(p_55293_); -- if (itemstack.m_150930_(Items.f_42574_)) { + public InteractionResult use(BlockState p_55289_, Level p_55290_, BlockPos p_55291_, Player p_55292_, InteractionHand p_55293_, BlockHitResult p_55294_) { + ItemStack itemstack = p_55292_.getItemInHand(p_55293_); +- if (itemstack.is(Items.SHEARS)) { + if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_CARVE)) { - if (!p_55290_.f_46443_) { - Direction direction = p_55294_.m_82434_(); - Direction direction1 = direction.m_122434_() == Direction.Axis.Y ? p_55292_.m_6350_().m_122424_() : direction; + if (!p_55290_.isClientSide) { + Direction direction = p_55294_.getDirection(); + Direction direction1 = direction.getAxis() == Direction.Axis.Y ? p_55292_.getDirection().getOpposite() : direction; diff --git a/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch index 09b395d0..6a710fff 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RailBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/RailBlock.java +++ b/net/minecraft/world/level/block/RailBlock.java @@ -49,6 +_,9 @@ - return p_55405_.m_61124_(f_55392_, RailShape.SOUTH_EAST); + return p_55405_.setValue(SHAPE, RailShape.SOUTH_EAST); case NORTH_EAST: - return p_55405_.m_61124_(f_55392_, RailShape.SOUTH_WEST); + return p_55405_.setValue(SHAPE, RailShape.SOUTH_WEST); + case NORTH_SOUTH: //Forge fix: MC-196102 + case EAST_WEST: + return p_55405_; } case COUNTERCLOCKWISE_90: - switch((RailShape)p_55405_.m_61143_(f_55392_)) { + switch((RailShape)p_55405_.getValue(SHAPE)) { diff --git a/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch b/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch index 617b2509..ced459ee 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RailState.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/block/RailState.java +++ b/net/minecraft/world/level/block/RailState.java @@ -16,14 +_,16 @@ - private BlockState f_55417_; - private final boolean f_55418_; - private final List f_55419_ = Lists.newArrayList(); + private BlockState state; + private final boolean isStraight; + private final List connections = Lists.newArrayList(); + private final boolean canMakeSlopes; public RailState(Level p_55421_, BlockPos p_55422_, BlockState p_55423_) { - this.f_55414_ = p_55421_; - this.f_55415_ = p_55422_; - this.f_55417_ = p_55423_; - this.f_55416_ = (BaseRailBlock)p_55423_.m_60734_(); -- RailShape railshape = p_55423_.m_61143_(this.f_55416_.m_7978_()); -- this.f_55418_ = this.f_55416_.m_49413_(); -+ RailShape railshape = this.f_55416_.getRailDirection(f_55417_, p_55421_, p_55422_, null); -+ this.f_55418_ = !this.f_55416_.isFlexibleRail(f_55417_, p_55421_, p_55422_); -+ this.canMakeSlopes = this.f_55416_.canMakeSlopes(f_55417_, p_55421_, p_55422_); - this.m_55427_(railshape); + this.level = p_55421_; + this.pos = p_55422_; + this.state = p_55423_; + this.block = (BaseRailBlock)p_55423_.getBlock(); +- RailShape railshape = p_55423_.getValue(this.block.getShapeProperty()); +- this.isStraight = this.block.isStraight(); ++ RailShape railshape = this.block.getRailDirection(state, p_55421_, p_55422_, null); ++ this.isStraight = !this.block.isFlexibleRail(state, p_55421_, p_55422_); ++ this.canMakeSlopes = this.block.canMakeSlopes(state, p_55421_, p_55422_); + this.updateConnections(railshape); } @@ -179,7 +_,7 @@ @@ -25,7 +25,7 @@ - if (railshape == RailShape.NORTH_SOUTH) { + if (railshape == RailShape.NORTH_SOUTH && canMakeSlopes) { - if (BaseRailBlock.m_49364_(this.f_55414_, blockpos.m_7494_())) { + if (BaseRailBlock.isRail(this.level, blockpos.above())) { railshape = RailShape.ASCENDING_NORTH; } @@ -189,7 +_,7 @@ @@ -34,19 +34,19 @@ - if (railshape == RailShape.EAST_WEST) { + if (railshape == RailShape.EAST_WEST && canMakeSlopes) { - if (BaseRailBlock.m_49364_(this.f_55414_, blockpos3.m_7494_())) { + if (BaseRailBlock.isRail(this.level, blockpos3.above())) { railshape = RailShape.ASCENDING_EAST; } @@ -203,6 +_,10 @@ railshape = RailShape.NORTH_SOUTH; } -+ if (!this.f_55416_.isValidRailShape(railshape)) { // Forge: allow rail block to decide if the new shape is valid -+ this.f_55419_.remove(p_55442_.f_55415_); ++ if (!this.block.isValidRailShape(railshape)) { // Forge: allow rail block to decide if the new shape is valid ++ this.connections.remove(p_55442_.pos); + return; + } - this.f_55417_ = this.f_55417_.m_61124_(this.f_55416_.m_7978_(), railshape); - this.f_55414_.m_7731_(this.f_55415_, this.f_55417_, 3); + this.state = this.state.setValue(this.block.getShapeProperty(), railshape); + this.level.setBlock(this.pos, this.state, 3); } @@ -305,7 +_,7 @@ } @@ -54,7 +54,7 @@ - if (railshape == RailShape.NORTH_SOUTH) { + if (railshape == RailShape.NORTH_SOUTH && canMakeSlopes) { - if (BaseRailBlock.m_49364_(this.f_55414_, blockpos.m_7494_())) { + if (BaseRailBlock.isRail(this.level, blockpos.above())) { railshape = RailShape.ASCENDING_NORTH; } @@ -315,7 +_,7 @@ @@ -63,7 +63,7 @@ - if (railshape == RailShape.EAST_WEST) { + if (railshape == RailShape.EAST_WEST && canMakeSlopes) { - if (BaseRailBlock.m_49364_(this.f_55414_, blockpos3.m_7494_())) { + if (BaseRailBlock.isRail(this.level, blockpos3.above())) { railshape = RailShape.ASCENDING_EAST; } @@ -325,7 +_,7 @@ @@ -71,7 +71,7 @@ } - if (railshape == null) { -+ if (railshape == null || !this.f_55416_.isValidRailShape(railshape)) { // Forge: allow rail block to decide if the new shape is valid ++ if (railshape == null || !this.block.isValidRailShape(railshape)) { // Forge: allow rail block to decide if the new shape is valid railshape = p_55434_; } diff --git a/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch index 900db180..0965b29c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch @@ -3,76 +3,76 @@ @@ -30,29 +_,48 @@ } - public void m_6256_(BlockState p_55467_, Level p_55468_, BlockPos p_55469_, Player p_55470_) { -- m_55492_(p_55467_, p_55468_, p_55469_); + public void attack(BlockState p_55467_, Level p_55468_, BlockPos p_55469_, Player p_55470_) { +- interact(p_55467_, p_55468_, p_55469_); + interact(p_55467_, p_55468_, p_55469_, p_55470_); // CraftBukkit - add player - super.m_6256_(p_55467_, p_55468_, p_55469_, p_55470_); + super.attack(p_55467_, p_55468_, p_55469_, p_55470_); } - public void m_141947_(Level p_154299_, BlockPos p_154300_, BlockState p_154301_, Entity p_154302_) { -- m_55492_(p_154301_, p_154299_, p_154300_); -- super.m_141947_(p_154299_, p_154300_, p_154301_, p_154302_); + public void stepOn(Level p_154299_, BlockPos p_154300_, BlockState p_154301_, Entity p_154302_) { +- interact(p_154301_, p_154299_, p_154300_); +- super.stepOn(p_154299_, p_154300_, p_154301_, p_154302_); + // CraftBukkit start + if (p_154302_ instanceof Player) { + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent((Player) p_154302_, org.bukkit.event.block.Action.PHYSICAL, p_154300_, null, null, null); + if (!event.isCancelled()) { -+ interact(p_154299_.m_8055_(p_154300_), p_154299_, p_154300_, p_154302_); // add p_154302_ -+ super.m_141947_(p_154299_, p_154300_, p_154301_, p_154302_); ++ interact(p_154299_.getBlockState(p_154300_), p_154299_, p_154300_, p_154302_); // add p_154302_ ++ super.stepOn(p_154299_, p_154300_, p_154301_, p_154302_); + } + } else { -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_154302_.getBukkitEntity(), p_154299_.getWorld().getBlockAt(p_154300_.m_123341_(), p_154300_.m_123342_(), p_154300_.m_123343_())); ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_154302_.getBukkitEntity(), p_154299_.getWorld().getBlockAt(p_154300_.getX(), p_154300_.getY(), p_154300_.getZ())); + p_154299_.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ interact(p_154299_.m_8055_(p_154300_), p_154299_, p_154300_, p_154302_); // add p_154302_ -+ super.m_141947_(p_154299_, p_154300_, p_154301_, p_154302_); ++ interact(p_154299_.getBlockState(p_154300_), p_154299_, p_154300_, p_154302_); // add p_154302_ ++ super.stepOn(p_154299_, p_154300_, p_154301_, p_154302_); + } + } + // CraftBukkit end } - public InteractionResult m_6227_(BlockState p_55472_, Level p_55473_, BlockPos p_55474_, Player p_55475_, InteractionHand p_55476_, BlockHitResult p_55477_) { - if (p_55473_.f_46443_) { - m_55454_(p_55473_, p_55474_); + public InteractionResult use(BlockState p_55472_, Level p_55473_, BlockPos p_55474_, Player p_55475_, InteractionHand p_55476_, BlockHitResult p_55477_) { + if (p_55473_.isClientSide) { + spawnParticles(p_55473_, p_55474_); } else { -- m_55492_(p_55472_, p_55473_, p_55474_); +- interact(p_55472_, p_55473_, p_55474_); + interact(p_55472_, p_55473_, p_55474_, p_55475_); // CraftBukkit - add player } - ItemStack itemstack = p_55475_.m_21120_(p_55476_); - return itemstack.m_41720_() instanceof BlockItem && (new BlockPlaceContext(p_55475_, p_55476_, itemstack, p_55477_)).m_7059_() ? InteractionResult.PASS : InteractionResult.SUCCESS; + ItemStack itemstack = p_55475_.getItemInHand(p_55476_); + return itemstack.getItem() instanceof BlockItem && (new BlockPlaceContext(p_55475_, p_55476_, itemstack, p_55477_)).canPlace() ? InteractionResult.PASS : InteractionResult.SUCCESS; } -- private static void m_55492_(BlockState p_55493_, Level p_55494_, BlockPos p_55495_) { +- private static void interact(BlockState p_55493_, Level p_55494_, BlockPos p_55495_) { + private static void interact(BlockState p_55493_, Level p_55494_, BlockPos p_55495_, Entity entity) { // CraftBukkit - add player - m_55454_(p_55494_, p_55495_); - if (!p_55493_.m_61143_(f_55450_)) { + spawnParticles(p_55494_, p_55495_); + if (!p_55493_.getValue(LIT)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_55495_, p_55493_.m_61124_(f_55450_, true)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(entity, p_55495_, p_55493_.setValue(LIT, true)).isCancelled()) { + return; + } + // CraftBukkit end - p_55494_.m_7731_(p_55495_, p_55493_.m_61124_(f_55450_, Boolean.valueOf(true)), 3); + p_55494_.setBlock(p_55495_, p_55493_.setValue(LIT, Boolean.valueOf(true)), 3); } @@ -64,6 +_,11 @@ - public void m_7455_(BlockState p_55488_, ServerLevel p_55489_, BlockPos p_55490_, Random p_55491_) { - if (p_55488_.m_61143_(f_55450_)) { + public void randomTick(BlockState p_55488_, ServerLevel p_55489_, BlockPos p_55490_, Random p_55491_) { + if (p_55488_.getValue(LIT)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_55489_, p_55490_, p_55488_.m_61124_(f_55450_, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_55489_, p_55490_, p_55488_.setValue(LIT, false)).isCancelled()) { + return; + } + // CraftBukkit end - p_55489_.m_7731_(p_55490_, p_55488_.m_61124_(f_55450_, Boolean.valueOf(false)), 3); + p_55489_.setBlock(p_55490_, p_55488_.setValue(LIT, Boolean.valueOf(false)), 3); } @@ -71,11 +_,11 @@ - public void m_8101_(BlockState p_55462_, ServerLevel p_55463_, BlockPos p_55464_, ItemStack p_55465_) { - super.m_8101_(p_55462_, p_55463_, p_55464_, p_55465_); -- if (EnchantmentHelper.m_44843_(Enchantments.f_44985_, p_55465_) == 0) { -- int i = 1 + p_55463_.f_46441_.nextInt(5); -- this.m_49805_(p_55463_, p_55464_, i); + public void spawnAfterBreak(BlockState p_55462_, ServerLevel p_55463_, BlockPos p_55464_, ItemStack p_55465_) { + super.spawnAfterBreak(p_55462_, p_55463_, p_55464_, p_55465_); +- if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, p_55465_) == 0) { +- int i = 1 + p_55463_.random.nextInt(5); +- this.popExperience(p_55463_, p_55464_, i); - } + } @@ -81,4 +81,4 @@ + return silktouch == 0 ? 1 + RANDOM.nextInt(5) : 0; } - public void m_7100_(BlockState p_55479_, Level p_55480_, BlockPos p_55481_, Random p_55482_) { + public void animateTick(BlockState p_55479_, Level p_55480_, BlockPos p_55481_, Random p_55482_) { 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 62a9b177..eec65dd8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch @@ -1,85 +1,85 @@ --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -172,18 +_,32 @@ - if (redstoneside != RedstoneSide.NONE && !p_55580_.m_8055_(blockpos$mutableblockpos.m_122159_(p_55581_, direction)).m_60713_(this)) { - blockpos$mutableblockpos.m_122173_(Direction.DOWN); - BlockState blockstate = p_55580_.m_8055_(blockpos$mutableblockpos); -- if (!blockstate.m_60713_(Blocks.f_50455_)) { -- BlockPos blockpos = blockpos$mutableblockpos.m_142300_(direction.m_122424_()); -- BlockState blockstate1 = blockstate.m_60728_(direction.m_122424_(), p_55580_.m_8055_(blockpos), p_55580_, blockpos$mutableblockpos, blockpos); -- m_49908_(blockstate, blockstate1, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); + if (redstoneside != RedstoneSide.NONE && !p_55580_.getBlockState(blockpos$mutableblockpos.setWithOffset(p_55581_, direction)).is(this)) { + blockpos$mutableblockpos.move(Direction.DOWN); + BlockState blockstate = p_55580_.getBlockState(blockpos$mutableblockpos); +- if (!blockstate.is(Blocks.OBSERVER)) { +- BlockPos blockpos = blockpos$mutableblockpos.relative(direction.getOpposite()); +- BlockState blockstate1 = blockstate.updateShape(direction.getOpposite(), p_55580_.getBlockState(blockpos), p_55580_, blockpos$mutableblockpos, blockpos); +- updateOrDestroy(blockstate, blockstate1, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) { -+ if (blockstate.m_60713_(this)) { -+ BlockPos blockpos = blockpos$mutableblockpos.m_142300_(direction.m_122424_()); -+ p_55580_.neighborShapeChanged(direction.m_122424_(), p_55580_.m_8055_(blockpos), blockpos$mutableblockpos, blockpos, p_55582_, p_55583_); ++ if (blockstate.is(this)) { ++ BlockPos blockpos = blockpos$mutableblockpos.relative(direction.getOpposite()); ++ p_55580_.neighborShapeChanged(direction.getOpposite(), p_55580_.getBlockState(blockpos), blockpos$mutableblockpos, blockpos, p_55582_, p_55583_); + } + } else { -+ if (!blockstate.m_60713_(Blocks.f_50455_)) { -+ BlockPos blockpos = blockpos$mutableblockpos.m_142300_(direction.m_122424_()); -+ BlockState blockstate1 = blockstate.m_60728_(direction.m_122424_(), p_55580_.m_8055_(blockpos), p_55580_, blockpos$mutableblockpos, blockpos); -+ m_49908_(blockstate, blockstate1, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); ++ if (!blockstate.is(Blocks.OBSERVER)) { ++ BlockPos blockpos = blockpos$mutableblockpos.relative(direction.getOpposite()); ++ BlockState blockstate1 = blockstate.updateShape(direction.getOpposite(), p_55580_.getBlockState(blockpos), p_55580_, blockpos$mutableblockpos, blockpos); ++ updateOrDestroy(blockstate, blockstate1, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); + } } - blockpos$mutableblockpos.m_122159_(p_55581_, direction).m_122173_(Direction.UP); - BlockState blockstate3 = p_55580_.m_8055_(blockpos$mutableblockpos); -- if (!blockstate3.m_60713_(Blocks.f_50455_)) { -- BlockPos blockpos1 = blockpos$mutableblockpos.m_142300_(direction.m_122424_()); -- BlockState blockstate2 = blockstate3.m_60728_(direction.m_122424_(), p_55580_.m_8055_(blockpos1), p_55580_, blockpos$mutableblockpos, blockpos1); -- m_49908_(blockstate3, blockstate2, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); + blockpos$mutableblockpos.setWithOffset(p_55581_, direction).move(Direction.UP); + BlockState blockstate3 = p_55580_.getBlockState(blockpos$mutableblockpos); +- if (!blockstate3.is(Blocks.OBSERVER)) { +- BlockPos blockpos1 = blockpos$mutableblockpos.relative(direction.getOpposite()); +- BlockState blockstate2 = blockstate3.updateShape(direction.getOpposite(), p_55580_.getBlockState(blockpos1), p_55580_, blockpos$mutableblockpos, blockpos1); +- updateOrDestroy(blockstate3, blockstate2, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) { -+ if (blockstate3.m_60713_(this)) { -+ BlockPos blockpos1 = blockpos$mutableblockpos.m_142300_(direction.m_122424_()); -+ p_55580_.neighborShapeChanged(direction.m_122424_(), p_55580_.m_8055_(blockpos1), blockpos$mutableblockpos, blockpos1, p_55582_, p_55583_); ++ if (blockstate3.is(this)) { ++ BlockPos blockpos1 = blockpos$mutableblockpos.relative(direction.getOpposite()); ++ p_55580_.neighborShapeChanged(direction.getOpposite(), p_55580_.getBlockState(blockpos1), blockpos$mutableblockpos, blockpos1, p_55582_, p_55583_); + } + } else { -+ if (!blockstate3.m_60713_(Blocks.f_50455_)) { -+ BlockPos blockpos1 = blockpos$mutableblockpos.m_142300_(direction.m_122424_()); -+ BlockState blockstate2 = blockstate3.m_60728_(direction.m_122424_(), p_55580_.m_8055_(blockpos1), p_55580_, blockpos$mutableblockpos, blockpos1); -+ m_49908_(blockstate3, blockstate2, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); ++ if (!blockstate3.is(Blocks.OBSERVER)) { ++ BlockPos blockpos1 = blockpos$mutableblockpos.relative(direction.getOpposite()); ++ BlockState blockstate2 = blockstate3.updateShape(direction.getOpposite(), p_55580_.getBlockState(blockpos1), p_55580_, blockpos$mutableblockpos, blockpos1); ++ updateOrDestroy(blockstate3, blockstate2, p_55580_, blockpos$mutableblockpos, p_55582_, p_55583_); + } } } } @@ -199,7 +_,7 @@ - BlockState blockstate = p_55523_.m_8055_(blockpos); + BlockState blockstate = p_55523_.getBlockState(blockpos); if (p_55526_) { - boolean flag = this.m_55612_(p_55523_, blockpos, blockstate); -- if (flag && m_55640_(p_55523_.m_8055_(blockpos.m_7494_()))) { -+ if (flag && p_55523_.m_8055_(blockpos.m_7494_()).canRedstoneConnectTo(p_55523_, blockpos.m_7494_(), null)) { - if (blockstate.m_60783_(p_55523_, blockpos, p_55525_.m_122424_())) { + boolean flag = this.canSurviveOn(p_55523_, blockpos, blockstate); +- if (flag && shouldConnectTo(p_55523_.getBlockState(blockpos.above()))) { ++ if (flag && p_55523_.getBlockState(blockpos.above()).canRedstoneConnectTo(p_55523_, blockpos.above(), null)) { + if (blockstate.isFaceSturdy(p_55523_, blockpos, p_55525_.getOpposite())) { return RedstoneSide.UP; } @@ -208,7 +_,14 @@ } } -- return !m_55594_(blockstate, p_55525_) && (blockstate.m_60796_(p_55523_, blockpos) || !m_55640_(p_55523_.m_8055_(blockpos.m_7495_()))) ? RedstoneSide.NONE : RedstoneSide.SIDE; +- return !shouldConnectTo(blockstate, p_55525_) && (blockstate.isRedstoneConductor(p_55523_, blockpos) || !shouldConnectTo(p_55523_.getBlockState(blockpos.below()))) ? RedstoneSide.NONE : RedstoneSide.SIDE; + if (blockstate.canRedstoneConnectTo(p_55523_, blockpos, p_55525_)) { + return RedstoneSide.SIDE; -+ } else if (blockstate.m_60796_(p_55523_, blockpos)) { ++ } else if (blockstate.isRedstoneConductor(p_55523_, blockpos)) { + return RedstoneSide.NONE; + } else { -+ BlockPos blockPosBelow = blockpos.m_7495_(); -+ return p_55523_.m_8055_(blockPosBelow).canRedstoneConnectTo(p_55523_, blockPosBelow, null) ? RedstoneSide.SIDE : RedstoneSide.NONE; ++ BlockPos blockPosBelow = blockpos.below(); ++ return p_55523_.getBlockState(blockPosBelow).canRedstoneConnectTo(p_55523_, blockPosBelow, null) ? RedstoneSide.SIDE : RedstoneSide.NONE; + } } - public boolean m_7898_(BlockState p_55585_, LevelReader p_55586_, BlockPos p_55587_) { + public boolean canSurvive(BlockState p_55585_, LevelReader p_55586_, BlockPos p_55587_) { @@ -223,7 +_,15 @@ - private void m_55530_(Level p_55531_, BlockPos p_55532_, BlockState p_55533_) { - int i = this.m_55527_(p_55531_, p_55532_); -- if (p_55533_.m_61143_(f_55500_) != i) { + private void updatePowerStrength(Level p_55531_, BlockPos p_55532_, BlockState p_55533_) { + int i = this.calculateTargetStrength(p_55531_, p_55532_); +- if (p_55533_.getValue(POWER) != i) { + // CraftBukkit start -+ int oldPower = (Integer) p_55533_.m_61143_(f_55500_); ++ int oldPower = (Integer) p_55533_.getValue(POWER); + if (oldPower != i) { -+ org.bukkit.event.block.BlockRedstoneEvent event = new org.bukkit.event.block.BlockRedstoneEvent(p_55531_.getWorld().getBlockAt(p_55532_.m_123341_(), p_55532_.m_123342_(), p_55532_.m_123343_()), oldPower, i); ++ org.bukkit.event.block.BlockRedstoneEvent event = new org.bukkit.event.block.BlockRedstoneEvent(p_55531_.getWorld().getBlockAt(p_55532_.getX(), p_55532_.getY(), p_55532_.getZ()), oldPower, i); + p_55531_.getCraftServer().getPluginManager().callEvent(event); + i = event.getNewCurrent(); + } + if (oldPower != i) { + // CraftBukkit end - if (p_55531_.m_8055_(p_55532_) == p_55533_) { - p_55531_.m_7731_(p_55532_, p_55533_.m_61124_(f_55500_, Integer.valueOf(i)), 2); + if (p_55531_.getBlockState(p_55532_) == p_55533_) { + p_55531_.setBlock(p_55532_, p_55533_.setValue(POWER, Integer.valueOf(i)), 2); } diff --git a/patches/minecraft/net/minecraft/world/level/block/RedstoneLampBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedstoneLampBlock.java.patch index 85f91a74..e5d1355e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedstoneLampBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedstoneLampBlock.java.patch @@ -2,25 +2,25 @@ +++ b/net/minecraft/world/level/block/RedstoneLampBlock.java @@ -31,6 +_,11 @@ if (flag) { - p_55667_.m_186460_(p_55668_, this, 4); + p_55667_.scheduleTick(p_55668_, this, 4); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_55667_, p_55668_, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - p_55667_.m_7731_(p_55668_, p_55666_.m_61122_(f_55654_), 2); + p_55667_.setBlock(p_55668_, p_55666_.cycle(LIT), 2); } } @@ -40,6 +_,11 @@ - public void m_7458_(BlockState p_55661_, ServerLevel p_55662_, BlockPos p_55663_, Random p_55664_) { - if (p_55661_.m_61143_(f_55654_) && !p_55662_.m_46753_(p_55663_)) { + public void tick(BlockState p_55661_, ServerLevel p_55662_, BlockPos p_55663_, Random p_55664_) { + if (p_55661_.getValue(LIT) && !p_55662_.hasNeighborSignal(p_55663_)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_55662_, p_55663_, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - p_55662_.m_7731_(p_55663_, p_55661_.m_61122_(f_55654_), 2); + p_55662_.setBlock(p_55663_, p_55661_.cycle(LIT), 2); } diff --git a/patches/minecraft/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch index 851f666d..dfcff18a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch @@ -6,12 +6,12 @@ + // CraftBukkit start + org.bukkit.plugin.PluginManager manager = p_55690_.getCraftServer().getPluginManager(); -+ org.bukkit.block.Block block = p_55690_.getWorld().getBlockAt(p_55691_.m_123341_(), p_55691_.m_123342_(), p_55691_.m_123343_()); -+ int oldCurrent = ((Boolean) p_55689_.m_61143_(f_55674_)).booleanValue() ? 15 : 0; ++ org.bukkit.block.Block block = p_55690_.getWorld().getBlockAt(p_55691_.getX(), p_55691_.getY(), p_55691_.getZ()); ++ int oldCurrent = ((Boolean) p_55689_.getValue(LIT)).booleanValue() ? 15 : 0; + + org.bukkit.event.block.BlockRedstoneEvent event = new org.bukkit.event.block.BlockRedstoneEvent(block, oldCurrent, oldCurrent); + // CraftBukkit end - if (p_55689_.m_61143_(f_55674_)) { + if (p_55689_.getValue(LIT)) { if (flag) { + // CraftBukkit start + if (oldCurrent != 0) { @@ -22,13 +22,13 @@ + } + } + // CraftBukkit end - p_55690_.m_7731_(p_55691_, p_55689_.m_61124_(f_55674_, Boolean.valueOf(false)), 3); - if (m_55684_(p_55690_, p_55691_, true)) { - p_55690_.m_46796_(1502, p_55691_, 0); + p_55690_.setBlock(p_55691_, p_55689_.setValue(LIT, Boolean.valueOf(false)), 3); + if (isToggledTooFrequently(p_55690_, p_55691_, true)) { + p_55690_.levelEvent(1502, p_55691_, 0); @@ -71,6 +_,15 @@ } } - } else if (!flag && !m_55684_(p_55690_, p_55691_, false)) { + } else if (!flag && !isToggledTooFrequently(p_55690_, p_55691_, false)) { + // CraftBukkit start + if (oldCurrent != 15) { + event.setNewCurrent(15); @@ -38,6 +38,6 @@ + } + } + // CraftBukkit end - p_55690_.m_7731_(p_55691_, p_55689_.m_61124_(f_55674_, Boolean.valueOf(true)), 3); + p_55690_.setBlock(p_55691_, p_55689_.setValue(LIT, Boolean.valueOf(true)), 3); } diff --git a/patches/minecraft/net/minecraft/world/level/block/RootedDirtBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RootedDirtBlock.java.patch index d7eef127..88484e19 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RootedDirtBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RootedDirtBlock.java.patch @@ -3,8 +3,8 @@ @@ -22,6 +_,6 @@ } - public void m_7719_(ServerLevel p_154361_, Random p_154362_, BlockPos p_154363_, BlockState p_154364_) { -- p_154361_.m_46597_(p_154363_.m_7495_(), Blocks.f_152548_.m_49966_()); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_154361_, p_154363_, p_154363_.m_7495_(), Blocks.f_152548_.m_49966_()); + public void performBonemeal(ServerLevel p_154361_, Random p_154362_, BlockPos p_154363_, BlockState p_154364_) { +- p_154361_.setBlockAndUpdate(p_154363_.below(), Blocks.HANGING_ROOTS.defaultBlockState()); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_154361_, p_154363_, p_154363_.below(), Blocks.HANGING_ROOTS.defaultBlockState()); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch index 2348752d..7a178b05 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/SaplingBlock.java +++ b/net/minecraft/world/level/block/SaplingBlock.java @@ -19,6 +_,7 @@ - protected static final float f_154380_ = 6.0F; - protected static final VoxelShape f_55974_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); - private final AbstractTreeGrower f_55975_; + protected static final float AABB_OFFSET = 6.0F; + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); + private final AbstractTreeGrower treeGrower; + public static org.bukkit.TreeType treeType; // CraftBukkit public SaplingBlock(AbstractTreeGrower p_55978_, BlockBehaviour.Properties p_55979_) { @@ -11,20 +11,20 @@ @@ -31,8 +_,32 @@ } - public void m_7455_(BlockState p_56003_, ServerLevel p_56004_, BlockPos p_56005_, Random p_56006_) { -- if (p_56004_.m_46803_(p_56005_.m_7494_()) >= 9 && p_56006_.nextInt(7) == 0) { -+ if (p_56004_.m_46803_(p_56005_.m_7494_()) >= 9 && p_56006_.nextInt(Math.max(2, (int) (((100.0F / p_56004_.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) { // Spigot + public void randomTick(BlockState p_56003_, ServerLevel p_56004_, BlockPos p_56005_, Random p_56006_) { +- if (p_56004_.getMaxLocalRawBrightness(p_56005_.above()) >= 9 && p_56006_.nextInt(7) == 0) { ++ if (p_56004_.getMaxLocalRawBrightness(p_56005_.above()) >= 9 && p_56006_.nextInt(Math.max(2, (int) (((100.0F / p_56004_.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) { // Spigot + if (!p_56004_.isAreaLoaded(p_56005_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light + //CraftBukkit start + p_56004_.captureTreeGeneration = true; + //CraftBukkit end - this.m_55980_(p_56004_, p_56005_, p_56003_, p_56006_); + this.advanceTree(p_56004_, p_56005_, p_56003_, p_56006_); + // CraftBukkit start + p_56004_.captureTreeGeneration = false; + if (p_56004_.capturedBlockStates.size() > 0) { + org.bukkit.TreeType treeType = SaplingBlock.treeType; + SaplingBlock.treeType = null; -+ org.bukkit.Location location = new org.bukkit.Location(p_56004_.getWorld(), p_56005_.m_123341_(), p_56005_.m_123342_(), p_56005_.m_123343_()); ++ org.bukkit.Location location = new org.bukkit.Location(p_56004_.getWorld(), p_56005_.getX(), p_56005_.getY(), p_56005_.getZ()); + java.util.List blocks = new java.util.ArrayList<>(p_56004_.capturedBlockStates.values()); + p_56004_.capturedBlockStates.clear(); + org.bukkit.event.world.StructureGrowEvent event = null; diff --git a/patches/minecraft/net/minecraft/world/level/block/ScaffoldingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ScaffoldingBlock.java.patch index 6ae0ea46..c6c8b634 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ScaffoldingBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ScaffoldingBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/ScaffoldingBlock.java +++ b/net/minecraft/world/level/block/ScaffoldingBlock.java @@ -88,7 +_,7 @@ - int i = m_56024_(p_56033_, p_56034_); - BlockState blockstate = p_56032_.m_61124_(f_56012_, Integer.valueOf(i)).m_61124_(f_56014_, Boolean.valueOf(this.m_56027_(p_56033_, p_56034_, i))); - if (blockstate.m_61143_(f_56012_) == 7) { -- if (p_56032_.m_61143_(f_56012_) == 7) { -+ if (p_56032_.m_61143_(f_56012_) == 7 && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_56033_, p_56034_, Blocks.f_50016_.m_49966_()).isCancelled()) { // CraftBukkit - BlockFadeEvent - FallingBlockEntity.m_201971_(p_56033_, p_56034_, blockstate); + int i = getDistance(p_56033_, p_56034_); + BlockState blockstate = p_56032_.setValue(DISTANCE, Integer.valueOf(i)).setValue(BOTTOM, Boolean.valueOf(this.isBottom(p_56033_, p_56034_, i))); + if (blockstate.getValue(DISTANCE) == 7) { +- if (p_56032_.getValue(DISTANCE) == 7) { ++ if (p_56032_.getValue(DISTANCE) == 7 && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_56033_, p_56034_, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit - BlockFadeEvent + FallingBlockEntity.fall(p_56033_, p_56034_, blockstate); } else { - p_56033_.m_46961_(p_56034_, true); + p_56033_.destroyBlock(p_56034_, true); 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 a2649cd1..3e0c4f0f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -3,24 +3,24 @@ @@ -200,6 +_,14 @@ } - public static void m_154407_(Level p_154408_, BlockPos p_154409_, BlockState p_154410_) { + public static void deactivate(Level p_154408_, BlockPos p_154409_, BlockState p_154410_) { + // CraftBukkit start -+ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154408_, p_154409_), p_154410_.m_61143_(SculkSensorBlock.f_154387_), 0); ++ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154408_, p_154409_), p_154410_.getValue(SculkSensorBlock.POWER), 0); + p_154408_.getCraftServer().getPluginManager().callEvent(eventRedstone); + if (eventRedstone.getNewCurrent() > 0) { -+ p_154408_.m_7731_(p_154409_, p_154410_.m_61124_(SculkSensorBlock.f_154387_, eventRedstone.getNewCurrent()), 3); ++ p_154408_.setBlock(p_154409_, p_154410_.setValue(SculkSensorBlock.POWER, eventRedstone.getNewCurrent()), 3); + return; + } + // CraftBukkit end - p_154408_.m_7731_(p_154409_, p_154410_.m_61124_(f_154386_, SculkSensorPhase.COOLDOWN).m_61124_(f_154387_, Integer.valueOf(0)), 3); - p_154408_.m_186460_(new BlockPos(p_154409_), p_154410_.m_60734_(), 1); - if (!p_154410_.m_61143_(f_154388_)) { + p_154408_.setBlock(p_154409_, p_154410_.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, Integer.valueOf(0)), 3); + p_154408_.scheduleTick(new BlockPos(p_154409_), p_154410_.getBlock(), 1); + if (!p_154410_.getValue(WATERLOGGED)) { @@ -210,6 +_,15 @@ } - public static void m_154411_(Level p_154412_, BlockPos p_154413_, BlockState p_154414_, int p_154415_) { + public static void activate(Level p_154412_, BlockPos p_154413_, BlockState p_154414_, int p_154415_) { + // CraftBukkit start -+ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154412_, p_154413_), p_154414_.m_61143_(SculkSensorBlock.f_154387_), p_154415_); ++ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154412_, p_154413_), p_154414_.getValue(SculkSensorBlock.POWER), p_154415_); + p_154412_.getCraftServer().getPluginManager().callEvent(eventRedstone); + + if (eventRedstone.getNewCurrent() <= 0) { @@ -28,6 +28,6 @@ + } + p_154415_ = eventRedstone.getNewCurrent(); + // CraftBukkit end - p_154412_.m_7731_(p_154413_, p_154414_.m_61124_(f_154386_, SculkSensorPhase.ACTIVE).m_61124_(f_154387_, Integer.valueOf(p_154415_)), 3); - p_154412_.m_186460_(new BlockPos(p_154413_), p_154414_.m_60734_(), 40); - m_154404_(p_154412_, p_154413_); + p_154412_.setBlock(p_154413_, p_154414_.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, Integer.valueOf(p_154415_)), 3); + p_154412_.scheduleTick(new BlockPos(p_154413_), p_154414_.getBlock(), 40); + updateNeighbours(p_154412_, p_154413_); 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 28f28317..c486d80c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -6,6 +6,6 @@ -public class SeagrassBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer { +public class SeagrassBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer, net.minecraftforge.common.IForgeShearable { - protected static final float f_154492_ = 6.0F; - protected static final VoxelShape f_154493_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); + protected static final float AABB_OFFSET = 6.0F; + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); diff --git a/patches/minecraft/net/minecraft/world/level/block/SnowLayerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SnowLayerBlock.java.patch index a1f26128..bd519023 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SnowLayerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SnowLayerBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/SnowLayerBlock.java @@ -83,6 +_,11 @@ - public void m_7455_(BlockState p_56615_, ServerLevel p_56616_, BlockPos p_56617_, Random p_56618_) { - if (p_56616_.m_45517_(LightLayer.BLOCK, p_56617_) > 11) { + public void randomTick(BlockState p_56615_, ServerLevel p_56616_, BlockPos p_56617_, Random p_56618_) { + if (p_56616_.getBrightness(LightLayer.BLOCK, p_56617_) > 11) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_56616_, p_56617_, Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_56616_, p_56617_, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - m_49950_(p_56615_, p_56616_, p_56617_); - p_56616_.m_7471_(p_56617_, false); + dropResources(p_56615_, p_56616_, p_56617_); + p_56616_.removeBlock(p_56617_, false); } 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 709d5cef..b37e2562 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java @@ -88,6 +_,7 @@ - public final SoundEvent f_56737_; - private final SoundEvent f_56738_; + public final SoundEvent hitSound; + private final SoundEvent fallSound; + @Deprecated // Forge: Use {@link net.minecraftforge.common.util.ForgeSoundType} instead for suppliers public SoundType(float p_56766_, float p_56767_, SoundEvent p_56768_, SoundEvent p_56769_, SoundEvent p_56770_, SoundEvent p_56771_, SoundEvent p_56772_) { - this.f_56731_ = p_56766_; - this.f_56732_ = p_56767_; + this.volume = p_56766_; + this.pitch = p_56767_; diff --git a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch index 071112a2..e8c6020d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/level/block/SpawnerBlock.java @@ -29,8 +_,11 @@ - public void m_8101_(BlockState p_56789_, ServerLevel p_56790_, BlockPos p_56791_, ItemStack p_56792_) { - super.m_8101_(p_56789_, p_56790_, p_56791_, p_56792_); -- int i = 15 + p_56790_.f_46441_.nextInt(15) + p_56790_.f_46441_.nextInt(15); -- this.m_49805_(p_56790_, p_56791_, i); + public void spawnAfterBreak(BlockState p_56789_, ServerLevel p_56790_, BlockPos p_56791_, ItemStack p_56792_) { + super.spawnAfterBreak(p_56789_, p_56790_, p_56791_, p_56792_); +- int i = 15 + p_56790_.random.nextInt(15) + p_56790_.random.nextInt(15); +- this.popExperience(p_56790_, p_56791_, i); + } + + @Override @@ -13,4 +13,4 @@ + return 15 + RANDOM.nextInt(15) + RANDOM.nextInt(15); } - public RenderShape m_7514_(BlockState p_56794_) { + public RenderShape getRenderShape(BlockState p_56794_) { 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 62227ca9..889be8bb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -11,34 +11,34 @@ @@ -52,25 +_,27 @@ for(Direction direction : Direction.values()) { - BlockPos blockpos1 = blockpos.m_142300_(direction); -- BlockState blockstate = p_56808_.m_8055_(blockpos1); -- FluidState fluidstate = p_56808_.m_6425_(blockpos1); + BlockPos blockpos1 = blockpos.relative(direction); +- BlockState blockstate = p_56808_.getBlockState(blockpos1); +- FluidState fluidstate = p_56808_.getFluidState(blockpos1); + // CraftBukkit start -+ BlockState blockstate = blockList.m_8055_(blockpos1); -+ FluidState fluidstate = blockList.m_6425_(blockpos1); ++ BlockState blockstate = blockList.getBlockState(blockpos1); ++ FluidState fluidstate = blockList.getFluidState(blockpos1); + // CraftBukkit end - Material material = blockstate.m_60767_(); - if (fluidstate.m_205070_(FluidTags.f_13131_)) { -- if (blockstate.m_60734_() instanceof BucketPickup && !((BucketPickup)blockstate.m_60734_()).m_142598_(p_56808_, blockpos1, blockstate).m_41619_()) { -+ if (blockstate.m_60734_() instanceof BucketPickup && !((BucketPickup)blockstate.m_60734_()).m_142598_(blockList, blockpos1, blockstate).m_41619_()) { // CraftBukkit - Use BlockStateListPopulator + Material material = blockstate.getMaterial(); + if (fluidstate.is(FluidTags.WATER)) { +- if (blockstate.getBlock() instanceof BucketPickup && !((BucketPickup)blockstate.getBlock()).pickupBlock(p_56808_, blockpos1, blockstate).isEmpty()) { ++ if (blockstate.getBlock() instanceof BucketPickup && !((BucketPickup)blockstate.getBlock()).pickupBlock(blockList, blockpos1, blockstate).isEmpty()) { // CraftBukkit - Use BlockStateListPopulator ++i; if (j < 6) { queue.add(new Tuple<>(blockpos1, j + 1)); } - } else if (blockstate.m_60734_() instanceof LiquidBlock) { -- p_56808_.m_7731_(blockpos1, Blocks.f_50016_.m_49966_(), 3); -+ blockList.m_7731_(blockpos1, Blocks.f_50016_.m_49966_(), 3); // CraftBukkit + } else if (blockstate.getBlock() instanceof LiquidBlock) { +- p_56808_.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); ++ blockList.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit ++i; if (j < 6) { queue.add(new Tuple<>(blockpos1, j + 1)); } - } else if (material == Material.f_76301_ || material == Material.f_76304_) { -- BlockEntity blockentity = blockstate.m_155947_() ? p_56808_.m_7702_(blockpos1) : null; -- m_49892_(blockstate, p_56808_, blockpos1, blockentity); -- p_56808_.m_7731_(blockpos1, Blocks.f_50016_.m_49966_(), 3); + } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { +- BlockEntity blockentity = blockstate.hasBlockEntity() ? p_56808_.getBlockEntity(blockpos1) : null; +- dropResources(blockstate, p_56808_, blockpos1, blockentity); +- p_56808_.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); + // CraftBukkit start -+ blockList.m_7731_(blockpos1, Blocks.f_50016_.m_49966_(), 3); ++ blockList.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); + // CraftBukkit end ++i; if (j < 6) { @@ -51,7 +51,7 @@ + // CraftBukkit start + java.util.List blocks = blockList.getList(); // Is a clone + if (!blocks.isEmpty()) { -+ final org.bukkit.block.Block bblock = p_56808_.getWorld().getBlockAt(p_56809_.m_123341_(), p_56809_.m_123342_(), p_56809_.m_123343_()); ++ final org.bukkit.block.Block bblock = p_56808_.getWorld().getBlockAt(p_56809_.getX(), p_56809_.getY(), p_56809_.getZ()); + org.bukkit.event.block.SpongeAbsorbEvent event = new org.bukkit.event.block.SpongeAbsorbEvent(bblock, (java.util.List) (java.util.List) blocks); + p_56808_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { @@ -59,20 +59,20 @@ + } + for (org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState block : blocks) { + BlockPos blockposition2 = block.getPosition(); -+ BlockState blockState = p_56808_.m_8055_(blockposition2); -+ FluidState fluidState = p_56808_.m_6425_(blockposition2); -+ Material material = blockState.m_60767_(); -+ if (fluidState.m_205070_(FluidTags.f_13131_)) { -+ if (blockState.m_60734_() instanceof BucketPickup && !((BucketPickup) blockState.m_60734_()).m_142598_(blockList, blockposition2, blockState).m_41619_()) { ++ BlockState blockState = p_56808_.getBlockState(blockposition2); ++ FluidState fluidState = p_56808_.getFluidState(blockposition2); ++ Material material = blockState.getMaterial(); ++ if (fluidState.is(FluidTags.WATER)) { ++ if (blockState.getBlock() instanceof BucketPickup && !((BucketPickup) blockState.getBlock()).pickupBlock(blockList, blockposition2, blockState).isEmpty()) { + // NOP -+ } else if (blockState.m_60734_() instanceof LiquidBlock) { ++ } else if (blockState.getBlock() instanceof LiquidBlock) { + // NOP -+ } else if (material == Material.f_76301_ || material == Material.f_76304_) { -+ BlockEntity blockEntity = blockState.m_155947_() ? p_56808_.m_7702_(blockposition2) : null; -+ m_49892_(blockState, p_56808_, blockposition2, blockEntity); ++ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { ++ BlockEntity blockEntity = blockState.hasBlockEntity() ? p_56808_.getBlockEntity(blockposition2) : null; ++ dropResources(blockState, p_56808_, blockposition2, blockEntity); + } + } -+ p_56808_.m_7731_(blockposition2, block.getHandle(), block.getFlag()); ++ p_56808_.setBlock(blockposition2, block.getHandle(), block.getFlag()); + } + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch index f3cb2629..07b13a06 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch @@ -2,25 +2,25 @@ +++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java @@ -35,15 +_,22 @@ - public void m_7455_(BlockState p_56819_, ServerLevel p_56820_, BlockPos p_56821_, Random p_56822_) { - if (!m_56823_(p_56819_, p_56820_, p_56821_)) { + public void randomTick(BlockState p_56819_, ServerLevel p_56820_, BlockPos p_56821_, Random p_56822_) { + if (!canBeGrass(p_56819_, p_56820_, p_56821_)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_56820_, p_56821_, Blocks.f_50493_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_56820_, p_56821_, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end + if (!p_56820_.isAreaLoaded(p_56821_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light and spreading - p_56820_.m_46597_(p_56821_, Blocks.f_50493_.m_49966_()); + p_56820_.setBlockAndUpdate(p_56821_, Blocks.DIRT.defaultBlockState()); } else { + if (!p_56820_.isAreaLoaded(p_56821_, 3)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light and spreading - if (p_56820_.m_46803_(p_56821_.m_7494_()) >= 9) { - BlockState blockstate = this.m_49966_(); + if (p_56820_.getMaxLocalRawBrightness(p_56821_.above()) >= 9) { + BlockState blockstate = this.defaultBlockState(); for(int i = 0; i < 4; ++i) { - BlockPos blockpos = p_56821_.m_142082_(p_56822_.nextInt(3) - 1, p_56822_.nextInt(5) - 3, p_56822_.nextInt(3) - 1); - if (p_56820_.m_8055_(blockpos).m_60713_(Blocks.f_50493_) && m_56827_(blockstate, p_56820_, blockpos)) { -- p_56820_.m_46597_(blockpos, blockstate.m_61124_(f_56637_, Boolean.valueOf(p_56820_.m_8055_(blockpos.m_7494_()).m_60713_(Blocks.f_50125_)))); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_56820_, p_56821_, blockpos, blockstate.m_61124_(f_56637_, Boolean.valueOf(p_56820_.m_8055_(blockpos.m_7494_()).m_60713_(Blocks.f_50125_)))); // CraftBukkit + BlockPos blockpos = p_56821_.offset(p_56822_.nextInt(3) - 1, p_56822_.nextInt(5) - 3, p_56822_.nextInt(3) - 1); + if (p_56820_.getBlockState(blockpos).is(Blocks.DIRT) && canPropagate(blockstate, p_56820_, blockpos)) { +- p_56820_.setBlockAndUpdate(blockpos, blockstate.setValue(SNOWY, Boolean.valueOf(p_56820_.getBlockState(blockpos.above()).is(Blocks.SNOW)))); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_56820_, p_56821_, blockpos, blockstate.setValue(SNOWY, Boolean.valueOf(p_56820_.getBlockState(blockpos.above()).is(Blocks.SNOW)))); // CraftBukkit } } } diff --git a/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch index 5d888f52..a2129c06 100644 --- a/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/StairBlock.java.patch @@ -7,42 +7,42 @@ + @Deprecated // Forge: Use the other constructor that takes a Supplier public StairBlock(BlockState p_56862_, BlockBehaviour.Properties p_56863_) { super(p_56863_); - this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_56841_, Direction.NORTH).m_61124_(f_56842_, Half.BOTTOM).m_61124_(f_56843_, StairsShape.STRAIGHT).m_61124_(f_56844_, Boolean.valueOf(false))); - this.f_56858_ = p_56862_.m_60734_(); - this.f_56859_ = p_56862_; + this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(HALF, Half.BOTTOM).setValue(SHAPE, StairsShape.STRAIGHT).setValue(WATERLOGGED, Boolean.valueOf(false))); + this.base = p_56862_.getBlock(); + this.baseState = p_56862_; + this.stateSupplier = () -> p_56862_; + } + + public StairBlock(java.util.function.Supplier state, BlockBehaviour.Properties properties) { + super(properties); -+ this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_56841_, Direction.NORTH).m_61124_(f_56842_, Half.BOTTOM).m_61124_(f_56843_, StairsShape.STRAIGHT).m_61124_(f_56844_, Boolean.valueOf(false))); -+ this.f_56858_ = Blocks.f_50016_; // These are unused, fields are redirected -+ this.f_56859_ = Blocks.f_50016_.m_49966_(); ++ this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(HALF, Half.BOTTOM).setValue(SHAPE, StairsShape.STRAIGHT).setValue(WATERLOGGED, Boolean.valueOf(false))); ++ this.base = Blocks.AIR; // These are unused, fields are redirected ++ this.baseState = Blocks.AIR.defaultBlockState(); + this.stateSupplier = state; } - public boolean m_7923_(BlockState p_56967_) { + public boolean useShapeForLightOcclusion(BlockState p_56967_) { @@ -118,7 +_,10 @@ - public void m_6807_(BlockState p_56961_, Level p_56962_, BlockPos p_56963_, BlockState p_56964_, boolean p_56965_) { - if (!p_56961_.m_60713_(p_56961_.m_60734_())) { -- this.f_56859_.m_60690_(p_56962_, p_56963_, Blocks.f_50016_, p_56963_, false); + public void onPlace(BlockState p_56961_, Level p_56962_, BlockPos p_56963_, BlockState p_56964_, boolean p_56965_) { + if (!p_56961_.is(p_56961_.getBlock())) { +- this.baseState.neighborChanged(p_56962_, p_56963_, Blocks.AIR, p_56963_, false); + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) -+ p_56962_.neighborChanged(this.f_56859_, p_56963_, Blocks.f_50016_, p_56963_, false); ++ p_56962_.neighborChanged(this.baseState, p_56963_, Blocks.AIR, p_56963_, false); + else -+ this.f_56859_.m_60690_(p_56962_, p_56963_, Blocks.f_50016_, p_56963_, false); - this.f_56858_.m_6807_(this.f_56859_, p_56962_, p_56963_, p_56964_, false); ++ this.baseState.neighborChanged(p_56962_, p_56963_, Blocks.AIR, p_56963_, false); + this.base.onPlace(this.baseState, p_56962_, p_56963_, p_56964_, false); } } @@ -262,4 +_,14 @@ - public boolean m_7357_(BlockState p_56891_, BlockGetter p_56892_, BlockPos p_56893_, PathComputationType p_56894_) { + public boolean isPathfindable(BlockState p_56891_, BlockGetter p_56892_, BlockPos p_56893_, PathComputationType p_56894_) { return false; } + + // Forge Start + private final java.util.function.Supplier stateSupplier; + private Block getModelBlock() { -+ return getModelState().m_60734_(); ++ return getModelState().getBlock(); + } + private BlockState getModelState() { + return stateSupplier.get(); diff --git a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch index 3bdfd6d6..df303bde 100644 --- a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch @@ -3,31 +3,31 @@ @@ -43,22 +_,28 @@ } - public void m_7455_(BlockState p_57042_, ServerLevel p_57043_, BlockPos p_57044_, Random p_57045_) { + public void randomTick(BlockState p_57042_, ServerLevel p_57043_, BlockPos p_57044_, Random p_57045_) { + if (!p_57043_.isAreaLoaded(p_57044_, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light - if (p_57043_.m_45524_(p_57044_, 0) >= 9) { - float f = CropBlock.m_52272_(this, p_57043_, p_57044_); + if (p_57043_.getRawBrightness(p_57044_, 0) >= 9) { + float f = CropBlock.getGrowthSpeed(this, p_57043_, p_57044_); - if (p_57045_.nextInt((int)(25.0F / f) + 1) == 0) { -+ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57043_, p_57044_, p_57042_, p_57045_.nextInt((int) ((100.0F / (this == Blocks.f_50189_ ? p_57043_.spigotConfig.pumpkinModifier : p_57043_.spigotConfig.melonModifier)) * (25.0F / f)) + 1) == 0)) { // Spigot - int i = p_57042_.m_61143_(f_57013_); ++ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57043_, p_57044_, p_57042_, p_57045_.nextInt((int) ((100.0F / (this == Blocks.PUMPKIN_STEM ? p_57043_.spigotConfig.pumpkinModifier : p_57043_.spigotConfig.melonModifier)) * (25.0F / f)) + 1) == 0)) { // Spigot + int i = p_57042_.getValue(AGE); if (i < 7) { -- p_57042_ = p_57042_.m_61124_(f_57013_, Integer.valueOf(i + 1)); -- p_57043_.m_7731_(p_57044_, p_57042_, 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57043_, p_57044_, p_57042_.m_61124_(f_57013_, Integer.valueOf(i + 1)), 2); // CraftBukkit +- p_57042_ = p_57042_.setValue(AGE, Integer.valueOf(i + 1)); +- p_57043_.setBlock(p_57044_, p_57042_, 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57043_, p_57044_, p_57042_.setValue(AGE, Integer.valueOf(i + 1)), 2); // CraftBukkit } else { - Direction direction = Direction.Plane.HORIZONTAL.m_122560_(p_57045_); - BlockPos blockpos = p_57044_.m_142300_(direction); - BlockState blockstate = p_57043_.m_8055_(blockpos.m_7495_()); -- if (p_57043_.m_8055_(blockpos).m_60795_() && (blockstate.m_60713_(Blocks.f_50093_) || blockstate.m_204336_(BlockTags.f_144274_))) { -- p_57043_.m_46597_(blockpos, this.f_57015_.m_49966_()); -+ Block block = blockstate.m_60734_(); -+ if (p_57043_.m_46859_(blockpos) && (blockstate.canSustainPlant(p_57043_, blockpos.m_7495_(), Direction.UP, this) || block == Blocks.f_50093_ || block == Blocks.f_50493_ || block == Blocks.f_50546_ || block == Blocks.f_50599_ || block == Blocks.f_50440_)) { + Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(p_57045_); + BlockPos blockpos = p_57044_.relative(direction); + BlockState blockstate = p_57043_.getBlockState(blockpos.below()); +- if (p_57043_.getBlockState(blockpos).isAir() && (blockstate.is(Blocks.FARMLAND) || blockstate.is(BlockTags.DIRT))) { +- p_57043_.setBlockAndUpdate(blockpos, this.fruit.defaultBlockState()); ++ Block block = blockstate.getBlock(); ++ if (p_57043_.isEmptyBlock(blockpos) && (blockstate.canSustainPlant(p_57043_, blockpos.below(), Direction.UP, this) || block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL || block == Blocks.GRASS_BLOCK)) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57043_, blockpos, this.f_57015_.m_49966_())) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57043_, blockpos, this.fruit.defaultBlockState())) { + return; + } + // CraftBukkit end - p_57043_.m_46597_(p_57044_, this.f_57015_.m_7810_().m_49966_().m_61124_(HorizontalDirectionalBlock.f_54117_, direction)); + p_57043_.setBlockAndUpdate(p_57044_, this.fruit.getAttachedStem().defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, direction)); } } + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_57043_, p_57044_, p_57042_); @@ -35,18 +35,18 @@ } @@ -79,7 +_,7 @@ - public void m_7719_(ServerLevel p_57021_, Random p_57022_, BlockPos p_57023_, BlockState p_57024_) { - int i = Math.min(7, p_57024_.m_61143_(f_57013_) + Mth.m_14072_(p_57021_.f_46441_, 2, 5)); - BlockState blockstate = p_57024_.m_61124_(f_57013_, Integer.valueOf(i)); -- p_57021_.m_7731_(p_57023_, blockstate, 2); + public void performBonemeal(ServerLevel p_57021_, Random p_57022_, BlockPos p_57023_, BlockState p_57024_) { + int i = Math.min(7, p_57024_.getValue(AGE) + Mth.nextInt(p_57021_.random, 2, 5)); + BlockState blockstate = p_57024_.setValue(AGE, Integer.valueOf(i)); +- p_57021_.setBlock(p_57023_, blockstate, 2); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57021_, p_57023_, blockstate, 2); // CraftBukkit if (i == 7) { - blockstate.m_60735_(p_57021_, p_57023_, p_57021_.f_46441_); + blockstate.randomTick(p_57021_, p_57023_, p_57021_.random); } @@ -92,5 +_,11 @@ - public StemGrownBlock m_57056_() { - return this.f_57015_; + public StemGrownBlock getFruit() { + return this.fruit; + } + + //FORGE START 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 5b8cdfaa..1f958568 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -6,21 +6,21 @@ -public class SugarCaneBlock extends Block { +public class SugarCaneBlock extends Block implements net.minecraftforge.common.IPlantable { - public static final IntegerProperty f_57164_ = BlockStateProperties.f_61410_; - protected static final float f_154735_ = 6.0F; - protected static final VoxelShape f_57165_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 16.0D, 14.0D); + public static final IntegerProperty AGE = BlockStateProperties.AGE_15; + protected static final float AABB_OFFSET = 6.0F; + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 16.0D, 14.0D); @@ -47,12 +_,14 @@ if (i < 3) { - int j = p_57188_.m_61143_(f_57164_); + int j = p_57188_.getValue(AGE); - if (j == 15) { -- p_57189_.m_46597_(p_57190_.m_7494_(), this.m_49966_()); +- p_57189_.setBlockAndUpdate(p_57190_.above(), this.defaultBlockState()); + if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57189_, p_57190_, p_57188_, true)) { + if (j >= (byte) range(3, ((100.0F / p_57189_.spigotConfig.caneModifier) * 15) + 0.5F, 15)) { // Spigot -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57189_, p_57190_.m_7494_(), this.m_49966_()); - p_57189_.m_7731_(p_57190_, p_57188_.m_61124_(f_57164_, Integer.valueOf(0)), 4); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57189_, p_57190_.above(), this.defaultBlockState()); + p_57189_.setBlock(p_57190_, p_57188_.setValue(AGE, Integer.valueOf(0)), 4); } else { - p_57189_.m_7731_(p_57190_, p_57188_.m_61124_(f_57164_, Integer.valueOf(j + 1)), 4); + p_57189_.setBlock(p_57190_, p_57188_.setValue(AGE, Integer.valueOf(j + 1)), 4); } + } } @@ -29,16 +29,16 @@ @@ -67,6 +_,8 @@ } - public boolean m_7898_(BlockState p_57175_, LevelReader p_57176_, BlockPos p_57177_) { -+ BlockState soil = p_57176_.m_8055_(p_57177_.m_7495_()); -+ if (soil.canSustainPlant(p_57176_, p_57177_.m_7495_(), Direction.UP, this)) return true; - BlockState blockstate = p_57176_.m_8055_(p_57177_.m_7495_()); - if (blockstate.m_60713_(this)) { + public boolean canSurvive(BlockState p_57175_, LevelReader p_57176_, BlockPos p_57177_) { ++ BlockState soil = p_57176_.getBlockState(p_57177_.below()); ++ if (soil.canSustainPlant(p_57176_, p_57177_.below(), Direction.UP, this)) return true; + BlockState blockstate = p_57176_.getBlockState(p_57177_.below()); + if (blockstate.is(this)) { return true; @@ -89,5 +_,15 @@ - protected void m_7926_(StateDefinition.Builder p_57186_) { - p_57186_.m_61104_(f_57164_); + protected void createBlockStateDefinition(StateDefinition.Builder p_57186_) { + p_57186_.add(AGE); + } + + @Override @@ -48,6 +48,6 @@ + + @Override + public BlockState getPlant(BlockGetter world, BlockPos pos) { -+ return m_49966_(); ++ return defaultBlockState(); } } 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 dadb5057..2e7edd0b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -2,22 +2,22 @@ +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java @@ -56,8 +_,9 @@ - public void m_7455_(BlockState p_57286_, ServerLevel p_57287_, BlockPos p_57288_, Random p_57289_) { - int i = p_57286_.m_61143_(f_57244_); -- if (i < 3 && p_57289_.nextInt(5) == 0 && p_57287_.m_45524_(p_57288_.m_7494_(), 0) >= 9) { -- p_57287_.m_7731_(p_57288_, p_57286_.m_61124_(f_57244_, Integer.valueOf(i + 1)), 2); -+ if (i < 3 && p_57287_.m_45524_(p_57288_.m_7494_(), 0) >= 9 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57287_, p_57288_, p_57286_,p_57289_.nextInt(Math.max(1, (int) (100.0F / p_57287_.spigotConfig.sweetBerryModifier) * 5)) == 0)) { // Spigot -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57287_, p_57288_, p_57286_.m_61124_(f_57244_, Integer.valueOf(i + 1)), 2); + public void randomTick(BlockState p_57286_, ServerLevel p_57287_, BlockPos p_57288_, Random p_57289_) { + int i = p_57286_.getValue(AGE); +- if (i < 3 && p_57289_.nextInt(5) == 0 && p_57287_.getRawBrightness(p_57288_.above(), 0) >= 9) { +- p_57287_.setBlock(p_57288_, p_57286_.setValue(AGE, Integer.valueOf(i + 1)), 2); ++ if (i < 3 && p_57287_.getRawBrightness(p_57288_.above(), 0) >= 9 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_57287_, p_57288_, p_57286_,p_57289_.nextInt(Math.max(1, (int) (100.0F / p_57287_.spigotConfig.sweetBerryModifier) * 5)) == 0)) { // Spigot ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57287_, p_57288_, p_57286_.setValue(AGE, Integer.valueOf(i + 1)), 2); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_57287_, p_57288_, p_57286_); } } @@ -69,7 +_,9 @@ - double d0 = Math.abs(p_57273_.m_20185_() - p_57273_.f_19790_); - double d1 = Math.abs(p_57273_.m_20189_() - p_57273_.f_19792_); + double d0 = Math.abs(p_57273_.getX() - p_57273_.xOld); + double d1 = Math.abs(p_57273_.getZ() - p_57273_.zOld); if (d0 >= (double)0.003F || d1 >= (double)0.003F) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_57271_, p_57272_); // CraftBukkit - p_57273_.m_6469_(DamageSource.f_19325_, 1.0F); + p_57273_.hurt(DamageSource.SWEET_BERRY_BUSH, 1.0F); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; // CraftBukkit } } @@ -25,17 +25,17 @@ @@ -83,7 +_,15 @@ return InteractionResult.PASS; } else if (i > 1) { - int j = 1 + p_57276_.f_46441_.nextInt(2); -- m_49840_(p_57276_, p_57277_, new ItemStack(Items.f_42780_, j + (flag ? 1 : 0))); + int j = 1 + p_57276_.random.nextInt(2); +- popResource(p_57276_, p_57277_, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))); + // CraftBukkit start -+ org.bukkit.event.player.PlayerHarvestBlockEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerHarvestBlockEvent(p_57276_, p_57277_, p_57278_, java.util.Collections.singletonList(new ItemStack(Items.f_42780_, j + (flag ? 1 : 0)))); ++ org.bukkit.event.player.PlayerHarvestBlockEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerHarvestBlockEvent(p_57276_, p_57277_, p_57278_, java.util.Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0)))); + if (event.isCancelled()) { + return InteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block + } + for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) { -+ m_49840_(p_57276_, p_57277_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(itemStack)); ++ popResource(p_57276_, p_57277_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(itemStack)); + } + // CraftBukkit end - p_57276_.m_5594_((Player)null, p_57277_, SoundEvents.f_12457_, SoundSource.BLOCKS, 1.0F, 0.8F + p_57276_.f_46441_.nextFloat() * 0.4F); - p_57276_.m_7731_(p_57277_, p_57275_.m_61124_(f_57244_, Integer.valueOf(1)), 2); - return InteractionResult.m_19078_(p_57276_.f_46443_); + p_57276_.playSound((Player)null, p_57277_, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, 0.8F + p_57276_.random.nextFloat() * 0.4F); + p_57276_.setBlock(p_57277_, p_57275_.setValue(AGE, Integer.valueOf(1)), 2); + return InteractionResult.sidedSuccess(p_57276_.isClientSide); diff --git a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch index c5c15734..d00306af 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch @@ -6,6 +6,6 @@ -public class TallGrassBlock extends BushBlock implements BonemealableBlock { +public class TallGrassBlock extends BushBlock implements BonemealableBlock, net.minecraftforge.common.IForgeShearable { - protected static final float f_154739_ = 6.0F; - protected static final VoxelShape f_57315_ = Block.m_49796_(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); + protected static final float AABB_OFFSET = 6.0F; + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); 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 a3a9805f..30a572e0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,72 +1,72 @@ --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java @@ -33,10 +_,14 @@ - this.m_49959_(this.m_49966_().m_61124_(f_57419_, Boolean.valueOf(false))); + this.registerDefaultState(this.defaultBlockState().setValue(UNSTABLE, Boolean.valueOf(false))); } + public void onCaughtFire(BlockState state, Level world, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { -+ m_57436_(world, pos, igniter); ++ explode(world, pos, igniter); + } + - public void m_6807_(BlockState p_57466_, Level p_57467_, BlockPos p_57468_, BlockState p_57469_, boolean p_57470_) { - if (!p_57469_.m_60713_(p_57466_.m_60734_())) { - if (p_57467_.m_46753_(p_57468_)) { -- m_57433_(p_57467_, p_57468_); + public 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_)) { +- explode(p_57467_, p_57468_); + onCaughtFire(p_57466_, p_57467_, p_57468_, null, null); - p_57467_.m_7471_(p_57468_, false); + p_57467_.removeBlock(p_57468_, false); } @@ -45,7 +_,7 @@ - public void m_6861_(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, boolean p_57462_) { - if (p_57458_.m_46753_(p_57459_)) { -- m_57433_(p_57458_, p_57459_); + public void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, 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_.m_7471_(p_57459_, false); + p_57458_.removeBlock(p_57459_, false); } @@ -53,7 +_,7 @@ - public void m_5707_(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { - if (!p_57445_.m_5776_() && !p_57448_.m_7500_() && p_57447_.m_61143_(f_57419_)) { -- m_57433_(p_57445_, p_57446_); + public void playerWillDestroy(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { + if (!p_57445_.isClientSide() && !p_57448_.isCreative() && p_57447_.getValue(UNSTABLE)) { +- explode(p_57445_, p_57446_); + onCaughtFire(p_57447_, p_57445_, p_57446_, null, null); } - super.m_5707_(p_57445_, p_57446_, p_57447_, p_57448_); + super.playerWillDestroy(p_57445_, p_57446_, p_57447_, p_57448_); @@ -68,10 +_,12 @@ } } + @Deprecated //Forge: Prefer using IForgeBlock#catchFire - public static void m_57433_(Level p_57434_, BlockPos p_57435_) { - m_57436_(p_57434_, p_57435_, (LivingEntity)null); + public static void explode(Level p_57434_, BlockPos p_57435_) { + explode(p_57434_, p_57435_, (LivingEntity)null); } + @Deprecated //Forge: Prefer using IForgeBlock#catchFire - private static void m_57436_(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_) { - if (!p_57437_.f_46443_) { - PrimedTnt primedtnt = new PrimedTnt(p_57437_, (double)p_57438_.m_123341_() + 0.5D, (double)p_57438_.m_123342_(), (double)p_57438_.m_123343_() + 0.5D, p_57439_); + private static void explode(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_) { + if (!p_57437_.isClientSide) { + PrimedTnt primedtnt = new PrimedTnt(p_57437_, (double)p_57438_.getX() + 0.5D, (double)p_57438_.getY(), (double)p_57438_.getZ() + 0.5D, p_57439_); @@ -86,7 +_,7 @@ - if (!itemstack.m_150930_(Items.f_42409_) && !itemstack.m_150930_(Items.f_42613_)) { - return super.m_6227_(p_57450_, p_57451_, p_57452_, p_57453_, p_57454_, p_57455_); + if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) { + return super.use(p_57450_, p_57451_, p_57452_, p_57453_, p_57454_, p_57455_); } else { -- m_57436_(p_57451_, p_57452_, p_57453_); -+ onCaughtFire(p_57450_, p_57451_, p_57452_, p_57455_.m_82434_(), p_57453_); - p_57451_.m_7731_(p_57452_, Blocks.f_50016_.m_49966_(), 11); - Item item = itemstack.m_41720_(); - if (!p_57453_.m_7500_()) { +- explode(p_57451_, p_57452_, p_57453_); ++ onCaughtFire(p_57450_, p_57451_, p_57452_, p_57455_.getDirection(), p_57453_); + p_57451_.setBlock(p_57452_, Blocks.AIR.defaultBlockState(), 11); + Item item = itemstack.getItem(); + if (!p_57453_.isCreative()) { @@ -109,7 +_,12 @@ - BlockPos blockpos = p_57431_.m_82425_(); - Entity entity = p_57432_.m_37282_(); - if (p_57432_.m_6060_() && p_57432_.m_142265_(p_57429_, blockpos)) { -- m_57436_(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); + BlockPos blockpos = p_57431_.getBlockPos(); + Entity entity = p_57432_.getOwner(); + if (p_57432_.isOnFire() && p_57432_.mayInteract(p_57429_, blockpos)) { +- explode(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_57432_, blockpos, Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_57432_, blockpos, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end + onCaughtFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); - p_57429_.m_7471_(blockpos, false); + 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 ad4f0024..987d588d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,37 +1,37 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java @@ -106,6 +_,19 @@ - if (!p_57548_.f_46443_) { - boolean flag = p_57548_.m_46753_(p_57549_); - if (flag != p_57547_.m_61143_(f_57516_)) { + if (!p_57548_.isClientSide) { + boolean flag = p_57548_.hasNeighborSignal(p_57549_); + if (flag != p_57547_.getValue(POWERED)) { + // CraftBukkit start + org.bukkit.World bworld = p_57548_.getWorld(); -+ org.bukkit.block.Block bblock = bworld.getBlockAt(p_57549_.m_123341_(), p_57549_.m_123342_(), p_57549_.m_123343_()); ++ org.bukkit.block.Block bblock = bworld.getBlockAt(p_57549_.getX(), p_57549_.getY(), p_57549_.getZ()); + + int power = bblock.getBlockPower(); -+ int oldPower = (Boolean) p_57547_.m_61143_(f_57514_) ? 15 : 0; ++ int oldPower = (Boolean) p_57547_.getValue(OPEN) ? 15 : 0; + -+ if (oldPower == 0 ^ power == 0 || p_57550_.m_49966_().m_60803_()) { ++ if (oldPower == 0 ^ power == 0 || p_57550_.defaultBlockState().isSignalSource()) { + org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bblock, oldPower, power); + p_57548_.getCraftServer().getPluginManager().callEvent(eventRedstone); + flag = eventRedstone.getNewCurrent() > 0; + } + // CraftBukkit end - if (p_57547_.m_61143_(f_57514_) != flag) { - p_57547_ = p_57547_.m_61124_(f_57514_, Boolean.valueOf(flag)); - this.m_57527_((Player)null, p_57548_, p_57549_, flag); + if (p_57547_.getValue(OPEN) != flag) { + p_57547_ = p_57547_.setValue(OPEN, Boolean.valueOf(flag)); + this.playSound((Player)null, p_57548_, p_57549_, flag); @@ -152,4 +_,17 @@ - return super.m_7417_(p_57554_, p_57555_, p_57556_, p_57557_, p_57558_, p_57559_); + return super.updateShape(p_57554_, p_57555_, p_57556_, p_57557_, p_57558_, p_57559_); } + + //Forge Start + @Override + public boolean isLadder(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, net.minecraft.world.entity.LivingEntity entity) { -+ if (state.m_61143_(f_57514_)) { -+ BlockPos downPos = pos.m_7495_(); -+ BlockState down = world.m_8055_(downPos); -+ return down.m_60734_().makesOpenTrapdoorAboveClimbable(down, world, downPos, state); ++ if (state.getValue(OPEN)) { ++ BlockPos downPos = pos.below(); ++ BlockState down = world.getBlockState(downPos); ++ return down.getBlock().makesOpenTrapdoorAboveClimbable(down, world, downPos, state); + } + return false; + } 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 e7069688..3d29f3b2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -3,11 +3,11 @@ @@ -69,7 +_,7 @@ } - public void m_5707_(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { -- if (!p_57615_.f_46443_ && !p_57618_.m_21205_().m_41619_() && p_57618_.m_21205_().m_150930_(Items.f_42574_)) { -+ if (!p_57615_.f_46443_ && !p_57618_.m_21205_().m_41619_() && p_57618_.m_21205_().canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_DISARM)) { - p_57615_.m_7731_(p_57616_, p_57617_.m_61124_(f_57592_, Boolean.valueOf(true)), 4); - p_57615_.m_142346_(p_57618_, GameEvent.f_157781_, p_57616_); + public void playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { +- if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().is(Items.SHEARS)) { ++ if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_DISARM)) { + p_57615_.setBlock(p_57616_, p_57617_.setValue(DISARMED, Boolean.valueOf(true)), 4); + p_57615_.gameEvent(p_57618_, GameEvent.SHEAR, p_57616_); } @@ -124,6 +_,38 @@ } @@ -15,10 +15,10 @@ } + + // CraftBukkit start - Call interact even when triggering connected tripwire -+ if (flag != flag1 && flag1 && (Boolean)blockstate.m_61143_(f_57591_)) { ++ if (flag != flag1 && flag1 && (Boolean)blockstate.getValue(ATTACHED)) { + org.bukkit.World bworld = p_57608_.getWorld(); + org.bukkit.plugin.PluginManager manager = p_57608_.getCraftServer().getPluginManager(); -+ org.bukkit.block.Block block = bworld.getBlockAt(p_57609_.m_123341_(), p_57609_.m_123342_(), p_57609_.m_123343_()); ++ org.bukkit.block.Block block = bworld.getBlockAt(p_57609_.getX(), p_57609_.getY(), p_57609_.getZ()); + boolean allowed = false; + + // If all of the events are cancelled block the tripwire trigger, else allow @@ -47,4 +47,4 @@ + // CraftBukkit end if (flag1 != flag) { - blockstate = blockstate.m_61124_(f_57590_, Boolean.valueOf(flag1)); + blockstate = blockstate.setValue(POWERED, Boolean.valueOf(flag1)); diff --git a/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch index f7cae889..b64d454a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java @@ -142,6 +_,17 @@ - this.m_57697_(p_57686_, blockpos1, flag2, flag3, flag, flag1); + this.playSound(p_57686_, blockpos1, flag2, flag3, flag, flag1); } + // CraftBukkit start -+ org.bukkit.block.Block block = p_57686_.getWorld().getBlockAt(p_57687_.m_123341_(), p_57687_.m_123342_(), p_57687_.m_123343_()); ++ org.bukkit.block.Block block = p_57686_.getWorld().getBlockAt(p_57687_.getX(), p_57687_.getY(), p_57687_.getZ()); + + org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(block, 15, 0); + p_57686_.getCraftServer().getPluginManager().callEvent(eventRedstone); @@ -15,16 +15,16 @@ + } + // CraftBukkit end + - this.m_57697_(p_57686_, p_57687_, flag2, flag3, flag, flag1); + this.playSound(p_57686_, p_57687_, flag2, flag3, flag, flag1); if (!p_57689_) { - p_57686_.m_7731_(p_57687_, blockstate1.m_61124_(f_57667_, direction), 3); + p_57686_.setBlock(p_57687_, blockstate1.setValue(FACING, direction), 3); @@ -155,8 +_,8 @@ - BlockPos blockpos2 = p_57687_.m_5484_(direction, k); + BlockPos blockpos2 = p_57687_.relative(direction, k); BlockState blockstate2 = ablockstate[k]; if (blockstate2 != null) { -+ if (!p_57686_.m_8055_(blockpos2).m_60795_()) { // FORGE: fix MC-129055 - p_57686_.m_7731_(blockpos2, blockstate2.m_61124_(f_57669_, Boolean.valueOf(flag2)), 3); -- if (!p_57686_.m_8055_(blockpos2).m_60795_()) { ++ if (!p_57686_.getBlockState(blockpos2).isAir()) { // FORGE: fix MC-129055 + p_57686_.setBlock(blockpos2, blockstate2.setValue(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 741d3436..21abdce4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java @@ -58,6 +_,19 @@ - private void m_154850_(Level p_154851_, BlockState p_154852_, BlockPos p_154853_, Entity p_154854_, int p_154855_) { - if (this.m_57767_(p_154851_, p_154854_)) { - if (!p_154851_.f_46443_ && p_154851_.f_46441_.nextInt(p_154855_) == 0 && p_154852_.m_60713_(Blocks.f_50578_)) { + private void destroyEgg(Level p_154851_, BlockState p_154852_, BlockPos p_154853_, Entity p_154854_, int p_154855_) { + if (this.canDestroyEgg(p_154851_, p_154854_)) { + if (!p_154851_.isClientSide && p_154851_.random.nextInt(p_154855_) == 0 && p_154852_.is(Blocks.TURTLE_EGG)) { + // CraftBukkit start - Step on eggs + org.bukkit.event.Cancellable cancellable; + if (p_154854_ instanceof Player) { @@ -17,43 +17,43 @@ + return; + } + // CraftBukkit end - this.m_57791_(p_154851_, p_154853_, p_154852_); + this.decreaseEggs(p_154851_, p_154853_, p_154852_); } @@ -80,9 +_,19 @@ - if (this.m_57765_(p_57805_) && m_57762_(p_57805_, p_57806_)) { - int i = p_57804_.m_61143_(f_57753_); + if (this.shouldUpdateHatchLevel(p_57805_) && onSand(p_57805_, p_57806_)) { + int i = p_57804_.getValue(HATCH); if (i < 2) { + // CraftBukkit start - Call BlockGrowEvent -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57805_, p_57806_, p_57804_.m_61124_(f_57753_, i + 1), 2)) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockGrowEvent(p_57805_, p_57806_, p_57804_.setValue(HATCH, i + 1), 2)) { + return; + } + // CraftBukkit end - p_57805_.m_5594_((Player)null, p_57806_, SoundEvents.f_12534_, SoundSource.BLOCKS, 0.7F, 0.9F + p_57807_.nextFloat() * 0.2F); -- p_57805_.m_7731_(p_57806_, p_57804_.m_61124_(f_57753_, Integer.valueOf(i + 1)), 2); + p_57805_.playSound((Player)null, p_57806_, SoundEvents.TURTLE_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + p_57807_.nextFloat() * 0.2F); +- p_57805_.setBlock(p_57806_, p_57804_.setValue(HATCH, Integer.valueOf(i + 1)), 2); + // p_57805_.setBlock(p_57806_, p_57804_.setValue(HATCH, Integer.valueOf(i + 1)), 2); // CraftBukkit - handled above } else { + // CraftBukkit start - Call BlockFadeEvent -+ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_57805_, p_57806_, Blocks.f_50016_.m_49966_()).isCancelled()) { ++ if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockFadeEvent(p_57805_, p_57806_, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - p_57805_.m_5594_((Player)null, p_57806_, SoundEvents.f_12535_, SoundSource.BLOCKS, 0.7F, 0.9F + p_57807_.nextFloat() * 0.2F); - p_57805_.m_7471_(p_57806_, false); + p_57805_.playSound((Player)null, p_57806_, SoundEvents.TURTLE_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + p_57807_.nextFloat() * 0.2F); + p_57805_.removeBlock(p_57806_, false); @@ -92,6 +_,7 @@ - turtle.m_146762_(-24000); - turtle.m_30219_(p_57806_); - turtle.m_7678_((double)p_57806_.m_123341_() + 0.3D + (double)j * 0.2D, (double)p_57806_.m_123342_(), (double)p_57806_.m_123343_() + 0.3D, 0.0F, 0.0F); + turtle.setAge(-24000); + turtle.setHomePos(p_57806_); + turtle.moveTo((double)p_57806_.getX() + 0.3D + (double)j * 0.2D, (double)p_57806_.getY(), (double)p_57806_.getZ() + 0.3D, 0.0F, 0.0F); + p_57805_.prepareEntity(turtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); //Magma - add spawn reason - p_57805_.m_7967_(turtle); + p_57805_.addFreshEntity(turtle); } } @@ -151,7 +_,7 @@ if (!(p_57769_ instanceof LivingEntity)) { return false; } else { -- return p_57769_ instanceof Player || p_57768_.m_46469_().m_46207_(GameRules.f_46132_); +- return p_57769_ instanceof Player || p_57768_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + return p_57769_ instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_57768_, p_57769_); } } else { 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 05fc9409..1b17d47d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch @@ -6,62 +6,62 @@ -public class VineBlock extends Block { +public class VineBlock extends Block implements net.minecraftforge.common.IForgeShearable { - public static final BooleanProperty f_57833_ = PipeBlock.f_55152_; - public static final BooleanProperty f_57834_ = PipeBlock.f_55148_; - public static final BooleanProperty f_57835_ = PipeBlock.f_55149_; + public static final BooleanProperty UP = PipeBlock.UP; + public static final BooleanProperty NORTH = PipeBlock.NORTH; + public static final BooleanProperty EAST = PipeBlock.EAST; @@ -157,7 +_,7 @@ } - public void m_7455_(BlockState p_57892_, ServerLevel p_57893_, BlockPos p_57894_, Random p_57895_) { + public void randomTick(BlockState p_57892_, ServerLevel p_57893_, BlockPos p_57894_, Random p_57895_) { - if (p_57895_.nextInt(4) == 0) { -+ if (p_57893_.f_46441_.nextInt(Math.max(1, (int) (100.0F / p_57893_.spigotConfig.vineModifier) * 4)) == 0 && p_57893_.isAreaLoaded(p_57894_, 4)) { // Forge: check area to prevent loading unloaded chunks // Spigot - Direction direction = Direction.m_122404_(p_57895_); - BlockPos blockpos = p_57894_.m_7494_(); - if (direction.m_122434_().m_122479_() && !p_57892_.m_61143_(m_57883_(direction))) { ++ if (p_57893_.random.nextInt(Math.max(1, (int) (100.0F / p_57893_.spigotConfig.vineModifier) * 4)) == 0 && p_57893_.isAreaLoaded(p_57894_, 4)) { // Forge: check area to prevent loading unloaded chunks // Spigot + Direction direction = Direction.getRandom(p_57895_); + BlockPos blockpos = p_57894_.above(); + if (direction.getAxis().isHorizontal() && !p_57892_.getValue(getPropertyForFace(direction))) { @@ -171,19 +_,24 @@ - boolean flag1 = p_57892_.m_61143_(m_57883_(direction4)); - BlockPos blockpos2 = blockpos4.m_142300_(direction3); - BlockPos blockpos3 = blockpos4.m_142300_(direction4); + boolean flag1 = p_57892_.getValue(getPropertyForFace(direction4)); + BlockPos blockpos2 = blockpos4.relative(direction3); + BlockPos blockpos3 = blockpos4.relative(direction4); + + // CraftBukkit start - Call BlockSpreadEvent + BlockPos source = p_57894_; + - if (flag && m_57853_(p_57893_, blockpos2, direction3)) { -- p_57893_.m_7731_(blockpos4, this.m_49966_().m_61124_(m_57883_(direction3), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos4, this.m_49966_().m_61124_(m_57883_(direction3), Boolean.valueOf(true)), 2); - } else if (flag1 && m_57853_(p_57893_, blockpos3, direction4)) { -- p_57893_.m_7731_(blockpos4, this.m_49966_().m_61124_(m_57883_(direction4), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos4, this.m_49966_().m_61124_(m_57883_(direction4), Boolean.valueOf(true)), 2); + if (flag && isAcceptableNeighbour(p_57893_, blockpos2, direction3)) { +- p_57893_.setBlock(blockpos4, this.defaultBlockState().setValue(getPropertyForFace(direction3), Boolean.valueOf(true)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos4, this.defaultBlockState().setValue(getPropertyForFace(direction3), Boolean.valueOf(true)), 2); + } else if (flag1 && isAcceptableNeighbour(p_57893_, blockpos3, direction4)) { +- p_57893_.setBlock(blockpos4, this.defaultBlockState().setValue(getPropertyForFace(direction4), Boolean.valueOf(true)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos4, this.defaultBlockState().setValue(getPropertyForFace(direction4), Boolean.valueOf(true)), 2); } else { - Direction direction1 = direction.m_122424_(); - if (flag && p_57893_.m_46859_(blockpos2) && m_57853_(p_57893_, p_57894_.m_142300_(direction3), direction1)) { -- p_57893_.m_7731_(blockpos2, this.m_49966_().m_61124_(m_57883_(direction1), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos2, this.m_49966_().m_61124_(m_57883_(direction1), Boolean.valueOf(true)), 2); - } else if (flag1 && p_57893_.m_46859_(blockpos3) && m_57853_(p_57893_, p_57894_.m_142300_(direction4), direction1)) { -- p_57893_.m_7731_(blockpos3, this.m_49966_().m_61124_(m_57883_(direction1), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos3, this.m_49966_().m_61124_(m_57883_(direction1), Boolean.valueOf(true)), 2); - } else if ((double)p_57895_.nextFloat() < 0.05D && m_57853_(p_57893_, blockpos4.m_7494_(), Direction.UP)) { -- p_57893_.m_7731_(blockpos4, this.m_49966_().m_61124_(f_57833_, Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos4, this.m_49966_().m_61124_(f_57833_, Boolean.valueOf(true)), 2); + Direction direction1 = direction.getOpposite(); + if (flag && p_57893_.isEmptyBlock(blockpos2) && isAcceptableNeighbour(p_57893_, p_57894_.relative(direction3), direction1)) { +- p_57893_.setBlock(blockpos2, this.defaultBlockState().setValue(getPropertyForFace(direction1), Boolean.valueOf(true)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos2, this.defaultBlockState().setValue(getPropertyForFace(direction1), Boolean.valueOf(true)), 2); + } else if (flag1 && p_57893_.isEmptyBlock(blockpos3) && isAcceptableNeighbour(p_57893_, p_57894_.relative(direction4), direction1)) { +- p_57893_.setBlock(blockpos3, this.defaultBlockState().setValue(getPropertyForFace(direction1), Boolean.valueOf(true)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos3, this.defaultBlockState().setValue(getPropertyForFace(direction1), Boolean.valueOf(true)), 2); + } else if ((double)p_57895_.nextFloat() < 0.05D && isAcceptableNeighbour(p_57893_, blockpos4.above(), Direction.UP)) { +- p_57893_.setBlock(blockpos4, this.defaultBlockState().setValue(UP, Boolean.valueOf(true)), 2); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, source, blockpos4, this.defaultBlockState().setValue(UP, Boolean.valueOf(true)), 2); } + // CraftBukkit end } - } else if (m_57853_(p_57893_, blockpos4, direction)) { - p_57893_.m_7731_(p_57894_, p_57892_.m_61124_(m_57883_(direction), Boolean.valueOf(true)), 2); + } else if (isAcceptableNeighbour(p_57893_, blockpos4, direction)) { + p_57893_.setBlock(p_57894_, p_57892_.setValue(getPropertyForFace(direction), Boolean.valueOf(true)), 2); @@ -211,7 +_,7 @@ } - if (this.m_57911_(blockstate3)) { -- p_57893_.m_7731_(blockpos, blockstate3, 2); + if (this.hasHorizontalConnection(blockstate3)) { +- p_57893_.setBlock(blockpos, blockstate3, 2); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, p_57894_, blockpos, blockstate3, 2); } return; @@ -225,7 +_,7 @@ - BlockState blockstate1 = blockstate.m_60795_() ? this.m_49966_() : blockstate; - BlockState blockstate2 = this.m_57870_(p_57892_, blockstate1, p_57895_); - if (blockstate1 != blockstate2 && this.m_57911_(blockstate2)) { -- p_57893_.m_7731_(blockpos1, blockstate2, 2); + BlockState blockstate1 = blockstate.isAir() ? this.defaultBlockState() : blockstate; + BlockState blockstate2 = this.copyRandomFaces(p_57892_, blockstate1, p_57895_); + if (blockstate1 != blockstate2 && this.hasHorizontalConnection(blockstate2)) { +- p_57893_.setBlock(blockpos1, blockstate2, 2); + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockSpreadEvent(p_57893_, p_57894_, blockpos1, blockstate2, 2); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/WaterlilyBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/WaterlilyBlock.java.patch index 5d7a9130..59d3ebfb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/WaterlilyBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/WaterlilyBlock.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/level/block/WaterlilyBlock.java @@ -23,7 +_,7 @@ - public void m_7892_(BlockState p_58164_, Level p_58165_, BlockPos p_58166_, Entity p_58167_) { - super.m_7892_(p_58164_, p_58165_, p_58166_, p_58167_); + public void entityInside(BlockState p_58164_, Level p_58165_, BlockPos p_58166_, Entity p_58167_) { + super.entityInside(p_58164_, p_58165_, p_58166_, p_58167_); - if (p_58165_ instanceof ServerLevel && p_58167_ instanceof Boat) { -+ if (p_58165_ instanceof ServerLevel && p_58167_ instanceof Boat && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_58167_, p_58166_, Blocks.f_50016_.m_49966_()).isCancelled()) { // CraftBukkit - p_58165_.m_46953_(new BlockPos(p_58166_), true, p_58167_); ++ if (p_58165_ instanceof ServerLevel && p_58167_ instanceof Boat && !org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntityChangeBlockEvent(p_58167_, p_58166_, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit + p_58165_.destroyBlock(new BlockPos(p_58166_), true, p_58167_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch index 617ec7df..796f9b22 100644 --- a/patches/minecraft/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch @@ -3,16 +3,16 @@ @@ -25,7 +_,23 @@ } - protected int m_6693_(Level p_58213_, BlockPos p_58214_) { -- int i = Math.min(p_58213_.m_45976_(Entity.class, f_49287_.m_82338_(p_58214_)).size(), this.f_58199_); + protected int getSignalStrength(Level p_58213_, BlockPos p_58214_) { +- int i = Math.min(p_58213_.getEntitiesOfClass(Entity.class, TOUCH_AABB.move(p_58214_)).size(), this.maxWeight); + // CraftBukkit start + int i = 0; -+ for (Entity entity : p_58213_.m_45976_(Entity.class, f_49287_.m_82338_(p_58214_))) { ++ for (Entity entity : p_58213_.getEntitiesOfClass(Entity.class, TOUCH_AABB.move(p_58214_))) { + org.bukkit.event.Cancellable cancellable; + if (entity instanceof Player) { + cancellable = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, p_58214_, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), p_58213_.getWorld().getBlockAt(p_58214_.m_123341_(), p_58214_.m_123342_(), p_58214_.m_123343_())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), p_58213_.getWorld().getBlockAt(p_58214_.getX(), p_58214_.getY(), p_58214_.getZ())); + p_58213_.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + // We only want to block turning the plate on if all events are cancelled @@ -20,8 +20,8 @@ + i++; + } + } -+ i = Math.min(i, this.f_58199_); ++ i = Math.min(i, this.maxWeight); + // CraftBukkit end if (i > 0) { - float f = (float)Math.min(this.f_58199_, i) / (float)this.f_58199_; - return Mth.m_14167_(f * 15.0F); + float f = (float)Math.min(this.maxWeight, i) / (float)this.maxWeight; + return Mth.ceil(f * 15.0F); diff --git a/patches/minecraft/net/minecraft/world/level/block/WitherRoseBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/WitherRoseBlock.java.patch index af45a5b2..ccdf2c2a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/WitherRoseBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/WitherRoseBlock.java.patch @@ -3,9 +3,9 @@ @@ -46,7 +_,7 @@ if (p_58241_ instanceof LivingEntity) { LivingEntity livingentity = (LivingEntity)p_58241_; - if (!livingentity.m_6673_(DamageSource.f_19320_)) { -- livingentity.m_7292_(new MobEffectInstance(MobEffects.f_19615_, 40)); -+ livingentity.addEffect(new MobEffectInstance(MobEffects.f_19615_, 40), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit + if (!livingentity.isInvulnerableTo(DamageSource.WITHER)) { +- livingentity.addEffect(new MobEffectInstance(MobEffects.WITHER, 40)); ++ livingentity.addEffect(new MobEffectInstance(MobEffects.WITHER, 40), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit } } diff --git a/patches/minecraft/net/minecraft/world/level/block/WitherSkullBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/WitherSkullBlock.java.patch index 5f7253e3..c1382d90 100644 --- a/patches/minecraft/net/minecraft/world/level/block/WitherSkullBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/WitherSkullBlock.java.patch @@ -3,48 +3,48 @@ @@ -44,6 +_,7 @@ } - public static void m_58255_(Level p_58256_, BlockPos p_58257_, SkullBlockEntity p_58258_) { + public static void checkSpawn(Level p_58256_, BlockPos p_58257_, SkullBlockEntity p_58258_) { + if (p_58256_.captureBlockStates) return; // CraftBukkit - if (!p_58256_.f_46443_) { - BlockState blockstate = p_58258_.m_58900_(); - boolean flag = blockstate.m_60713_(Blocks.f_50312_) || blockstate.m_60713_(Blocks.f_50313_); + if (!p_58256_.isClientSide) { + BlockState blockstate = p_58258_.getBlockState(); + boolean flag = blockstate.is(Blocks.WITHER_SKELETON_SKULL) || blockstate.is(Blocks.WITHER_SKELETON_WALL_SKULL); @@ -51,11 +_,13 @@ - BlockPattern blockpattern = m_58273_(); - BlockPattern.BlockPatternMatch blockpattern$blockpatternmatch = blockpattern.m_61184_(p_58256_, p_58257_); + BlockPattern blockpattern = getOrCreateWitherFull(); + BlockPattern.BlockPatternMatch blockpattern$blockpatternmatch = blockpattern.find(p_58256_, p_58257_); if (blockpattern$blockpatternmatch != null) { + // CraftBukkit start - Use BlockStateListPopulator + org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator(p_58256_); - for(int i = 0; i < blockpattern.m_61203_(); ++i) { - for(int j = 0; j < blockpattern.m_61202_(); ++j) { - BlockInWorld blockinworld = blockpattern$blockpatternmatch.m_61229_(i, j, 0); -- p_58256_.m_7731_(blockinworld.m_61176_(), Blocks.f_50016_.m_49966_(), 2); -- p_58256_.m_46796_(2001, blockinworld.m_61176_(), Block.m_49956_(blockinworld.m_61168_())); -+ blockList.m_7731_(blockinworld.m_61176_(), Blocks.f_50016_.m_49966_(), 2); // CraftBukkit + for(int i = 0; i < blockpattern.getWidth(); ++i) { + for(int j = 0; j < blockpattern.getHeight(); ++j) { + BlockInWorld blockinworld = blockpattern$blockpatternmatch.getBlock(i, j, 0); +- p_58256_.setBlock(blockinworld.getPos(), Blocks.AIR.defaultBlockState(), 2); +- p_58256_.levelEvent(2001, blockinworld.getPos(), Block.getId(blockinworld.getState())); ++ blockList.setBlock(blockinworld.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit + // p_58256_.levelEvent(2001, blockinworld.getPos(), Block.getId(blockinworld.getState())); // CraftBukkit } } @@ -64,12 +_,22 @@ - witherboss.m_7678_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.55D, (double)blockpos.m_123343_() + 0.5D, blockpattern$blockpatternmatch.m_61233_().m_122434_() == Direction.Axis.X ? 0.0F : 90.0F, 0.0F); - witherboss.f_20883_ = blockpattern$blockpatternmatch.m_61233_().m_122434_() == Direction.Axis.X ? 0.0F : 90.0F; - witherboss.m_31506_(); + witherboss.moveTo((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.55D, (double)blockpos.getZ() + 0.5D, blockpattern$blockpatternmatch.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F, 0.0F); + witherboss.yBodyRot = blockpattern$blockpatternmatch.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F; + witherboss.makeInvulnerable(); + // CraftBukkit start + p_58256_.prepareEntity(witherboss, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_WITHER); //Magma - add spawn reason -+ if (!p_58256_.m_7967_(witherboss)) { ++ if (!p_58256_.addFreshEntity(witherboss)) { + return; + } + for (BlockPos pos : blockList.getBlocks()) { -+ p_58256_.m_46796_(2001, pos, Block.m_49956_(p_58256_.m_8055_(pos))); ++ p_58256_.levelEvent(2001, pos, Block.getId(p_58256_.getBlockState(pos))); + } + blockList.updateList(); + // CraftBukkit end - for(ServerPlayer serverplayer : p_58256_.m_45976_(ServerPlayer.class, witherboss.m_142469_().m_82400_(50.0D))) { - CriteriaTriggers.f_10580_.m_68256_(serverplayer, witherboss); + for(ServerPlayer serverplayer : p_58256_.getEntitiesOfClass(ServerPlayer.class, witherboss.getBoundingBox().inflate(50.0D))) { + CriteriaTriggers.SUMMONED_ENTITY.trigger(serverplayer, witherboss); } -- p_58256_.m_7967_(witherboss); +- p_58256_.addFreshEntity(witherboss); + // p_58256_.addFreshEntity(witherboss); // CraftBukkit - moved up - for(int k = 0; k < blockpattern.m_61203_(); ++k) { - for(int l = 0; l < blockpattern.m_61202_(); ++l) { + for(int k = 0; k < blockpattern.getWidth(); ++k) { + for(int l = 0; l < blockpattern.getHeight(); ++l) { 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 d267d40d..687697f1 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,121 +1,121 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -107,6 +_,7 @@ - this.f_58312_ = p_154994_; + this.recipeType = p_154994_; } + /**@deprecated Forge: get burn times by calling ForgeHooks#getBurnTime(ItemStack)*/ @Deprecated - public static Map m_58423_() { + public static Map getFuel() { Map map = Maps.newLinkedHashMap(); - m_58374_(map, Items.f_42448_, 20000); + add(map, Items.LAVA_BUCKET, 20000); @@ -206,9 +_,9 @@ - super.m_142466_(p_155025_); - this.f_58310_ = NonNullList.m_122780_(this.m_6643_(), ItemStack.f_41583_); - ContainerHelper.m_18980_(p_155025_, this.f_58310_); -- this.f_58316_ = p_155025_.m_128448_("BurnTime"); -- this.f_58318_ = p_155025_.m_128448_("CookTime"); -- this.f_58319_ = p_155025_.m_128448_("CookTimeTotal"); -+ this.f_58316_ = p_155025_.m_128451_("BurnTime"); -+ this.f_58318_ = p_155025_.m_128451_("CookTime"); -+ this.f_58319_ = p_155025_.m_128451_("CookTimeTotal"); - this.f_58317_ = this.m_7743_(this.f_58310_.get(1)); - CompoundTag compoundtag = p_155025_.m_128469_("RecipesUsed"); + super.load(p_155025_); + this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + ContainerHelper.loadAllItems(p_155025_, this.items); +- this.litTime = p_155025_.getShort("BurnTime"); +- this.cookingProgress = p_155025_.getShort("CookTime"); +- this.cookingTotalTime = p_155025_.getShort("CookTimeTotal"); ++ this.litTime = p_155025_.getInt("BurnTime"); ++ this.cookingProgress = p_155025_.getInt("CookTime"); ++ this.cookingTotalTime = p_155025_.getInt("CookTimeTotal"); + this.litDuration = this.getBurnDuration(this.items.get(1)); + CompoundTag compoundtag = p_155025_.getCompound("RecipesUsed"); @@ -220,9 +_,9 @@ - protected void m_183515_(CompoundTag p_187452_) { - super.m_183515_(p_187452_); -- p_187452_.m_128376_("BurnTime", (short)this.f_58316_); -- p_187452_.m_128376_("CookTime", (short)this.f_58318_); -- p_187452_.m_128376_("CookTimeTotal", (short)this.f_58319_); -+ p_187452_.m_128405_("BurnTime", this.f_58316_); -+ p_187452_.m_128405_("CookTime", this.f_58318_); -+ p_187452_.m_128405_("CookTimeTotal", this.f_58319_); - ContainerHelper.m_18973_(p_187452_, this.f_58310_); + protected void saveAdditional(CompoundTag p_187452_) { + super.saveAdditional(p_187452_); +- p_187452_.putShort("BurnTime", (short)this.litTime); +- p_187452_.putShort("CookTime", (short)this.cookingProgress); +- p_187452_.putShort("CookTimeTotal", (short)this.cookingTotalTime); ++ p_187452_.putInt("BurnTime", this.litTime); ++ p_187452_.putInt("CookTime", this.cookingProgress); ++ p_187452_.putInt("CookTimeTotal", this.cookingTotalTime); + ContainerHelper.saveAllItems(p_187452_, this.items); CompoundTag compoundtag = new CompoundTag(); - this.f_58320_.forEach((p_187449_, p_187450_) -> { + this.recipesUsed.forEach((p_187449_, p_187450_) -> { @@ -240,30 +_,51 @@ - ItemStack itemstack = p_155017_.f_58310_.get(1); - if (p_155017_.m_58425_() || !itemstack.m_41619_() && !p_155017_.f_58310_.get(0).m_41619_()) { -- Recipe recipe = p_155014_.m_7465_().m_44015_((RecipeType)p_155017_.f_58312_, p_155017_, p_155014_).orElse((AbstractCookingRecipe)null); -+ Recipe recipe = p_155014_.m_7465_().m_44015_((RecipeType)p_155017_.f_58312_, p_155017_, p_155014_).orElse(null); - int i = p_155017_.m_6893_(); -- if (!p_155017_.m_58425_() && m_155005_(recipe, p_155017_.f_58310_, i)) { -- p_155017_.f_58316_ = p_155017_.m_7743_(itemstack); -+ if (!p_155017_.m_58425_() && p_155017_.m_155005_(recipe, p_155017_.f_58310_, i)) { + ItemStack itemstack = p_155017_.items.get(1); + if (p_155017_.isLit() || !itemstack.isEmpty() && !p_155017_.items.get(0).isEmpty()) { +- Recipe recipe = p_155014_.getRecipeManager().getRecipeFor((RecipeType)p_155017_.recipeType, p_155017_, p_155014_).orElse((AbstractCookingRecipe)null); ++ Recipe recipe = p_155014_.getRecipeManager().getRecipeFor((RecipeType)p_155017_.recipeType, p_155017_, p_155014_).orElse(null); + int i = p_155017_.getMaxStackSize(); +- if (!p_155017_.isLit() && canBurn(recipe, p_155017_.items, i)) { +- p_155017_.litTime = p_155017_.getBurnDuration(itemstack); ++ if (!p_155017_.isLit() && p_155017_.canBurn(recipe, p_155017_.items, i)) { + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack fuel = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack); -+ org.bukkit.event.inventory.FurnaceBurnEvent furnaceBurnEvent = new org.bukkit.event.inventory.FurnaceBurnEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155014_, p_155015_), fuel, p_155017_.m_7743_(itemstack)); ++ org.bukkit.event.inventory.FurnaceBurnEvent furnaceBurnEvent = new org.bukkit.event.inventory.FurnaceBurnEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155014_, p_155015_), fuel, p_155017_.getBurnDuration(itemstack)); + p_155014_.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent); + + if (furnaceBurnEvent.isCancelled()) { + return; + } + -+ p_155017_.f_58316_ = furnaceBurnEvent.getBurnTime(); - p_155017_.f_58317_ = p_155017_.f_58316_; -- if (p_155017_.m_58425_()) { -+ if (p_155017_.m_58425_() && furnaceBurnEvent.isBurning()) { ++ p_155017_.litTime = furnaceBurnEvent.getBurnTime(); + p_155017_.litDuration = p_155017_.litTime; +- if (p_155017_.isLit()) { ++ if (p_155017_.isLit() && furnaceBurnEvent.isBurning()) { + // CraftBukkit end flag1 = true; + if (itemstack.hasContainerItem()) -+ p_155017_.f_58310_.set(1, itemstack.getContainerItem()); ++ p_155017_.items.set(1, itemstack.getContainerItem()); + else - if (!itemstack.m_41619_()) { - Item item = itemstack.m_41720_(); - itemstack.m_41774_(1); - if (itemstack.m_41619_()) { -- Item item1 = item.m_41469_(); -- p_155017_.f_58310_.set(1, item1 == null ? ItemStack.f_41583_ : new ItemStack(item1)); -+ p_155017_.f_58310_.set(1, itemstack.getContainerItem()); + if (!itemstack.isEmpty()) { + 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.getContainerItem()); } } } } -- if (p_155017_.m_58425_() && m_155005_(recipe, p_155017_.f_58310_, i)) { -+ if (p_155017_.m_58425_() && p_155017_.m_155005_(recipe, p_155017_.f_58310_, i)) { +- if (p_155017_.isLit() && canBurn(recipe, p_155017_.items, i)) { ++ if (p_155017_.isLit() && p_155017_.canBurn(recipe, p_155017_.items, i)) { + // CraftBukkit start -+ if (recipe != null && p_155017_.f_58318_ == 0) { -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack source = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_155017_.f_58310_.get(0)); ++ if (recipe != null && p_155017_.cookingProgress == 0) { ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack source = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_155017_.items.get(0)); + org.bukkit.inventory.CookingRecipe cookingRecipe = (org.bukkit.inventory.CookingRecipe) recipe.toBukkitRecipe(); + org.bukkit.event.inventory.FurnaceStartSmeltEvent event = new org.bukkit.event.inventory.FurnaceStartSmeltEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155014_, p_155015_), source, cookingRecipe); + p_155014_.getCraftServer().getPluginManager().callEvent(event); -+ p_155017_.f_58319_ = event.getTotalCookTime(); ++ p_155017_.cookingTotalTime = event.getTotalCookTime(); + } + // CraftBukkit end - ++p_155017_.f_58318_; - if (p_155017_.f_58318_ == p_155017_.f_58319_) { - p_155017_.f_58318_ = 0; - p_155017_.f_58319_ = m_155009_(p_155014_, p_155017_.f_58312_, p_155017_); -- if (m_155026_(recipe, p_155017_.f_58310_, i)) { -+ if (p_155017_.burn(p_155017_.f_58857_, p_155017_.f_58858_, recipe, p_155017_.f_58310_, i)) { // CraftBukkit - p_155017_.m_6029_(recipe); + ++p_155017_.cookingProgress; + if (p_155017_.cookingProgress == p_155017_.cookingTotalTime) { + p_155017_.cookingProgress = 0; + p_155017_.cookingTotalTime = getTotalCookTime(p_155014_, p_155017_.recipeType, p_155017_); +- if (burn(recipe, p_155017_.items, i)) { ++ if (p_155017_.burn(p_155017_.level, p_155017_.worldPosition, recipe, p_155017_.items, i)) { // CraftBukkit + p_155017_.setRecipeUsed(recipe); } @@ -288,9 +_,9 @@ } -- private static boolean m_155005_(@Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { -+ private boolean m_155005_(@Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { - if (!p_155007_.get(0).m_41619_() && p_155006_ != null) { -- ItemStack itemstack = p_155006_.m_8043_(); -+ ItemStack itemstack = ((Recipe) p_155006_).m_5874_(this); - if (itemstack.m_41619_()) { +- private static boolean canBurn(@Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { ++ private boolean canBurn(@Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { + if (!p_155007_.get(0).isEmpty() && p_155006_ != null) { +- ItemStack itemstack = p_155006_.getResultItem(); ++ ItemStack itemstack = ((Recipe) p_155006_).assemble(this); + if (itemstack.isEmpty()) { return false; } else { @@ -299,10 +_,10 @@ return true; - } else if (!itemstack1.m_41656_(itemstack)) { + } else if (!itemstack1.sameItem(itemstack)) { return false; -- } else if (itemstack1.m_41613_() < p_155008_ && itemstack1.m_41613_() < itemstack1.m_41741_()) { -+ } else if (itemstack1.m_41613_() + itemstack.m_41613_() <= p_155008_ && itemstack1.m_41613_() + itemstack.m_41613_() <= itemstack1.m_41741_()) { // Forge fix: make furnace respect stack sizes in furnace recipes +- } else if (itemstack1.getCount() < p_155008_ && itemstack1.getCount() < itemstack1.getMaxStackSize()) { ++ } else if (itemstack1.getCount() + itemstack.getCount() <= p_155008_ && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) { // Forge fix: make furnace respect stack sizes in furnace recipes return true; } else { -- return itemstack1.m_41613_() < itemstack.m_41741_(); -+ return itemstack1.m_41613_() + itemstack.m_41613_() <= itemstack.m_41741_(); // Forge fix: make furnace respect stack sizes in furnace recipes +- return itemstack1.getCount() < itemstack.getMaxStackSize(); ++ return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: make furnace respect stack sizes in furnace recipes } } } else { @@ -123,11 +123,11 @@ } } -- private static boolean m_155026_(@Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { +- private static boolean burn(@Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { + //Magma start - mixin inject + private @Nullable Level burn_level; + private @Nullable BlockPos burn_pos; -+ private boolean m_155026_(@Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { ++ private boolean burn(@Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { + Level level = burn_level; + BlockPos blockposition = burn_pos; + @@ -135,15 +135,15 @@ + burn_level = null; + burn_pos = null; + - if (p_155027_ != null && m_155005_(p_155027_, p_155028_, p_155029_)) { + if (p_155027_ != null && canBurn(p_155027_, p_155028_, p_155029_)) { ItemStack itemstack = p_155028_.get(0); -- ItemStack itemstack1 = p_155027_.m_8043_(); -+ ItemStack itemstack1 = ((Recipe) p_155027_).m_5874_(this); +- ItemStack itemstack1 = p_155027_.getResultItem(); ++ ItemStack itemstack1 = ((Recipe) p_155027_).assemble(this); ItemStack itemstack2 = p_155028_.get(2); -- if (itemstack2.m_41619_()) { -- p_155028_.set(2, itemstack1.m_41777_()); -- } else if (itemstack2.m_150930_(itemstack1.m_41720_())) { -- itemstack2.m_41769_(1); +- if (itemstack2.isEmpty()) { +- p_155028_.set(2, itemstack1.copy()); +- } else if (itemstack2.is(itemstack1.getItem())) { +- itemstack2.grow(1); - } - + @@ -163,18 +163,18 @@ + + itemstack1 = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(result); + -+ if (!itemstack1.m_41619_()) { -+ if (itemstack2.m_41619_()) { -+ p_155028_.set(2, itemstack1.m_41777_()); ++ if (!itemstack1.isEmpty()) { ++ if (itemstack2.isEmpty()) { ++ p_155028_.set(2, itemstack1.copy()); + } else if (org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) { -+ itemstack2.m_41769_(itemstack1.m_41613_()); ++ itemstack2.grow(itemstack1.getCount()); + } else { + return false; + } + } + // CraftBukkit end - if (itemstack.m_150930_(Blocks.f_50057_.m_5456_()) && !p_155028_.get(1).m_41619_() && p_155028_.get(1).m_150930_(Items.f_42446_)) { - p_155028_.set(1, new ItemStack(Items.f_42447_)); + if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !p_155028_.get(1).isEmpty() && p_155028_.get(1).is(Items.BUCKET)) { + p_155028_.set(1, new ItemStack(Items.WATER_BUCKET)); } @@ -332,21 +_,28 @@ } @@ -183,64 +183,64 @@ + private boolean burn(Level level, BlockPos blockposition, @Nullable Recipe p_155027_, NonNullList p_155028_, int p_155029_) { + burn_level = level; + burn_pos = blockposition; -+ return m_155026_(p_155027_, p_155028_, p_155029_); ++ return burn(p_155027_, p_155028_, p_155029_); + } + //Magma end + - protected int m_7743_(ItemStack p_58343_) { - if (p_58343_.m_41619_()) { + protected int getBurnDuration(ItemStack p_58343_) { + if (p_58343_.isEmpty()) { return 0; } else { - Item item = p_58343_.m_41720_(); -- return m_58423_().getOrDefault(item, 0); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58343_, this.f_58312_); + Item item = p_58343_.getItem(); +- return getFuel().getOrDefault(item, 0); ++ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58343_, this.recipeType); } } - private static int m_155009_(Level p_155010_, RecipeType p_155011_, Container p_155012_) { -- return p_155010_.m_7465_().m_44015_((RecipeType)p_155011_, p_155012_, p_155010_).map(AbstractCookingRecipe::m_43753_).orElse(200); -+ return (p_155010_ != null) ? p_155010_.m_7465_().m_44015_((RecipeType)p_155011_, p_155012_, p_155010_).map(AbstractCookingRecipe::m_43753_).orElse(200) : 200; + private static int getTotalCookTime(Level p_155010_, RecipeType p_155011_, Container p_155012_) { +- return p_155010_.getRecipeManager().getRecipeFor((RecipeType)p_155011_, p_155012_, p_155010_).map(AbstractCookingRecipe::getCookingTime).orElse(200); ++ return (p_155010_ != null) ? p_155010_.getRecipeManager().getRecipeFor((RecipeType)p_155011_, p_155012_, p_155010_).map(AbstractCookingRecipe::getCookingTime).orElse(200) : 200; } - public static boolean m_58399_(ItemStack p_58400_) { -- return m_58423_().containsKey(p_58400_.m_41720_()); + public static boolean isFuel(ItemStack p_58400_) { +- return getFuel().containsKey(p_58400_.getItem()); + return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58400_, null) > 0; } - public int[] m_7071_(Direction p_58363_) { + public int[] getSlotsForFace(Direction p_58363_) { @@ -426,7 +_,7 @@ return true; } else { - ItemStack itemstack = this.f_58310_.get(1); -- return m_58399_(p_58390_) || p_58390_.m_150930_(Items.f_42446_) && !itemstack.m_150930_(Items.f_42446_); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58390_, this.f_58312_) > 0 || p_58390_.m_150930_(Items.f_42446_) && !itemstack.m_150930_(Items.f_42446_); + 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); } } @@ -456,19 +_,36 @@ - this.f_58320_.clear(); + this.recipesUsed.clear(); } + public void awardUsedRecipesAndPopExperience(ServerPlayer p_155004_, ItemStack itemstack, int amount) { -+ List> list = this.getRecipesToAwardAndPopExperience(p_155004_.m_183503_(), p_155004_.m_20182_(), this.f_58858_, p_155004_, itemstack, amount); // CraftBukkit -+ p_155004_.m_7281_(list); -+ this.f_58320_.clear(); ++ List> list = this.getRecipesToAwardAndPopExperience(p_155004_.getLevel(), p_155004_.position(), this.worldPosition, p_155004_, itemstack, amount); // CraftBukkit ++ p_155004_.awardRecipes(list); ++ this.recipesUsed.clear(); + } + - public List> m_154995_(ServerLevel p_154996_, Vec3 p_154997_) { + public List> getRecipesToAwardAndPopExperience(ServerLevel p_154996_, Vec3 p_154997_) { + // CraftBukkit start -+ return this.getRecipesToAwardAndPopExperience(p_154996_, p_154997_, this.f_58858_, null, null, 0); ++ return this.getRecipesToAwardAndPopExperience(p_154996_, p_154997_, this.worldPosition, null, null, 0); + } + + public List> getRecipesToAwardAndPopExperience(ServerLevel p_154996_, Vec3 p_154997_, BlockPos blockposition, ServerPlayer entityplayer, ItemStack itemstack, int amount) { + // CraftBukkit end List> list = Lists.newArrayList(); - for(Entry entry : this.f_58320_.object2IntEntrySet()) { - p_154996_.m_7465_().m_44043_(entry.getKey()).ifPresent((p_155023_) -> { + for(Entry entry : this.recipesUsed.object2IntEntrySet()) { + p_154996_.getRecipeManager().byKey(entry.getKey()).ifPresent((p_155023_) -> { list.add(p_155023_); -- m_154998_(p_154996_, p_154997_, entry.getIntValue(), ((AbstractCookingRecipe)p_155023_).m_43750_()); -+ createExperience(p_154996_, p_154997_, entry.getIntValue(), ((AbstractCookingRecipe)p_155023_).m_43750_(), blockposition, entityplayer, itemstack, amount); // CraftBukkit +- createExperience(p_154996_, p_154997_, entry.getIntValue(), ((AbstractCookingRecipe)p_155023_).getExperience()); ++ createExperience(p_154996_, p_154997_, entry.getIntValue(), ((AbstractCookingRecipe)p_155023_).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit }); } @@ -252,9 +252,9 @@ + private static Player createExperience_entityhuman; + private static ItemStack createExperience_itemstack; + private static int createExperience_amount; - private static void m_154998_(ServerLevel p_154999_, Vec3 p_155000_, int p_155001_, float p_155002_) { - int i = Mth.m_14143_((float)p_155001_ * p_155002_); - float f = Mth.m_14187_((float)p_155001_ * p_155002_); + private static void createExperience(ServerLevel p_154999_, Vec3 p_155000_, int p_155001_, float p_155002_) { + int i = Mth.floor((float)p_155001_ * p_155002_); + float f = Mth.frac((float)p_155001_ * p_155002_); @@ -476,13 +_,96 @@ ++i; } @@ -262,7 +262,7 @@ + // CraftBukkit start - fire org.bukkit.event.inventory.FurnaceExtractEvent / BlockExpEvent + org.bukkit.event.block.BlockExpEvent event; + if (createExperience_amount != 0) { -+ event = new org.bukkit.event.inventory.FurnaceExtractEvent((org.bukkit.entity.Player) createExperience_entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154999_, createExperience_blockposition), org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.getMaterial(createExperience_itemstack.m_41720_()), createExperience_amount, i); ++ event = new org.bukkit.event.inventory.FurnaceExtractEvent((org.bukkit.entity.Player) createExperience_entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154999_, createExperience_blockposition), org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.getMaterial(createExperience_itemstack.getItem()), createExperience_amount, i); + } else { + event = new org.bukkit.event.block.BlockExpEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_154999_, createExperience_blockposition), i); + } @@ -270,7 +270,7 @@ + i = event.getExpToDrop(); + // CraftBukkit end + - ExperienceOrb.m_147082_(p_154999_, p_155000_, i); + ExperienceOrb.award(p_154999_, p_155000_, i); } + private static void createExperience(ServerLevel p_154999_, Vec3 p_155000_, int p_155001_, float p_155002_, BlockPos blockposition, Player entityhuman, ItemStack itemstack, int amount) { // CraftBukkit @@ -278,13 +278,13 @@ + createExperience_entityhuman = entityhuman; + createExperience_itemstack = itemstack; + createExperience_amount = amount; -+ m_154998_(p_154999_, p_155000_, p_155001_, p_155002_); ++ createExperience(p_154999_, p_155000_, p_155001_, p_155002_); + } + //Magma end + - public void m_5809_(StackedContents p_58342_) { - for(ItemStack itemstack : this.f_58310_) { - p_58342_.m_36491_(itemstack); + public void fillStackedContents(StackedContents p_58342_) { + for(ItemStack itemstack : this.items) { + p_58342_.accountStack(itemstack); } } @@ -294,7 +294,7 @@ + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (!this.f_58859_ && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (!this.remove && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (facing == Direction.UP) + return handlers[0].cast(); + else if (facing == Direction.DOWN) @@ -323,7 +323,7 @@ + public List transaction = new java.util.ArrayList(); + + public List getContents() { -+ return this.f_58310_; ++ return this.items; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -339,7 +339,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -348,7 +348,7 @@ + } + + public Object2IntOpenHashMap getRecipesUsed() { -+ return this.f_58320_; ++ return this.recipesUsed; + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch index 7ce9fb03..37de46ab 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch @@ -3,12 +3,12 @@ @@ -95,6 +_,11 @@ } - this.f_58475_ = p_155042_.m_128437_("Patterns", 10); + this.itemPatterns = p_155042_.getList("Patterns", 10); + // CraftBukkit start -+ while (this.f_58475_.size() > 20) { -+ this.f_58475_.remove(20); ++ while (this.itemPatterns.size() > 20) { ++ this.itemPatterns.remove(20); + } + // CraftBukkit end - this.f_58477_ = null; + this.patterns = null; } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch index c3ca0233..0d692e23 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BannerPattern.java.patch @@ -12,30 +12,30 @@ @@ -54,10 +_,16 @@ PIGLIN("piglin", "pig", true); - private static final BannerPattern[] f_58529_ = values(); + private static final BannerPattern[] VALUES = values(); + /** @deprecated Use {@link BannerPattern#values()} and get the length from the array **/ + @Deprecated - public static final int f_58526_ = f_58529_.length; + public static final int COUNT = VALUES.length; + /** @deprecated Subtract {@link net.minecraftforge.common.ForgeHooks#getNonPatternItemCount()} from {@link BannerPattern#values()} **/ + @Deprecated - public static final int f_58527_ = (int)Arrays.stream(f_58529_).filter((p_58581_) -> { - return p_58581_.f_58530_; + public static final int PATTERN_ITEM_COUNT = (int)Arrays.stream(VALUES).filter((p_58581_) -> { + return p_58581_.hasPatternItem; }).count(); + /** @deprecated Subtract 1 from {@link net.minecraftforge.common.ForgeHooks#getNonPatternItemCount()} to get the maximum non-pattern item index**/ + @Deprecated - public static final int f_58528_ = f_58526_ - f_58527_ - 1; - public final boolean f_58530_; - private final String f_58531_; + public static final int AVAILABLE_PATTERNS = COUNT - PATTERN_ITEM_COUNT - 1; + public final boolean hasPatternItem; + private final String filename; @@ -75,7 +_,8 @@ - public ResourceLocation m_58577_(boolean p_58578_) { + public ResourceLocation location(boolean p_58578_) { String s = p_58578_ ? "banner" : "shield"; -- return new ResourceLocation("entity/" + s + "/" + this.m_58572_()); -+ ResourceLocation fileLoc = new ResourceLocation(this.m_58572_()); -+ return new ResourceLocation(fileLoc.m_135827_(), "entity/" + s + "/" + fileLoc.m_135815_()); +- return new ResourceLocation("entity/" + s + "/" + this.getFilename()); ++ ResourceLocation fileLoc = new ResourceLocation(this.getFilename()); ++ return new ResourceLocation(fileLoc.getNamespace(), "entity/" + s + "/" + fileLoc.getPath()); } - public String m_58572_() { + public String getFilename() { @@ -106,6 +_,19 @@ } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch index 5f15ccd3..b2dcd501 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch @@ -10,7 +10,7 @@ + + @Override + public java.util.List getContents() { -+ return this.f_58591_; ++ return this.items; + } + + @Override @@ -29,7 +29,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -41,5 +41,5 @@ + // CraftBukkit end + public BarrelBlockEntity(BlockPos p_155052_, BlockState p_155053_) { - super(BlockEntityType.f_58942_, p_155052_, p_155053_); + super(BlockEntityType.BARREL, p_155052_, p_155053_); } 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 df21d3c2..ba18ea02 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 @@ -3,7 +3,7 @@ @@ -81,4 +_,35 @@ } - protected abstract AbstractContainerMenu m_6555_(int p_58627_, Inventory p_58628_); + protected abstract AbstractContainerMenu createMenu(int p_58627_, Inventory p_58628_); + + private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> createUnSidedHandler()); + protected net.minecraftforge.items.IItemHandler createUnSidedHandler() { @@ -11,7 +11,7 @@ + } + + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability cap, @javax.annotation.Nullable net.minecraft.core.Direction side) { -+ if (!this.f_58859_ && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) ++ if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) + return itemHandler.cast(); + return super.getCapability(cap, side); + } @@ -31,8 +31,8 @@ + // CraftBukkit start + @Override + public org.bukkit.Location getLocation() { -+ if (f_58857_ == null) return null; -+ return new org.bukkit.Location(f_58857_.getWorld(), f_58858_.m_123341_(), f_58858_.m_123342_(), f_58858_.m_123343_()); ++ if (level == null) return null; ++ return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 32cb8ed0..0978210e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,34 +1,34 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java @@ -98,6 +_,15 @@ - super(BlockEntityType.f_58930_, p_155088_, p_155089_); + super(BlockEntityType.BEACON, p_155088_, p_155089_); } + // CraftBukkit start - add fields and methods + public org.bukkit.potion.PotionEffect getPrimaryEffect() { -+ return (this.f_58652_ != null) ? org.bukkit.craftbukkit.v1_18_R2.potion.CraftPotionUtil.toBukkit(new MobEffectInstance(this.f_58652_, getLevel(this.f_58650_), getAmplification(f_58650_, f_58652_, f_58653_), true, true)) : null; ++ return (this.primaryPower != null) ? org.bukkit.craftbukkit.v1_18_R2.potion.CraftPotionUtil.toBukkit(new MobEffectInstance(this.primaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null; + } + public org.bukkit.potion.PotionEffect getSecondaryEffect() { -+ return (hasSecondaryEffect(f_58650_, f_58652_, f_58653_)) ? org.bukkit.craftbukkit.v1_18_R2.potion.CraftPotionUtil.toBukkit(new MobEffectInstance(this.f_58653_, getLevel(this.f_58650_), getAmplification(f_58650_, f_58652_, f_58653_), true, true)) : null; ++ return (hasSecondaryEffect(levels, primaryPower, secondaryPower)) ? org.bukkit.craftbukkit.v1_18_R2.potion.CraftPotionUtil.toBukkit(new MobEffectInstance(this.secondaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null; + } + // CraftBukkit end + - public static void m_155107_(Level p_155108_, BlockPos p_155109_, BlockState p_155110_, BeaconBlockEntity p_155111_) { - int i = p_155109_.m_123341_(); - int j = p_155109_.m_123342_(); + public static void tick(Level p_155108_, BlockPos p_155109_, BlockState p_155110_, BeaconBlockEntity p_155111_) { + int i = p_155109_.getX(); + int j = p_155109_.getY(); @@ -117,8 +_,8 @@ - for(int i1 = 0; i1 < 10 && blockpos.m_123342_() <= l; ++i1) { - BlockState blockstate = p_155108_.m_8055_(blockpos); - Block block = blockstate.m_60734_(); + for(int i1 = 0; i1 < 10 && blockpos.getY() <= l; ++i1) { + BlockState blockstate = p_155108_.getBlockState(blockpos); + Block block = blockstate.getBlock(); - if (block instanceof BeaconBeamBlock) { -- float[] afloat = ((BeaconBeamBlock)block).m_7988_().m_41068_(); +- float[] afloat = ((BeaconBeamBlock)block).getColor().getTextureDiffuseColors(); + float[] afloat = blockstate.getBeaconColorMultiplier(p_155108_, blockpos, p_155109_); + if (afloat != null) { - if (p_155111_.f_58649_.size() <= 1) { + if (p_155111_.checkingBeamSections.size() <= 1) { beaconblockentity$beaconbeamsection = new BeaconBlockEntity.BeaconBeamSection(afloat); - p_155111_.f_58649_.add(beaconblockentity$beaconbeamsection); + p_155111_.checkingBeamSections.add(beaconblockentity$beaconbeamsection); @@ -209,6 +_,54 @@ - super.m_7651_(); + super.setRemoved(); } + // CraftBukkit start - split into components @@ -54,8 +54,8 @@ + public static List getHumansInRange(Level world, BlockPos blockposition, int i) { + { + double d0 = (double) (i * 10 + 10); -+ AABB aabb = (new AABB(blockposition)).m_82400_(d0).m_82363_(0.0D, (double) world.m_141928_(), 0.0D); -+ List list = world.m_45976_(Player.class, aabb); ++ AABB aabb = (new AABB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D); ++ List list = world.getEntitiesOfClass(Player.class, aabb); + return list; + } + } @@ -63,7 +63,7 @@ + private static void applyEffect(List list, MobEffect p_155101_, int j, int i) { + { + for (Player player : list) { -+ player.m_7292_(new MobEffectInstance(p_155101_, j, i, true, true)); ++ player.addEffect(new MobEffectInstance(p_155101_, j, i, true, true)); + } + } + } @@ -79,8 +79,8 @@ + } + + //Magma start - revert to original to fix mixin inject, nothing really changed here apart from being moved to a different constructor - private static void m_155097_(Level p_155098_, BlockPos p_155099_, int p_155100_, @Nullable MobEffect p_155101_, @Nullable MobEffect p_155102_) { - if (!p_155098_.f_46443_ && p_155101_ != null) { + private static void applyEffects(Level p_155098_, BlockPos p_155099_, int p_155100_, @Nullable MobEffect p_155101_, @Nullable MobEffect p_155102_) { + if (!p_155098_.isClientSide && p_155101_ != null) { double d0 = (double)(p_155100_ * 10 + 10); @@ -233,6 +_,8 @@ @@ -89,19 +89,19 @@ + // CraftBukkit end + //Magma end - public static void m_155103_(Level p_155104_, BlockPos p_155105_, SoundEvent p_155106_) { - p_155104_.m_5594_((Player)null, p_155105_, p_155106_, SoundSource.BLOCKS, 1.0F, 1.0F); + public static void playSound(Level p_155104_, BlockPos p_155105_, SoundEvent p_155106_) { + p_155104_.playSound((Player)null, p_155105_, p_155106_, SoundSource.BLOCKS, 1.0F, 1.0F); @@ -258,8 +_,11 @@ - public void m_142466_(CompoundTag p_155113_) { - super.m_142466_(p_155113_); -- this.f_58652_ = m_58686_(p_155113_.m_128451_("Primary")); -- this.f_58653_ = m_58686_(p_155113_.m_128451_("Secondary")); + public void load(CompoundTag p_155113_) { + super.load(p_155113_); +- this.primaryPower = getValidEffectById(p_155113_.getInt("Primary")); +- this.secondaryPower = getValidEffectById(p_155113_.getInt("Secondary")); + // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598) -+ this.f_58652_ = MobEffect.m_19453_(p_155113_.m_128451_("Primary")); -+ this.f_58653_ = MobEffect.m_19453_(p_155113_.m_128451_("Secondary")); -+ this.f_58650_ = p_155113_.m_128451_("Levels"); // SPIGOT-5053, use where available ++ this.primaryPower = MobEffect.byId(p_155113_.getInt("Primary")); ++ this.secondaryPower = MobEffect.byId(p_155113_.getInt("Secondary")); ++ this.levels = p_155113_.getInt("Levels"); // SPIGOT-5053, use where available + // CraftBukkit end - if (p_155113_.m_128425_("CustomName", 8)) { - this.f_58654_ = Component.Serializer.m_130701_(p_155113_.m_128461_("CustomName")); + if (p_155113_.contains("CustomName", 8)) { + this.name = Component.Serializer.fromJson(p_155113_.getString("CustomName")); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index a5c105d6..88a7dab7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -1,156 +1,151 @@ --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java @@ -41,6 +_,7 @@ - private final List f_58732_ = Lists.newArrayList(); + private final List stored = Lists.newArrayList(); @Nullable - public BlockPos f_58733_; + public BlockPos savedFlowerPos; + public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold public BeehiveBlockEntity(BlockPos p_155134_, BlockState p_155135_) { - super(BlockEntityType.f_58912_, p_155134_, p_155135_); + super(BlockEntityType.BEEHIVE, p_155134_, p_155135_); @@ -73,7 +_,7 @@ } - public boolean m_58775_() { -- return this.f_58732_.size() == 3; -+ return this.f_58732_.size() == this.maxBees; // CraftBukkit + public boolean isFull() { +- return this.stored.size() == 3; ++ return this.stored.size() == this.maxBees; // CraftBukkit } - public void m_58748_(@Nullable Player p_58749_, BlockState p_58750_, BeehiveBlockEntity.BeeReleaseStatus p_58751_) { + public void emptyAllLivingFromHive(@Nullable Player p_58749_, BlockState p_58750_, BeehiveBlockEntity.BeeReleaseStatus p_58751_) { @@ -84,7 +_,7 @@ Bee bee = (Bee)entity; - if (p_58749_.m_20182_().m_82557_(entity.m_20182_()) <= 16.0D) { - if (!this.m_58777_()) { -- bee.m_6710_(p_58749_); + if (p_58749_.position().distanceToSqr(entity.position()) <= 16.0D) { + if (!this.isSedated()) { +- bee.setTarget(p_58749_); + bee.setTarget(p_58749_, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit } else { - bee.m_27915_(400); + bee.setStayOutOfHiveCountdown(400); } @@ -96,9 +_,15 @@ } - private List m_58759_(BlockState p_58760_, BeehiveBlockEntity.BeeReleaseStatus p_58761_) { + private List releaseAllOccupants(BlockState p_58760_, BeehiveBlockEntity.BeeReleaseStatus p_58761_) { + // CraftBukkit start - This allows us to bypass the night/rain/emergency check + return releaseBees(p_58760_, p_58761_, false); + } + + public List releaseBees(BlockState p_58760_, BeehiveBlockEntity.BeeReleaseStatus p_58761_, boolean force) { List list = Lists.newArrayList(); - this.f_58732_.removeIf((p_58766_) -> { -- return m_155136_(this.f_58857_, this.f_58858_, p_58760_, p_58766_, list, p_58761_, this.f_58733_); -+ return releaseBee(this.f_58857_, this.f_58858_, p_58760_, p_58766_, list, p_58761_, this.f_58733_, force); + this.stored.removeIf((p_58766_) -> { +- return releaseOccupant(this.level, this.worldPosition, p_58760_, p_58766_, list, p_58761_, this.savedFlowerPos); ++ return releaseBee(this.level, this.worldPosition, p_58760_, p_58766_, list, p_58761_, this.savedFlowerPos, force); + // CraftBukkit end }); if (!list.isEmpty()) { - super.m_6596_(); + super.setChanged(); @@ -126,7 +_,19 @@ } - public void m_58744_(Entity p_58745_, boolean p_58746_, int p_58747_) { -- if (this.f_58732_.size() < 3) { -+ if (this.f_58732_.size() < this.maxBees) { // CraftBukkit + public void addOccupantWithPresetTicks(Entity p_58745_, boolean p_58746_, int p_58747_) { +- if (this.stored.size() < 3) { ++ if (this.stored.size() < this.maxBees) { // CraftBukkit + // CraftBukkit start -+ if (this.f_58857_ != null) { -+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(p_58745_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(f_58857_, m_58899_())); ++ if (this.level != null) { ++ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(p_58745_.getBukkitEntity(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(level, getBlockPos())); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + if (p_58745_ instanceof Bee) { -+ ((Bee) p_58745_).m_27915_(400); ++ ((Bee) p_58745_).setStayOutOfHiveCountdown(400); + } + return; + } + } + // CraftBukkit end - p_58745_.m_8127_(); - p_58745_.m_20153_(); + p_58745_.stopRiding(); + p_58745_.ejectPassengers(); CompoundTag compoundtag = new CompoundTag(); @@ -154,7 +_,13 @@ } - private static boolean m_155136_(Level p_155137_, BlockPos p_155138_, BlockState p_155139_, BeehiveBlockEntity.BeeData p_155140_, @Nullable List p_155141_, BeehiveBlockEntity.BeeReleaseStatus p_155142_, @Nullable BlockPos p_155143_) { -- if ((p_155137_.m_46462_() || p_155137_.m_46471_()) && p_155142_ != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + private static boolean releaseOccupant(Level p_155137_, BlockPos p_155138_, BlockState p_155139_, BeehiveBlockEntity.BeeData p_155140_, @Nullable List p_155141_, BeehiveBlockEntity.BeeReleaseStatus p_155142_, @Nullable BlockPos p_155143_) { +- if ((p_155137_.isNight() || p_155137_.isRaining()) && p_155142_ != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + // CraftBukkit start - This allows us to bypass the night/rain/emergency check + return releaseBee(p_155137_, p_155138_, p_155139_, p_155140_, p_155141_, p_155142_, p_155143_, false); + } + + private static boolean releaseBee(Level p_155137_, BlockPos p_155138_, BlockState p_155139_, BeehiveBlockEntity.BeeData p_155140_, @Nullable List p_155141_, BeehiveBlockEntity.BeeReleaseStatus p_155142_, @Nullable BlockPos p_155143_, boolean force) { -+ if (!force && (p_155137_.m_46462_() || p_155137_.m_46471_()) && p_155142_ != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { ++ if (!force && (p_155137_.isNight() || p_155137_.isRaining()) && p_155142_ != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + // CraftBukkit end return false; } else { - CompoundTag compoundtag = p_155140_.f_58782_.m_6426_(); + CompoundTag compoundtag = p_155140_.entityData.copy(); @@ -174,6 +_,18 @@ - if (!entity.m_6095_().m_204039_(EntityTypeTags.f_13122_)) { + if (!entity.getType().is(EntityTypeTags.BEEHIVE_INHABITORS)) { return false; } else { + // CraftBukkit start + if (entity instanceof Bee) { -+ float f = entity.m_20205_(); ++ float f = entity.getBbWidth(); + double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F); -+ double d1 = (double) p_155138_.m_123341_() + 0.5D + d0 * (double) direction.m_122429_(); -+ double d2 = (double) p_155138_.m_123342_() + 0.5D - (double) (entity.m_20206_() / 2.0F); -+ double d3 = (double) p_155138_.m_123343_() + 0.5D + d0 * (double) direction.m_122431_(); -+ entity.m_7678_(d1, d2, d3, entity.m_146908_(), entity.m_146909_()); ++ double d1 = (double) p_155138_.getX() + 0.5D + d0 * (double) direction.getStepX(); ++ double d2 = (double) p_155138_.getY() + 0.5D - (double) (entity.getBbHeight() / 2.0F); ++ double d3 = (double) p_155138_.getZ() + 0.5D + d0 * (double) direction.getStepZ(); ++ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + } + p_155137_.prepareEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE); //Magma - add spawn reason -+ if (!p_155137_.m_7967_(entity)) return false; ++ if (!p_155137_.addFreshEntity(entity)) return false; + // CraftBukkit end if (entity instanceof Bee) { Bee bee = (Bee)entity; - if (p_155143_ != null && !bee.m_27852_() && p_155137_.f_46441_.nextFloat() < 0.9F) { + if (p_155143_ != null && !bee.hasSavedFlowerPos() && p_155137_.random.nextFloat() < 0.9F) { @@ -202,16 +_,18 @@ p_155141_.add(bee); } -- float f = entity.m_20205_(); + /* // CraftBukkit start -+ float f = entity.getBbWidth(); + float f = entity.getBbWidth(); double d3 = flag ? 0.0D : 0.55D + (double)(f / 2.0F); -- double d0 = (double)p_155138_.m_123341_() + 0.5D + d3 * (double)direction.m_122429_(); -- double d1 = (double)p_155138_.m_123342_() + 0.5D - (double)(entity.m_20206_() / 2.0F); -- double d2 = (double)p_155138_.m_123343_() + 0.5D + d3 * (double)direction.m_122431_(); -- entity.m_7678_(d0, d1, d2, entity.m_146908_(), entity.m_146909_()); -+ double d0 = (double)p_155138_.getX() + 0.5D + d3 * (double)direction.getStepX(); -+ double d1 = (double)p_155138_.getY() + 0.5D - (double)(entity.getBbHeight() / 2.0F); -+ double d2 = (double)p_155138_.getZ() + 0.5D + d3 * (double)direction.getStepZ(); -+ entity.moveTo(d0, d1, d2, entity.getYRot(), entity.getXRot()); + double d0 = (double)p_155138_.getX() + 0.5D + d3 * (double)direction.getStepX(); + double d1 = (double)p_155138_.getY() + 0.5D - (double)(entity.getBbHeight() / 2.0F); + double d2 = (double)p_155138_.getZ() + 0.5D + d3 * (double)direction.getStepZ(); + entity.moveTo(d0, d1, d2, entity.getYRot(), entity.getXRot()); + */ // CraftBukkit end } - p_155137_.m_5594_((Player)null, p_155138_, SoundEvents.f_11696_, SoundSource.BLOCKS, 1.0F, 1.0F); -- return p_155137_.m_7967_(entity); + p_155137_.playSound((Player)null, p_155138_, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1.0F, 1.0F); +- return p_155137_.addFreshEntity(entity); + return true; // return p_155137_.addFreshEntity(entity); // CraftBukkit - moved up } } else { return false; @@ -253,6 +_,10 @@ - if (m_155136_(p_155150_, p_155151_, p_155152_, beehiveblockentity$beedata, (List)null, beehiveblockentity$beereleasestatus, p_155154_)) { + if (releaseOccupant(p_155150_, p_155151_, p_155152_, beehiveblockentity$beedata, (List)null, beehiveblockentity$beereleasestatus, p_155154_)) { flag = true; iterator.remove(); + // CraftBukkit start + } else { -+ beehiveblockentity$beedata.f_58783_ = beehiveblockentity$beedata.f_58784_ / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable ++ beehiveblockentity$beedata.ticksInHive = beehiveblockentity$beedata.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable + // CraftBukkit end } } } @@ -291,6 +_,11 @@ - this.f_58733_ = NbtUtils.m_129239_(p_155156_.m_128469_("FlowerPos")); + this.savedFlowerPos = NbtUtils.readBlockPos(p_155156_.getCompound("FlowerPos")); } + // CraftBukkit start -+ if (p_155156_.m_128441_("Bukkit.MaxEntities")) { -+ this.maxBees = p_155156_.m_128451_("Bukkit.MaxEntities"); ++ if (p_155156_.contains("Bukkit.MaxEntities")) { ++ this.maxBees = p_155156_.getInt("Bukkit.MaxEntities"); + } + // CraftBukkit end } - protected void m_183515_(CompoundTag p_187467_) { + protected void saveAdditional(CompoundTag p_187467_) { @@ -299,6 +_,7 @@ - if (this.m_58780_()) { - p_187467_.m_128365_("FlowerPos", NbtUtils.m_129224_(this.f_58733_)); + if (this.hasSavedFlowerPos()) { + p_187467_.put("FlowerPos", NbtUtils.writeBlockPos(this.savedFlowerPos)); } -+ p_187467_.m_128405_("Bukkit.MaxEntities", this.maxBees); // CraftBukkit ++ p_187467_.putInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit } 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 b4a90e80..0e9588b7 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 @@ -7,13 +7,13 @@ -public abstract class BlockEntity { + +public abstract class BlockEntity extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeBlockEntity { - private static final Logger f_58854_ = LogUtils.getLogger(); - private final BlockEntityType f_58855_; + private static final Logger LOGGER = LogUtils.getLogger(); + private final BlockEntityType type; @Nullable @@ -23,11 +_,21 @@ - protected final BlockPos f_58858_; - protected boolean f_58859_; - private BlockState f_58856_; + protected final BlockPos worldPosition; + protected boolean remove; + private BlockState blockState; + private CompoundTag customTileData; + + public co.aikar.timings.Timing tickTimer = co.aikar.timings.MinecraftTimings.getTileEntityTimings(this); // Paper @@ -25,41 +25,41 @@ public BlockEntity(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { + super(BlockEntity.class); - this.f_58855_ = p_155228_; - this.f_58858_ = p_155229_.m_7949_(); - this.f_58856_ = p_155230_; + this.type = p_155228_; + this.worldPosition = p_155229_.immutable(); + this.blockState = p_155230_; + this.gatherCapabilities(); } - public static BlockPos m_187472_(CompoundTag p_187473_) { + public static BlockPos getPosFromTag(CompoundTag p_187473_) { @@ -48,9 +_,20 @@ } - public void m_142466_(CompoundTag p_155245_) { -+ if (p_155245_.m_128441_("ForgeData")) this.customTileData = p_155245_.m_128469_("ForgeData"); -+ if (getCapabilities() != null && p_155245_.m_128441_("ForgeCaps")) deserializeCaps(p_155245_.m_128469_("ForgeCaps")); + public void load(CompoundTag p_155245_) { ++ if (p_155245_.contains("ForgeData")) this.customTileData = p_155245_.getCompound("ForgeData"); ++ if (getCapabilities() != null && p_155245_.contains("ForgeCaps")) deserializeCaps(p_155245_.getCompound("ForgeCaps")); + // CraftBukkit start - read container + this.persistentDataContainer = new org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); -+ net.minecraft.nbt.Tag persistentDataTag = p_155245_.m_128423_("PublicBukkitValues"); ++ net.minecraft.nbt.Tag persistentDataTag = p_155245_.get("PublicBukkitValues"); + if (persistentDataTag instanceof CompoundTag) { + this.persistentDataContainer.putAll((CompoundTag) persistentDataTag); + } + // CraftBukkit end } - protected void m_183515_(CompoundTag p_187471_) { -+ if (this.customTileData != null) p_187471_.m_128365_("ForgeData", this.customTileData.m_6426_()); -+ if (getCapabilities() != null) p_187471_.m_128365_("ForgeCaps", serializeCaps()); + protected void saveAdditional(CompoundTag p_187471_) { ++ if (this.customTileData != null) p_187471_.put("ForgeData", this.customTileData.copy()); ++ if (getCapabilities() != null) p_187471_.put("ForgeCaps", serializeCaps()); } - public final CompoundTag m_187480_() { + public final CompoundTag saveWithFullMetadata() { @@ -68,6 +_,11 @@ - public final CompoundTag m_187482_() { + public final CompoundTag saveWithoutMetadata() { CompoundTag compoundtag = new CompoundTag(); - this.m_183515_(compoundtag); + this.saveAdditional(compoundtag); + // CraftBukkit start - store container + if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { -+ compoundtag.m_128365_("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); ++ compoundtag.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); + } + // CraftBukkit end return compoundtag; @@ -68,16 +68,16 @@ @@ -133,7 +_,7 @@ } - protected static void m_155232_(Level p_155233_, BlockPos p_155234_, BlockState p_155235_) { -- p_155233_.m_151543_(p_155234_); + protected static void setChanged(Level p_155233_, BlockPos p_155234_, BlockState p_155235_) { +- p_155233_.blockEntityChanged(p_155234_); + p_155233_.blockEntityChangedWithoutNeighborUpdates(p_155234_); - if (!p_155235_.m_60795_()) { - p_155233_.m_46717_(p_155234_, p_155235_.m_60734_()); + if (!p_155235_.isAir()) { + p_155233_.updateNeighbourForOutputSignal(p_155234_, p_155235_.getBlock()); } @@ -163,6 +_,13 @@ - public void m_7651_() { - this.f_58859_ = true; + public void setRemoved() { + this.remove = true; + this.invalidateCaps(); + requestModelDataUpdate(); + } @@ -87,9 +87,9 @@ + this.invalidateCaps(); } - public void m_6339_() { + public void clearRemoved() { @@ -191,9 +_,22 @@ - return this.f_58855_; + return this.type; } + @Override @@ -101,13 +101,13 @@ + /** @deprecated */ @Deprecated - public void m_155250_(BlockState p_155251_) { - this.f_58856_ = p_155251_; + public void setBlockState(BlockState p_155251_) { + this.blockState = p_155251_; } + + // CraftBukkit start - add method + public org.bukkit.inventory.InventoryHolder getOwner() { -+ return org.magmafoundation.magma.helpers.InventoryHelper.getHolder(f_58857_, f_58858_); ++ return org.magmafoundation.magma.helpers.InventoryHelper.getHolder(level, worldPosition); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch index 5f8a7e84..e629eba6 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntityType.java.patch @@ -6,6 +6,6 @@ -public class BlockEntityType { +public class BlockEntityType extends net.minecraftforge.registries.ForgeRegistryEntry> { - private static final Logger f_58913_ = LogUtils.getLogger(); - public static final BlockEntityType f_58917_ = m_58956_("furnace", BlockEntityType.Builder.m_155273_(FurnaceBlockEntity::new, Blocks.f_50094_)); - public static final BlockEntityType f_58918_ = m_58956_("chest", BlockEntityType.Builder.m_155273_(ChestBlockEntity::new, Blocks.f_50087_)); + private static final Logger LOGGER = LogUtils.getLogger(); + public static final BlockEntityType FURNACE = register("furnace", BlockEntityType.Builder.of(FurnaceBlockEntity::new, Blocks.FURNACE)); + public static final BlockEntityType CHEST = register("chest", BlockEntityType.Builder.of(ChestBlockEntity::new, Blocks.CHEST)); 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 2dfaf6df..e28647f6 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 @@ -22,11 +22,11 @@ + } + + public java.util.List getContents() { -+ return this.f_58975_; ++ return this.items; + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -36,14 +36,14 @@ + // CraftBukkit end + public BrewingStandBlockEntity(BlockPos p_155283_, BlockState p_155284_) { - super(BlockEntityType.f_58927_, p_155283_, p_155284_); + super(BlockEntityType.BREWING_STAND, p_155283_, p_155284_); } @@ -92,19 +_,37 @@ - public static void m_155285_(Level p_155286_, BlockPos p_155287_, BlockState p_155288_, BrewingStandBlockEntity p_155289_) { - ItemStack itemstack = p_155289_.f_58975_.get(4); - if (p_155289_.f_58979_ <= 0 && itemstack.m_150930_(Items.f_42593_)) { -- p_155289_.f_58979_ = 20; -- itemstack.m_41774_(1); + public static void serverTick(Level p_155286_, BlockPos p_155287_, BlockState p_155288_, BrewingStandBlockEntity p_155289_) { + ItemStack itemstack = p_155289_.items.get(4); + if (p_155289_.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) { +- p_155289_.fuel = 20; +- itemstack.shrink(1); + // CraftBukkit start + org.bukkit.event.inventory.BrewingStandFuelEvent event = new org.bukkit.event.inventory.BrewingStandFuelEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155286_, p_155287_), org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(itemstack), 20); + p_155286_.getCraftServer().getPluginManager().callEvent(event); @@ -52,43 +52,43 @@ + return; + } + -+ p_155289_.f_58979_ = event.getFuelPower(); -+ if (p_155289_.f_58979_ > 0 && event.isConsuming()) { -+ itemstack.m_41774_(1); ++ p_155289_.fuel = event.getFuelPower(); ++ if (p_155289_.fuel > 0 && event.isConsuming()) { ++ itemstack.shrink(1); + } + // CraftBukkit end - m_155232_(p_155286_, p_155287_, p_155288_); + setChanged(p_155286_, p_155287_, p_155288_); } - boolean flag = m_155294_(p_155289_.f_58975_); - boolean flag1 = p_155289_.f_58976_ > 0; - ItemStack itemstack1 = p_155289_.f_58975_.get(3); + boolean flag = isBrewable(p_155289_.items); + boolean flag1 = p_155289_.brewTime > 0; + ItemStack itemstack1 = p_155289_.items.get(3); + + // CraftBukkit start - Use wall time instead of ticks for brewing + int elapsedTicks = net.minecraft.server.MinecraftServer.currentTick - p_155289_.lastTick; + p_155289_.lastTick = net.minecraft.server.MinecraftServer.currentTick; + if (flag1) { -- --p_155289_.f_58976_; -- boolean flag2 = p_155289_.f_58976_ == 0; -+ p_155289_.f_58976_ -= elapsedTicks; -+ boolean flag2 = p_155289_.f_58976_ <= 0; // == -> <= +- --p_155289_.brewTime; +- boolean flag2 = p_155289_.brewTime == 0; ++ p_155289_.brewTime -= elapsedTicks; ++ boolean flag2 = p_155289_.brewTime <= 0; // == -> <= + // CraftBukkit end if (flag2 && flag) { -- m_155290_(p_155286_, p_155287_, p_155289_.f_58975_); +- doBrew(p_155286_, p_155287_, p_155289_.items); + prepareBrew(p_155289_); // Magma -+ m_155290_(p_155286_, p_155287_, p_155289_.f_58975_); // CraftBukkit - m_155232_(p_155286_, p_155287_, p_155288_); - } else if (!flag || !itemstack1.m_150930_(p_155289_.f_58978_)) { - p_155289_.f_58976_ = 0; ++ doBrew(p_155286_, p_155287_, p_155289_.items); // CraftBukkit + setChanged(p_155286_, p_155287_, p_155288_); + } else if (!flag || !itemstack1.is(p_155289_.ingredient)) { + p_155289_.brewTime = 0; @@ -148,6 +_,7 @@ - private static boolean m_155294_(NonNullList p_155295_) { + private static boolean isBrewable(NonNullList p_155295_) { ItemStack itemstack = p_155295_.get(3); -+ if (!itemstack.m_41619_()) return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(p_155295_, itemstack, f_58974_); // divert to VanillaBrewingRegistry - if (itemstack.m_41619_()) { ++ if (!itemstack.isEmpty()) return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(p_155295_, itemstack, SLOTS_FOR_SIDES); // divert to VanillaBrewingRegistry + if (itemstack.isEmpty()) { return false; - } else if (!PotionBrewing.m_43506_(itemstack)) { + } else if (!PotionBrewing.isIngredient(itemstack)) { @@ -164,22 +_,44 @@ } } @@ -100,20 +100,20 @@ + } + // Magma end + - private static void m_155290_(Level p_155291_, BlockPos p_155292_, NonNullList p_155293_) { + private static void doBrew(Level p_155291_, BlockPos p_155292_, NonNullList p_155293_) { + if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBrew(p_155293_)) return; ItemStack itemstack = p_155293_.get(3); - for(int i = 0; i < 3; ++i) { -- p_155293_.set(i, PotionBrewing.m_43529_(itemstack, p_155293_.get(i))); +- p_155293_.set(i, PotionBrewing.mix(itemstack, p_155293_.get(i))); - } + org.bukkit.inventory.InventoryHolder owner = blockEntity.getOwner(); + java.util.List brewResults = new java.util.ArrayList<>(3); + for (int i = 0; i < 3; ++i) { -+ brewResults.add(i, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(PotionBrewing.m_43529_(itemstack, (ItemStack) p_155293_.get(i)))); ++ brewResults.add(i, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(PotionBrewing.mix(itemstack, (ItemStack) p_155293_.get(i)))); + } + if (owner != null) { -+ org.bukkit.event.inventory.BrewEvent event = new org.bukkit.event.inventory.BrewEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155291_, p_155292_), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), brewResults, blockEntity.f_58979_); ++ org.bukkit.event.inventory.BrewEvent event = new org.bukkit.event.inventory.BrewEvent(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155291_, p_155292_), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), brewResults, blockEntity.fuel); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; @@ -121,43 +121,43 @@ + } + // CraftBukkit end -- itemstack.m_41774_(1); -- if (itemstack.m_41720_().m_41470_()) { -- ItemStack itemstack1 = new ItemStack(itemstack.m_41720_().m_41469_()); -+ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(p_155293_, itemstack, f_58974_); +- itemstack.shrink(1); +- if (itemstack.getItem().hasCraftingRemainingItem()) { +- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getCraftingRemainingItem()); ++ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(p_155293_, itemstack, SLOTS_FOR_SIDES); + net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(p_155293_); + // TODO: 02/06/2022 Magma - add brewEvent brewResults. + if (itemstack.hasContainerItem()) { + ItemStack itemstack1 = itemstack.getContainerItem(); -+ itemstack.m_41774_(1); - if (itemstack.m_41619_()) { ++ itemstack.shrink(1); + if (itemstack.isEmpty()) { itemstack = itemstack1; } else { - Containers.m_18992_(p_155291_, (double)p_155292_.m_123341_(), (double)p_155292_.m_123342_(), (double)p_155292_.m_123343_(), itemstack1); + Containers.dropItemStack(p_155291_, (double)p_155292_.getX(), (double)p_155292_.getY(), (double)p_155292_.getZ(), itemstack1); } } -+ else itemstack.m_41774_(1); ++ else itemstack.shrink(1); p_155293_.set(3, itemstack); - p_155291_.m_46796_(1035, p_155292_, 0); + p_155291_.levelEvent(1035, p_155292_, 0); @@ -229,11 +_,11 @@ - public boolean m_7013_(int p_59017_, ItemStack p_59018_) { + public boolean canPlaceItem(int p_59017_, ItemStack p_59018_) { if (p_59017_ == 3) { -- return PotionBrewing.m_43506_(p_59018_); +- return PotionBrewing.isIngredient(p_59018_); + return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_59018_); } else if (p_59017_ == 4) { - return p_59018_.m_150930_(Items.f_42593_); + return p_59018_.is(Items.BLAZE_POWDER); } else { -- return (p_59018_.m_150930_(Items.f_42589_) || p_59018_.m_150930_(Items.f_42736_) || p_59018_.m_150930_(Items.f_42739_) || p_59018_.m_150930_(Items.f_42590_)) && this.m_8020_(p_59017_).m_41619_(); -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_59018_) && this.m_8020_(p_59017_).m_41619_(); +- return (p_59018_.is(Items.POTION) || p_59018_.is(Items.SPLASH_POTION) || p_59018_.is(Items.LINGERING_POTION) || p_59018_.is(Items.GLASS_BOTTLE)) && this.getItem(p_59017_).isEmpty(); ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_59018_) && this.getItem(p_59017_).isEmpty(); } } @@ -259,5 +_,34 @@ - protected AbstractContainerMenu m_6555_(int p_58990_, Inventory p_58991_) { - return new BrewingStandMenu(p_58990_, p_58991_, this, this.f_58971_); + protected AbstractContainerMenu createMenu(int p_58990_, Inventory p_58991_) { + return new BrewingStandMenu(p_58990_, p_58991_, this, this.dataAccess); + } + + net.minecraftforge.common.util.LazyOptional[] handlers = @@ -165,7 +165,7 @@ + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { -+ if (!this.f_58859_ && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (!this.remove && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (facing == Direction.UP) + return handlers[0].cast(); + else if (facing == Direction.DOWN) diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch index 0bd1e93d..bb494b40 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java @@ -45,6 +_,19 @@ - ItemStack itemstack1 = p_155307_.m_7465_().m_44015_(RecipeType.f_44111_, container, p_155307_).map((p_155305_) -> { - return p_155305_.m_5874_(container); + ItemStack itemstack1 = p_155307_.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, container, p_155307_).map((p_155305_) -> { + return p_155305_.assemble(container); }).orElse(itemstack); + + // CraftBukkit start - fire BlockCookEvent @@ -17,6 +17,6 @@ + itemstack1 = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(result); + // CraftBukkit end + - Containers.m_18992_(p_155307_, (double)p_155308_.m_123341_(), (double)p_155308_.m_123342_(), (double)p_155308_.m_123343_(), itemstack1); - p_155310_.f_59042_.set(i, ItemStack.f_41583_); - p_155307_.m_7260_(p_155308_, p_155309_, p_155309_, 3); + Containers.dropItemStack(p_155307_, (double)p_155308_.getX(), (double)p_155308_.getY(), (double)p_155308_.getZ(), itemstack1); + p_155310_.items.set(i, ItemStack.EMPTY); + p_155307_.sendBlockUpdated(p_155308_, p_155309_, p_155309_, 3); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch index 7b30a96c..92990a95 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java @@ -51,6 +_,36 @@ }; - private final ChestLidController f_155325_ = new ChestLidController(); + private final ChestLidController chestLidController = new ChestLidController(); + // CraftBukkit start - add fields and methods + public java.util.List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.f_59073_; ++ return this.items; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -25,7 +25,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -38,13 +38,13 @@ super(p_155327_, p_155328_, p_155329_); } @@ -161,6 +_,45 @@ - return ChestMenu.m_39237_(p_59082_, p_59083_, this); + return ChestMenu.threeRows(p_59082_, p_59083_, this); } + private net.minecraftforge.common.util.LazyOptional chestHandler; + @Override -+ public void m_155250_(BlockState p_155251_) { -+ super.m_155250_(p_155251_); ++ public void setBlockState(BlockState p_155251_) { ++ super.setBlockState(p_155251_); + if (this.chestHandler != null) { + net.minecraftforge.common.util.LazyOptional oldHandler = this.chestHandler; + this.chestHandler = null; @@ -54,7 +54,7 @@ + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability cap, Direction side) { -+ if (!this.f_58859_ && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { ++ if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (this.chestHandler == null) + this.chestHandler = net.minecraftforge.common.util.LazyOptional.of(this::createHandler); + return this.chestHandler.cast(); @@ -63,11 +63,11 @@ + } + + private net.minecraftforge.items.IItemHandlerModifiable createHandler() { -+ BlockState state = this.m_58900_(); -+ if (!(state.m_60734_() instanceof ChestBlock)) { ++ BlockState state = this.getBlockState(); ++ if (!(state.getBlock() instanceof ChestBlock)) { + return new net.minecraftforge.items.wrapper.InvWrapper(this); + } -+ Container inv = ChestBlock.m_51511_((ChestBlock) state.m_60734_(), state, m_58904_(), m_58899_(), true); ++ Container inv = ChestBlock.getContainer((ChestBlock) state.getBlock(), state, getLevel(), getBlockPos(), true); + return new net.minecraftforge.items.wrapper.InvWrapper(inv == null ? this : inv); + } + @@ -80,17 +80,17 @@ + } + } + - public void m_155350_() { - if (!this.f_58859_) { - this.f_155324_.m_155476_(this.m_58904_(), this.m_58899_(), this.m_58900_()); + public void recheckOpen() { + if (!this.remove) { + this.openersCounter.recheckOpeners(this.getLevel(), this.getBlockPos(), this.getBlockState()); @@ -172,4 +_,11 @@ - Block block = p_155335_.m_60734_(); - p_155333_.m_7696_(p_155334_, block, 1, p_155337_); + Block block = p_155335_.getBlock(); + p_155333_.blockEvent(p_155334_, block, 1, p_155337_); } + + // CraftBukkit start + @Override -+ public boolean m_6326_() { ++ public boolean onlyOpCanSetNbt() { + return false; + } + // CraftBukkit end diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index f9197eb5..ad23195d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java @@ -18,6 +_,13 @@ - private boolean f_59124_; - private boolean f_59125_; - private final BaseCommandBlock f_59127_ = new BaseCommandBlock() { + private boolean auto; + private boolean conditionMet; + private final BaseCommandBlock commandBlock = new BaseCommandBlock() { + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { @@ -11,6 +11,6 @@ + } + // CraftBukkit end + - public void m_6590_(String p_59157_) { - super.m_6590_(p_59157_); - CommandBlockEntity.this.m_6596_(); + public void setCommand(String p_59157_) { + super.setCommand(p_59157_); + CommandBlockEntity.this.setChanged(); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 09bc066b..13ca67ac 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java @@ -153,10 +_,8 @@ - BlockPos blockpos1 = p_155416_.m_142082_(j1, k1, l1); - BlockState blockstate = p_155415_.m_8055_(blockpos1); + BlockPos blockpos1 = p_155416_.offset(j1, k1, l1); + BlockState blockstate = p_155415_.getBlockState(blockpos1); -- for(Block block : f_59184_) { -- if (blockstate.m_60713_(block)) { +- for(Block block : VALID_BLOCKS) { +- if (blockstate.is(block)) { - p_155417_.add(blockpos1); - } + if (blockstate.isConduitFrame(p_155415_, blockpos1, p_155416_)) { @@ -16,25 +16,25 @@ @@ -177,7 +_,7 @@ if (!list.isEmpty()) { for(Player player : list) { - if (p_155445_.m_123314_(player.m_142538_(), (double)j) && player.m_20070_()) { -- player.m_7292_(new MobEffectInstance(MobEffects.f_19592_, 260, 0, true, true)); -+ player.addEffect(new MobEffectInstance(MobEffects.f_19592_, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit + if (p_155445_.closerThan(player.blockPosition(), (double)j) && player.isInWaterOrRain()) { +- player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true)); ++ player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit } } @@ -204,8 +_,13 @@ } - if (p_155413_.f_59189_ != null) { -- p_155409_.m_6263_((Player)null, p_155413_.f_59189_.m_20185_(), p_155413_.f_59189_.m_20186_(), p_155413_.f_59189_.m_20189_(), SoundEvents.f_11823_, SoundSource.BLOCKS, 1.0F, 1.0F); -- p_155413_.f_59189_.m_6469_(DamageSource.f_19319_, 4.0F); + if (p_155413_.destroyTarget != null) { +- p_155409_.playSound((Player)null, p_155413_.destroyTarget.getX(), p_155413_.destroyTarget.getY(), p_155413_.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F); +- p_155413_.destroyTarget.hurt(DamageSource.MAGIC, 4.0F); + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_155409_, p_155410_); -+ if (p_155413_.f_59189_.m_6469_(DamageSource.f_19319_, 4.0F)) { -+ p_155409_.m_6263_((Player) null, p_155413_.f_59189_.m_20185_(), p_155413_.f_59189_.m_20186_(), p_155413_.f_59189_.m_20189_(), SoundEvents.f_11823_, SoundSource.BLOCKS, 1.0F, 1.0F); ++ if (p_155413_.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) { ++ p_155409_.playSound((Player) null, p_155413_.destroyTarget.getX(), p_155413_.destroyTarget.getY(), p_155413_.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F); + } + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.blockDamage = null; + // CraftBukkit end } - if (livingentity != p_155413_.f_59189_) { + if (livingentity != p_155413_.destroyTarget) { diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java.patch index 07c4187a..474ddcfd 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java.patch @@ -2,22 +2,22 @@ +++ b/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java @@ -12,6 +_,7 @@ public abstract class ContainerOpenersCounter { - private static final int f_155447_ = 5; - private int f_155448_; + private static final int CHECK_TICK_DELAY = 5; + private int openCount; + public boolean opened; // CraftBukkit - protected abstract void m_142292_(Level p_155460_, BlockPos p_155461_, BlockState p_155462_); + protected abstract void onOpen(Level p_155460_, BlockPos p_155461_, BlockState p_155462_); @@ -22,7 +_,18 @@ - protected abstract boolean m_142718_(Player p_155451_); + protected abstract boolean isOwnContainer(Player p_155451_); - public void m_155452_(Player p_155453_, Level p_155454_, BlockPos p_155455_, BlockState p_155456_) { -+ int oldPower = Math.max(0, Math.min(15, this.f_155448_)); // CraftBukkit - Get power before new viewer is added - int i = this.f_155448_++; + public void incrementOpeners(Player p_155453_, Level p_155454_, BlockPos p_155455_, BlockState p_155456_) { ++ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added + int i = this.openCount++; + + // CraftBukkit start - Call redstone event -+ if (p_155454_.m_8055_(p_155455_).m_60713_(net.minecraft.world.level.block.Blocks.f_50325_)) { -+ int newPower = Math.max(0, Math.min(15, this.f_155448_)); ++ if (p_155454_.getBlockState(p_155455_).is(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) { ++ int newPower = Math.max(0, Math.min(15, this.openCount)); + if (oldPower != newPower) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_155454_, p_155455_, oldPower, newPower); + } @@ -25,32 +25,32 @@ + // CraftBukkit end + if (i == 0) { - this.m_142292_(p_155454_, p_155455_, p_155456_); - p_155454_.m_142346_(p_155453_, GameEvent.f_157803_, p_155455_); + this.onOpen(p_155454_, p_155455_, p_155456_); + p_155454_.gameEvent(p_155453_, GameEvent.CONTAINER_OPEN, p_155455_); @@ -33,7 +_,18 @@ } - public void m_155468_(Player p_155469_, Level p_155470_, BlockPos p_155471_, BlockState p_155472_) { -+ int oldPower = Math.max(0, Math.min(15, this.f_155448_)); // CraftBukkit - Get power before new viewer is added - int i = this.f_155448_--; + public void decrementOpeners(Player p_155469_, Level p_155470_, BlockPos p_155471_, BlockState p_155472_) { ++ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added + int i = this.openCount--; + + // CraftBukkit start - Call redstone event -+ if (p_155470_.m_8055_(p_155471_).m_60713_(net.minecraft.world.level.block.Blocks.f_50325_)) { -+ int newPower = Math.max(0, Math.min(15, this.f_155448_)); ++ if (p_155470_.getBlockState(p_155471_).is(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) { ++ int newPower = Math.max(0, Math.min(15, this.openCount)); + if (oldPower != newPower) { + org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callRedstoneChange(p_155470_, p_155471_, oldPower, newPower); + } + } + // CraftBukkit end + - if (this.f_155448_ == 0) { - this.m_142289_(p_155470_, p_155471_, p_155472_); - p_155470_.m_142346_(p_155469_, GameEvent.f_157802_, p_155471_); + if (this.openCount == 0) { + this.onClose(p_155470_, p_155471_, p_155472_); + p_155470_.gameEvent(p_155469_, GameEvent.CONTAINER_CLOSE, p_155471_); @@ -53,6 +_,7 @@ - public void m_155476_(Level p_155477_, BlockPos p_155478_, BlockState p_155479_) { - int i = this.m_155457_(p_155477_, p_155478_); + public void recheckOpeners(Level p_155477_, BlockPos p_155478_, BlockState p_155479_) { + int i = this.getOpenCount(p_155477_, p_155478_); + if (opened) i++; // CraftBukkit - add dummy count from API - int j = this.f_155448_; + int j = this.openCount; if (j != i) { boolean flag = i != 0; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch index 9fbeff35..9f0b8000 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java @@ -19,6 +_,36 @@ - public static final int f_155487_ = 9; - private NonNullList f_59228_ = NonNullList.m_122780_(9, ItemStack.f_41583_); + public static final int CONTAINER_SIZE = 9; + private NonNullList items = NonNullList.withSize(9, ItemStack.EMPTY); + // CraftBukkit start - add fields and methods + public java.util.List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.f_59228_; ++ return this.items; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -25,7 +25,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index a014461b..27298c78 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -39,6 +_,36 @@ - private int f_59302_ = -1; - private long f_59303_; + private int cooldownTime = -1; + private long tickedGameTime; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public List getContents() { -+ return this.f_59301_; ++ return this.items; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -25,7 +25,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -35,62 +35,62 @@ + // CraftBukkit end + public HopperBlockEntity(BlockPos p_155550_, BlockState p_155551_) { - super(BlockEntityType.f_58933_, p_155550_, p_155551_); + super(BlockEntityType.HOPPER, p_155550_, p_155551_); } @@ -89,9 +_,14 @@ - p_155577_.f_59303_ = p_155574_.m_46467_(); - if (!p_155577_.m_59407_()) { - p_155577_.m_59395_(0); -- m_155578_(p_155574_, p_155575_, p_155576_, p_155577_, () -> { + p_155577_.tickedGameTime = p_155574_.getGameTime(); + if (!p_155577_.isOnCooldown()) { + p_155577_.setCooldown(0); +- tryMoveItems(p_155574_, p_155575_, p_155576_, p_155577_, () -> { + // Spigot start -+ boolean result = m_155578_(p_155574_, p_155575_, p_155576_, p_155577_, () -> { - return m_155552_(p_155574_, p_155577_); ++ boolean result = tryMoveItems(p_155574_, p_155575_, p_155576_, p_155577_, () -> { + return suckInItems(p_155574_, p_155577_); }); -+ if (!result && p_155577_.f_58857_.spigotConfig.hopperCheck > 1) { -+ p_155577_.m_59395_(p_155577_.f_58857_.spigotConfig.hopperCheck); ++ if (!result && p_155577_.level.spigotConfig.hopperCheck > 1) { ++ p_155577_.setCooldown(p_155577_.level.spigotConfig.hopperCheck); + } + // Spigot end } } @@ -103,7 +_,7 @@ - if (!p_155582_.m_59407_() && p_155581_.m_61143_(HopperBlock.f_54022_)) { + if (!p_155582_.isOnCooldown() && p_155581_.getValue(HopperBlock.ENABLED)) { boolean flag = false; - if (!p_155582_.m_7983_()) { -- flag = m_155562_(p_155579_, p_155580_, p_155581_, p_155582_); + if (!p_155582_.isEmpty()) { +- flag = ejectItems(p_155579_, p_155580_, p_155581_, p_155582_); + flag = ejectItems(p_155579_, p_155580_, p_155581_, p_155582_); //Magma - use original method } - if (!p_155582_.m_59404_()) { + if (!p_155582_.inventoryFull()) { @@ -111,7 +_,7 @@ } if (flag) { -- p_155582_.m_59395_(8); -+ p_155582_.m_59395_(p_155579_.spigotConfig.hopperTransfer); // Spigot - m_155232_(p_155579_, p_155580_, p_155581_); +- p_155582_.setCooldown(8); ++ p_155582_.setCooldown(p_155579_.spigotConfig.hopperTransfer); // Spigot + setChanged(p_155579_, p_155580_, p_155581_); return true; } @@ -131,7 +_,9 @@ return true; } -- private static boolean m_155562_(Level p_155563_, BlockPos p_155564_, BlockState p_155565_, Container p_155566_) { +- private static boolean ejectItems(Level p_155563_, BlockPos p_155564_, BlockState p_155565_, Container p_155566_) { + //Magma start - add original method and remove bukkit one + private static boolean ejectItems(Level p_155563_, BlockPos p_155564_, BlockState p_155565_, HopperBlockEntity p_155566_) { + if (net.minecraftforge.items.VanillaInventoryCodeHooks.insertHook(p_155566_)) return true; - Container container = m_155592_(p_155563_, p_155564_, p_155565_); + Container container = getAttachedContainer(p_155563_, p_155564_, p_155565_); if (container == null) { return false; @@ -143,12 +_,37 @@ - for(int i = 0; i < p_155566_.m_6643_(); ++i) { - if (!p_155566_.m_8020_(i).m_41619_()) { - ItemStack itemstack = p_155566_.m_8020_(i).m_41777_(); -- ItemStack itemstack1 = m_59326_(p_155566_, container, p_155566_.m_7407_(i, 1), direction); + for(int i = 0; i < p_155566_.getContainerSize(); ++i) { + if (!p_155566_.getItem(i).isEmpty()) { + ItemStack itemstack = p_155566_.getItem(i).copy(); +- ItemStack itemstack1 = addItem(p_155566_, container, p_155566_.removeItem(i, 1), direction); + //ItemStack itemstack1 = addItem(p_155566_, container, p_155566_.removeItem(i, 1), direction); + + // CraftBukkit start - Call event when pushing items into other inventories -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_155566_.m_7407_(i, p_155563_.spigotConfig.hopperAmount)); // Spigot ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_155566_.removeItem(i, p_155563_.spigotConfig.hopperAmount)); // Spigot + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly @@ -104,21 +104,21 @@ + p_155563_.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ p_155566_.m_6836_(i, itemstack); -+ p_155566_.m_59395_(p_155563_.spigotConfig.hopperTransfer); // Spigot ++ p_155566_.setItem(i, itemstack); ++ p_155566_.setCooldown(p_155563_.spigotConfig.hopperTransfer); // Spigot + return false; + } + int originalAmount = event.getItem().getAmount(); -+ ItemStack itemstack1 = m_59326_(p_155566_, container, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction); ++ ItemStack itemstack1 = addItem(p_155566_, container, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction); + // CraftBukkit end + - if (itemstack1.m_41619_()) { - container.m_6596_(); + if (itemstack1.isEmpty()) { + container.setChanged(); return true; } -+ itemstack.m_41774_(originalAmount - itemstack1.m_41613_()); // Spigot - p_155566_.m_6836_(i, itemstack); ++ itemstack.shrink(originalAmount - itemstack1.getCount()); // Spigot + p_155566_.setItem(i, itemstack); } } @@ -157,6 +_,7 @@ @@ -127,39 +127,39 @@ } + //Magma end - private static IntStream m_59339_(Container p_59340_, Direction p_59341_) { - return p_59340_ instanceof WorldlyContainer ? IntStream.of(((WorldlyContainer)p_59340_).m_7071_(p_59341_)) : IntStream.range(0, p_59340_.m_6643_()); + private static IntStream getSlots(Container p_59340_, Direction p_59341_) { + return p_59340_ instanceof WorldlyContainer ? IntStream.of(((WorldlyContainer)p_59340_).getSlotsForFace(p_59341_)) : IntStream.range(0, p_59340_.getContainerSize()); @@ -176,11 +_,13 @@ } - public static boolean m_155552_(Level p_155553_, Hopper p_155554_) { + public static boolean suckInItems(Level p_155553_, Hopper p_155554_) { + Boolean ret = net.minecraftforge.items.VanillaInventoryCodeHooks.extractHook(p_155553_, p_155554_); + if (ret != null) return ret; - Container container = m_155596_(p_155553_, p_155554_); + Container container = getSourceContainer(p_155553_, p_155554_); if (container != null) { Direction direction = Direction.DOWN; - return m_59397_(container, direction) ? false : m_59339_(container, direction).anyMatch((p_59363_) -> { -- return m_59354_(p_155554_, container, p_59363_, direction); + return isEmptyContainer(container, direction) ? false : getSlots(container, direction).anyMatch((p_59363_) -> { +- return tryTakeInItemFromSlot(p_155554_, container, p_59363_, direction); + return tryTakeInItemFromSlot(p_155554_, container, p_59363_, direction, p_155553_); }); } else { - for(ItemEntity itementity : m_155589_(p_155553_, p_155554_)) { + for(ItemEntity itementity : getItemsAtAndAbove(p_155553_, p_155554_)) { @@ -193,24 +_,71 @@ } } + //Magma - add original method + private static @Nullable Level tryTakeInItemFromSlot_level; - private static boolean m_59354_(Hopper p_59355_, Container p_59356_, int p_59357_, Direction p_59358_) { + private static boolean tryTakeInItemFromSlot(Hopper p_59355_, Container p_59356_, int p_59357_, Direction p_59358_) { + Level level = tryTakeInItemFromSlot_level; + tryTakeInItemFromSlot_level = null; + - ItemStack itemstack = p_59356_.m_8020_(p_59357_); - if (!itemstack.m_41619_() && m_59380_(p_59356_, itemstack, p_59357_, p_59358_)) { - ItemStack itemstack1 = itemstack.m_41777_(); -- ItemStack itemstack2 = m_59326_(p_59356_, p_59355_, p_59356_.m_7407_(p_59357_, 1), (Direction)null); + ItemStack itemstack = p_59356_.getItem(p_59357_); + if (!itemstack.isEmpty() && canTakeItemFromContainer(p_59356_, itemstack, p_59357_, p_59358_)) { + ItemStack itemstack1 = itemstack.copy(); +- ItemStack itemstack2 = addItem(p_59356_, p_59355_, p_59356_.removeItem(p_59357_, 1), (Direction)null); + // CraftBukkit start - Call event on collection of items from inventories into the hopper -+ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_59356_.m_7407_(p_59357_, level.spigotConfig.hopperAmount)); // Spigot ++ org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asCraftMirror(p_59356_.removeItem(p_59357_, level.spigotConfig.hopperAmount)); // Spigot + + org.bukkit.inventory.Inventory sourceInventory; + // Have to special case large chests as they work oddly @@ -173,27 +173,27 @@ + + org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ p_59356_.m_6836_(p_59357_, itemstack1); ++ p_59356_.setItem(p_59357_, itemstack1); + + if (p_59355_ instanceof HopperBlockEntity) { -+ ((HopperBlockEntity) p_59355_).m_59395_(level.spigotConfig.hopperTransfer); // Spigot ++ ((HopperBlockEntity) p_59355_).setCooldown(level.spigotConfig.hopperTransfer); // Spigot + } else if (p_59355_ instanceof net.minecraft.world.entity.vehicle.MinecartHopper) { -+ ((net.minecraft.world.entity.vehicle.MinecartHopper) p_59355_).m_38610_(level.spigotConfig.hopperTransfer / 2); // Spigot ++ ((net.minecraft.world.entity.vehicle.MinecartHopper) p_59355_).setCooldown(level.spigotConfig.hopperTransfer / 2); // Spigot + } + + return false; + } + int originalAmount = event.getItem().getAmount(); -+ ItemStack itemstack2 = m_59326_(p_59356_, p_59355_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()), null); ++ ItemStack itemstack2 = addItem(p_59356_, p_59355_, org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(event.getItem()), null); + // CraftBukkit end + - if (itemstack2.m_41619_()) { - p_59356_.m_6596_(); + if (itemstack2.isEmpty()) { + p_59356_.setChanged(); return true; } -+ itemstack1.m_41774_(originalAmount - itemstack2.m_41613_()); // Spigot - p_59356_.m_6836_(p_59357_, itemstack1); ++ itemstack1.shrink(originalAmount - itemstack2.getCount()); // Spigot + p_59356_.setItem(p_59357_, itemstack1); } return false; @@ -201,54 +201,54 @@ + private static boolean tryTakeInItemFromSlot(Hopper p_59355_, Container p_59356_, int p_59357_, Direction p_59358_, Level level) { + tryTakeInItemFromSlot_level = level; -+ return m_59354_(p_59355_, p_59356_, p_59357_, p_59358_); ++ return tryTakeInItemFromSlot(p_59355_, p_59356_, p_59357_, p_59358_); + } + //Magma end + - public static boolean m_59331_(Container p_59332_, ItemEntity p_59333_) { + public static boolean addItem(Container p_59332_, ItemEntity p_59333_) { boolean flag = false; + // CraftBukkit start + org.bukkit.event.inventory.InventoryPickupItemEvent event = new org.bukkit.event.inventory.InventoryPickupItemEvent(p_59332_.getOwner().getInventory(), (org.bukkit.entity.Item) p_59333_.getBukkitEntity()); -+ p_59333_.f_19853_.getCraftServer().getPluginManager().callEvent(event); ++ p_59333_.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } + // CraftBukkit end - ItemStack itemstack = p_59333_.m_32055_().m_41777_(); - ItemStack itemstack1 = m_59326_((Container)null, p_59332_, itemstack, (Direction)null); - if (itemstack1.m_41619_()) { + ItemStack itemstack = p_59333_.getItem().copy(); + ItemStack itemstack1 = addItem((Container)null, p_59332_, itemstack, (Direction)null); + if (itemstack1.isEmpty()) { @@ -260,6 +_,11 @@ boolean flag = false; - boolean flag1 = p_59322_.m_7983_(); - if (itemstack.m_41619_()) { + boolean flag1 = p_59322_.isEmpty(); + if (itemstack.isEmpty()) { + // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem -+ if (!itemstack.m_41619_() && itemstack.m_41613_() > p_59322_.m_6893_()) { -+ p_59323_ = itemstack.m_41620_(p_59322_.m_6893_()); ++ if (!itemstack.isEmpty() && itemstack.getCount() > p_59322_.getMaxStackSize()) { ++ p_59323_ = itemstack.split(p_59322_.getMaxStackSize()); + } + // Spigot end - p_59322_.m_6836_(p_59324_, p_59323_); - p_59323_ = ItemStack.f_41583_; + p_59322_.setItem(p_59324_, p_59323_); + p_59323_ = ItemStack.EMPTY; flag = true; @@ -283,7 +_,7 @@ } } -- hopperblockentity1.m_59395_(8 - k); -+ hopperblockentity1.m_59395_(hopperblockentity1.f_58857_.spigotConfig.hopperTransfer - k); // Spigot +- hopperblockentity1.setCooldown(8 - k); ++ hopperblockentity1.setCooldown(hopperblockentity1.level.spigotConfig.hopperTransfer - k); // Spigot } } @@ -320,6 +_,7 @@ - private static Container m_59347_(Level p_59348_, double p_59349_, double p_59350_, double p_59351_) { + private static Container getContainerAt(Level p_59348_, double p_59349_, double p_59350_, double p_59351_) { Container container = null; BlockPos blockpos = new BlockPos(p_59349_, p_59350_, p_59351_); -+ if ( !p_59348_.m_46805_( blockpos ) ) return null; // Spigot - BlockState blockstate = p_59348_.m_8055_(blockpos); - Block block = blockstate.m_60734_(); ++ if ( !p_59348_.hasChunkAt( blockpos ) ) return null; // Spigot + BlockState blockstate = p_59348_.getBlockState(blockpos); + Block block = blockstate.getBlock(); if (block instanceof WorldlyContainerHolder) { @@ -399,5 +_,14 @@ - protected AbstractContainerMenu m_6555_(int p_59312_, Inventory p_59313_) { + protected AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { return new HopperMenu(p_59312_, p_59313_, this); + } + @@ -258,6 +258,6 @@ + } + + public long getLastUpdateTime() { -+ return this.f_59303_; ++ return this.tickedGameTime; } } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index 25c6cde1..125014f0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -6,37 +6,37 @@ -public class LecternBlockEntity extends BlockEntity implements Clearable, MenuProvider { +public class LecternBlockEntity extends BlockEntity implements Clearable, MenuProvider, CommandSource { // CraftBukkit - CommandSource - public static final int f_155617_ = 0; - public static final int f_155618_ = 1; - public static final int f_155619_ = 0; - public static final int f_155620_ = 1; -- public final Container f_59525_ = new Container() { -+ public final Container f_59525_ = new LecternInventory(); + public static final int DATA_PAGE = 0; + public static final int NUM_DATA = 1; + public static final int SLOT_BOOK = 0; + public static final int NUM_SLOTS = 1; +- public final Container bookAccess = new Container() { ++ public final Container bookAccess = new LecternInventory(); + + public class LecternInventory implements Container { - public int m_6643_() { + public int getContainerSize() { return 1; } @@ -69,10 +_,18 @@ } - public void m_6836_(int p_59585_, ItemStack p_59586_) { + public void setItem(int p_59585_, ItemStack p_59586_) { + // CraftBukkit start + if (p_59585_ == 0) { -+ LecternBlockEntity.this.m_59536_(p_59586_); -+ if (LecternBlockEntity.this.m_58904_() != null) { -+ LecternBlock.m_54497_(LecternBlockEntity.this.m_58904_(), LecternBlockEntity.this.m_58899_(), LecternBlockEntity.this.m_58900_(), LecternBlockEntity.this.m_59567_()); ++ LecternBlockEntity.this.setBook(p_59586_); ++ if (LecternBlockEntity.this.getLevel() != null) { ++ LecternBlock.resetBookState(LecternBlockEntity.this.getLevel(), LecternBlockEntity.this.getBlockPos(), LecternBlockEntity.this.getBlockState(), LecternBlockEntity.this.hasBook()); + } + } + // CraftBukkit end } - public int m_6893_() { + public int getMaxStackSize() { - return 1; + return maxStack; // CraftBukkit } - public void m_6596_() { + public void setChanged() { @@ -91,9 +_,54 @@ return false; } @@ -47,7 +47,7 @@ + + @Override + public java.util.List getContents() { -+ return java.util.Arrays.asList(f_59527_); ++ return java.util.Arrays.asList(book); + } + + @Override @@ -77,7 +77,7 @@ + + @Override + public org.bukkit.Location getLocation() { -+ return new org.bukkit.Location(f_58857_.getWorld(), f_58858_.m_123341_(), f_58858_.m_123342_(), f_58858_.m_123343_()); ++ return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); + } + + public LecternBlockEntity getLectern() { @@ -85,20 +85,20 @@ + } + // CraftBukkit end + - public void m_6211_() { + public void clearContent() { } - }; + } + - private final ContainerData f_59526_ = new ContainerData() { - public int m_6413_(int p_59600_) { - return p_59600_ == 0 ? LecternBlockEntity.this.f_59528_ : 0; + private final ContainerData dataAccess = new ContainerData() { + public int get(int p_59600_) { + return p_59600_ == 0 ? LecternBlockEntity.this.page : 0; @@ -148,7 +_,7 @@ - if (i != this.f_59528_) { - this.f_59528_ = i; - this.m_6596_(); -- LecternBlock.m_54488_(this.m_58904_(), this.m_58899_(), this.m_58900_()); -+ if (this.f_58857_ != null) LecternBlock.m_54488_(this.m_58904_(), this.m_58899_(), this.m_58900_()); // CraftBukkit + if (i != this.page) { + this.page = i; + this.setChanged(); +- LecternBlock.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState()); ++ if (this.level != null) LecternBlock.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState()); // CraftBukkit } } @@ -108,39 +108,39 @@ + // CraftBukkit start + @Override -+ public void m_6352_(Component ichatbasecomponent, java.util.UUID uuid) { ++ public void sendMessage(Component ichatbasecomponent, java.util.UUID uuid) { + } + + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return wrapper.m_81373_() != null ? wrapper.m_81373_().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.v1_18_R2.command.CraftBlockCommandSender(wrapper, this); ++ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.v1_18_R2.command.CraftBlockCommandSender(wrapper, this); + } + + @Override -+ public boolean m_6999_() { ++ public boolean acceptsSuccess() { + return false; + } + + @Override -+ public boolean m_7028_() { ++ public boolean acceptsFailure() { + return false; + } + + @Override -+ public boolean m_6102_() { ++ public boolean shouldInformAdmins() { + return false; + } + // CraftBukkit end + - private CommandSourceStack m_59534_(@Nullable Player p_59535_) { + private CommandSourceStack createCommandSourceStack(@Nullable Player p_59535_) { String s; Component component; @@ -215,7 +_,7 @@ } - public AbstractContainerMenu m_7208_(int p_59562_, Inventory p_59563_, Player p_59564_) { -- return new LecternMenu(p_59562_, this.f_59525_, this.f_59526_); -+ return new LecternMenu(p_59562_, this.f_59525_, this.f_59526_, p_59563_); // CraftBukkit + public AbstractContainerMenu createMenu(int p_59562_, Inventory p_59563_, Player p_59564_) { +- return new LecternMenu(p_59562_, this.bookAccess, this.dataAccess); ++ return new LecternMenu(p_59562_, this.bookAccess, this.dataAccess, p_59563_); // CraftBukkit } - public Component m_5446_() { + public Component getDisplayName() { diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index ce431727..2d29d014 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java @@ -50,6 +_,37 @@ @Nullable - private final DyeColor f_59650_; + private final DyeColor color; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -10,7 +10,7 @@ + public boolean opened; + + public List getContents() { -+ return this.f_59645_; ++ return this.itemStacks; + } + + public void onOpen(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity who) { @@ -26,7 +26,7 @@ + } + + @Override -+ public int m_6893_() { ++ public int getMaxStackSize() { + return maxStack; + } + @@ -36,37 +36,37 @@ + // CraftBukkit end + public ShulkerBoxBlockEntity(@Nullable DyeColor p_155666_, BlockPos p_155667_, BlockState p_155668_) { - super(BlockEntityType.f_58939_, p_155667_, p_155668_); - this.f_59650_ = p_155666_; + super(BlockEntityType.SHULKER_BOX, p_155667_, p_155668_); + this.color = p_155666_; @@ -153,6 +_,7 @@ } - ++this.f_59646_; + ++this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.f_58857_.m_7696_(this.f_58858_, this.m_58900_().m_60734_(), 1, this.f_59646_); - if (this.f_59646_ == 1) { - this.f_58857_.m_142346_(p_59692_, GameEvent.f_157803_, this.f_58858_); + this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); + if (this.openCount == 1) { + this.level.gameEvent(p_59692_, GameEvent.CONTAINER_OPEN, this.worldPosition); @@ -165,6 +_,7 @@ - public void m_5785_(Player p_59688_) { - if (!p_59688_.m_5833_()) { - --this.f_59646_; + public void stopOpen(Player p_59688_) { + if (!p_59688_.isSpectator()) { + --this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.f_58857_.m_7696_(this.f_58858_, this.m_58900_().m_60734_(), 1, this.f_59646_); - if (this.f_59646_ <= 0) { - this.f_58857_.m_142346_(p_59688_, GameEvent.f_157802_, this.f_58858_); + this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); + if (this.openCount <= 0) { + this.level.gameEvent(p_59688_, GameEvent.CONTAINER_CLOSE, this.worldPosition); @@ -212,7 +_,7 @@ } - public boolean m_7155_(int p_59663_, ItemStack p_59664_, @Nullable Direction p_59665_) { -- return !(Block.m_49814_(p_59664_.m_41720_()) instanceof ShulkerBoxBlock); -+ return !(Block.m_49814_(p_59664_.m_41720_()) instanceof ShulkerBoxBlock) && p_59664_.m_41720_().m_142095_(); // FORGE: Make shulker boxes respect Item#canFitInsideContainerItems + public boolean canPlaceItemThroughFace(int p_59663_, ItemStack p_59664_, @Nullable Direction p_59665_) { +- return !(Block.byItem(p_59664_.getItem()) instanceof ShulkerBoxBlock); ++ return !(Block.byItem(p_59664_.getItem()) instanceof ShulkerBoxBlock) && p_59664_.getItem().canFitInsideContainerItems(); // FORGE: Make shulker boxes respect Item#canFitInsideContainerItems } - public boolean m_7157_(int p_59682_, ItemStack p_59683_, Direction p_59684_) { + public boolean canTakeItemThroughFace(int p_59682_, ItemStack p_59683_, Direction p_59684_) { @@ -234,6 +_,11 @@ - public boolean m_59702_() { - return this.f_59647_ == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; + public boolean isClosed() { + return this.animationStatus == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 47dac8d2..77ba5be6 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -6,47 +6,47 @@ -public class SignBlockEntity extends BlockEntity { +public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements - public static final int f_155692_ = 4; - private static final String[] f_155693_ = new String[]{"Text1", "Text2", "Text3", "Text4"}; - private static final String[] f_155694_ = new String[]{"FilteredText1", "FilteredText2", "FilteredText3", "FilteredText4"}; + public static final int LINES = 4; + private static final String[] RAW_TEXT_FIELD_NAMES = new String[]{"Text1", "Text2", "Text3", "Text4"}; + private static final String[] FILTERED_TEXT_FIELD_NAMES = new String[]{"FilteredText1", "FilteredText2", "FilteredText3", "FilteredText4"}; @@ -55,6 +_,12 @@ } } + // CraftBukkit start + if (Boolean.getBoolean("convertLegacySigns")) { -+ p_187515_.m_128379_("Bukkit.isConverted", true); ++ p_187515_.putBoolean("Bukkit.isConverted", true); + } + // CraftBukkit end + - p_187515_.m_128359_("Color", this.f_59724_.m_41065_()); - p_187515_.m_128379_("GlowingText", this.f_155697_); + p_187515_.putString("Color", this.color.getName()); + p_187515_.putBoolean("GlowingText", this.hasGlowingText); } @@ -64,8 +_,24 @@ - super.m_142466_(p_155716_); - this.f_59724_ = DyeColor.m_41057_(p_155716_.m_128461_("Color"), DyeColor.BLACK); + super.load(p_155716_); + this.color = DyeColor.byName(p_155716_.getString("Color"), DyeColor.BLACK); + // CraftBukkit start - Add an option to convert signs correctly + // This is done with a flag instead of all the time because + // we have no way to tell whether a sign is from 1.7.10 or 1.8 -+ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !p_155716_.m_128471_("Bukkit.isConverted"); ++ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !p_155716_.getBoolean("Bukkit.isConverted"); + // CraftBukkit end + for(int i = 0; i < 4; ++i) { - String s = p_155716_.m_128461_(f_155693_[i]); + String s = p_155716_.getString(RAW_TEXT_FIELD_NAMES[i]); + // CraftBukkit start + if (s != null && s.length() > 2048) { + s = "\"\""; + } + + if (oldSign) { -+ f_59720_[i] = org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(s)[0]; ++ messages[i] = org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromString(s)[0]; + continue; + } + // CraftBukkit end - Component component = this.m_155711_(s); - this.f_59720_[i] = component; - String s1 = f_155694_[i]; + Component component = this.loadLine(s); + this.messages[i] = component; + String s1 = FILTERED_TEXT_FIELD_NAMES[i]; @@ -98,6 +_,10 @@ if (component != null) { return component; @@ -64,43 +64,43 @@ + // CraftBukkit start + @Override -+ public void m_6352_(Component component, java.util.UUID uuid) {} ++ public void sendMessage(Component component, java.util.UUID uuid) {} + + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return wrapper.m_81373_() != null ? wrapper.m_81373_().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.v1_18_R2.command.CraftBlockCommandSender(wrapper, this); ++ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.v1_18_R2.command.CraftBlockCommandSender(wrapper, this); + } + + @Override -+ public boolean m_6999_() { ++ public boolean acceptsSuccess() { + return false; + } + + @Override -+ public boolean m_7028_() { ++ public boolean acceptsFailure() { + return false; + } + + @Override -+ public boolean m_6102_() { ++ public boolean shouldInformAdmins() { + return false; + } + // CraftBukkit end + - public CommandSourceStack m_59735_(@Nullable ServerPlayer p_59736_) { - String s = p_59736_ == null ? "Sign" : p_59736_.m_7755_().getString(); - Component component = (Component)(p_59736_ == null ? new TextComponent("Sign") : p_59736_.m_5446_()); -- return new CommandSourceStack(CommandSource.f_80164_, Vec3.m_82512_(this.f_58858_), Vec2.f_82462_, (ServerLevel)this.f_58857_, 2, s, component, this.f_58857_.m_142572_(), p_59736_); + public CommandSourceStack createCommandSourceStack(@Nullable ServerPlayer p_59736_) { + String s = p_59736_ == null ? "Sign" : p_59736_.getName().getString(); + Component component = (Component)(p_59736_ == null ? new TextComponent("Sign") : p_59736_.getDisplayName()); +- return new CommandSourceStack(CommandSource.NULL, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel)this.level, 2, s, component, this.level.getServer(), p_59736_); + // CraftBukkit - this -+ return new CommandSourceStack(this, Vec3.m_82512_(this.f_58858_), Vec2.f_82462_, (ServerLevel) this.f_58857_, 2, s, (Component) component, this.f_58857_.m_142572_(), p_59736_); ++ return new CommandSourceStack(this, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) component, this.level.getServer(), p_59736_); } - public DyeColor m_59753_() { + public DyeColor getColor() { @@ -216,6 +_,6 @@ - private void m_155728_() { - this.m_6596_(); -- this.f_58857_.m_7260_(this.m_58899_(), this.m_58900_(), this.m_58900_(), 3); -+ if (this.f_58857_ != null) this.f_58857_.m_7260_(this.m_58899_(), this.m_58900_(), this.m_58900_(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122) + private void markUpdated() { + this.setChanged(); +- this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); ++ if (this.level != null) this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122) } } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch index bcb142f1..1ac585c5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java @@ -181,6 +_,24 @@ - entity = p_155832_.m_20201_(); + entity = p_155832_.getRootVehicle(); } + // CraftBukkit start - Fire PlayerTeleportEvent + if (entity instanceof ServerPlayer) { + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer player = (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) entity.getBukkitEntity(); -+ org.bukkit.Location location = new org.bukkit.Location(p_155829_.getWorld(), (double) blockpos1.m_123341_() + 0.5D, (double) blockpos1.m_123342_() + 0.5D, (double) blockpos1.m_123343_() + 0.5D); ++ org.bukkit.Location location = new org.bukkit.Location(p_155829_.getWorld(), (double) blockpos1.getX() + 0.5D, (double) blockpos1.getY() + 0.5D, (double) blockpos1.getZ() + 0.5D); + location.setPitch(player.getLocation().getPitch()); + location.setYaw(player.getLocation().getYaw()); + org.bukkit.event.player.PlayerTeleportEvent teleEvent = new org.bukkit.event.player.PlayerTeleportEvent(player, player.getLocation(), location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_GATEWAY); @@ -15,13 +15,13 @@ + if (teleEvent.isCancelled()) { + return; + } -+ entity.m_20091_(); -+ ((ServerPlayer) entity).f_8906_.teleport(teleEvent.getTo()); -+ m_155849_(p_155829_, p_155830_, p_155831_, p_155833_); // CraftBukkit - call at end of method ++ entity.setPortalCooldown(); ++ ((ServerPlayer) entity).connection.teleport(teleEvent.getTo()); ++ triggerCooldown(p_155829_, p_155830_, p_155831_, p_155833_); // CraftBukkit - call at end of method + return; + } + // CraftBukkit end + - entity.m_20091_(); - entity.m_20324_((double)blockpos1.m_123341_() + 0.5D, (double)blockpos1.m_123342_(), (double)blockpos1.m_123343_() + 0.5D); + entity.setPortalCooldown(); + entity.teleportToWithTicket((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY(), (double)blockpos1.getZ() + 0.5D); } diff --git a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch index de45eadd..784592c5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch @@ -2,16 +2,16 @@ +++ b/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java @@ -30,10 +_,12 @@ - public boolean m_59990_(ServerLevel p_59991_, ChunkGenerator p_59992_, BlockPos p_59993_, BlockState p_59994_, Random p_59995_, int p_59996_, int p_59997_) { - Holder> holder = this.m_203620_(p_59995_); + public boolean placeMega(ServerLevel p_59991_, ChunkGenerator p_59992_, BlockPos p_59993_, BlockState p_59994_, Random p_59995_, int p_59996_, int p_59997_) { + Holder> holder = this.getConfiguredMegaFeature(p_59995_); - if (holder == null) { + net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_59991_, p_59995_, p_59993_, holder); + if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || holder == null) { return false; } else { -- ConfiguredFeature configuredfeature = holder.m_203334_(); +- ConfiguredFeature configuredfeature = holder.value(); + setTreeType(holder); // CraftBukkit -+ ConfiguredFeature configuredfeature = event.getFeature().m_203334_(); - BlockState blockstate = Blocks.f_50016_.m_49966_(); - p_59991_.m_7731_(p_59993_.m_142082_(p_59996_, 0, p_59997_), blockstate, 4); - p_59991_.m_7731_(p_59993_.m_142082_(p_59996_ + 1, 0, p_59997_), blockstate, 4); ++ ConfiguredFeature configuredfeature = event.getFeature().value(); + BlockState blockstate = Blocks.AIR.defaultBlockState(); + p_59991_.setBlock(p_59993_.offset(p_59996_, 0, p_59997_), blockstate, 4); + p_59991_.setBlock(p_59993_.offset(p_59996_ + 1, 0, p_59997_), blockstate, 4); diff --git a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch index 44e1425c..9002798b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch @@ -2,18 +2,18 @@ +++ b/net/minecraft/world/level/block/grower/AbstractTreeGrower.java @@ -18,10 +_,12 @@ - public boolean m_6334_(ServerLevel p_60006_, ChunkGenerator p_60007_, BlockPos p_60008_, BlockState p_60009_, Random p_60010_) { - Holder> holder = this.m_203525_(p_60010_, this.m_60011_(p_60006_, p_60008_)); + public boolean growTree(ServerLevel p_60006_, ChunkGenerator p_60007_, BlockPos p_60008_, BlockState p_60009_, Random p_60010_) { + Holder> holder = this.getConfiguredFeature(p_60010_, this.hasFlowers(p_60006_, p_60008_)); - if (holder == null) { + net.minecraftforge.event.world.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_60006_, p_60010_, p_60008_, holder); + if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || holder == null) { return false; } else { -- ConfiguredFeature configuredfeature = holder.m_203334_(); +- ConfiguredFeature configuredfeature = holder.value(); + setTreeType(holder); // CraftBukkit -+ ConfiguredFeature configuredfeature = event.getFeature().m_203334_(); - p_60006_.m_7731_(p_60008_, Blocks.f_50016_.m_49966_(), 4); - if (configuredfeature.m_65385_(p_60006_, p_60007_, p_60010_, p_60008_)) { ++ ConfiguredFeature configuredfeature = event.getFeature().value(); + p_60006_.setBlock(p_60008_, Blocks.AIR.defaultBlockState(), 4); + if (configuredfeature.place(p_60006_, p_60007_, p_60010_, p_60008_)) { return true; @@ -41,4 +_,48 @@ @@ -22,41 +22,41 @@ + + // CraftBukkit start + protected void setTreeType(Holder> worldgentreeabstract) { -+ if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195123_ || worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195142_) { ++ if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.OAK || worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.OAK_BEES_005) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TREE; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195122_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.HUGE_RED_MUSHROOM) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.RED_MUSHROOM; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195121_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.HUGE_BROWN_MUSHROOM) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BROWN_MUSHROOM; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195129_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.JUNGLE_TREE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.COCOA_TREE; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195131_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.JUNGLE_TREE_NO_VINE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.SMALL_JUNGLE; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195128_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.PINE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_REDWOOD; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195127_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.SPRUCE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.REDWOOD; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195126_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.ACACIA) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.ACACIA; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195125_ || worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195108_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.BIRCH || worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.BIRCH_BEES_005) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BIRCH; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195135_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.SUPER_BIRCH_BEES_0002) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_BIRCH; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195137_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.SWAMP_OAK) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.SWAMP; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195130_ || worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195111_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.FANCY_OAK || worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.FANCY_OAK_BEES_005) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BIG_TREE; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195138_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.JUNGLE_BUSH) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.JUNGLE_BUSH; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195124_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.DARK_OAK) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.DARK_OAK; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195133_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.MEGA_SPRUCE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195134_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.MEGA_PINE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195132_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.MEGA_JUNGLE_TREE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.JUNGLE; -+ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.f_195139_) { ++ } else if (worldgentreeabstract == net.minecraft.data.worldgen.features.TreeFeatures.AZALEA_TREE) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.AZALEA; + } else { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MODDED; //Magma - default to modded 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 55f9a350..996bdeee 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 @@ -5,8 +5,8 @@ } + // CraftBukkit start -+ if (!this.f_60160_) { -+ org.bukkit.block.Block block = p_60168_.getWorld().getBlockAt(p_60169_.m_123341_(), p_60169_.m_123342_(), p_60169_.m_123343_()); ++ if (!this.isSticky) { ++ org.bukkit.block.Block block = p_60168_.getWorld().getBlockAt(p_60169_.getX(), p_60169_.getY(), p_60169_.getZ()); + org.bukkit.event.block.BlockPistonRetractEvent event = new org.bukkit.event.block.BlockPistonRetractEvent(block, com.google.common.collect.ImmutableList.of(), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.notchToBlockFace(direction)); + p_60168_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { @@ -16,7 +16,7 @@ + // PAIL: checkME - what happened to setTypeAndData? + // CraftBukkit end + - p_60168_.m_7696_(p_60169_, this, i, direction.m_122411_()); + p_60168_.blockEvent(p_60169_, this, i, direction.get3DDataValue()); } @@ -168,6 +_,7 @@ @@ -24,19 +24,19 @@ if (p_60195_ == 0) { + if (net.minecraftforge.event.ForgeEventFactory.onPistonMovePre(p_60193_, p_60194_, direction, true)) return false; - if (!this.m_60181_(p_60193_, p_60194_, direction, true)) { + if (!this.moveBlocks(p_60193_, p_60194_, direction, true)) { return false; } @@ -176,6 +_,7 @@ - p_60193_.m_5594_((Player)null, p_60194_, SoundEvents.f_12312_, SoundSource.BLOCKS, 0.5F, p_60193_.f_46441_.nextFloat() * 0.25F + 0.6F); - p_60193_.m_151555_(GameEvent.f_157775_, p_60194_); + p_60193_.playSound((Player)null, p_60194_, SoundEvents.PISTON_EXTEND, SoundSource.BLOCKS, 0.5F, p_60193_.random.nextFloat() * 0.25F + 0.6F); + p_60193_.gameEvent(GameEvent.PISTON_EXTEND, p_60194_); } else if (p_60195_ == 1 || p_60195_ == 2) { + if (net.minecraftforge.event.ForgeEventFactory.onPistonMovePre(p_60193_, p_60194_, direction, false)) return false; - BlockEntity blockentity1 = p_60193_.m_7702_(p_60194_.m_142300_(direction)); + BlockEntity blockentity1 = p_60193_.getBlockEntity(p_60194_.relative(direction)); if (blockentity1 instanceof PistonMovingBlockEntity) { - ((PistonMovingBlockEntity)blockentity1).m_60401_(); + ((PistonMovingBlockEntity)blockentity1).finalTick(); @@ -216,6 +_,7 @@ - p_60193_.m_151555_(GameEvent.f_157774_, p_60194_); + p_60193_.gameEvent(GameEvent.PISTON_CONTRACT, p_60194_); } + net.minecraftforge.event.ForgeEventFactory.onPistonMovePost(p_60193_, p_60194_, direction, (p_60195_ == 0)); @@ -44,13 +44,13 @@ } @@ -282,6 +_,44 @@ - Direction direction = p_60185_ ? p_60184_ : p_60184_.m_122424_(); + Direction direction = p_60185_ ? p_60184_ : p_60184_.getOpposite(); int j = 0; + // CraftBukkit start -+ final org.bukkit.block.Block bblock = p_60182_.getWorld().getBlockAt(blockpos.m_123341_(), blockpos.m_123342_(), blockpos.m_123343_()); -+ final List moved = pistonstructureresolver.m_60436_(); -+ final List broken = pistonstructureresolver.m_60437_(); ++ final org.bukkit.block.Block bblock = p_60182_.getWorld().getBlockAt(blockpos.getX(), blockpos.getY(), blockpos.getZ()); ++ final List moved = pistonstructureresolver.getToPush(); ++ final List broken = pistonstructureresolver.getToDestroy(); + List blocks = new java.util.AbstractList() { + @Override + public int size() { @@ -62,7 +62,7 @@ + throw new ArrayIndexOutOfBoundsException(index); + } + BlockPos pos = (BlockPos) (index < moved.size() ? moved.get(index) : broken.get(index - moved.size())); -+ return bblock.getWorld().getBlockAt(pos.m_123341_(), pos.m_123342_(), pos.m_123343_()); ++ return bblock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); + } + }; + org.bukkit.event.block.BlockPistonEvent event; @@ -74,12 +74,12 @@ + p_60182_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + for (BlockPos b : broken) { -+ p_60182_.m_7260_(b, Blocks.f_50016_.m_49966_(), p_60182_.m_8055_(b), 3); ++ p_60182_.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), p_60182_.getBlockState(b), 3); + } + for (BlockPos b : moved) { -+ p_60182_.m_7260_(b, Blocks.f_50016_.m_49966_(), p_60182_.m_8055_(b), 3); -+ b = b.m_142300_(direction); -+ p_60182_.m_7260_(b, Blocks.f_50016_.m_49966_(), p_60182_.m_8055_(b), 3); ++ p_60182_.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), p_60182_.getBlockState(b), 3); ++ b = b.relative(direction); ++ p_60182_.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), p_60182_.getBlockState(b), 3); + } + return false; + } @@ -87,15 +87,15 @@ + for(int k = list2.size() - 1; k >= 0; --k) { BlockPos blockpos2 = list2.get(k); - BlockState blockstate1 = p_60182_.m_8055_(blockpos2); + BlockState blockstate1 = p_60182_.getBlockState(blockpos2); @@ -352,6 +_,10 @@ - public BlockState m_6843_(BlockState p_60215_, Rotation p_60216_) { - return p_60215_.m_61124_(f_52588_, p_60216_.m_55954_(p_60215_.m_61143_(f_52588_))); + public BlockState rotate(BlockState p_60215_, Rotation p_60216_) { + return p_60215_.setValue(FACING, p_60216_.rotate(p_60215_.getValue(FACING))); + } + + public BlockState rotate(BlockState state, net.minecraft.world.level.LevelAccessor world, BlockPos pos, Rotation direction) { -+ return state.m_61143_(f_60153_) ? state : super.rotate(state, world, pos, direction); ++ return state.getValue(EXTENDED) ? state : super.rotate(state, world, pos, direction); } - public BlockState m_6943_(BlockState p_60212_, Mirror p_60213_) { + public BlockState mirror(BlockState p_60212_, Mirror p_60213_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonHeadBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonHeadBlock.java.patch index f3fadab8..90a26255 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonHeadBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonHeadBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/piston/PistonHeadBlock.java @@ -131,6 +_,11 @@ - public void m_6861_(BlockState p_60275_, Level p_60276_, BlockPos p_60277_, Block p_60278_, BlockPos p_60279_, boolean p_60280_) { - if (p_60275_.m_60710_(p_60276_, p_60277_)) { + public void neighborChanged(BlockState p_60275_, Level p_60276_, BlockPos p_60277_, Block p_60278_, BlockPos p_60279_, boolean p_60280_) { + if (p_60275_.canSurvive(p_60276_, p_60277_)) { + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) { -+ p_60276_.m_46586_(p_60277_.m_142300_(p_60275_.m_61143_(f_52588_).m_122424_()), p_60278_, p_60279_); ++ p_60276_.neighborChanged(p_60277_.relative(p_60275_.getValue(FACING).getOpposite()), p_60278_, p_60279_); + return; + } + - BlockPos blockpos = p_60277_.m_142300_(p_60275_.m_61143_(f_52588_).m_122424_()); - p_60276_.m_8055_(blockpos).m_60690_(p_60276_, blockpos, p_60278_, p_60279_, false); + BlockPos blockpos = p_60277_.relative(p_60275_.getValue(FACING).getOpposite()); + p_60276_.getBlockState(blockpos).neighborChanged(p_60276_, blockpos, p_60278_, p_60279_, false); } 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 d07ada5c..6df84157 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,11 +1,11 @@ --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java @@ -106,7 +_,7 @@ - List list = p_155911_.m_45933_((Entity)null, PistonMath.m_60328_(aabb, direction, d0).m_82367_(aabb)); + List list = p_155911_.getEntities((Entity)null, PistonMath.getMovementArea(aabb, direction, d0).minmax(aabb)); if (!list.isEmpty()) { - List list1 = voxelshape.m_83299_(); -- boolean flag = p_155914_.f_60334_.m_60713_(Blocks.f_50374_); -+ boolean flag = p_155914_.f_60334_.isSlimeBlock(); //TODO: is this patch really needed the logic of the original seems sound revisit later + List list1 = voxelshape.toAabbs(); +- boolean flag = p_155914_.movedState.is(Blocks.SLIME_BLOCK); ++ boolean flag = p_155914_.movedState.isSlimeBlock(); //TODO: is this patch really needed the logic of the original seems sound revisit later Iterator iterator = list.iterator(); while(true) { diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch index cbc96d42..884d8f02 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonStructureResolver.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/level/block/piston/PistonStructureResolver.java @@ -51,7 +_,7 @@ } else { - for(int i = 0; i < this.f_60414_.size(); ++i) { - BlockPos blockpos = this.f_60414_.get(i); -- if (m_155937_(this.f_60409_.m_8055_(blockpos)) && !this.m_60431_(blockpos)) { -+ if (this.f_60409_.m_8055_(blockpos).isStickyBlock() && !this.m_60431_(blockpos)) { + for(int i = 0; i < this.toPush.size(); ++i) { + BlockPos blockpos = this.toPush.get(i); +- if (isSticky(this.level.getBlockState(blockpos)) && !this.addBranchingBlocks(blockpos)) { ++ if (this.level.getBlockState(blockpos).isStickyBlock() && !this.addBranchingBlocks(blockpos)) { return false; } } @@ -13,58 +13,58 @@ } } -- private static boolean m_155937_(BlockState p_155938_) { -- return p_155938_.m_60713_(Blocks.f_50374_) || p_155938_.m_60713_(Blocks.f_50719_); +- private static boolean isSticky(BlockState p_155938_) { +- return p_155938_.is(Blocks.SLIME_BLOCK) || p_155938_.is(Blocks.HONEY_BLOCK); - } - -- private static boolean m_155939_(BlockState p_155940_, BlockState p_155941_) { -- if (p_155940_.m_60713_(Blocks.f_50719_) && p_155941_.m_60713_(Blocks.f_50374_)) { +- private static boolean canStickToEachOther(BlockState p_155940_, BlockState p_155941_) { +- if (p_155940_.is(Blocks.HONEY_BLOCK) && p_155941_.is(Blocks.SLIME_BLOCK)) { - return false; -- } else if (p_155940_.m_60713_(Blocks.f_50374_) && p_155941_.m_60713_(Blocks.f_50719_)) { +- } else if (p_155940_.is(Blocks.SLIME_BLOCK) && p_155941_.is(Blocks.HONEY_BLOCK)) { - return false; - } else { -- return m_155937_(p_155940_) || m_155937_(p_155941_); +- return isSticky(p_155940_) || isSticky(p_155941_); - } - } - - private boolean m_60433_(BlockPos p_60434_, Direction p_60435_) { - BlockState blockstate = this.f_60409_.m_8055_(p_60434_); -- if (blockstate.m_60795_()) { -+ if (f_60409_.m_46859_(p_60434_)) { + private boolean addBlockLine(BlockPos p_60434_, Direction p_60435_) { + BlockState blockstate = this.level.getBlockState(p_60434_); +- if (blockstate.isAir()) { ++ if (level.isEmptyBlock(p_60434_)) { return true; - } else if (!PistonBaseBlock.m_60204_(blockstate, this.f_60409_, p_60434_, this.f_60413_, false, p_60435_)) { + } else if (!PistonBaseBlock.isPushable(blockstate, this.level, p_60434_, this.pushDirection, false, p_60435_)) { return true; @@ -89,11 +_,12 @@ - if (i + this.f_60414_.size() > 12) { + if (i + this.toPush.size() > 12) { return false; } else { -- while(m_155937_(blockstate)) { +- while(isSticky(blockstate)) { + BlockState oldState; + while(blockstate.isStickyBlock()) { - BlockPos blockpos = p_60434_.m_5484_(this.f_60413_.m_122424_(), i); + BlockPos blockpos = p_60434_.relative(this.pushDirection.getOpposite(), i); - BlockState blockstate1 = blockstate; + oldState = blockstate; - blockstate = this.f_60409_.m_8055_(blockpos); -- if (blockstate.m_60795_() || !m_155939_(blockstate1, blockstate) || !PistonBaseBlock.m_60204_(blockstate, this.f_60409_, blockpos, this.f_60413_, false, this.f_60413_.m_122424_()) || blockpos.equals(this.f_60410_)) { -+ if (blockstate.m_60795_() || !oldState.canStickTo(blockstate) || !PistonBaseBlock.m_60204_(blockstate, this.f_60409_, blockpos, this.f_60413_, false, this.f_60413_.m_122424_()) || blockpos.equals(this.f_60410_)) { + blockstate = this.level.getBlockState(blockpos); +- if (blockstate.isAir() || !canStickToEachOther(blockstate1, blockstate) || !PistonBaseBlock.isPushable(blockstate, this.level, blockpos, this.pushDirection, false, this.pushDirection.getOpposite()) || blockpos.equals(this.pistonPos)) { ++ if (blockstate.isAir() || !oldState.canStickTo(blockstate) || !PistonBaseBlock.isPushable(blockstate, this.level, blockpos, this.pushDirection, false, this.pushDirection.getOpposite()) || blockpos.equals(this.pistonPos)) { break; } @@ -120,7 +_,7 @@ for(int k = 0; k <= j + l; ++k) { - BlockPos blockpos2 = this.f_60414_.get(k); -- if (m_155937_(this.f_60409_.m_8055_(blockpos2)) && !this.m_60431_(blockpos2)) { -+ if (this.f_60409_.m_8055_(blockpos2).isStickyBlock() && !this.m_60431_(blockpos2)) { + BlockPos blockpos2 = this.toPush.get(k); +- if (isSticky(this.level.getBlockState(blockpos2)) && !this.addBranchingBlocks(blockpos2)) { ++ if (this.level.getBlockState(blockpos2).isStickyBlock() && !this.addBranchingBlocks(blockpos2)) { return false; } } @@ -174,7 +_,7 @@ - if (direction.m_122434_() != this.f_60413_.m_122434_()) { - BlockPos blockpos = p_60432_.m_142300_(direction); - BlockState blockstate1 = this.f_60409_.m_8055_(blockpos); -- if (m_155939_(blockstate1, blockstate) && !this.m_60433_(blockpos, direction)) { -+ if (blockstate1.canStickTo(blockstate) && !this.m_60433_(blockpos, direction)) { + if (direction.getAxis() != this.pushDirection.getAxis()) { + BlockPos blockpos = p_60432_.relative(direction); + BlockState blockstate1 = this.level.getBlockState(blockpos); +- if (canStickToEachOther(blockstate1, blockstate) && !this.addBlockLine(blockpos, direction)) { ++ if (blockstate1.canStickTo(blockstate) && !this.addBlockLine(blockpos, direction)) { return false; } } 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 5e9ca390..ae6d2e69 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 @@ -8,40 +8,40 @@ + +//TODO, Delegates are weird here now, because Block extends this. +public abstract class BlockBehaviour extends net.minecraftforge.registries.ForgeRegistryEntry { - protected static final Direction[] f_60441_ = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; - protected final Material f_60442_; - protected final boolean f_60443_; + protected static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; + protected final Material material; + protected final boolean hasCollision; @@ -93,6 +_,8 @@ - this.f_60449_ = p_60452_.f_60893_; - this.f_60438_ = p_60452_.f_60903_; - this.f_60439_ = p_60452_; -+ final ResourceLocation lootTableCache = p_60452_.f_60894_; -+ this.lootTableSupplier = lootTableCache != null ? () -> lootTableCache : p_60452_.lootTableSupplier != null ? p_60452_.lootTableSupplier : () -> new ResourceLocation(this.getRegistryName().m_135827_(), "blocks/" + this.getRegistryName().m_135815_()); + this.jumpFactor = p_60452_.jumpFactor; + this.dynamicShape = p_60452_.dynamicShape; + this.properties = p_60452_; ++ final ResourceLocation lootTableCache = p_60452_.drops; ++ this.lootTableSupplier = lootTableCache != null ? () -> lootTableCache : p_60452_.lootTableSupplier != null ? p_60452_.lootTableSupplier : () -> new ResourceLocation(this.getRegistryName().getNamespace(), "blocks/" + this.getRegistryName().getPath()); } /** @deprecated */ @@ -136,12 +_,14 @@ /** @deprecated */ @Deprecated - public void m_6807_(BlockState p_60566_, Level p_60567_, BlockPos p_60568_, BlockState p_60569_, boolean p_60570_) { + public void onPlace(BlockState p_60566_, Level p_60567_, BlockPos p_60568_, BlockState p_60569_, boolean p_60570_) { + org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot } /** @deprecated */ @Deprecated - public void m_6810_(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { -- if (p_60515_.m_155947_() && !p_60515_.m_60713_(p_60518_.m_60734_())) { + public void onRemove(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { +- if (p_60515_.hasBlockEntity() && !p_60515_.is(p_60518_.getBlock())) { + org.spigotmc.AsyncCatcher.catchOp("block remove"); // Spigot -+ if (p_60515_.m_155947_() && (!p_60515_.m_60713_(p_60518_.m_60734_()) || !p_60518_.m_155947_())) { - p_60516_.m_46747_(p_60517_); ++ if (p_60515_.hasBlockEntity() && (!p_60515_.is(p_60518_.getBlock()) || !p_60518_.hasBlockEntity())) { + p_60516_.removeBlockEntity(p_60517_); } @@ -222,7 +_,7 @@ /** @deprecated */ @Deprecated - public boolean m_6864_(BlockState p_60470_, BlockPlaceContext p_60471_) { -- return this.f_60442_.m_76336_() && (p_60471_.m_43722_().m_41619_() || !p_60471_.m_43722_().m_150930_(this.m_5456_())); -+ return p_60470_.m_60767_().m_76336_() && (p_60471_.m_43722_().m_41619_() || p_60471_.m_43722_().m_41720_() != this.m_5456_()); + public boolean canBeReplaced(BlockState p_60470_, BlockPlaceContext p_60471_) { +- return this.material.isReplaceable() && (p_60471_.getItemInHand().isEmpty() || !p_60471_.getItemInHand().is(this.asItem())); ++ return p_60470_.getMaterial().isReplaceable() && (p_60471_.getItemInHand().isEmpty() || p_60471_.getItemInHand().getItem() != this.asItem()); } /** @deprecated */ @@ -49,8 +49,8 @@ if (f == -1.0F) { return 0.0F; } else { -- int i = p_60467_.m_36298_(p_60466_) ? 30 : 100; -- return p_60467_.m_36281_(p_60466_) / f / (float)i; +- int i = p_60467_.hasCorrectToolForDrops(p_60466_) ? 30 : 100; +- return p_60467_.getDestroySpeed(p_60466_) / f / (float)i; + int i = net.minecraftforge.common.ForgeHooks.isCorrectToolForDrops(p_60466_, p_60467_) ? 30 : 100; + return p_60467_.getDigSpeed(p_60466_, p_60469_) / f / (float)i; } @@ -58,20 +58,20 @@ @@ -380,8 +_,7 @@ - public final ResourceLocation m_60589_() { - if (this.f_60440_ == null) { -- ResourceLocation resourcelocation = Registry.f_122824_.m_7981_(this.m_7374_()); -- this.f_60440_ = new ResourceLocation(resourcelocation.m_135827_(), "blocks/" + resourcelocation.m_135815_()); -+ this.f_60440_ = this.lootTableSupplier.get(); + public final ResourceLocation getLootTable() { + if (this.drops == null) { +- ResourceLocation resourcelocation = Registry.BLOCK.getKey(this.asBlock()); +- this.drops = new ResourceLocation(resourcelocation.getNamespace(), "blocks/" + resourcelocation.getPath()); ++ this.drops = this.lootTableSupplier.get(); } - return this.f_60440_; + return this.drops; @@ -404,6 +_,14 @@ - return this.f_60439_.f_60888_; + return this.properties.destroyTime; } + protected boolean isAir(BlockState state) { -+ return ((BlockStateBase)state).f_60596_; ++ return ((BlockStateBase)state).isAir; + } + + /* ======================================== FORGE START ===================================== */ @@ -79,41 +79,41 @@ + /* ========================================= FORGE END ====================================== */ + public abstract static class BlockStateBase extends StateHolder { - private final int f_60594_; - private final boolean f_60595_; + private final int lightEmission; + private final boolean useShapeForLightOcclusion; @@ -482,18 +_,22 @@ - return this.f_60595_; + return this.useShapeForLightOcclusion; } + /** @deprecated use {@link BlockState#getLightEmission(BlockGetter, BlockPos)} */ + @Deprecated - public int m_60791_() { - return this.f_60594_; + public int getLightEmission() { + return this.lightEmission; } - public boolean m_60795_() { -- return this.f_60596_; -+ return this.m_60734_().isAir((BlockState)this); + public boolean isAir() { +- return this.isAir; ++ return this.getBlock().isAir((BlockState)this); } - public MaterialColor m_60780_(BlockGetter p_60781_, BlockPos p_60782_) { -- return this.f_60598_; -+ return m_60734_().getMapColor(this.m_7160_(), p_60781_, p_60782_, this.f_60598_); + public MaterialColor getMapColor(BlockGetter p_60781_, BlockPos p_60782_) { +- return this.materialColor; ++ return getBlock().getMapColor(this.asState(), p_60781_, p_60782_, this.materialColor); } + /** @deprecated use {@link BlockState#rotate(LevelAccessor, BlockPos, Rotation)} */ + @Deprecated - public BlockState m_60717_(Rotation p_60718_) { - return this.m_60734_().m_6843_(this.m_7160_(), p_60718_); + public BlockState rotate(Rotation p_60718_) { + return this.getBlock().rotate(this.asState(), p_60718_); } @@ -623,6 +_,17 @@ } - public void m_60690_(Level p_60691_, BlockPos p_60692_, Block p_60693_, BlockPos p_60694_, boolean p_60695_) { + public void neighborChanged(Level p_60691_, BlockPos p_60692_, Block p_60693_, BlockPos p_60694_, boolean p_60695_) { + // CraftBukkit start + org.bukkit.craftbukkit.v1_18_R2.CraftWorld world = ((ServerLevel) p_60691_).getWorld(); + if (world != null) { -+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( world.getBlockAt( p_60692_.m_123341_(), p_60692_.m_123342_(), p_60692_.m_123343_() ), org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData( p_60691_.m_8055_(p_60692_)), world.getBlockAt( p_60694_.m_123341_(), p_60694_.m_123342_(), p_60694_.m_123343_() ) ); ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( world.getBlockAt( p_60692_.getX(), p_60692_.getY(), p_60692_.getZ() ), org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData.fromData( p_60691_.getBlockState(p_60692_)), world.getBlockAt( p_60694_.getX(), p_60694_.getY(), p_60694_.getZ() ) ); + p_60691_.getCraftServer().getPluginManager().callEvent( event ); + + if (event.isCancelled()) { @@ -121,52 +121,52 @@ + } + } + // CraftBukkit end - this.m_60734_().m_6861_(this.m_7160_(), p_60691_, p_60692_, p_60693_, p_60694_, p_60695_); + this.getBlock().neighborChanged(this.asState(), p_60691_, p_60692_, p_60693_, p_60694_, p_60695_); } @@ -636,9 +_,14 @@ - for(Direction direction : BlockBehaviour.f_60441_) { - blockpos$mutableblockpos.m_122159_(p_60707_, direction); -- BlockState blockstate = p_60706_.m_8055_(blockpos$mutableblockpos); -- BlockState blockstate1 = blockstate.m_60728_(direction.m_122424_(), this.m_7160_(), p_60706_, blockpos$mutableblockpos, p_60707_); -- Block.m_49908_(blockstate, blockstate1, p_60706_, blockpos$mutableblockpos, p_60708_, p_60709_); + for(Direction direction : BlockBehaviour.UPDATE_SHAPE_ORDER) { + blockpos$mutableblockpos.setWithOffset(p_60707_, direction); +- BlockState blockstate = p_60706_.getBlockState(blockpos$mutableblockpos); +- BlockState blockstate1 = blockstate.updateShape(direction.getOpposite(), this.asState(), p_60706_, blockpos$mutableblockpos, p_60707_); +- Block.updateOrDestroy(blockstate, blockstate1, p_60706_, blockpos$mutableblockpos, p_60708_, p_60709_); + + if (org.magmafoundation.magma.configuration.MagmaConfig.instance.patchUpdateSuppression.getValues()) { -+ p_60706_.neighborShapeChanged(direction.m_122424_(), this.m_7160_(), blockpos$mutableblockpos, p_60707_, p_60708_, p_60709_); ++ p_60706_.neighborShapeChanged(direction.getOpposite(), this.asState(), blockpos$mutableblockpos, p_60707_, p_60708_, p_60709_); + } else { -+ BlockState blockstate = p_60706_.m_8055_(blockpos$mutableblockpos); -+ BlockState blockstate1 = blockstate.m_60728_(direction.m_122424_(), this.m_7160_(), p_60706_, blockpos$mutableblockpos, p_60707_); -+ Block.m_49908_(blockstate, blockstate1, p_60706_, blockpos$mutableblockpos, p_60708_, p_60709_); ++ BlockState blockstate = p_60706_.getBlockState(blockpos$mutableblockpos); ++ BlockState blockstate1 = blockstate.updateShape(direction.getOpposite(), this.asState(), p_60706_, blockpos$mutableblockpos, p_60707_); ++ Block.updateOrDestroy(blockstate, blockstate1, p_60706_, blockpos$mutableblockpos, p_60708_, p_60709_); + } } } @@ -873,8 +_,9 @@ - ResourceLocation f_60894_; - boolean f_60895_ = true; - boolean f_60896_; + ResourceLocation drops; + boolean canOcclude = true; + boolean isAir; + private java.util.function.Supplier lootTableSupplier; - BlockBehaviour.StateArgumentPredicate> f_60897_ = (p_60935_, p_60936_, p_60937_, p_60938_) -> { -- return p_60935_.m_60783_(p_60936_, p_60937_, Direction.UP) && p_60935_.m_60791_() < 14; -+ return p_60935_.m_60783_(p_60936_, p_60937_, Direction.UP) && p_60935_.getLightEmission(p_60936_, p_60937_) < 14; + BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_60935_, p_60936_, p_60937_, p_60938_) -> { +- return p_60935_.isFaceSturdy(p_60936_, p_60937_, Direction.UP) && p_60935_.getLightEmission() < 14; ++ return p_60935_.isFaceSturdy(p_60936_, p_60937_, Direction.UP) && p_60935_.getLightEmission(p_60936_, p_60937_) < 14; }; - BlockBehaviour.StatePredicate f_60898_ = (p_60985_, p_60986_, p_60987_) -> { - return p_60985_.m_60767_().m_76337_() && p_60985_.m_60838_(p_60986_, p_60987_); + BlockBehaviour.StatePredicate isRedstoneConductor = (p_60985_, p_60986_, p_60987_) -> { + return p_60985_.getMaterial().isSolidBlocking() && p_60985_.isCollisionShapeFullBlock(p_60986_, p_60987_); @@ -1001,9 +_,15 @@ return this; } + @Deprecated // FORGE: Use the variant that takes a Supplier below - public BlockBehaviour.Properties m_60916_(Block p_60917_) { -- this.f_60894_ = p_60917_.m_60589_(); -+ this.lootTableSupplier = () -> p_60917_.delegate.get().m_60589_(); + public BlockBehaviour.Properties dropsLike(Block p_60917_) { +- this.drops = p_60917_.getLootTable(); ++ this.lootTableSupplier = () -> p_60917_.delegate.get().getLootTable(); return this; + } + + public BlockBehaviour.Properties lootFrom(java.util.function.Supplier blockIn) { -+ this.lootTableSupplier = () -> blockIn.get().m_60589_(); ++ this.lootTableSupplier = () -> blockIn.get().getLootTable(); + return this; } - public BlockBehaviour.Properties m_60996_() { + public BlockBehaviour.Properties air() { diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch index acf7303c..67b0d3c4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch @@ -6,6 +6,6 @@ -public class BlockState extends BlockBehaviour.BlockStateBase { +public class BlockState extends BlockBehaviour.BlockStateBase implements net.minecraftforge.common.extensions.IForgeBlockState { - public static final Codec f_61039_ = m_61127_(Registry.f_122824_.m_194605_(), Block::m_49966_).stable(); + public static final Codec CODEC = codec(Registry.BLOCK.byNameCodec(), Block::defaultBlockState).stable(); public BlockState(Block p_61042_, ImmutableMap, Comparable> p_61043_, MapCodec p_61044_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch index 2916df90..ae523c7d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch @@ -3,7 +3,7 @@ @@ -8,9 +_,15 @@ public class IntegerProperty extends Property { - private final ImmutableSet f_61621_; + private final ImmutableSet values; + // CraftBukkit start + public final int min; + public final int max; diff --git a/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch index 19a5262a..d36bcb83 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/state/properties/WoodType.java +++ b/net/minecraft/world/level/block/state/properties/WoodType.java @@ -32,4 +_,11 @@ - public String m_61846_() { - return this.f_61839_; + public String name() { + return this.name; } + + /** diff --git a/patches/minecraft/net/minecraft/world/level/border/WorldBorder.java.patch b/patches/minecraft/net/minecraft/world/level/border/WorldBorder.java.patch index 722f368e..41306de7 100644 --- a/patches/minecraft/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/patches/minecraft/net/minecraft/world/level/border/WorldBorder.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java @@ -27,6 +_,7 @@ - int f_61913_ = 29999984; - private WorldBorder.BorderExtent f_61914_ = new WorldBorder.StaticBorderExtent(5.9999968E7D); - public static final WorldBorder.Settings f_61907_ = new WorldBorder.Settings(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 5.9999968E7D, 0L, 0.0D); + int absoluteMaxSize = 29999984; + private WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.9999968E7D); + public static final WorldBorder.Settings DEFAULT_SETTINGS = new WorldBorder.Settings(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 5.9999968E7D, 0L, 0.0D); + public net.minecraft.world.level.Level world; // CraftBukkit //Magma - ServerLevel -> Level - public boolean m_61937_(BlockPos p_61938_) { - return (double)(p_61938_.m_123341_() + 1) > this.m_61955_() && (double)p_61938_.m_123341_() < this.m_61957_() && (double)(p_61938_.m_123343_() + 1) > this.m_61956_() && (double)p_61938_.m_123343_() < this.m_61958_(); + public boolean isWithinBounds(BlockPos p_61938_) { + return (double)(p_61938_.getX() + 1) > this.getMinX() && (double)p_61938_.getX() < this.getMaxX() && (double)(p_61938_.getZ() + 1) > this.getMinZ() && (double)p_61938_.getZ() < this.getMaxZ(); 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 1f7f5f5d..d26f78c4 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -79,6 +_,12 @@ - protected final LevelHeightAccessor f_187611_; - protected final LevelChunkSection[] f_187612_; + protected final LevelHeightAccessor levelHeightAccessor; + protected final LevelChunkSection[] sections; + public final Registry biomeRegistry; + // CraftBukkit start - SPIGOT-6814: move to IChunkAccess to account for 1.17 to 1.18 chunk upgrading. @@ -11,29 +11,29 @@ + // CraftBukkit end + public ChunkAccess(ChunkPos p_187621_, UpgradeData p_187622_, LevelHeightAccessor p_187623_, Registry p_187624_, long p_187625_, @Nullable LevelChunkSection[] p_187626_, @Nullable BlendingData p_187627_) { - this.f_187604_ = p_187621_; - this.f_187606_ = p_187622_; + this.chunkPos = p_187621_; + this.upgradeData = p_187622_; @@ -96,6 +_,7 @@ } - m_187634_(p_187623_, p_187624_, this.f_187612_); + replaceMissingSections(p_187623_, p_187624_, this.sections); + this.biomeRegistry = p_187624_; // CraftBukkit } - private static void m_187634_(LevelHeightAccessor p_187635_, Registry p_187636_, LevelChunkSection[] p_187637_) { + private static void replaceMissingSections(LevelHeightAccessor p_187635_, Registry p_187636_, LevelChunkSection[] p_187637_) { @@ -248,10 +_,11 @@ - public void m_8092_(boolean p_62094_) { - this.f_187603_ = p_62094_; + public void setUnsaved(boolean p_62094_) { + this.unsaved = p_62094_; + if (!p_62094_) this.persistentDataContainer.dirty(false); // CraftBukkit - SPIGOT-6814: chunk was saved, pdc is no longer dirty } - public boolean m_6344_() { -- return this.f_187603_; -+ return this.f_187603_ || this.persistentDataContainer.dirty(); // CraftBukkit - SPIGOT-6814: chunk is unsaved if pdc was mutated + public boolean isUnsaved() { +- return this.unsaved; ++ return this.unsaved || this.persistentDataContainer.dirty(); // CraftBukkit - SPIGOT-6814: chunk is unsaved if pdc was mutated } - public abstract ChunkStatus m_6415_(); + public abstract ChunkStatus getStatus(); @@ -379,6 +_,27 @@ } } @@ -41,30 +41,30 @@ + // CraftBukkit start + public void setBiome(int i, int j, int k, Holder biome) { + try { -+ int l = QuartPos.m_175400_(this.m_141937_()); -+ int i1 = l + QuartPos.m_175400_(this.m_141928_()) - 1; -+ int j1 = Mth.m_14045_(j, l, i1); -+ int k1 = this.m_151564_(QuartPos.m_175402_(j1)); ++ int l = QuartPos.fromBlock(this.getMinBuildHeight()); ++ int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1; ++ int j1 = Mth.clamp(j, l, i1); ++ int k1 = this.getSectionIndex(QuartPos.toBlock(j1)); + -+ this.f_187612_[k1].setBiome(i & 3, j1 & 3, k & 3, biome); ++ this.sections[k1].setBiome(i & 3, j1 & 3, k & 3, biome); + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_(throwable, "Setting biome"); -+ CrashReportCategory crashreportsystemdetails = crashreport.m_127514_("Biome being set"); ++ CrashReport crashreport = CrashReport.forThrowable(throwable, "Setting biome"); ++ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Biome being set"); + -+ crashreportsystemdetails.m_128165_("Location", () -> { -+ return CrashReportCategory.m_178942_(this, i, j, k); ++ crashreportsystemdetails.setDetail("Location", () -> { ++ return CrashReportCategory.formatLocation(this, i, j, k); + }); + throw new ReportedException(crashreport); + } + } + // CraftBukkit end + - public void m_183442_(BiomeResolver p_187638_, Climate.Sampler p_187639_) { - ChunkPos chunkpos = this.m_7697_(); - int i = QuartPos.m_175400_(chunkpos.m_45604_()); + public void fillBiomesFromNoise(BiomeResolver p_187638_, Climate.Sampler p_187639_) { + ChunkPos chunkpos = this.getPos(); + int i = QuartPos.fromBlock(chunkpos.getMinBlockX()); @@ -411,4 +_,8 @@ - public static record TicksToSave(SerializableTickContainer f_187680_, SerializableTickContainer f_187681_) { + public static record TicksToSave(SerializableTickContainer blocks, SerializableTickContainer fluids) { } + + @Nullable diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index 270d30ab..cbb22acd 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -4,22 +4,22 @@ import org.slf4j.Logger; public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource { -- private static final Logger f_211627_; -- public static final Codec f_62136_; -- public final Registry f_207955_; -- protected final BiomeSource f_62137_; -- protected final BiomeSource f_62138_; -- public final Optional> f_207956_; -- private final Map, List> f_207957_ = new Object2ObjectOpenHashMap<>(); -- private final Map>> f_204350_ = new Object2ObjectArrayMap<>(); -- private boolean f_207958_; +- private static final Logger LOGGER; +- public static final Codec CODEC; +- public final Registry structureSets; +- protected final BiomeSource biomeSource; +- protected final BiomeSource runtimeBiomeSource; +- public final Optional> structureOverrides; +- private final Map, List> placementsForFeature = new Object2ObjectOpenHashMap<>(); +- private final Map>> ringPositions = new Object2ObjectArrayMap<>(); +- private boolean hasGeneratedPositions; - /** @deprecated */ - @Deprecated -- public final long f_212255_; +- public final long ringPlacementSeed; - -- protected static final P1, Registry> m_208005_(Instance p_208006_) { -- return p_208006_.group(RegistryOps.m_206832_(Registry.f_211073_).forGetter((p_208008_) -> { -- return p_208008_.f_207955_; +- protected static final P1, Registry> commonCodec(Instance p_208006_) { +- return p_208006_.group(RegistryOps.retrieveRegistry(Registry.STRUCTURE_SET_REGISTRY).forGetter((p_208008_) -> { +- return p_208008_.structureSets; - })); - } - @@ -28,53 +28,53 @@ - } - - public ChunkGenerator(Registry p_207964_, Optional> p_207965_, BiomeSource p_207966_, BiomeSource p_207967_, long p_207968_) { -- this.f_207955_ = p_207964_; -- this.f_62137_ = p_207966_; -- this.f_62138_ = p_207967_; -- this.f_207956_ = p_207965_; -- this.f_212255_ = p_207968_; +- this.structureSets = p_207964_; +- this.biomeSource = p_207966_; +- this.runtimeBiomeSource = p_207967_; +- this.structureOverrides = p_207965_; +- this.ringPlacementSeed = p_207968_; - } - -- public Stream> m_207969_() { -- return this.f_207956_.isPresent() ? this.f_207956_.get().m_203614_() : this.f_207955_.m_203611_().map(Holder::m_205706_); +- public Stream> possibleStructureSets() { +- return this.structureOverrides.isPresent() ? this.structureOverrides.get().stream() : this.structureSets.holders().map(Holder::hackyErase); - } - -- private void m_208097_() { -- Set> set = this.f_62138_.m_207840_(); -- this.m_207969_().forEach((p_208094_) -> { -- StructureSet structureset = p_208094_.m_203334_(); +- private void generatePositions() { +- Set> set = this.runtimeBiomeSource.possibleBiomes(); +- this.possibleStructureSets().forEach((p_208094_) -> { +- StructureSet structureset = p_208094_.value(); - -- for(StructureSet.StructureSelectionEntry structureset$structureselectionentry : structureset.f_210003_()) { -- this.f_207957_.computeIfAbsent(structureset$structureselectionentry.f_210026_().m_203334_(), (p_208087_) -> { +- for(StructureSet.StructureSelectionEntry structureset$structureselectionentry : structureset.structures()) { +- this.placementsForFeature.computeIfAbsent(structureset$structureselectionentry.structure().value(), (p_208087_) -> { - return new ArrayList(); -- }).add(structureset.f_210004_()); +- }).add(structureset.placement()); - } - -- StructurePlacement structureplacement = structureset.f_210004_(); +- StructurePlacement structureplacement = structureset.placement(); - if (structureplacement instanceof ConcentricRingsStructurePlacement) { - ConcentricRingsStructurePlacement concentricringsstructureplacement = (ConcentricRingsStructurePlacement)structureplacement; -- if (structureset.f_210003_().stream().anyMatch((p_208071_) -> { -- return p_208071_.m_210035_(set::contains); +- if (structureset.structures().stream().anyMatch((p_208071_) -> { +- return p_208071_.generatesInMatchingBiome(set::contains); - })) { -- this.f_204350_.put(concentricringsstructureplacement, this.m_211667_(p_208094_, concentricringsstructureplacement)); +- this.ringPositions.put(concentricringsstructureplacement, this.generateRingPositions(p_208094_, concentricringsstructureplacement)); - } - } - - }); - } - -- private CompletableFuture> m_211667_(Holder p_211668_, ConcentricRingsStructurePlacement p_211669_) { -- return p_211669_.f_204952_() == 0 ? CompletableFuture.completedFuture(List.of()) : CompletableFuture.supplyAsync(Util.m_183946_("placement calculation", () -> { -- Stopwatch stopwatch = Stopwatch.createStarted(Util.f_211544_); +- private CompletableFuture> generateRingPositions(Holder p_211668_, ConcentricRingsStructurePlacement p_211669_) { +- return p_211669_.count() == 0 ? CompletableFuture.completedFuture(List.of()) : CompletableFuture.supplyAsync(Util.wrapThreadWithTaskName("placement calculation", () -> { +- Stopwatch stopwatch = Stopwatch.createStarted(Util.TICKER); - List list = new ArrayList<>(); -- Set> set = p_211668_.m_203334_().f_210003_().stream().flatMap((p_208015_) -> { -- return p_208015_.f_210026_().m_203334_().m_209752_().m_203614_(); +- Set> set = p_211668_.value().structures().stream().flatMap((p_208015_) -> { +- return p_208015_.structure().value().biomes().stream(); - }).collect(Collectors.toSet()); -- int i = p_211669_.f_204950_(); -- int j = p_211669_.f_204952_(); -- int k = p_211669_.f_204951_(); +- int i = p_211669_.distance(); +- int j = p_211669_.count(); +- int k = p_211669_.spread(); - Random random = new Random(); -- random.setSeed(this.f_212255_); +- random.setSeed(this.ringPlacementSeed); - double d0 = random.nextDouble() * Math.PI * 2.0D; - int l = 0; - int i1 = 0; @@ -83,11 +83,11 @@ - double d1 = (double)(4 * i + i * i1 * 6) + (random.nextDouble() - 0.5D) * (double)i * 2.5D; - int k1 = (int)Math.round(Math.cos(d0) * d1); - int l1 = (int)Math.round(Math.sin(d0) * d1); -- Pair> pair = this.f_62137_.m_207829_(SectionPos.m_175554_(k1, 8), 0, SectionPos.m_175554_(l1, 8), 112, set::contains, random, this.m_183403_()); +- Pair> pair = this.biomeSource.findBiomeHorizontal(SectionPos.sectionToBlockCoord(k1, 8), 0, SectionPos.sectionToBlockCoord(l1, 8), 112, set::contains, random, this.climateSampler()); - if (pair != null) { - BlockPos blockpos = pair.getFirst(); -- k1 = SectionPos.m_123171_(blockpos.m_123341_()); -- l1 = SectionPos.m_123171_(blockpos.m_123343_()); +- k1 = SectionPos.blockToSectionCoord(blockpos.getX()); +- l1 = SectionPos.blockToSectionCoord(blockpos.getZ()); - } - - list.add(new ChunkPos(k1, l1)); @@ -103,63 +103,63 @@ - } - - double d2 = (double)stopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000.0D; -- f_211627_.debug("Calculation for {} took {}s", p_211668_, d2); +- LOGGER.debug("Calculation for {} took {}s", p_211668_, d2); - return list; -- }), Util.m_183991_()); +- }), Util.backgroundExecutor()); - } - -- protected abstract Codec m_6909_(); +- protected abstract Codec codec(); - -- public Optional>> m_187743_() { -- return Registry.f_122890_.m_7854_(this.m_6909_()); +- public Optional>> getTypeNameForDataFixer() { +- return Registry.CHUNK_GENERATOR.getResourceKey(this.codec()); - } - -- public abstract ChunkGenerator m_6819_(long p_62156_); +- public abstract ChunkGenerator withSeed(long p_62156_); - -- public CompletableFuture m_196423_(Registry p_196743_, Executor p_196744_, Blender p_196745_, StructureFeatureManager p_196746_, ChunkAccess p_196747_) { -- return CompletableFuture.supplyAsync(Util.m_183946_("init_biomes", () -> { -- p_196747_.m_183442_(this.f_62138_::m_203407_, this.m_183403_()); +- public CompletableFuture createBiomes(Registry p_196743_, Executor p_196744_, Blender p_196745_, StructureFeatureManager p_196746_, ChunkAccess p_196747_) { +- return CompletableFuture.supplyAsync(Util.wrapThreadWithTaskName("init_biomes", () -> { +- p_196747_.fillBiomesFromNoise(this.runtimeBiomeSource::getNoiseBiome, this.climateSampler()); - return p_196747_; -- }), Util.m_183991_()); +- }), Util.backgroundExecutor()); - } - -- public abstract Climate.Sampler m_183403_(); +- public abstract Climate.Sampler climateSampler(); - -- public Holder m_203495_(int p_204416_, int p_204417_, int p_204418_) { -- return this.m_62218_().m_203407_(p_204416_, p_204417_, p_204418_, this.m_183403_()); +- public Holder getNoiseBiome(int p_204416_, int p_204417_, int p_204418_) { +- return this.getBiomeSource().getNoiseBiome(p_204416_, p_204417_, p_204418_, this.climateSampler()); - } - -- public abstract void m_183516_(WorldGenRegion p_187691_, long p_187692_, BiomeManager p_187693_, StructureFeatureManager p_187694_, ChunkAccess p_187695_, GenerationStep.Carving p_187696_); +- public abstract void applyCarvers(WorldGenRegion p_187691_, long p_187692_, BiomeManager p_187693_, StructureFeatureManager p_187694_, ChunkAccess p_187695_, GenerationStep.Carving p_187696_); - - @Nullable -- public Pair>> m_207970_(ServerLevel p_207971_, HolderSet> p_207972_, BlockPos p_207973_, int p_207974_, boolean p_207975_) { -- Set> set = p_207972_.m_203614_().flatMap((p_211699_) -> { -- return p_211699_.m_203334_().m_209752_().m_203614_(); +- public Pair>> findNearestMapFeature(ServerLevel p_207971_, HolderSet> p_207972_, BlockPos p_207973_, int p_207974_, boolean p_207975_) { +- Set> set = p_207972_.stream().flatMap((p_211699_) -> { +- return p_211699_.value().biomes().stream(); - }).collect(Collectors.toSet()); - if (set.isEmpty()) { - return null; - } else { -- Set> set1 = this.f_62138_.m_207840_(); +- Set> set1 = this.runtimeBiomeSource.possibleBiomes(); - if (Collections.disjoint(set1, set)) { -+ private static final Logger f_211627_; -+ public static final Codec f_62136_; -+ public final Registry f_207955_; -+ protected final BiomeSource f_62137_; -+ protected final BiomeSource f_62138_; -+ public final Optional> f_207956_; -+ private final Map, List> f_207957_ = new Object2ObjectOpenHashMap<>(); -+ private final Map>> f_204350_ = new Object2ObjectArrayMap<>(); -+ private boolean f_207958_; ++ private static final Logger LOGGER; ++ public static final Codec CODEC; ++ public final Registry structureSets; ++ protected final BiomeSource biomeSource; ++ protected final BiomeSource runtimeBiomeSource; ++ public final Optional> structureOverrides; ++ private final Map, List> placementsForFeature = new Object2ObjectOpenHashMap<>(); ++ private final Map>> ringPositions = new Object2ObjectArrayMap<>(); ++ private boolean hasGeneratedPositions; + /** + * @deprecated + */ + @Deprecated -+ public final long f_212255_; ++ public final long ringPlacementSeed; + public org.spigotmc.SpigotWorldConfig conf; // Spigot + -+ protected static final P1, Registry> m_208005_(Instance p_208006_) { -+ return p_208006_.group( RegistryOps.m_206832_( Registry.f_211073_ ).forGetter( (p_208008_) -> { -+ return p_208008_.f_207955_; ++ protected static final P1, Registry> commonCodec(Instance p_208006_) { ++ return p_208006_.group( RegistryOps.retrieveRegistry( Registry.STRUCTURE_SET_REGISTRY ).forGetter( (p_208008_) -> { ++ return p_208008_.structureSets; + } ) ); + } + @@ -168,23 +168,23 @@ + } + + public ChunkGenerator(Registry p_207964_, Optional> p_207965_, BiomeSource p_207966_, BiomeSource p_207967_, long p_207968_) { -+ this.f_207955_ = p_207964_; -+ this.f_62137_ = p_207966_; -+ this.f_62138_ = p_207967_; -+ this.f_207956_ = p_207965_; -+ this.f_212255_ = p_207968_; ++ this.structureSets = p_207964_; ++ this.biomeSource = p_207966_; ++ this.runtimeBiomeSource = p_207967_; ++ this.structureOverrides = p_207965_; ++ this.ringPlacementSeed = p_207968_; + } + -+ public Stream> m_207969_() { -+ return this.f_207956_.isPresent() ? this.f_207956_.get().m_203614_() : this.f_207955_.m_203611_().map( Holder::m_205706_ ); ++ public Stream> possibleStructureSets() { ++ return this.structureOverrides.isPresent() ? this.structureOverrides.get().stream() : this.structureSets.holders().map( Holder::hackyErase ); + } + + // Spigot start + private Stream possibleStructureSetsSpigot() { -+ return m_207969_().map( Holder::m_203334_ ).map( (structureset) -> { -+ if (structureset.f_210004_() instanceof RandomSpreadStructurePlacement randomConfig && conf != null) { -+ String name = f_207955_.m_7981_( structureset ).m_135815_(); -+ int seed = randomConfig.f_204976_(); ++ return possibleStructureSets().map( Holder::value ).map( (structureset) -> { ++ if (structureset.placement() instanceof RandomSpreadStructurePlacement randomConfig && conf != null) { ++ String name = structureSets.getKey( structureset ).getPath(); ++ int seed = randomConfig.salt(); + + switch (name) { + case "desert_pyramids": @@ -231,7 +231,7 @@ + break; + } + -+ structureset = new StructureSet( structureset.f_210003_(), new RandomSpreadStructurePlacement( randomConfig.f_204973_(), randomConfig.f_204974_(), randomConfig.f_204975_(), seed, randomConfig.f_204977_() ) ); ++ structureset = new StructureSet( structureset.structures(), new RandomSpreadStructurePlacement( randomConfig.spacing(), randomConfig.separation(), randomConfig.spreadType(), seed, randomConfig.locateOffset() ) ); + } + return structureset; + } ); @@ -239,25 +239,25 @@ + // Spigot end + + -+ private void m_208097_() { -+ Set> set = this.f_62138_.m_207840_(); ++ private void generatePositions() { ++ Set> set = this.runtimeBiomeSource.possibleBiomes(); + // Spigot start + this.possibleStructureSetsSpigot().forEach( (p_208094_) -> { + StructureSet structureset = (StructureSet) p_208094_; + // Spigot end -+ for (StructureSet.StructureSelectionEntry structureset$structureselectionentry : structureset.f_210003_()) { -+ this.f_207957_.computeIfAbsent( structureset$structureselectionentry.f_210026_().m_203334_(), (p_208087_) -> { ++ for (StructureSet.StructureSelectionEntry structureset$structureselectionentry : structureset.structures()) { ++ this.placementsForFeature.computeIfAbsent( structureset$structureselectionentry.structure().value(), (p_208087_) -> { + return new ArrayList(); -+ } ).add( structureset.f_210004_() ); ++ } ).add( structureset.placement() ); + } + -+ StructurePlacement structureplacement = structureset.f_210004_(); ++ StructurePlacement structureplacement = structureset.placement(); + if (structureplacement instanceof ConcentricRingsStructurePlacement) { + ConcentricRingsStructurePlacement concentricringsstructureplacement = (ConcentricRingsStructurePlacement) structureplacement; -+ if (structureset.f_210003_().stream().anyMatch( (p_208071_) -> { -+ return p_208071_.m_210035_( set::contains ); ++ if (structureset.structures().stream().anyMatch( (p_208071_) -> { ++ return p_208071_.generatesInMatchingBiome( set::contains ); + } )) { -+ this.f_204350_.put( concentricringsstructureplacement, this.generateRingPositions( p_208094_, concentricringsstructureplacement ) ); ++ this.ringPositions.put( concentricringsstructureplacement, this.generateRingPositions( p_208094_, concentricringsstructureplacement ) ); + } + } + @@ -266,23 +266,23 @@ + + // Magma start - MixinError + // Fixes generateRingPositions - https://github.com/embeddedt/ModernFix/blob/7fb65f51447b492f91a240467565a1aa408c4c5b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/cache_strongholds/ChunkGeneratorMixin.java#LL32C55-L32C83 -+ private CompletableFuture> m_211667_(Holder p_211668_, ConcentricRingsStructurePlacement p_211669_) { // Spigot -+ return generateRingPositions(p_211668_.m_203334_(), p_211669_); ++ private CompletableFuture> generateRingPositions(Holder p_211668_, ConcentricRingsStructurePlacement p_211669_) { // Spigot ++ return generateRingPositions(p_211668_.value(), p_211669_); + } + // Magma end + + private CompletableFuture> generateRingPositions(StructureSet p_211668_, ConcentricRingsStructurePlacement p_211669_) { // Spigot -+ return p_211669_.f_204952_() == 0 ? CompletableFuture.completedFuture( List.of() ) : CompletableFuture.supplyAsync( Util.m_183946_( "placement calculation", () -> { -+ Stopwatch stopwatch = Stopwatch.createStarted( Util.f_211544_ ); ++ return p_211669_.count() == 0 ? CompletableFuture.completedFuture( List.of() ) : CompletableFuture.supplyAsync( Util.wrapThreadWithTaskName( "placement calculation", () -> { ++ Stopwatch stopwatch = Stopwatch.createStarted( Util.TICKER ); + List list = new ArrayList<>(); -+ Set> set = (Set) ((StructureSet) p_211668_).f_210003_().stream().flatMap( (p_208015_) -> { // Spigot -+ return p_208015_.f_210026_().m_203334_().m_209752_().m_203614_(); ++ Set> set = (Set) ((StructureSet) p_211668_).structures().stream().flatMap( (p_208015_) -> { // Spigot ++ return p_208015_.structure().value().biomes().stream(); + } ).collect( Collectors.toSet() ); -+ int i = p_211669_.f_204950_(); -+ int j = p_211669_.f_204952_(); -+ int k = p_211669_.f_204951_(); ++ int i = p_211669_.distance(); ++ int j = p_211669_.count(); ++ int k = p_211669_.spread(); + Random random = new Random(); -+ random.setSeed( this.f_212255_ ); ++ random.setSeed( this.ringPlacementSeed ); + double d0 = random.nextDouble() * Math.PI * 2.0D; + int l = 0; + int i1 = 0; @@ -291,11 +291,11 @@ + double d1 = (double) (4 * i + i * i1 * 6) + (random.nextDouble() - 0.5D) * (double) i * 2.5D; + int k1 = (int) Math.round( Math.cos( d0 ) * d1 ); + int l1 = (int) Math.round( Math.sin( d0 ) * d1 ); -+ Pair> pair = this.f_62137_.m_207829_( SectionPos.m_175554_( k1, 8 ), 0, SectionPos.m_175554_( l1, 8 ), 112, set::contains, random, this.m_183403_() ); ++ Pair> pair = this.biomeSource.findBiomeHorizontal( SectionPos.sectionToBlockCoord( k1, 8 ), 0, SectionPos.sectionToBlockCoord( l1, 8 ), 112, set::contains, random, this.climateSampler() ); + if (pair != null) { + BlockPos blockpos = pair.getFirst(); -+ k1 = SectionPos.m_123171_( blockpos.m_123341_() ); -+ l1 = SectionPos.m_123171_( blockpos.m_123343_() ); ++ k1 = SectionPos.blockToSectionCoord( blockpos.getX() ); ++ l1 = SectionPos.blockToSectionCoord( blockpos.getZ() ); + } + + list.add( new ChunkPos( k1, l1 ) ); @@ -311,45 +311,45 @@ + } + + double d2 = (double) stopwatch.stop().elapsed( TimeUnit.MILLISECONDS ) / 1000.0D; -+ f_211627_.debug( "Calculation for {} took {}s", p_211668_, d2 ); ++ LOGGER.debug( "Calculation for {} took {}s", p_211668_, d2 ); + return list; -+ } ), Util.m_183991_() ); ++ } ), Util.backgroundExecutor() ); + } + -+ protected abstract Codec m_6909_(); ++ protected abstract Codec codec(); + -+ public Optional>> m_187743_() { -+ return Registry.f_122890_.m_7854_( this.m_6909_() ); ++ public Optional>> getTypeNameForDataFixer() { ++ return Registry.CHUNK_GENERATOR.getResourceKey( this.codec() ); + } + -+ public abstract ChunkGenerator m_6819_(long p_62156_); ++ public abstract ChunkGenerator withSeed(long p_62156_); + -+ public CompletableFuture m_196423_(Registry p_196743_, Executor p_196744_, Blender p_196745_, StructureFeatureManager p_196746_, ChunkAccess p_196747_) { -+ return CompletableFuture.supplyAsync( Util.m_183946_( "init_biomes", () -> { -+ p_196747_.m_183442_( this.f_62138_::m_203407_, this.m_183403_() ); ++ public CompletableFuture createBiomes(Registry p_196743_, Executor p_196744_, Blender p_196745_, StructureFeatureManager p_196746_, ChunkAccess p_196747_) { ++ return CompletableFuture.supplyAsync( Util.wrapThreadWithTaskName( "init_biomes", () -> { ++ p_196747_.fillBiomesFromNoise( this.runtimeBiomeSource::getNoiseBiome, this.climateSampler() ); + return p_196747_; -+ } ), Util.m_183991_() ); ++ } ), Util.backgroundExecutor() ); + } + -+ public abstract Climate.Sampler m_183403_(); ++ public abstract Climate.Sampler climateSampler(); + -+ public Holder m_203495_(int p_204416_, int p_204417_, int p_204418_) { -+ return this.m_62218_().m_203407_( p_204416_, p_204417_, p_204418_, this.m_183403_() ); ++ public Holder getNoiseBiome(int p_204416_, int p_204417_, int p_204418_) { ++ return this.getBiomeSource().getNoiseBiome( p_204416_, p_204417_, p_204418_, this.climateSampler() ); + } + -+ public abstract void m_183516_(WorldGenRegion p_187691_, long p_187692_, BiomeManager p_187693_, StructureFeatureManager p_187694_, ChunkAccess p_187695_, GenerationStep.Carving p_187696_); ++ public abstract void applyCarvers(WorldGenRegion p_187691_, long p_187692_, BiomeManager p_187693_, StructureFeatureManager p_187694_, ChunkAccess p_187695_, GenerationStep.Carving p_187696_); + + @Nullable -+ public Pair>> m_207970_(ServerLevel p_207971_, HolderSet> p_207972_, BlockPos p_207973_, int p_207974_, boolean p_207975_) { -+ Set> set = p_207972_.m_203614_().flatMap( (p_211699_) -> { -+ return p_211699_.m_203334_().m_209752_().m_203614_(); ++ public Pair>> findNearestMapFeature(ServerLevel p_207971_, HolderSet> p_207972_, BlockPos p_207973_, int p_207974_, boolean p_207975_) { ++ Set> set = p_207972_.stream().flatMap( (p_211699_) -> { ++ return p_211699_.value().biomes().stream(); + } ).collect( Collectors.toSet() ); + if (set.isEmpty()) { return null; - } else { - Pair>> pair = null; + } else { -+ Set> set1 = this.f_62138_.m_207840_(); ++ Set> set1 = this.runtimeBiomeSource.possibleBiomes(); + if (Collections.disjoint( set1, set )) { + return null; + } else { @@ -358,8 +358,8 @@ + Map>>> map = new Object2ObjectArrayMap<>(); + + for (Holder> holder : p_207972_) { -+ if (!set1.stream().noneMatch( holder.m_203334_().m_209752_()::m_203333_ )) { -+ for (StructurePlacement structureplacement : this.m_208090_( holder )) { ++ if (!set1.stream().noneMatch( holder.value().biomes()::contains )) { ++ for (StructurePlacement structureplacement : this.getPlacementsForFeature( holder )) { + map.computeIfAbsent( structureplacement, (p_211663_) -> { + return new ObjectArraySet(); + } ).add( holder ); @@ -373,8 +373,8 @@ + StructurePlacement structureplacement1 = entry.getKey(); + if (structureplacement1 instanceof ConcentricRingsStructurePlacement) { + ConcentricRingsStructurePlacement concentricringsstructureplacement = (ConcentricRingsStructurePlacement) structureplacement1; -+ BlockPos blockpos = this.m_204382_( p_207973_, concentricringsstructureplacement ); -+ double d1 = p_207973_.m_123331_( blockpos ); ++ BlockPos blockpos = this.getNearestGeneratedStructure( p_207973_, concentricringsstructureplacement ); ++ double d1 = p_207973_.distSqr( blockpos ); + if (d1 < d0) { + d0 = d1; + pair = Pair.of( blockpos, entry.getValue().iterator().next() ); @@ -385,18 +385,18 @@ + } + + if (!list.isEmpty()) { -+ int i = SectionPos.m_123171_( p_207973_.m_123341_() ); -+ int j = SectionPos.m_123171_( p_207973_.m_123343_() ); ++ int i = SectionPos.blockToSectionCoord( p_207973_.getX() ); ++ int j = SectionPos.blockToSectionCoord( p_207973_.getZ() ); + + for (int k = 0; k <= p_207974_; ++k) { + boolean flag = false; + + for (Entry>>> entry1 : list) { + RandomSpreadStructurePlacement randomspreadstructureplacement = (RandomSpreadStructurePlacement) entry1.getKey(); -+ Pair>> pair1 = m_208059_( entry1.getValue(), p_207971_, p_207971_.m_8595_(), i, j, k, p_207975_, p_207971_.m_7328_(), randomspreadstructureplacement ); ++ Pair>> pair1 = getNearestGeneratedStructure( entry1.getValue(), p_207971_, p_207971_.structureFeatureManager(), i, j, k, p_207975_, p_207971_.getSeed(), randomspreadstructureplacement ); + if (pair1 != null) { + flag = true; -+ double d2 = p_207973_.m_123331_( pair1.getFirst() ); ++ double d2 = p_207973_.distSqr( pair1.getFirst() ); + if (d2 < d0) { + d0 = d2; + pair = pair1; @@ -416,8 +416,8 @@ + } + + @Nullable -+ private BlockPos m_204382_(BlockPos p_204383_, ConcentricRingsStructurePlacement p_204384_) { -+ List list = this.m_204380_( p_204384_ ); ++ private BlockPos getNearestGeneratedStructure(BlockPos p_204383_, ConcentricRingsStructurePlacement p_204384_) { ++ List list = this.getRingPositionsFor( p_204384_ ); + if (list == null) { + throw new IllegalStateException( "Somehow tried to find structures for a placement that doesn't exist" ); + } else { @@ -426,8 +426,8 @@ - Map>>> map = new Object2ObjectArrayMap<>(); - - for(Holder> holder : p_207972_) { -- if (!set1.stream().noneMatch(holder.m_203334_().m_209752_()::m_203333_)) { -- for(StructurePlacement structureplacement : this.m_208090_(holder)) { +- if (!set1.stream().noneMatch(holder.value().biomes()::contains)) { +- for(StructurePlacement structureplacement : this.getPlacementsForFeature(holder)) { - map.computeIfAbsent(structureplacement, (p_211663_) -> { - return new ObjectArraySet(); - }).add(holder); @@ -441,8 +441,8 @@ - StructurePlacement structureplacement1 = entry.getKey(); - if (structureplacement1 instanceof ConcentricRingsStructurePlacement) { - ConcentricRingsStructurePlacement concentricringsstructureplacement = (ConcentricRingsStructurePlacement)structureplacement1; -- BlockPos blockpos = this.m_204382_(p_207973_, concentricringsstructureplacement); -- double d1 = p_207973_.m_123331_(blockpos); +- BlockPos blockpos = this.getNearestGeneratedStructure(p_207973_, concentricringsstructureplacement); +- double d1 = p_207973_.distSqr(blockpos); - if (d1 < d0) { - d0 = d1; - pair = Pair.of(blockpos, entry.getValue().iterator().next()); @@ -453,18 +453,18 @@ - } - - if (!list.isEmpty()) { -- int i = SectionPos.m_123171_(p_207973_.m_123341_()); -- int j = SectionPos.m_123171_(p_207973_.m_123343_()); +- int i = SectionPos.blockToSectionCoord(p_207973_.getX()); +- int j = SectionPos.blockToSectionCoord(p_207973_.getZ()); - - for(int k = 0; k <= p_207974_; ++k) { - boolean flag = false; - - for(Entry>>> entry1 : list) { - RandomSpreadStructurePlacement randomspreadstructureplacement = (RandomSpreadStructurePlacement)entry1.getKey(); -- Pair>> pair1 = m_208059_(entry1.getValue(), p_207971_, p_207971_.m_8595_(), i, j, k, p_207975_, p_207971_.m_7328_(), randomspreadstructureplacement); +- Pair>> pair1 = getNearestGeneratedStructure(entry1.getValue(), p_207971_, p_207971_.structureFeatureManager(), i, j, k, p_207975_, p_207971_.getSeed(), randomspreadstructureplacement); - if (pair1 != null) { - flag = true; -- double d2 = p_207973_.m_123331_(pair1.getFirst()); +- double d2 = p_207973_.distSqr(pair1.getFirst()); - if (d2 < d0) { - d0 = d2; - pair = pair1; @@ -484,8 +484,8 @@ - } - - @Nullable -- private BlockPos m_204382_(BlockPos p_204383_, ConcentricRingsStructurePlacement p_204384_) { -- List list = this.m_204380_(p_204384_); +- private BlockPos getNearestGeneratedStructure(BlockPos p_204383_, ConcentricRingsStructurePlacement p_204384_) { +- List list = this.getRingPositionsFor(p_204384_); - if (list == null) { - throw new IllegalStateException("Somehow tried to find structures for a placement that doesn't exist"); - } else { @@ -494,8 +494,8 @@ - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - - for(ChunkPos chunkpos : list) { -- blockpos$mutableblockpos.m_122178_(SectionPos.m_175554_(chunkpos.f_45578_, 8), 32, SectionPos.m_175554_(chunkpos.f_45579_, 8)); -- double d1 = blockpos$mutableblockpos.m_123331_(p_204383_); +- blockpos$mutableblockpos.set(SectionPos.sectionToBlockCoord(chunkpos.x, 8), 32, SectionPos.sectionToBlockCoord(chunkpos.z, 8)); +- double d1 = blockpos$mutableblockpos.distSqr(p_204383_); - if (blockpos == null) { - blockpos = new BlockPos(blockpos$mutableblockpos); - d0 = d1; @@ -510,8 +510,8 @@ - } - - @Nullable -- private static Pair>> m_208059_(Set>> p_208060_, LevelReader p_208061_, StructureFeatureManager p_208062_, int p_208063_, int p_208064_, int p_208065_, boolean p_208066_, long p_208067_, RandomSpreadStructurePlacement p_208068_) { -- int i = p_208068_.f_204973_(); +- private static Pair>> getNearestGeneratedStructure(Set>> p_208060_, LevelReader p_208061_, StructureFeatureManager p_208062_, int p_208063_, int p_208064_, int p_208065_, boolean p_208066_, long p_208067_, RandomSpreadStructurePlacement p_208068_) { +- int i = p_208068_.spacing(); - - for(int j = -p_208065_; j <= p_208065_; ++j) { - boolean flag = j == -p_208065_ || j == p_208065_; @@ -521,25 +521,25 @@ - if (flag || flag1) { - int l = p_208063_ + i * j; - int i1 = p_208064_ + i * k; -- ChunkPos chunkpos = p_208068_.m_204991_(p_208067_, l, i1); +- ChunkPos chunkpos = p_208068_.getPotentialFeatureChunk(p_208067_, l, i1); - - for(Holder> holder : p_208060_) { -- StructureCheckResult structurecheckresult = p_208062_.m_207777_(chunkpos, holder.m_203334_(), p_208066_); +- StructureCheckResult structurecheckresult = p_208062_.checkStructurePresence(chunkpos, holder.value(), p_208066_); - if (structurecheckresult != StructureCheckResult.START_NOT_PRESENT) { - if (!p_208066_ && structurecheckresult == StructureCheckResult.START_PRESENT) { -- return Pair.of(StructureFeature.m_204766_(p_208068_, chunkpos), holder); +- return Pair.of(StructureFeature.getLocatePos(p_208068_, chunkpos), holder); - } - -- ChunkAccess chunkaccess = p_208061_.m_46819_(chunkpos.f_45578_, chunkpos.f_45579_, ChunkStatus.f_62315_); -- StructureStart structurestart = p_208062_.m_207802_(SectionPos.m_175562_(chunkaccess), holder.m_203334_(), chunkaccess); -- if (structurestart != null && structurestart.m_73603_()) { -- if (p_208066_ && structurestart.m_73606_()) { -- p_208062_.m_196674_(structurestart); -- return Pair.of(StructureFeature.m_204766_(p_208068_, structurestart.m_163625_()), holder); +- ChunkAccess chunkaccess = p_208061_.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS); +- StructureStart structurestart = p_208062_.getStartForFeature(SectionPos.bottomOf(chunkaccess), holder.value(), chunkaccess); +- if (structurestart != null && structurestart.isValid()) { +- if (p_208066_ && structurestart.canBeReferenced()) { +- p_208062_.addReference(structurestart); +- return Pair.of(StructureFeature.getLocatePos(p_208068_, structurestart.getChunkPos()), holder); - } - - if (!p_208066_) { -- return Pair.of(StructureFeature.m_204766_(p_208068_, structurestart.m_163625_()), holder); +- return Pair.of(StructureFeature.getLocatePos(p_208068_, structurestart.getChunkPos()), holder); - } - } - } @@ -551,58 +551,58 @@ - return null; - } - -- public void m_183372_(WorldGenLevel p_187712_, ChunkAccess p_187713_, StructureFeatureManager p_187714_) { -- ChunkPos chunkpos = p_187713_.m_7697_(); -- if (!SharedConstants.m_183707_(chunkpos)) { -- SectionPos sectionpos = SectionPos.m_123196_(chunkpos, p_187712_.m_151560_()); -- BlockPos blockpos = sectionpos.m_123249_(); -- Registry> registry = p_187712_.m_5962_().m_175515_(Registry.f_122882_); -- Map>> map = registry.m_123024_().collect(Collectors.groupingBy((p_211653_) -> { -- return p_211653_.f_65403_.m_67095_().ordinal(); +- public void applyBiomeDecoration(WorldGenLevel p_187712_, ChunkAccess p_187713_, StructureFeatureManager p_187714_) { +- ChunkPos chunkpos = p_187713_.getPos(); +- if (!SharedConstants.debugVoidTerrain(chunkpos)) { +- SectionPos sectionpos = SectionPos.of(chunkpos, p_187712_.getMinSection()); +- BlockPos blockpos = sectionpos.origin(); +- Registry> registry = p_187712_.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); +- Map>> map = registry.stream().collect(Collectors.groupingBy((p_211653_) -> { +- return p_211653_.feature.step().ordinal(); - })); -- List list = this.f_62137_.m_186733_(); -- WorldgenRandom worldgenrandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.m_189328_())); -- long i = worldgenrandom.m_64690_(p_187712_.m_7328_(), blockpos.m_123341_(), blockpos.m_123343_()); +- List list = this.biomeSource.featuresPerStep(); +- WorldgenRandom worldgenrandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.seedUniquifier())); +- long i = worldgenrandom.setDecorationSeed(p_187712_.getSeed(), blockpos.getX(), blockpos.getZ()); - Set set = new ObjectArraySet<>(); - if (this instanceof FlatLevelSource) { -- this.f_62137_.m_207840_().stream().map(Holder::m_203334_).forEach(set::add); +- this.biomeSource.possibleBiomes().stream().map(Holder::value).forEach(set::add); - } else { -- ChunkPos.m_45596_(sectionpos.m_123251_(), 1).forEach((p_211651_) -> { -- ChunkAccess chunkaccess = p_187712_.m_6325_(p_211651_.f_45578_, p_211651_.f_45579_); +- ChunkPos.rangeClosed(sectionpos.chunk(), 1).forEach((p_211651_) -> { +- ChunkAccess chunkaccess = p_187712_.getChunk(p_211651_.x, p_211651_.z); - -- for(LevelChunkSection levelchunksection : chunkaccess.m_7103_()) { -- levelchunksection.m_188013_().m_196879_((p_211688_) -> { -- set.add(p_211688_.m_203334_()); +- for(LevelChunkSection levelchunksection : chunkaccess.getSections()) { +- levelchunksection.getBiomes().getAll((p_211688_) -> { +- set.add(p_211688_.value()); - }); - } - - }); -- set.retainAll(this.f_62137_.m_207840_().stream().map(Holder::m_203334_).collect(Collectors.toSet())); +- set.retainAll(this.biomeSource.possibleBiomes().stream().map(Holder::value).collect(Collectors.toSet())); - } - - int j = list.size(); - - try { -- Registry registry1 = p_187712_.m_5962_().m_175515_(Registry.f_194567_); +- Registry registry1 = p_187712_.registryAccess().registryOrThrow(Registry.PLACED_FEATURE_REGISTRY); - int i1 = Math.max(GenerationStep.Decoration.values().length, j); - - for(int k = 0; k < i1; ++k) { - int l = 0; -- if (p_187714_.m_47271_()) { +- if (p_187714_.shouldGenerateFeatures()) { - for(ConfiguredStructureFeature configuredstructurefeature : map.getOrDefault(k, Collections.emptyList())) { -- worldgenrandom.m_190064_(i, l, k); +- worldgenrandom.setFeatureSeed(i, l, k); - Supplier supplier = () -> { -- return registry.m_7854_(configuredstructurefeature).map(Object::toString).orElseGet(configuredstructurefeature::toString); +- return registry.getResourceKey(configuredstructurefeature).map(Object::toString).orElseGet(configuredstructurefeature::toString); - }; - - try { -- p_187712_.m_183406_(supplier); -- p_187714_.m_207794_(sectionpos, configuredstructurefeature).forEach((p_211647_) -> { -- p_211647_.m_7129_(p_187712_, p_187714_, this, worldgenrandom, m_187717_(p_187713_), chunkpos); +- p_187712_.setCurrentlyGenerating(supplier); +- p_187714_.startsForFeature(sectionpos, configuredstructurefeature).forEach((p_211647_) -> { +- p_211647_.placeInChunk(p_187712_, p_187714_, this, worldgenrandom, getWritableArea(p_187713_), chunkpos); - }); - } catch (Exception exception) { -- CrashReport crashreport1 = CrashReport.m_127521_(exception, "Feature placement"); -- crashreport1.m_127514_("Feature").m_128165_("Description", supplier::get); +- CrashReport crashreport1 = CrashReport.forThrowable(exception, "Feature placement"); +- crashreport1.addCategory("Feature").setDetail("Description", supplier::get); - throw new ReportedException(crashreport1); - } - @@ -614,12 +614,12 @@ - IntSet intset = new IntArraySet(); - - for(Biome biome : set) { -- List> list1 = biome.m_47536_().m_47818_(); +- List> list1 = biome.getGenerationSettings().features(); - if (k < list1.size()) { - HolderSet holderset = list1.get(k); - BiomeSource.StepFeatureData biomesource$stepfeaturedata1 = list.get(k); -- holderset.m_203614_().map(Holder::m_203334_).forEach((p_211682_) -> { -- intset.add(biomesource$stepfeaturedata1.f_196678_().applyAsInt(p_211682_)); +- holderset.stream().map(Holder::value).forEach((p_211682_) -> { +- intset.add(biomesource$stepfeaturedata1.indexMapping().applyAsInt(p_211682_)); - }); - } - } @@ -631,43 +631,43 @@ - - for(int k1 = 0; k1 < j1; ++k1) { - int l1 = aint[k1]; -- PlacedFeature placedfeature = biomesource$stepfeaturedata.f_196677_().get(l1); +- PlacedFeature placedfeature = biomesource$stepfeaturedata.features().get(l1); - Supplier supplier1 = () -> { -- return registry1.m_7854_(placedfeature).map(Object::toString).orElseGet(placedfeature::toString); +- return registry1.getResourceKey(placedfeature).map(Object::toString).orElseGet(placedfeature::toString); - }; -- worldgenrandom.m_190064_(i, l1, k); +- worldgenrandom.setFeatureSeed(i, l1, k); - - try { -- p_187712_.m_183406_(supplier1); -- placedfeature.m_191806_(p_187712_, this, worldgenrandom, blockpos); +- p_187712_.setCurrentlyGenerating(supplier1); +- placedfeature.placeWithBiomeCheck(p_187712_, this, worldgenrandom, blockpos); - } catch (Exception exception1) { -- CrashReport crashreport2 = CrashReport.m_127521_(exception1, "Feature placement"); -- crashreport2.m_127514_("Feature").m_128165_("Description", supplier1::get); +- CrashReport crashreport2 = CrashReport.forThrowable(exception1, "Feature placement"); +- crashreport2.addCategory("Feature").setDetail("Description", supplier1::get); - throw new ReportedException(crashreport2); - } - } - } - } - -- p_187712_.m_183406_((Supplier)null); +- p_187712_.setCurrentlyGenerating((Supplier)null); - } catch (Exception exception2) { -- CrashReport crashreport = CrashReport.m_127521_(exception2, "Biome decoration"); -- crashreport.m_127514_("Generation").m_128159_("CenterX", chunkpos.f_45578_).m_128159_("CenterZ", chunkpos.f_45579_).m_128159_("Seed", i); +- CrashReport crashreport = CrashReport.forThrowable(exception2, "Biome decoration"); +- crashreport.addCategory("Generation").setDetail("CenterX", chunkpos.x).setDetail("CenterZ", chunkpos.z).setDetail("Seed", i); - throw new ReportedException(crashreport); - } - } - } - -- public boolean m_212265_(ResourceKey p_212266_, long p_212267_, int p_212268_, int p_212269_, int p_212270_) { -- StructureSet structureset = this.f_207955_.m_6246_(p_212266_); +- public boolean hasFeatureChunkInRange(ResourceKey p_212266_, long p_212267_, int p_212268_, int p_212269_, int p_212270_) { +- StructureSet structureset = this.structureSets.get(p_212266_); - if (structureset == null) { - return false; - } else { -- StructurePlacement structureplacement = structureset.f_210004_(); +- StructurePlacement structureplacement = structureset.placement(); - - for(int i = p_212268_ - p_212270_; i <= p_212268_ + p_212270_; ++i) { - for(int j = p_212269_ - p_212270_; j <= p_212269_ + p_212270_; ++j) { -- if (structureplacement.m_212129_(this, p_212267_, i, j)) { +- if (structureplacement.isFeatureChunk(this, p_212267_, i, j)) { - return true; - } - } @@ -677,86 +677,86 @@ - } - } - -- private static BoundingBox m_187717_(ChunkAccess p_187718_) { -- ChunkPos chunkpos = p_187718_.m_7697_(); -- int i = chunkpos.m_45604_(); -- int j = chunkpos.m_45605_(); -- LevelHeightAccessor levelheightaccessor = p_187718_.m_183618_(); -- int k = levelheightaccessor.m_141937_() + 1; -- int l = levelheightaccessor.m_151558_() - 1; +- private static BoundingBox getWritableArea(ChunkAccess p_187718_) { +- ChunkPos chunkpos = p_187718_.getPos(); +- int i = chunkpos.getMinBlockX(); +- int j = chunkpos.getMinBlockZ(); +- LevelHeightAccessor levelheightaccessor = p_187718_.getHeightAccessorForGeneration(); +- int k = levelheightaccessor.getMinBuildHeight() + 1; +- int l = levelheightaccessor.getMaxBuildHeight() - 1; - return new BoundingBox(i, k, j, i + 15, l, j + 15); - } - -- public abstract void m_183621_(WorldGenRegion p_187697_, StructureFeatureManager p_187698_, ChunkAccess p_187699_); +- public abstract void buildSurface(WorldGenRegion p_187697_, StructureFeatureManager p_187698_, ChunkAccess p_187699_); - -- public abstract void m_6929_(WorldGenRegion p_62167_); +- public abstract void spawnOriginalMobs(WorldGenRegion p_62167_); - -- public int m_142051_(LevelHeightAccessor p_156157_) { +- public int getSpawnHeight(LevelHeightAccessor p_156157_) { - return 64; - } - -- public BiomeSource m_62218_() { -- return this.f_62138_; +- public BiomeSource getBiomeSource() { +- return this.runtimeBiomeSource; - } - -- public abstract int m_6331_(); +- public abstract int getGenDepth(); - -- public WeightedRandomList m_203315_(Holder p_204386_, StructureFeatureManager p_204387_, MobCategory p_204388_, BlockPos p_204389_) { -- Map, LongSet> map = p_204387_.m_207815_(p_204389_); +- public WeightedRandomList getMobsAt(Holder p_204386_, StructureFeatureManager p_204387_, MobCategory p_204388_, BlockPos p_204389_) { +- Map, LongSet> map = p_204387_.getAllStructuresAt(p_204389_); - - for(Entry, LongSet> entry : map.entrySet()) { - ConfiguredStructureFeature configuredstructurefeature = entry.getKey(); -- StructureSpawnOverride structurespawnoverride = configuredstructurefeature.f_209744_.get(p_204388_); +- StructureSpawnOverride structurespawnoverride = configuredstructurefeature.spawnOverrides.get(p_204388_); - if (structurespawnoverride != null) { - MutableBoolean mutableboolean = new MutableBoolean(false); -- Predicate predicate = structurespawnoverride.f_210043_() == StructureSpawnOverride.BoundingBoxType.PIECE ? (p_211631_) -> { -- return p_204387_.m_207788_(p_204389_, p_211631_); +- Predicate predicate = structurespawnoverride.boundingBox() == StructureSpawnOverride.BoundingBoxType.PIECE ? (p_211631_) -> { +- return p_204387_.structureHasPieceAt(p_204389_, p_211631_); - } : (p_211666_) -> { -- return p_211666_.m_73601_().m_71051_(p_204389_); +- return p_211666_.getBoundingBox().isInside(p_204389_); - }; -- p_204387_.m_207781_(configuredstructurefeature, entry.getValue(), (p_211692_) -> { +- p_204387_.fillStartsForFeature(configuredstructurefeature, entry.getValue(), (p_211692_) -> { - if (mutableboolean.isFalse() && predicate.test(p_211692_)) { - mutableboolean.setTrue(); - } - - }); - if (mutableboolean.isTrue()) { -- return structurespawnoverride.f_210044_(); +- return structurespawnoverride.spawns(); - } - } - } - -- return p_204386_.m_203334_().m_47518_().m_151798_(p_204388_); +- return p_204386_.value().getMobSettings().getMobs(p_204388_); - } - -- public static Stream> m_208044_(Registry> p_208045_, StructureFeature p_208046_) { -- return p_208045_.m_123024_().filter((p_211656_) -> { -- return p_211656_.f_65403_ == p_208046_; +- public static Stream> allConfigurations(Registry> p_208045_, StructureFeature p_208046_) { +- return p_208045_.stream().filter((p_211656_) -> { +- return p_211656_.feature == p_208046_; - }); - } - -- public void m_62199_(RegistryAccess p_62200_, StructureFeatureManager p_62201_, ChunkAccess p_62202_, StructureManager p_62203_, long p_62204_) { -- ChunkPos chunkpos = p_62202_.m_7697_(); -- SectionPos sectionpos = SectionPos.m_175562_(p_62202_); -- this.m_207969_().forEach((p_212264_) -> { -- StructurePlacement structureplacement = p_212264_.m_203334_().f_210004_(); -- List list = p_212264_.m_203334_().f_210003_(); +- public void createStructures(RegistryAccess p_62200_, StructureFeatureManager p_62201_, ChunkAccess p_62202_, StructureManager p_62203_, long p_62204_) { +- ChunkPos chunkpos = p_62202_.getPos(); +- SectionPos sectionpos = SectionPos.bottomOf(p_62202_); +- this.possibleStructureSets().forEach((p_212264_) -> { +- StructurePlacement structureplacement = p_212264_.value().placement(); +- List list = p_212264_.value().structures(); - - for(StructureSet.StructureSelectionEntry structureset$structureselectionentry : list) { -- StructureStart structurestart = p_62201_.m_207802_(sectionpos, structureset$structureselectionentry.f_210026_().m_203334_(), p_62202_); -- if (structurestart != null && structurestart.m_73603_()) { +- StructureStart structurestart = p_62201_.getStartForFeature(sectionpos, structureset$structureselectionentry.structure().value(), p_62202_); +- if (structurestart != null && structurestart.isValid()) { - return; - } - } - -- if (structureplacement.m_212129_(this, p_62204_, chunkpos.f_45578_, chunkpos.f_45579_)) { +- if (structureplacement.isFeatureChunk(this, p_62204_, chunkpos.x, chunkpos.z)) { - if (list.size() == 1) { -- this.m_208016_(list.get(0), p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos); +- this.tryGenerateStructure(list.get(0), p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos); + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + + for (ChunkPos chunkpos : list) { -+ blockpos$mutableblockpos.m_122178_( SectionPos.m_175554_( chunkpos.f_45578_, 8 ), 32, SectionPos.m_175554_( chunkpos.f_45579_, 8 ) ); -+ double d1 = blockpos$mutableblockpos.m_123331_( p_204383_ ); ++ blockpos$mutableblockpos.set( SectionPos.sectionToBlockCoord( chunkpos.x, 8 ), 32, SectionPos.sectionToBlockCoord( chunkpos.z, 8 ) ); ++ double d1 = blockpos$mutableblockpos.distSqr( p_204383_ ); + if (blockpos == null) { + blockpos = new BlockPos( blockpos$mutableblockpos ); + d0 = d1; @@ -771,8 +771,8 @@ + } + + @Nullable -+ private static Pair>> m_208059_(Set>> p_208060_, LevelReader p_208061_, StructureFeatureManager p_208062_, int p_208063_, int p_208064_, int p_208065_, boolean p_208066_, long p_208067_, RandomSpreadStructurePlacement p_208068_) { -+ int i = p_208068_.f_204973_(); ++ private static Pair>> getNearestGeneratedStructure(Set>> p_208060_, LevelReader p_208061_, StructureFeatureManager p_208062_, int p_208063_, int p_208064_, int p_208065_, boolean p_208066_, long p_208067_, RandomSpreadStructurePlacement p_208068_) { ++ int i = p_208068_.spacing(); + + for (int j = -p_208065_; j <= p_208065_; ++j) { + boolean flag = j == -p_208065_ || j == p_208065_; @@ -782,25 +782,25 @@ + if (flag || flag1) { + int l = p_208063_ + i * j; + int i1 = p_208064_ + i * k; -+ ChunkPos chunkpos = p_208068_.m_204991_( p_208067_, l, i1 ); ++ ChunkPos chunkpos = p_208068_.getPotentialFeatureChunk( p_208067_, l, i1 ); + + for (Holder> holder : p_208060_) { -+ StructureCheckResult structurecheckresult = p_208062_.m_207777_( chunkpos, holder.m_203334_(), p_208066_ ); ++ StructureCheckResult structurecheckresult = p_208062_.checkStructurePresence( chunkpos, holder.value(), p_208066_ ); + if (structurecheckresult != StructureCheckResult.START_NOT_PRESENT) { + if (!p_208066_ && structurecheckresult == StructureCheckResult.START_PRESENT) { -+ return Pair.of( StructureFeature.m_204766_( p_208068_, chunkpos ), holder ); ++ return Pair.of( StructureFeature.getLocatePos( p_208068_, chunkpos ), holder ); + } + -+ ChunkAccess chunkaccess = p_208061_.m_46819_( chunkpos.f_45578_, chunkpos.f_45579_, ChunkStatus.f_62315_ ); -+ StructureStart structurestart = p_208062_.m_207802_( SectionPos.m_175562_( chunkaccess ), holder.m_203334_(), chunkaccess ); -+ if (structurestart != null && structurestart.m_73603_()) { -+ if (p_208066_ && structurestart.m_73606_()) { -+ p_208062_.m_196674_( structurestart ); -+ return Pair.of( StructureFeature.m_204766_( p_208068_, structurestart.m_163625_() ), holder ); ++ ChunkAccess chunkaccess = p_208061_.getChunk( chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS ); ++ StructureStart structurestart = p_208062_.getStartForFeature( SectionPos.bottomOf( chunkaccess ), holder.value(), chunkaccess ); ++ if (structurestart != null && structurestart.isValid()) { ++ if (p_208066_ && structurestart.canBeReferenced()) { ++ p_208062_.addReference( structurestart ); ++ return Pair.of( StructureFeature.getLocatePos( p_208068_, structurestart.getChunkPos() ), holder ); + } + + if (!p_208066_) { -+ return Pair.of( StructureFeature.m_204766_( p_208068_, structurestart.m_163625_() ), holder ); ++ return Pair.of( StructureFeature.getLocatePos( p_208068_, structurestart.getChunkPos() ), holder ); + } + } + } @@ -815,18 +815,18 @@ + // CraftBukkit start + public void applyBiomeDecoration(WorldGenLevel generatoraccessseed, ChunkAccess ichunkaccess, StructureFeatureManager structuremanager, boolean vanilla) { + if (vanilla) { -+ m_183372_( generatoraccessseed, ichunkaccess, structuremanager ); ++ applyBiomeDecoration( generatoraccessseed, ichunkaccess, structuremanager ); + } + + org.bukkit.World world = generatoraccessseed.getMinecraftWorld().getWorld(); + // only call when a populator is present (prevents unnecessary entity conversion) + if (!world.getPopulators().isEmpty()) { -+ org.bukkit.craftbukkit.v1_18_R2.generator.CraftLimitedRegion limitedRegion = new org.bukkit.craftbukkit.v1_18_R2.generator.CraftLimitedRegion( generatoraccessseed, ichunkaccess.m_7697_() ); -+ int x = ichunkaccess.m_7697_().f_45578_; -+ int z = ichunkaccess.m_7697_().f_45579_; ++ org.bukkit.craftbukkit.v1_18_R2.generator.CraftLimitedRegion limitedRegion = new org.bukkit.craftbukkit.v1_18_R2.generator.CraftLimitedRegion( generatoraccessseed, ichunkaccess.getPos() ); ++ int x = ichunkaccess.getPos().x; ++ int z = ichunkaccess.getPos().z; + for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { -+ WorldgenRandom seededrandom = new WorldgenRandom( new LegacyRandomSource( generatoraccessseed.m_7328_() ) ); -+ seededrandom.m_64690_( generatoraccessseed.m_7328_(), x, z ); ++ WorldgenRandom seededrandom = new WorldgenRandom( new LegacyRandomSource( generatoraccessseed.getSeed() ) ); ++ seededrandom.setDecorationSeed( generatoraccessseed.getSeed(), x, z ); + populator.populate( world, seededrandom, x, z, limitedRegion ); + } + limitedRegion.saveEntities(); @@ -836,30 +836,30 @@ + } + + -+ public void m_183372_(WorldGenLevel p_187712_, ChunkAccess p_187713_, StructureFeatureManager p_187714_) { -+ ChunkPos chunkpos = p_187713_.m_7697_(); -+ if (!SharedConstants.m_183707_( chunkpos )) { -+ SectionPos sectionpos = SectionPos.m_123196_( chunkpos, p_187712_.m_151560_() ); -+ BlockPos blockpos = sectionpos.m_123249_(); -+ Registry> registry = p_187712_.m_5962_().m_175515_( Registry.f_122882_ ); -+ Map>> map = registry.m_123024_().collect( Collectors.groupingBy( (p_211653_) -> { -+ return p_211653_.f_65403_.m_67095_().ordinal(); ++ public void applyBiomeDecoration(WorldGenLevel p_187712_, ChunkAccess p_187713_, StructureFeatureManager p_187714_) { ++ ChunkPos chunkpos = p_187713_.getPos(); ++ if (!SharedConstants.debugVoidTerrain( chunkpos )) { ++ SectionPos sectionpos = SectionPos.of( chunkpos, p_187712_.getMinSection() ); ++ BlockPos blockpos = sectionpos.origin(); ++ Registry> registry = p_187712_.registryAccess().registryOrThrow( Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY ); ++ Map>> map = registry.stream().collect( Collectors.groupingBy( (p_211653_) -> { ++ return p_211653_.feature.step().ordinal(); + } ) ); -+ List list = this.f_62137_.m_186733_(); -+ WorldgenRandom worldgenrandom = new WorldgenRandom( new XoroshiroRandomSource( RandomSupport.m_189328_() ) ); -+ long i = worldgenrandom.m_64690_( p_187712_.m_7328_(), blockpos.m_123341_(), blockpos.m_123343_() ); ++ List list = this.biomeSource.featuresPerStep(); ++ WorldgenRandom worldgenrandom = new WorldgenRandom( new XoroshiroRandomSource( RandomSupport.seedUniquifier() ) ); ++ long i = worldgenrandom.setDecorationSeed( p_187712_.getSeed(), blockpos.getX(), blockpos.getZ() ); + Set set = new ObjectArraySet<>(); + if (this instanceof FlatLevelSource) { -+ this.f_62137_.m_207840_().stream().map( Holder::m_203334_ ).forEach( set::add ); ++ this.biomeSource.possibleBiomes().stream().map( Holder::value ).forEach( set::add ); } else { - ArrayList arraylist = new ArrayList<>(list.size()); - arraylist.addAll(list); - WorldgenRandom worldgenrandom = new WorldgenRandom(new LegacyRandomSource(0L)); -- worldgenrandom.m_190068_(p_62204_, chunkpos.f_45578_, chunkpos.f_45579_); +- worldgenrandom.setLargeFeatureSeed(p_62204_, chunkpos.x, chunkpos.z); - int i = 0; - - for(StructureSet.StructureSelectionEntry structureset$structureselectionentry1 : arraylist) { -- i += structureset$structureselectionentry1.f_210027_(); +- i += structureset$structureselectionentry1.weight(); - } - - while(!arraylist.isEmpty()) { @@ -867,7 +867,7 @@ - int k = 0; - - for(StructureSet.StructureSelectionEntry structureset$structureselectionentry2 : arraylist) { -- j -= structureset$structureselectionentry2.f_210027_(); +- j -= structureset$structureselectionentry2.weight(); - if (j < 0) { - break; - } @@ -876,12 +876,12 @@ - } - - StructureSet.StructureSelectionEntry structureset$structureselectionentry3 = arraylist.get(k); -- if (this.m_208016_(structureset$structureselectionentry3, p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos)) { +- if (this.tryGenerateStructure(structureset$structureselectionentry3, p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos)) { - return; - } - - arraylist.remove(k); -- i -= structureset$structureselectionentry3.f_210027_(); +- i -= structureset$structureselectionentry3.weight(); - } - - } @@ -889,64 +889,64 @@ - }); - } - -- private boolean m_208016_(StructureSet.StructureSelectionEntry p_208017_, StructureFeatureManager p_208018_, RegistryAccess p_208019_, StructureManager p_208020_, long p_208021_, ChunkAccess p_208022_, ChunkPos p_208023_, SectionPos p_208024_) { -- ConfiguredStructureFeature configuredstructurefeature = p_208017_.f_210026_().m_203334_(); -- int i = m_207976_(p_208018_, p_208022_, p_208024_, configuredstructurefeature); -- HolderSet holderset = configuredstructurefeature.m_209752_(); +- private boolean tryGenerateStructure(StructureSet.StructureSelectionEntry p_208017_, StructureFeatureManager p_208018_, RegistryAccess p_208019_, StructureManager p_208020_, long p_208021_, ChunkAccess p_208022_, ChunkPos p_208023_, SectionPos p_208024_) { +- ConfiguredStructureFeature configuredstructurefeature = p_208017_.structure().value(); +- int i = fetchReferences(p_208018_, p_208022_, p_208024_, configuredstructurefeature); +- HolderSet holderset = configuredstructurefeature.biomes(); - Predicate> predicate = (p_211672_) -> { -- return holderset.m_203333_(this.m_203427_(p_211672_)); +- return holderset.contains(this.adjustBiome(p_211672_)); - }; -- StructureStart structurestart = configuredstructurefeature.m_204707_(p_208019_, this, this.f_62137_, p_208020_, p_208021_, p_208023_, i, p_208022_, predicate); -- if (structurestart.m_73603_()) { -- p_208018_.m_207806_(p_208024_, configuredstructurefeature, structurestart, p_208022_); +- StructureStart structurestart = configuredstructurefeature.generate(p_208019_, this, this.biomeSource, p_208020_, p_208021_, p_208023_, i, p_208022_, predicate); +- if (structurestart.isValid()) { +- p_208018_.setStartForFeature(p_208024_, configuredstructurefeature, structurestart, p_208022_); - return true; - } else { - return false; - } - } - -- private static int m_207976_(StructureFeatureManager p_207977_, ChunkAccess p_207978_, SectionPos p_207979_, ConfiguredStructureFeature p_207980_) { -- StructureStart structurestart = p_207977_.m_207802_(p_207979_, p_207980_, p_207978_); -- return structurestart != null ? structurestart.m_73608_() : 0; +- private static int fetchReferences(StructureFeatureManager p_207977_, ChunkAccess p_207978_, SectionPos p_207979_, ConfiguredStructureFeature p_207980_) { +- StructureStart structurestart = p_207977_.getStartForFeature(p_207979_, p_207980_, p_207978_); +- return structurestart != null ? structurestart.getReferences() : 0; - } - -- protected Holder m_203427_(Holder p_204385_) { +- protected Holder adjustBiome(Holder p_204385_) { - return p_204385_; - } - -- public void m_62177_(WorldGenLevel p_62178_, StructureFeatureManager p_62179_, ChunkAccess p_62180_) { +- public void createReferences(WorldGenLevel p_62178_, StructureFeatureManager p_62179_, ChunkAccess p_62180_) { - int i = 8; -- ChunkPos chunkpos = p_62180_.m_7697_(); -- int j = chunkpos.f_45578_; -- int k = chunkpos.f_45579_; -- int l = chunkpos.m_45604_(); -- int i1 = chunkpos.m_45605_(); -- SectionPos sectionpos = SectionPos.m_175562_(p_62180_); +- ChunkPos chunkpos = p_62180_.getPos(); +- int j = chunkpos.x; +- int k = chunkpos.z; +- int l = chunkpos.getMinBlockX(); +- int i1 = chunkpos.getMinBlockZ(); +- SectionPos sectionpos = SectionPos.bottomOf(p_62180_); - - for(int j1 = j - 8; j1 <= j + 8; ++j1) { - for(int k1 = k - 8; k1 <= k + 8; ++k1) { -- long l1 = ChunkPos.m_45589_(j1, k1); +- long l1 = ChunkPos.asLong(j1, k1); - -- for(StructureStart structurestart : p_62178_.m_6325_(j1, k1).m_6633_().values()) { +- for(StructureStart structurestart : p_62178_.getChunk(j1, k1).getAllStarts().values()) { - try { -- if (structurestart.m_73603_() && structurestart.m_73601_().m_71019_(l, i1, l + 15, i1 + 15)) { -- p_62179_.m_207797_(sectionpos, structurestart.m_210081_(), l1, p_62180_); -- DebugPackets.m_133711_(p_62178_, structurestart); +- if (structurestart.isValid() && structurestart.getBoundingBox().intersects(l, i1, l + 15, i1 + 15)) { +- p_62179_.addReferenceForFeature(sectionpos, structurestart.getFeature(), l1, p_62180_); +- DebugPackets.sendStructurePacket(p_62178_, structurestart); - } - } catch (Exception exception) { -- CrashReport crashreport = CrashReport.m_127521_(exception, "Generating structure reference"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Structure"); -- Optional>> optional = p_62178_.m_5962_().m_6632_(Registry.f_122882_); -- crashreportcategory.m_128165_("Id", () -> { +- CrashReport crashreport = CrashReport.forThrowable(exception, "Generating structure reference"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Structure"); +- Optional>> optional = p_62178_.registryAccess().registry(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); +- crashreportcategory.setDetail("Id", () -> { - return optional.map((p_211661_) -> { -- return p_211661_.m_7981_(structurestart.m_210081_()).toString(); +- return p_211661_.getKey(structurestart.getFeature()).toString(); - }).orElse("UNKNOWN"); - }); -- crashreportcategory.m_128165_("Name", () -> { -- return Registry.f_122841_.m_7981_(structurestart.m_210081_().f_65403_).toString(); +- crashreportcategory.setDetail("Name", () -> { +- return Registry.STRUCTURE_FEATURE.getKey(structurestart.getFeature().feature).toString(); - }); -- crashreportcategory.m_128165_("Class", () -> { -- return structurestart.m_210081_().getClass().getCanonicalName(); +- crashreportcategory.setDetail("Class", () -> { +- return structurestart.getFeature().getClass().getCanonicalName(); - }); - throw new ReportedException(crashreport); - } @@ -956,89 +956,89 @@ - - } - -- public abstract CompletableFuture m_183489_(Executor p_187748_, Blender p_187749_, StructureFeatureManager p_187750_, ChunkAccess p_187751_); +- public abstract CompletableFuture fillFromNoise(Executor p_187748_, Blender p_187749_, StructureFeatureManager p_187750_, ChunkAccess p_187751_); - -- public abstract int m_6337_(); +- public abstract int getSeaLevel(); - -- public abstract int m_142062_(); +- public abstract int getMinY(); - -- public abstract int m_142647_(int p_156153_, int p_156154_, Heightmap.Types p_156155_, LevelHeightAccessor p_156156_); +- public abstract int getBaseHeight(int p_156153_, int p_156154_, Heightmap.Types p_156155_, LevelHeightAccessor p_156156_); - -- public abstract NoiseColumn m_141914_(int p_156150_, int p_156151_, LevelHeightAccessor p_156152_); +- public abstract NoiseColumn getBaseColumn(int p_156150_, int p_156151_, LevelHeightAccessor p_156152_); - -- public int m_156174_(int p_156175_, int p_156176_, Heightmap.Types p_156177_, LevelHeightAccessor p_156178_) { -- return this.m_142647_(p_156175_, p_156176_, p_156177_, p_156178_); +- public int getFirstFreeHeight(int p_156175_, int p_156176_, Heightmap.Types p_156177_, LevelHeightAccessor p_156178_) { +- return this.getBaseHeight(p_156175_, p_156176_, p_156177_, p_156178_); - } - -- public int m_156179_(int p_156180_, int p_156181_, Heightmap.Types p_156182_, LevelHeightAccessor p_156183_) { -- return this.m_142647_(p_156180_, p_156181_, p_156182_, p_156183_) - 1; +- public int getFirstOccupiedHeight(int p_156180_, int p_156181_, Heightmap.Types p_156182_, LevelHeightAccessor p_156183_) { +- return this.getBaseHeight(p_156180_, p_156181_, p_156182_, p_156183_) - 1; - } - -- public void m_211700_() { -- if (!this.f_207958_) { -- this.m_208097_(); -- this.f_207958_ = true; +- public void ensureStructuresGenerated() { +- if (!this.hasGeneratedPositions) { +- this.generatePositions(); +- this.hasGeneratedPositions = true; - } - - } - - @Nullable -- public List m_204380_(ConcentricRingsStructurePlacement p_204381_) { -- this.m_211700_(); -- CompletableFuture> completablefuture = this.f_204350_.get(p_204381_); +- public List getRingPositionsFor(ConcentricRingsStructurePlacement p_204381_) { +- this.ensureStructuresGenerated(); +- CompletableFuture> completablefuture = this.ringPositions.get(p_204381_); - return completablefuture != null ? completablefuture.join() : null; - } - -- private List m_208090_(Holder> p_208091_) { -- this.m_211700_(); -- return this.f_207957_.getOrDefault(p_208091_.m_203334_(), List.of()); +- private List getPlacementsForFeature(Holder> p_208091_) { +- this.ensureStructuresGenerated(); +- return this.placementsForFeature.getOrDefault(p_208091_.value(), List.of()); - } - -- public abstract void m_207076_(List p_208054_, BlockPos p_208055_); +- public abstract void addDebugScreenInfo(List p_208054_, BlockPos p_208055_); - - static { -- Registry.m_122961_(Registry.f_122890_, "noise", NoiseBasedChunkGenerator.f_64314_); -- Registry.m_122961_(Registry.f_122890_, "flat", FlatLevelSource.f_64164_); -- Registry.m_122961_(Registry.f_122890_, "debug", DebugLevelSource.f_64111_); -- f_211627_ = LogUtils.getLogger(); -- f_62136_ = Registry.f_122890_.m_194605_().dispatchStable(ChunkGenerator::m_6909_, Function.identity()); +- Registry.register(Registry.CHUNK_GENERATOR, "noise", NoiseBasedChunkGenerator.CODEC); +- Registry.register(Registry.CHUNK_GENERATOR, "flat", FlatLevelSource.CODEC); +- Registry.register(Registry.CHUNK_GENERATOR, "debug", DebugLevelSource.CODEC); +- LOGGER = LogUtils.getLogger(); +- CODEC = Registry.CHUNK_GENERATOR.byNameCodec().dispatchStable(ChunkGenerator::codec, Function.identity()); - } -+ ChunkPos.m_45596_( sectionpos.m_123251_(), 1 ).forEach( (p_211651_) -> { -+ ChunkAccess chunkaccess = p_187712_.m_6325_( p_211651_.f_45578_, p_211651_.f_45579_ ); ++ ChunkPos.rangeClosed( sectionpos.chunk(), 1 ).forEach( (p_211651_) -> { ++ ChunkAccess chunkaccess = p_187712_.getChunk( p_211651_.x, p_211651_.z ); + -+ for (LevelChunkSection levelchunksection : chunkaccess.m_7103_()) { -+ levelchunksection.m_188013_().m_196879_( (p_211688_) -> { -+ set.add( p_211688_.m_203334_() ); ++ for (LevelChunkSection levelchunksection : chunkaccess.getSections()) { ++ levelchunksection.getBiomes().getAll( (p_211688_) -> { ++ set.add( p_211688_.value() ); + } ); + } + + } ); -+ set.retainAll( this.f_62137_.m_207840_().stream().map( Holder::m_203334_ ).collect( Collectors.toSet() ) ); ++ set.retainAll( this.biomeSource.possibleBiomes().stream().map( Holder::value ).collect( Collectors.toSet() ) ); + } + + int j = list.size(); + + try { -+ Registry registry1 = p_187712_.m_5962_().m_175515_( Registry.f_194567_ ); ++ Registry registry1 = p_187712_.registryAccess().registryOrThrow( Registry.PLACED_FEATURE_REGISTRY ); + int i1 = Math.max( GenerationStep.Decoration.values().length, j ); + + for (int k = 0; k < i1; ++k) { + int l = 0; -+ if (p_187714_.m_47271_()) { ++ if (p_187714_.shouldGenerateFeatures()) { + for (ConfiguredStructureFeature configuredstructurefeature : map.getOrDefault( k, Collections.emptyList() )) { -+ worldgenrandom.m_190064_( i, l, k ); ++ worldgenrandom.setFeatureSeed( i, l, k ); + Supplier supplier = () -> { -+ return registry.m_7854_( configuredstructurefeature ).map( Object::toString ).orElseGet( configuredstructurefeature::toString ); ++ return registry.getResourceKey( configuredstructurefeature ).map( Object::toString ).orElseGet( configuredstructurefeature::toString ); + }; + + try { -+ p_187712_.m_183406_( supplier ); -+ p_187714_.m_207794_( sectionpos, configuredstructurefeature ).forEach( (p_211647_) -> { -+ p_211647_.m_7129_( p_187712_, p_187714_, this, worldgenrandom, m_187717_( p_187713_ ), chunkpos ); ++ p_187712_.setCurrentlyGenerating( supplier ); ++ p_187714_.startsForFeature( sectionpos, configuredstructurefeature ).forEach( (p_211647_) -> { ++ p_211647_.placeInChunk( p_187712_, p_187714_, this, worldgenrandom, getWritableArea( p_187713_ ), chunkpos ); + } ); + } catch (Exception exception) { -+ CrashReport crashreport1 = CrashReport.m_127521_( exception, "Feature placement" ); -+ crashreport1.m_127514_( "Feature" ).m_128165_( "Description", supplier::get ); ++ CrashReport crashreport1 = CrashReport.forThrowable( exception, "Feature placement" ); ++ crashreport1.addCategory( "Feature" ).setDetail( "Description", supplier::get ); + throw new ReportedException( crashreport1 ); + } + @@ -1050,12 +1050,12 @@ + IntSet intset = new IntArraySet(); + + for (Biome biome : set) { -+ List> list1 = biome.m_47536_().m_47818_(); ++ List> list1 = biome.getGenerationSettings().features(); + if (k < list1.size()) { + HolderSet holderset = list1.get( k ); + BiomeSource.StepFeatureData biomesource$stepfeaturedata1 = list.get( k ); -+ holderset.m_203614_().map( Holder::m_203334_ ).forEach( (p_211682_) -> { -+ intset.add( biomesource$stepfeaturedata1.f_196678_().applyAsInt( p_211682_ ) ); ++ holderset.stream().map( Holder::value ).forEach( (p_211682_) -> { ++ intset.add( biomesource$stepfeaturedata1.indexMapping().applyAsInt( p_211682_ ) ); + } ); + } + } @@ -1067,43 +1067,43 @@ + + for (int k1 = 0; k1 < j1; ++k1) { + int l1 = aint[k1]; -+ PlacedFeature placedfeature = biomesource$stepfeaturedata.f_196677_().get( l1 ); ++ PlacedFeature placedfeature = biomesource$stepfeaturedata.features().get( l1 ); + Supplier supplier1 = () -> { -+ return registry1.m_7854_( placedfeature ).map( Object::toString ).orElseGet( placedfeature::toString ); ++ return registry1.getResourceKey( placedfeature ).map( Object::toString ).orElseGet( placedfeature::toString ); + }; -+ worldgenrandom.m_190064_( i, l1, k ); ++ worldgenrandom.setFeatureSeed( i, l1, k ); + + try { -+ p_187712_.m_183406_( supplier1 ); -+ placedfeature.m_191806_( p_187712_, this, worldgenrandom, blockpos ); ++ p_187712_.setCurrentlyGenerating( supplier1 ); ++ placedfeature.placeWithBiomeCheck( p_187712_, this, worldgenrandom, blockpos ); + } catch (Exception exception1) { -+ CrashReport crashreport2 = CrashReport.m_127521_( exception1, "Feature placement" ); -+ crashreport2.m_127514_( "Feature" ).m_128165_( "Description", supplier1::get ); ++ CrashReport crashreport2 = CrashReport.forThrowable( exception1, "Feature placement" ); ++ crashreport2.addCategory( "Feature" ).setDetail( "Description", supplier1::get ); + throw new ReportedException( crashreport2 ); + } + } + } + } + -+ p_187712_.m_183406_( (Supplier) null ); ++ p_187712_.setCurrentlyGenerating( (Supplier) null ); + } catch (Exception exception2) { -+ CrashReport crashreport = CrashReport.m_127521_( exception2, "Biome decoration" ); -+ crashreport.m_127514_( "Generation" ).m_128159_( "CenterX", chunkpos.f_45578_ ).m_128159_( "CenterZ", chunkpos.f_45579_ ).m_128159_( "Seed", i ); ++ CrashReport crashreport = CrashReport.forThrowable( exception2, "Biome decoration" ); ++ crashreport.addCategory( "Generation" ).setDetail( "CenterX", chunkpos.x ).setDetail( "CenterZ", chunkpos.z ).setDetail( "Seed", i ); + throw new ReportedException( crashreport ); + } + } + } + -+ public boolean m_212265_(ResourceKey p_212266_, long p_212267_, int p_212268_, int p_212269_, int p_212270_) { -+ StructureSet structureset = this.f_207955_.m_6246_( p_212266_ ); ++ public boolean hasFeatureChunkInRange(ResourceKey p_212266_, long p_212267_, int p_212268_, int p_212269_, int p_212270_) { ++ StructureSet structureset = this.structureSets.get( p_212266_ ); + if (structureset == null) { + return false; + } else { -+ StructurePlacement structureplacement = structureset.f_210004_(); ++ StructurePlacement structureplacement = structureset.placement(); + + for (int i = p_212268_ - p_212270_; i <= p_212268_ + p_212270_; ++i) { + for (int j = p_212269_ - p_212270_; j <= p_212269_ + p_212270_; ++j) { -+ if (structureplacement.m_212129_( this, p_212267_, i, j )) { ++ if (structureplacement.isFeatureChunk( this, p_212267_, i, j )) { + return true; + } + } @@ -1113,92 +1113,92 @@ + } + } + -+ private static BoundingBox m_187717_(ChunkAccess p_187718_) { -+ ChunkPos chunkpos = p_187718_.m_7697_(); -+ int i = chunkpos.m_45604_(); -+ int j = chunkpos.m_45605_(); -+ LevelHeightAccessor levelheightaccessor = p_187718_.m_183618_(); -+ int k = levelheightaccessor.m_141937_() + 1; -+ int l = levelheightaccessor.m_151558_() - 1; ++ private static BoundingBox getWritableArea(ChunkAccess p_187718_) { ++ ChunkPos chunkpos = p_187718_.getPos(); ++ int i = chunkpos.getMinBlockX(); ++ int j = chunkpos.getMinBlockZ(); ++ LevelHeightAccessor levelheightaccessor = p_187718_.getHeightAccessorForGeneration(); ++ int k = levelheightaccessor.getMinBuildHeight() + 1; ++ int l = levelheightaccessor.getMaxBuildHeight() - 1; + return new BoundingBox( i, k, j, i + 15, l, j + 15 ); + } + -+ public abstract void m_183621_(WorldGenRegion p_187697_, StructureFeatureManager p_187698_, ChunkAccess p_187699_); ++ public abstract void buildSurface(WorldGenRegion p_187697_, StructureFeatureManager p_187698_, ChunkAccess p_187699_); + -+ public abstract void m_6929_(WorldGenRegion p_62167_); ++ public abstract void spawnOriginalMobs(WorldGenRegion p_62167_); + -+ public int m_142051_(LevelHeightAccessor p_156157_) { ++ public int getSpawnHeight(LevelHeightAccessor p_156157_) { + return 64; + } + -+ public BiomeSource m_62218_() { -+ return this.f_62138_; ++ public BiomeSource getBiomeSource() { ++ return this.runtimeBiomeSource; + } + -+ public abstract int m_6331_(); ++ public abstract int getGenDepth(); + -+ public WeightedRandomList m_203315_(Holder p_204386_, StructureFeatureManager p_204387_, MobCategory p_204388_, BlockPos p_204389_) { -+ Map, LongSet> map = p_204387_.m_207815_( p_204389_ ); ++ public WeightedRandomList getMobsAt(Holder p_204386_, StructureFeatureManager p_204387_, MobCategory p_204388_, BlockPos p_204389_) { ++ Map, LongSet> map = p_204387_.getAllStructuresAt( p_204389_ ); + + for (Entry, LongSet> entry : map.entrySet()) { + ConfiguredStructureFeature configuredstructurefeature = entry.getKey(); -+ StructureSpawnOverride structurespawnoverride = configuredstructurefeature.f_209744_.get( p_204388_ ); ++ StructureSpawnOverride structurespawnoverride = configuredstructurefeature.spawnOverrides.get( p_204388_ ); + if (structurespawnoverride != null) { + MutableBoolean mutableboolean = new MutableBoolean( false ); -+ Predicate predicate = structurespawnoverride.f_210043_() == StructureSpawnOverride.BoundingBoxType.PIECE ? (p_211631_) -> { -+ return p_204387_.m_207788_( p_204389_, p_211631_ ); ++ Predicate predicate = structurespawnoverride.boundingBox() == StructureSpawnOverride.BoundingBoxType.PIECE ? (p_211631_) -> { ++ return p_204387_.structureHasPieceAt( p_204389_, p_211631_ ); + } : (p_211666_) -> { -+ return p_211666_.m_73601_().m_71051_( p_204389_ ); ++ return p_211666_.getBoundingBox().isInside( p_204389_ ); + }; -+ p_204387_.m_207781_( configuredstructurefeature, entry.getValue(), (p_211692_) -> { ++ p_204387_.fillStartsForFeature( configuredstructurefeature, entry.getValue(), (p_211692_) -> { + if (mutableboolean.isFalse() && predicate.test( p_211692_ )) { + mutableboolean.setTrue(); + } + + } ); + if (mutableboolean.isTrue()) { -+ return structurespawnoverride.f_210044_(); ++ return structurespawnoverride.spawns(); + } + } + } + -+ return p_204386_.m_203334_().m_47518_().m_151798_( p_204388_ ); ++ return p_204386_.value().getMobSettings().getMobs( p_204388_ ); + } + -+ public static Stream> m_208044_(Registry> p_208045_, StructureFeature p_208046_) { -+ return p_208045_.m_123024_().filter( (p_211656_) -> { -+ return p_211656_.f_65403_ == p_208046_; ++ public static Stream> allConfigurations(Registry> p_208045_, StructureFeature p_208046_) { ++ return p_208045_.stream().filter( (p_211656_) -> { ++ return p_211656_.feature == p_208046_; + } ); + } + -+ public void m_62199_(RegistryAccess p_62200_, StructureFeatureManager p_62201_, ChunkAccess p_62202_, StructureManager p_62203_, long p_62204_) { -+ ChunkPos chunkpos = p_62202_.m_7697_(); -+ SectionPos sectionpos = SectionPos.m_175562_( p_62202_ ); ++ public void createStructures(RegistryAccess p_62200_, StructureFeatureManager p_62201_, ChunkAccess p_62202_, StructureManager p_62203_, long p_62204_) { ++ ChunkPos chunkpos = p_62202_.getPos(); ++ SectionPos sectionpos = SectionPos.bottomOf( p_62202_ ); + // Spigot start + this.possibleStructureSetsSpigot().forEach( (p_212264_) -> { -+ StructurePlacement structureplacement = ((StructureSet) p_212264_).f_210004_(); -+ List list = ((StructureSet) p_212264_).f_210003_(); ++ StructurePlacement structureplacement = ((StructureSet) p_212264_).placement(); ++ List list = ((StructureSet) p_212264_).structures(); + // Spigot end + + for (StructureSet.StructureSelectionEntry structureset$structureselectionentry : list) { -+ StructureStart structurestart = p_62201_.m_207802_( sectionpos, structureset$structureselectionentry.f_210026_().m_203334_(), p_62202_ ); -+ if (structurestart != null && structurestart.m_73603_()) { ++ StructureStart structurestart = p_62201_.getStartForFeature( sectionpos, structureset$structureselectionentry.structure().value(), p_62202_ ); ++ if (structurestart != null && structurestart.isValid()) { + return; + } + } + -+ if (structureplacement.m_212129_( this, p_62204_, chunkpos.f_45578_, chunkpos.f_45579_ )) { ++ if (structureplacement.isFeatureChunk( this, p_62204_, chunkpos.x, chunkpos.z )) { + if (list.size() == 1) { -+ this.m_208016_( list.get( 0 ), p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos ); ++ this.tryGenerateStructure( list.get( 0 ), p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos ); + } else { + ArrayList arraylist = new ArrayList<>( list.size() ); + arraylist.addAll( list ); + WorldgenRandom worldgenrandom = new WorldgenRandom( new LegacyRandomSource( 0L ) ); -+ worldgenrandom.m_190068_( p_62204_, chunkpos.f_45578_, chunkpos.f_45579_ ); ++ worldgenrandom.setLargeFeatureSeed( p_62204_, chunkpos.x, chunkpos.z ); + int i = 0; + + for (StructureSet.StructureSelectionEntry structureset$structureselectionentry1 : arraylist) { -+ i += structureset$structureselectionentry1.f_210027_(); ++ i += structureset$structureselectionentry1.weight(); + } + + while (!arraylist.isEmpty()) { @@ -1206,7 +1206,7 @@ + int k = 0; + + for (StructureSet.StructureSelectionEntry structureset$structureselectionentry2 : arraylist) { -+ j -= structureset$structureselectionentry2.f_210027_(); ++ j -= structureset$structureselectionentry2.weight(); + if (j < 0) { + break; + } @@ -1215,12 +1215,12 @@ + } + + StructureSet.StructureSelectionEntry structureset$structureselectionentry3 = arraylist.get( k ); -+ if (this.m_208016_( structureset$structureselectionentry3, p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos )) { ++ if (this.tryGenerateStructure( structureset$structureselectionentry3, p_62201_, p_62200_, p_62203_, p_62204_, p_62202_, chunkpos, sectionpos )) { + return; + } + + arraylist.remove( k ); -+ i -= structureset$structureselectionentry3.f_210027_(); ++ i -= structureset$structureselectionentry3.weight(); + } + + } @@ -1228,64 +1228,64 @@ + } ); + } + -+ private boolean m_208016_(StructureSet.StructureSelectionEntry p_208017_, StructureFeatureManager p_208018_, RegistryAccess p_208019_, StructureManager p_208020_, long p_208021_, ChunkAccess p_208022_, ChunkPos p_208023_, SectionPos p_208024_) { -+ ConfiguredStructureFeature configuredstructurefeature = p_208017_.f_210026_().m_203334_(); -+ int i = m_207976_( p_208018_, p_208022_, p_208024_, configuredstructurefeature ); -+ HolderSet holderset = configuredstructurefeature.m_209752_(); ++ private boolean tryGenerateStructure(StructureSet.StructureSelectionEntry p_208017_, StructureFeatureManager p_208018_, RegistryAccess p_208019_, StructureManager p_208020_, long p_208021_, ChunkAccess p_208022_, ChunkPos p_208023_, SectionPos p_208024_) { ++ ConfiguredStructureFeature configuredstructurefeature = p_208017_.structure().value(); ++ int i = fetchReferences( p_208018_, p_208022_, p_208024_, configuredstructurefeature ); ++ HolderSet holderset = configuredstructurefeature.biomes(); + Predicate> predicate = (p_211672_) -> { -+ return holderset.m_203333_( this.m_203427_( p_211672_ ) ); ++ return holderset.contains( this.adjustBiome( p_211672_ ) ); + }; -+ StructureStart structurestart = configuredstructurefeature.m_204707_( p_208019_, this, this.f_62137_, p_208020_, p_208021_, p_208023_, i, p_208022_, predicate ); -+ if (structurestart.m_73603_()) { -+ p_208018_.m_207806_( p_208024_, configuredstructurefeature, structurestart, p_208022_ ); ++ StructureStart structurestart = configuredstructurefeature.generate( p_208019_, this, this.biomeSource, p_208020_, p_208021_, p_208023_, i, p_208022_, predicate ); ++ if (structurestart.isValid()) { ++ p_208018_.setStartForFeature( p_208024_, configuredstructurefeature, structurestart, p_208022_ ); + return true; + } else { + return false; + } + } + -+ private static int m_207976_(StructureFeatureManager p_207977_, ChunkAccess p_207978_, SectionPos p_207979_, ConfiguredStructureFeature p_207980_) { -+ StructureStart structurestart = p_207977_.m_207802_( p_207979_, p_207980_, p_207978_ ); -+ return structurestart != null ? structurestart.m_73608_() : 0; ++ private static int fetchReferences(StructureFeatureManager p_207977_, ChunkAccess p_207978_, SectionPos p_207979_, ConfiguredStructureFeature p_207980_) { ++ StructureStart structurestart = p_207977_.getStartForFeature( p_207979_, p_207980_, p_207978_ ); ++ return structurestart != null ? structurestart.getReferences() : 0; + } + -+ protected Holder m_203427_(Holder p_204385_) { ++ protected Holder adjustBiome(Holder p_204385_) { + return p_204385_; + } + -+ public void m_62177_(WorldGenLevel p_62178_, StructureFeatureManager p_62179_, ChunkAccess p_62180_) { ++ public void createReferences(WorldGenLevel p_62178_, StructureFeatureManager p_62179_, ChunkAccess p_62180_) { + int i = 8; -+ ChunkPos chunkpos = p_62180_.m_7697_(); -+ int j = chunkpos.f_45578_; -+ int k = chunkpos.f_45579_; -+ int l = chunkpos.m_45604_(); -+ int i1 = chunkpos.m_45605_(); -+ SectionPos sectionpos = SectionPos.m_175562_( p_62180_ ); ++ ChunkPos chunkpos = p_62180_.getPos(); ++ int j = chunkpos.x; ++ int k = chunkpos.z; ++ int l = chunkpos.getMinBlockX(); ++ int i1 = chunkpos.getMinBlockZ(); ++ SectionPos sectionpos = SectionPos.bottomOf( p_62180_ ); + + for (int j1 = j - 8; j1 <= j + 8; ++j1) { + for (int k1 = k - 8; k1 <= k + 8; ++k1) { -+ long l1 = ChunkPos.m_45589_( j1, k1 ); ++ long l1 = ChunkPos.asLong( j1, k1 ); + -+ for (StructureStart structurestart : p_62178_.m_6325_( j1, k1 ).m_6633_().values()) { ++ for (StructureStart structurestart : p_62178_.getChunk( j1, k1 ).getAllStarts().values()) { + try { -+ if (structurestart.m_73603_() && structurestart.m_73601_().m_71019_( l, i1, l + 15, i1 + 15 )) { -+ p_62179_.m_207797_( sectionpos, structurestart.m_210081_(), l1, p_62180_ ); -+ DebugPackets.m_133711_( p_62178_, structurestart ); ++ if (structurestart.isValid() && structurestart.getBoundingBox().intersects( l, i1, l + 15, i1 + 15 )) { ++ p_62179_.addReferenceForFeature( sectionpos, structurestart.getFeature(), l1, p_62180_ ); ++ DebugPackets.sendStructurePacket( p_62178_, structurestart ); + } + } catch (Exception exception) { -+ CrashReport crashreport = CrashReport.m_127521_( exception, "Generating structure reference" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Structure" ); -+ Optional>> optional = p_62178_.m_5962_().m_6632_( Registry.f_122882_ ); -+ crashreportcategory.m_128165_( "Id", () -> { ++ CrashReport crashreport = CrashReport.forThrowable( exception, "Generating structure reference" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Structure" ); ++ Optional>> optional = p_62178_.registryAccess().registry( Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY ); ++ crashreportcategory.setDetail( "Id", () -> { + return optional.map( (p_211661_) -> { -+ return p_211661_.m_7981_( structurestart.m_210081_() ).toString(); ++ return p_211661_.getKey( structurestart.getFeature() ).toString(); + } ).orElse( "UNKNOWN" ); + } ); -+ crashreportcategory.m_128165_( "Name", () -> { -+ return Registry.f_122841_.m_7981_( structurestart.m_210081_().f_65403_ ).toString(); ++ crashreportcategory.setDetail( "Name", () -> { ++ return Registry.STRUCTURE_FEATURE.getKey( structurestart.getFeature().feature ).toString(); + } ); -+ crashreportcategory.m_128165_( "Class", () -> { -+ return structurestart.m_210081_().getClass().getCanonicalName(); ++ crashreportcategory.setDetail( "Class", () -> { ++ return structurestart.getFeature().getClass().getCanonicalName(); + } ); + throw new ReportedException( crashreport ); + } @@ -1295,51 +1295,51 @@ + + } + -+ public abstract CompletableFuture m_183489_(Executor p_187748_, Blender p_187749_, StructureFeatureManager p_187750_, ChunkAccess p_187751_); ++ public abstract CompletableFuture fillFromNoise(Executor p_187748_, Blender p_187749_, StructureFeatureManager p_187750_, ChunkAccess p_187751_); + -+ public abstract int m_6337_(); ++ public abstract int getSeaLevel(); + -+ public abstract int m_142062_(); ++ public abstract int getMinY(); + -+ public abstract int m_142647_(int p_156153_, int p_156154_, Heightmap.Types p_156155_, LevelHeightAccessor p_156156_); ++ public abstract int getBaseHeight(int p_156153_, int p_156154_, Heightmap.Types p_156155_, LevelHeightAccessor p_156156_); + -+ public abstract NoiseColumn m_141914_(int p_156150_, int p_156151_, LevelHeightAccessor p_156152_); ++ public abstract NoiseColumn getBaseColumn(int p_156150_, int p_156151_, LevelHeightAccessor p_156152_); + -+ public int m_156174_(int p_156175_, int p_156176_, Heightmap.Types p_156177_, LevelHeightAccessor p_156178_) { -+ return this.m_142647_( p_156175_, p_156176_, p_156177_, p_156178_ ); ++ public int getFirstFreeHeight(int p_156175_, int p_156176_, Heightmap.Types p_156177_, LevelHeightAccessor p_156178_) { ++ return this.getBaseHeight( p_156175_, p_156176_, p_156177_, p_156178_ ); + } + -+ public int m_156179_(int p_156180_, int p_156181_, Heightmap.Types p_156182_, LevelHeightAccessor p_156183_) { -+ return this.m_142647_( p_156180_, p_156181_, p_156182_, p_156183_ ) - 1; ++ public int getFirstOccupiedHeight(int p_156180_, int p_156181_, Heightmap.Types p_156182_, LevelHeightAccessor p_156183_) { ++ return this.getBaseHeight( p_156180_, p_156181_, p_156182_, p_156183_ ) - 1; + } + -+ public void m_211700_() { -+ if (!this.f_207958_) { -+ this.m_208097_(); -+ this.f_207958_ = true; ++ public void ensureStructuresGenerated() { ++ if (!this.hasGeneratedPositions) { ++ this.generatePositions(); ++ this.hasGeneratedPositions = true; + } + + } + + @Nullable -+ public List m_204380_(ConcentricRingsStructurePlacement p_204381_) { -+ this.m_211700_(); -+ CompletableFuture> completablefuture = this.f_204350_.get( p_204381_ ); ++ public List getRingPositionsFor(ConcentricRingsStructurePlacement p_204381_) { ++ this.ensureStructuresGenerated(); ++ CompletableFuture> completablefuture = this.ringPositions.get( p_204381_ ); + return completablefuture != null ? completablefuture.join() : null; + } + -+ private List m_208090_(Holder> p_208091_) { -+ this.m_211700_(); -+ return this.f_207957_.getOrDefault( p_208091_.m_203334_(), List.of() ); ++ private List getPlacementsForFeature(Holder> p_208091_) { ++ this.ensureStructuresGenerated(); ++ return this.placementsForFeature.getOrDefault( p_208091_.value(), List.of() ); + } + -+ public abstract void m_207076_(List p_208054_, BlockPos p_208055_); ++ public abstract void addDebugScreenInfo(List p_208054_, BlockPos p_208055_); + + static { -+ Registry.m_122961_( Registry.f_122890_, "noise", NoiseBasedChunkGenerator.f_64314_ ); -+ Registry.m_122961_( Registry.f_122890_, "flat", FlatLevelSource.f_64164_ ); -+ Registry.m_122961_( Registry.f_122890_, "debug", DebugLevelSource.f_64111_ ); -+ f_211627_ = LogUtils.getLogger(); -+ f_62136_ = Registry.f_122890_.m_194605_().dispatchStable( ChunkGenerator::m_6909_, Function.identity() ); ++ Registry.register( Registry.CHUNK_GENERATOR, "noise", NoiseBasedChunkGenerator.CODEC ); ++ Registry.register( Registry.CHUNK_GENERATOR, "flat", FlatLevelSource.CODEC ); ++ Registry.register( Registry.CHUNK_GENERATOR, "debug", DebugLevelSource.CODEC ); ++ LOGGER = LogUtils.getLogger(); ++ CODEC = Registry.CHUNK_GENERATOR.byNameCodec().dispatchStable( ChunkGenerator::codec, Function.identity() ); + } } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch index 808d9ede..f3462a8f 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch @@ -6,6 +6,6 @@ -public class ChunkStatus { +public class ChunkStatus extends net.minecraftforge.registries.ForgeRegistryEntry { - public static final int f_187758_ = 8; - private static final EnumSet f_62327_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.WORLD_SURFACE_WG); - public static final EnumSet f_62328_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES); + public static final int MAX_STRUCTURE_DISTANCE = 8; + private static final EnumSet PRE_FEATURES = EnumSet.of(Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.WORLD_SURFACE_WG); + public static final EnumSet POST_FEATURES = EnumSet.of(Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES); 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 8ed94b7b..187ff81b 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -5,214 +5,214 @@ import org.slf4j.Logger; -public class LevelChunk extends ChunkAccess { -- static final Logger f_62771_ = LogUtils.getLogger(); -- private static final TickingBlockEntity f_156361_ = new TickingBlockEntity() { -- public void m_142224_() { +- static final Logger LOGGER = LogUtils.getLogger(); +- private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { +- public void tick() { - } - -- public boolean m_142220_() { +- public boolean isRemoved() { - return true; - } - -- public BlockPos m_142689_() { -- return BlockPos.f_121853_; +- public BlockPos getPos() { +- return BlockPos.ZERO; - } - -- public String m_142280_() { +- public String getType() { - return ""; - } - }; -- private final Map f_156362_ = Maps.newHashMap(); -- private boolean f_62775_; -- private boolean f_196848_ = false; -- public final Level f_62776_; +- private final Map tickersInLevel = Maps.newHashMap(); +- private boolean loaded; +- private boolean clientLightReady = false; +- public final Level level; - @Nullable -- private Supplier f_62790_; +- private Supplier fullStatus; - @Nullable -- private LevelChunk.PostLoadProcessor f_62791_; -- private final Int2ObjectMap f_156363_; -- private final LevelChunkTicks f_62784_; -- private final LevelChunkTicks f_187943_; +- private LevelChunk.PostLoadProcessor postLoad; +- private final Int2ObjectMap gameEventDispatcherSections; +- private final LevelChunkTicks blockTicks; +- private final LevelChunkTicks fluidTicks; - - public LevelChunk(Level p_187945_, ChunkPos p_187946_) { -- this(p_187945_, p_187946_, UpgradeData.f_63320_, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[])null, (LevelChunk.PostLoadProcessor)null, (BlendingData)null); +- this(p_187945_, p_187946_, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[])null, (LevelChunk.PostLoadProcessor)null, (BlendingData)null); - } - - public LevelChunk(Level p_196854_, ChunkPos p_196855_, UpgradeData p_196856_, LevelChunkTicks p_196857_, LevelChunkTicks p_196858_, long p_196859_, @Nullable LevelChunkSection[] p_196860_, @Nullable LevelChunk.PostLoadProcessor p_196861_, @Nullable BlendingData p_196862_) { -- super(p_196855_, p_196856_, p_196854_, p_196854_.m_5962_().m_175515_(Registry.f_122885_), p_196859_, p_196860_, p_196862_); -- this.f_62776_ = p_196854_; -- this.f_156363_ = new Int2ObjectOpenHashMap<>(); +- super(p_196855_, p_196856_, p_196854_, p_196854_.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), p_196859_, p_196860_, p_196862_); +- this.level = p_196854_; +- this.gameEventDispatcherSections = new Int2ObjectOpenHashMap<>(); - - for(Heightmap.Types heightmap$types : Heightmap.Types.values()) { -- if (ChunkStatus.f_62326_.m_62500_().contains(heightmap$types)) { -- this.f_187608_.put(heightmap$types, new Heightmap(this, heightmap$types)); +- if (ChunkStatus.FULL.heightmapsAfter().contains(heightmap$types)) { +- this.heightmaps.put(heightmap$types, new Heightmap(this, heightmap$types)); - } - } - -- this.f_62791_ = p_196861_; -- this.f_62784_ = p_196857_; -- this.f_187943_ = p_196858_; +- this.postLoad = p_196861_; +- this.blockTicks = p_196857_; +- this.fluidTicks = p_196858_; - } - - public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) { -- this(p_196850_, p_196851_.m_7697_(), p_196851_.m_7387_(), p_196851_.m_188181_(), p_196851_.m_188182_(), p_196851_.m_6319_(), p_196851_.m_7103_(), p_196852_, p_196851_.m_183407_()); +- this(p_196850_, p_196851_.getPos(), p_196851_.getUpgradeData(), p_196851_.unpackBlockTicks(), p_196851_.unpackFluidTicks(), p_196851_.getInhabitedTime(), p_196851_.getSections(), p_196852_, p_196851_.getBlendingData()); - -- for(BlockEntity blockentity : p_196851_.m_63292_().values()) { -- this.m_142169_(blockentity); +- for(BlockEntity blockentity : p_196851_.getBlockEntities().values()) { +- this.setBlockEntity(blockentity); - } - -- this.f_187609_.putAll(p_196851_.m_63294_()); +- this.pendingBlockEntities.putAll(p_196851_.getBlockEntityNbts()); - -- for(int i = 0; i < p_196851_.m_6720_().length; ++i) { -- this.f_187602_[i] = p_196851_.m_6720_()[i]; +- for(int i = 0; i < p_196851_.getPostProcessing().length; ++i) { +- this.postProcessing[i] = p_196851_.getPostProcessing()[i]; - } - -- this.m_8040_(p_196851_.m_6633_()); -- this.m_7946_(p_196851_.m_7049_()); +- this.setAllStarts(p_196851_.getAllStarts()); +- this.setAllReferences(p_196851_.getAllReferences()); - -- for(Entry entry : p_196851_.m_6890_()) { -- if (ChunkStatus.f_62326_.m_62500_().contains(entry.getKey())) { -- this.m_6511_(entry.getKey(), entry.getValue().m_64239_()); +- for(Entry entry : p_196851_.getHeightmaps()) { +- if (ChunkStatus.FULL.heightmapsAfter().contains(entry.getKey())) { +- this.setHeightmap(entry.getKey(), entry.getValue().getRawData()); - } - } - -- this.m_8094_(p_196851_.m_6332_()); -- this.f_187603_ = true; +- this.setLightCorrect(p_196851_.isLightCorrect()); +- this.unsaved = true; - } - -- public TickContainerAccess m_183531_() { -- return this.f_62784_; +- public TickContainerAccess getBlockTicks() { +- return this.blockTicks; - } - -- public TickContainerAccess m_183526_() { -- return this.f_187943_; +- public TickContainerAccess getFluidTicks() { +- return this.fluidTicks; - } - -- public ChunkAccess.TicksToSave m_183568_() { -- return new ChunkAccess.TicksToSave(this.f_62784_, this.f_187943_); +- public ChunkAccess.TicksToSave getTicksForSerialization() { +- return new ChunkAccess.TicksToSave(this.blockTicks, this.fluidTicks); - } - -- public GameEventDispatcher m_142336_(int p_156372_) { -- return this.f_156363_.computeIfAbsent(p_156372_, (p_156395_) -> { -- return new EuclideanGameEventDispatcher(this.f_62776_); +- public GameEventDispatcher getEventDispatcher(int p_156372_) { +- return this.gameEventDispatcherSections.computeIfAbsent(p_156372_, (p_156395_) -> { +- return new EuclideanGameEventDispatcher(this.level); - }); - } - -- public BlockState m_8055_(BlockPos p_62923_) { -- int i = p_62923_.m_123341_(); -- int j = p_62923_.m_123342_(); -- int k = p_62923_.m_123343_(); -- if (this.f_62776_.m_46659_()) { +- public BlockState getBlockState(BlockPos p_62923_) { +- int i = p_62923_.getX(); +- int j = p_62923_.getY(); +- int k = p_62923_.getZ(); +- if (this.level.isDebug()) { - BlockState blockstate = null; - if (j == 60) { -- blockstate = Blocks.f_50375_.m_49966_(); +- blockstate = Blocks.BARRIER.defaultBlockState(); - } - - if (j == 70) { -- blockstate = DebugLevelSource.m_64148_(i, k); +- blockstate = DebugLevelSource.getBlockStateFor(i, k); - } - -- return blockstate == null ? Blocks.f_50016_.m_49966_() : blockstate; +- return blockstate == null ? Blocks.AIR.defaultBlockState() : blockstate; - } else { - try { -- int l = this.m_151564_(j); -- if (l >= 0 && l < this.f_187612_.length) { -- LevelChunkSection levelchunksection = this.f_187612_[l]; -- if (!levelchunksection.m_188008_()) { -- return levelchunksection.m_62982_(i & 15, j & 15, k & 15); +- int l = this.getSectionIndex(j); +- if (l >= 0 && l < this.sections.length) { +- LevelChunkSection levelchunksection = this.sections[l]; +- if (!levelchunksection.hasOnlyAir()) { +- return levelchunksection.getBlockState(i & 15, j & 15, k & 15); - } - } - -- return Blocks.f_50016_.m_49966_(); +- return Blocks.AIR.defaultBlockState(); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Getting block state"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being got"); -- crashreportcategory.m_128165_("Location", () -> { -- return CrashReportCategory.m_178942_(this, i, j, k); +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting block state"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Block being got"); +- crashreportcategory.setDetail("Location", () -> { +- return CrashReportCategory.formatLocation(this, i, j, k); - }); - throw new ReportedException(crashreport); - } - } - } - -- public FluidState m_6425_(BlockPos p_62895_) { -- return this.m_62814_(p_62895_.m_123341_(), p_62895_.m_123342_(), p_62895_.m_123343_()); +- public FluidState getFluidState(BlockPos p_62895_) { +- return this.getFluidState(p_62895_.getX(), p_62895_.getY(), p_62895_.getZ()); - } - -- public FluidState m_62814_(int p_62815_, int p_62816_, int p_62817_) { +- public FluidState getFluidState(int p_62815_, int p_62816_, int p_62817_) { - try { -- int i = this.m_151564_(p_62816_); -- if (i >= 0 && i < this.f_187612_.length) { -- LevelChunkSection levelchunksection = this.f_187612_[i]; -- if (!levelchunksection.m_188008_()) { -- return levelchunksection.m_63007_(p_62815_ & 15, p_62816_ & 15, p_62817_ & 15); +- int i = this.getSectionIndex(p_62816_); +- if (i >= 0 && i < this.sections.length) { +- LevelChunkSection levelchunksection = this.sections[i]; +- if (!levelchunksection.hasOnlyAir()) { +- return levelchunksection.getFluidState(p_62815_ & 15, p_62816_ & 15, p_62817_ & 15); - } - } - -- return Fluids.f_76191_.m_76145_(); +- return Fluids.EMPTY.defaultFluidState(); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Getting fluid state"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being got"); -- crashreportcategory.m_128165_("Location", () -> { -- return CrashReportCategory.m_178942_(this, p_62815_, p_62816_, p_62817_); +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting fluid state"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Block being got"); +- crashreportcategory.setDetail("Location", () -> { +- return CrashReportCategory.formatLocation(this, p_62815_, p_62816_, p_62817_); - }); - throw new ReportedException(crashreport); - } - } - - @Nullable -- public BlockState m_6978_(BlockPos p_62865_, BlockState p_62866_, boolean p_62867_) { -- int i = p_62865_.m_123342_(); -- LevelChunkSection levelchunksection = this.m_183278_(this.m_151564_(i)); -- boolean flag = levelchunksection.m_188008_(); -- if (flag && p_62866_.m_60795_()) { +- public BlockState setBlockState(BlockPos p_62865_, BlockState p_62866_, boolean p_62867_) { +- int i = p_62865_.getY(); +- LevelChunkSection levelchunksection = this.getSection(this.getSectionIndex(i)); +- boolean flag = levelchunksection.hasOnlyAir(); +- if (flag && p_62866_.isAir()) { - return null; - } else { -- int j = p_62865_.m_123341_() & 15; +- int j = p_62865_.getX() & 15; - int k = i & 15; -- int l = p_62865_.m_123343_() & 15; -- BlockState blockstate = levelchunksection.m_62986_(j, k, l, p_62866_); +- int l = p_62865_.getZ() & 15; +- BlockState blockstate = levelchunksection.setBlockState(j, k, l, p_62866_); - if (blockstate == p_62866_) { - return null; - } else { -- Block block = p_62866_.m_60734_(); -- this.f_187608_.get(Heightmap.Types.MOTION_BLOCKING).m_64249_(j, i, l, p_62866_); -- this.f_187608_.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).m_64249_(j, i, l, p_62866_); -- this.f_187608_.get(Heightmap.Types.OCEAN_FLOOR).m_64249_(j, i, l, p_62866_); -- this.f_187608_.get(Heightmap.Types.WORLD_SURFACE).m_64249_(j, i, l, p_62866_); -- boolean flag1 = levelchunksection.m_188008_(); +- Block block = p_62866_.getBlock(); +- this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(j, i, l, p_62866_); +- this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(j, i, l, p_62866_); +- this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(j, i, l, p_62866_); +- this.heightmaps.get(Heightmap.Types.WORLD_SURFACE).update(j, i, l, p_62866_); +- boolean flag1 = levelchunksection.hasOnlyAir(); - if (flag != flag1) { -- this.f_62776_.m_7726_().m_7827_().m_75834_(p_62865_, flag1); +- this.level.getChunkSource().getLightEngine().updateSectionStatus(p_62865_, flag1); - } - -- boolean flag2 = blockstate.m_155947_(); -- if (!this.f_62776_.f_46443_) { -- blockstate.m_60753_(this.f_62776_, p_62865_, p_62866_, p_62867_); -- } else if (!blockstate.m_60713_(block) && flag2) { -- this.m_8114_(p_62865_); +- boolean flag2 = blockstate.hasBlockEntity(); +- if (!this.level.isClientSide) { +- blockstate.onRemove(this.level, p_62865_, p_62866_, p_62867_); +- } else if (!blockstate.is(block) && flag2) { +- this.removeBlockEntity(p_62865_); - } - -- if (!levelchunksection.m_62982_(j, k, l).m_60713_(block)) { +- if (!levelchunksection.getBlockState(j, k, l).is(block)) { - return null; - } else { -- if (!this.f_62776_.f_46443_) { -- p_62866_.m_60696_(this.f_62776_, p_62865_, blockstate, p_62867_); +- if (!this.level.isClientSide) { +- p_62866_.onPlace(this.level, p_62865_, blockstate, p_62867_); - } - -- if (p_62866_.m_155947_()) { -- BlockEntity blockentity = this.m_5685_(p_62865_, LevelChunk.EntityCreationType.CHECK); +- if (p_62866_.hasBlockEntity()) { +- BlockEntity blockentity = this.getBlockEntity(p_62865_, LevelChunk.EntityCreationType.CHECK); - if (blockentity == null) { -- blockentity = ((EntityBlock)block).m_142194_(p_62865_, p_62866_); +- blockentity = ((EntityBlock)block).newBlockEntity(p_62865_, p_62866_); - if (blockentity != null) { -- this.m_142170_(blockentity); +- this.addAndRegisterBlockEntity(blockentity); - } - } else { -- blockentity.m_155250_(p_62866_); -- this.m_156406_(blockentity); +- blockentity.setBlockState(p_62866_); +- this.updateBlockEntityTicker(blockentity); - } - } - -- this.f_187603_ = true; +- this.unsaved = true; - return blockstate; - } - } @@ -221,27 +221,27 @@ - - /** @deprecated */ - @Deprecated -- public void m_6286_(Entity p_62826_) { +- public void addEntity(Entity p_62826_) { - } - - @Nullable -- private BlockEntity m_62934_(BlockPos p_62935_) { -- BlockState blockstate = this.m_8055_(p_62935_); -- return !blockstate.m_155947_() ? null : ((EntityBlock)blockstate.m_60734_()).m_142194_(p_62935_, blockstate); +- private BlockEntity createBlockEntity(BlockPos p_62935_) { +- BlockState blockstate = this.getBlockState(p_62935_); +- return !blockstate.hasBlockEntity() ? null : ((EntityBlock)blockstate.getBlock()).newBlockEntity(p_62935_, blockstate); - } - - @Nullable -- public BlockEntity m_7702_(BlockPos p_62912_) { -- return this.m_5685_(p_62912_, LevelChunk.EntityCreationType.CHECK); +- public BlockEntity getBlockEntity(BlockPos p_62912_) { +- return this.getBlockEntity(p_62912_, LevelChunk.EntityCreationType.CHECK); - } - - @Nullable -- public BlockEntity m_5685_(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { -- BlockEntity blockentity = this.f_187610_.get(p_62868_); +- public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { +- BlockEntity blockentity = this.blockEntities.get(p_62868_); - if (blockentity == null) { -- CompoundTag compoundtag = this.f_187609_.remove(p_62868_); +- CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); - if (compoundtag != null) { -- BlockEntity blockentity1 = this.m_62870_(p_62868_, compoundtag); +- BlockEntity blockentity1 = this.promotePendingBlockEntity(p_62868_, compoundtag); - if (blockentity1 != null) { - return blockentity1; - } @@ -250,108 +250,108 @@ - - if (blockentity == null) { - if (p_62869_ == LevelChunk.EntityCreationType.IMMEDIATE) { -- blockentity = this.m_62934_(p_62868_); +- blockentity = this.createBlockEntity(p_62868_); - if (blockentity != null) { -- this.m_142170_(blockentity); +- this.addAndRegisterBlockEntity(blockentity); - } - } -- } else if (blockentity.m_58901_()) { -- this.f_187610_.remove(p_62868_); +- } else if (blockentity.isRemoved()) { +- this.blockEntities.remove(p_62868_); - return null; - } - - return blockentity; - } - -- public void m_142170_(BlockEntity p_156391_) { -- this.m_142169_(p_156391_); -- if (this.m_156370_()) { -- this.m_156404_(p_156391_); -- this.m_156406_(p_156391_); +- public void addAndRegisterBlockEntity(BlockEntity p_156391_) { +- this.setBlockEntity(p_156391_); +- if (this.isInLevel()) { +- this.addGameEventListener(p_156391_); +- this.updateBlockEntityTicker(p_156391_); - } - - } - -- private boolean m_156370_() { -- return this.f_62775_ || this.f_62776_.m_5776_(); +- private boolean isInLevel() { +- return this.loaded || this.level.isClientSide(); - } - -- boolean m_156410_(BlockPos p_156411_) { -- if (!this.f_62776_.m_6857_().m_61937_(p_156411_)) { +- boolean isTicking(BlockPos p_156411_) { +- if (!this.level.getWorldBorder().isWithinBounds(p_156411_)) { - return false; - } else { -- Level level = this.f_62776_; +- Level level = this.level; - if (!(level instanceof ServerLevel)) { + +public class LevelChunk extends ChunkAccess implements net.minecraftforge.common.capabilities.ICapabilityProviderImpl { -+ static final Logger f_62771_ = LogUtils.getLogger(); -+ private static final TickingBlockEntity f_156361_ = new TickingBlockEntity() { -+ public void m_142224_() { ++ static final Logger LOGGER = LogUtils.getLogger(); ++ private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { ++ public void tick() { + } + -+ public boolean m_142220_() { ++ public boolean isRemoved() { return true; - } else { - ServerLevel serverlevel = (ServerLevel)level; -- return this.m_6708_().m_140114_(ChunkHolder.FullChunkStatus.TICKING) && serverlevel.m_143319_(ChunkPos.m_151388_(p_156411_)); +- return this.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING) && serverlevel.areEntitiesLoaded(ChunkPos.asLong(p_156411_)); - } - } - } - -- public void m_142169_(BlockEntity p_156374_) { -- BlockPos blockpos = p_156374_.m_58899_(); -- if (this.m_8055_(blockpos).m_155947_()) { -- p_156374_.m_142339_(this.f_62776_); -- p_156374_.m_6339_(); -- BlockEntity blockentity = this.f_187610_.put(blockpos.m_7949_(), p_156374_); +- public void setBlockEntity(BlockEntity p_156374_) { +- BlockPos blockpos = p_156374_.getBlockPos(); +- if (this.getBlockState(blockpos).hasBlockEntity()) { +- p_156374_.setLevel(this.level); +- p_156374_.clearRemoved(); +- BlockEntity blockentity = this.blockEntities.put(blockpos.immutable(), p_156374_); - if (blockentity != null && blockentity != p_156374_) { -- blockentity.m_7651_(); +- blockentity.setRemoved(); - } - - } - } - - @Nullable -- public CompoundTag m_8051_(BlockPos p_62932_) { -- BlockEntity blockentity = this.m_7702_(p_62932_); -- if (blockentity != null && !blockentity.m_58901_()) { -- CompoundTag compoundtag1 = blockentity.m_187480_(); -- compoundtag1.m_128379_("keepPacked", false); +- public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_) { +- BlockEntity blockentity = this.getBlockEntity(p_62932_); +- if (blockentity != null && !blockentity.isRemoved()) { +- CompoundTag compoundtag1 = blockentity.saveWithFullMetadata(); +- compoundtag1.putBoolean("keepPacked", false); - return compoundtag1; - } else { -- CompoundTag compoundtag = this.f_187609_.get(p_62932_); +- CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); - if (compoundtag != null) { -- compoundtag = compoundtag.m_6426_(); -- compoundtag.m_128379_("keepPacked", true); +- compoundtag = compoundtag.copy(); +- compoundtag.putBoolean("keepPacked", true); - } - - return compoundtag; - } - } - -- public void m_8114_(BlockPos p_62919_) { -- if (this.m_156370_()) { -- BlockEntity blockentity = this.f_187610_.remove(p_62919_); +- public void removeBlockEntity(BlockPos p_62919_) { +- if (this.isInLevel()) { +- BlockEntity blockentity = this.blockEntities.remove(p_62919_); - if (blockentity != null) { -- this.m_156396_(blockentity); -- blockentity.m_7651_(); +- this.removeGameEventListener(blockentity); +- blockentity.setRemoved(); - } - } - -- this.m_156412_(p_62919_); +- this.removeBlockEntityTicker(p_62919_); - } - -- private void m_156396_(T p_156397_) { -- if (!this.f_62776_.f_46443_) { -- Block block = p_156397_.m_58900_().m_60734_(); +- private void removeGameEventListener(T p_156397_) { +- if (!this.level.isClientSide) { +- Block block = p_156397_.getBlockState().getBlock(); - if (block instanceof EntityBlock) { -- GameEventListener gameeventlistener = ((EntityBlock)block).m_142226_(this.f_62776_, p_156397_); +- GameEventListener gameeventlistener = ((EntityBlock)block).getListener(this.level, p_156397_); - if (gameeventlistener != null) { -- int i = SectionPos.m_123171_(p_156397_.m_58899_().m_123342_()); -- GameEventDispatcher gameeventdispatcher = this.m_142336_(i); -- gameeventdispatcher.m_142500_(gameeventlistener); -- if (gameeventdispatcher.m_142086_()) { -- this.f_156363_.remove(i); +- int i = SectionPos.blockToSectionCoord(p_156397_.getBlockPos().getY()); +- GameEventDispatcher gameeventdispatcher = this.getEventDispatcher(i); +- gameeventdispatcher.unregister(gameeventlistener); +- if (gameeventdispatcher.isEmpty()) { +- this.gameEventDispatcherSections.remove(i); - } - } - } @@ -359,128 +359,128 @@ - } - } - -- private void m_156412_(BlockPos p_156413_) { -- LevelChunk.RebindableTickingBlockEntityWrapper levelchunk$rebindabletickingblockentitywrapper = this.f_156362_.remove(p_156413_); +- private void removeBlockEntityTicker(BlockPos p_156413_) { +- LevelChunk.RebindableTickingBlockEntityWrapper levelchunk$rebindabletickingblockentitywrapper = this.tickersInLevel.remove(p_156413_); - if (levelchunk$rebindabletickingblockentitywrapper != null) { -- levelchunk$rebindabletickingblockentitywrapper.m_156449_(f_156361_); +- levelchunk$rebindabletickingblockentitywrapper.rebind(NULL_TICKER); - } - - } - -- public void m_62952_() { -- if (this.f_62791_ != null) { -- this.f_62791_.m_196866_(this); -- this.f_62791_ = null; +- public void runPostLoad() { +- if (this.postLoad != null) { +- this.postLoad.run(this); +- this.postLoad = null; - } - - } - -- public boolean m_6430_() { +- public boolean isEmpty() { - return false; - } - -- public void m_187971_(FriendlyByteBuf p_187972_, CompoundTag p_187973_, Consumer p_187974_) { -- this.m_187957_(); +- public void replaceWithPacketData(FriendlyByteBuf p_187972_, CompoundTag p_187973_, Consumer p_187974_) { +- this.clearAllBlockEntities(); - -- for(LevelChunkSection levelchunksection : this.f_187612_) { -- levelchunksection.m_63004_(p_187972_); +- for(LevelChunkSection levelchunksection : this.sections) { +- levelchunksection.read(p_187972_); - } - - for(Heightmap.Types heightmap$types : Heightmap.Types.values()) { -- String s = heightmap$types.m_64294_(); -- if (p_187973_.m_128425_(s, 12)) { -- this.m_6511_(heightmap$types, p_187973_.m_128467_(s)); +- String s = heightmap$types.getSerializationKey(); +- if (p_187973_.contains(s, 12)) { +- this.setHeightmap(heightmap$types, p_187973_.getLongArray(s)); - } - } - - p_187974_.accept((p_187968_, p_187969_, p_187970_) -> { -- BlockEntity blockentity = this.m_5685_(p_187968_, LevelChunk.EntityCreationType.IMMEDIATE); -- if (blockentity != null && p_187970_ != null && blockentity.m_58903_() == p_187969_) { -- blockentity.m_142466_(p_187970_); +- BlockEntity blockentity = this.getBlockEntity(p_187968_, LevelChunk.EntityCreationType.IMMEDIATE); +- if (blockentity != null && p_187970_ != null && blockentity.getType() == p_187969_) { +- blockentity.load(p_187970_); - } - - }); - } - -- public void m_62913_(boolean p_62914_) { -- this.f_62775_ = p_62914_; +- public void setLoaded(boolean p_62914_) { +- this.loaded = p_62914_; - } - -- public Level m_62953_() { -- return this.f_62776_; +- public Level getLevel() { +- return this.level; - } - -- public Map m_62954_() { -- return this.f_187610_; +- public Map getBlockEntities() { +- return this.blockEntities; - } - -- public Stream m_6267_() { -- return StreamSupport.stream(BlockPos.m_121976_(this.f_187604_.m_45604_(), this.m_141937_(), this.f_187604_.m_45605_(), this.f_187604_.m_45608_(), this.m_151558_() - 1, this.f_187604_.m_45609_()).spliterator(), false).filter((p_187990_) -> { -- return this.m_8055_(p_187990_).m_60791_() != 0; +- public Stream getLights() { +- return StreamSupport.stream(BlockPos.betweenClosed(this.chunkPos.getMinBlockX(), this.getMinBuildHeight(), this.chunkPos.getMinBlockZ(), this.chunkPos.getMaxBlockX(), this.getMaxBuildHeight() - 1, this.chunkPos.getMaxBlockZ()).spliterator(), false).filter((p_187990_) -> { +- return this.getBlockState(p_187990_).getLightEmission() != 0; - }); - } - -- public void m_62812_() { -- ChunkPos chunkpos = this.m_7697_(); -- -- for(int i = 0; i < this.f_187602_.length; ++i) { -- if (this.f_187602_[i] != null) { -- for(Short oshort : this.f_187602_[i]) { -- BlockPos blockpos = ProtoChunk.m_63227_(oshort, this.m_151568_(i), chunkpos); -- BlockState blockstate = this.m_8055_(blockpos); -- FluidState fluidstate = blockstate.m_60819_(); -- if (!fluidstate.m_76178_()) { -- fluidstate.m_76163_(this.f_62776_, blockpos); +- public void postProcessGeneration() { +- ChunkPos chunkpos = this.getPos(); +- +- for(int i = 0; i < this.postProcessing.length; ++i) { +- if (this.postProcessing[i] != null) { +- for(Short oshort : this.postProcessing[i]) { +- BlockPos blockpos = ProtoChunk.unpackOffsetCoordinates(oshort, this.getSectionYFromSectionIndex(i), chunkpos); +- BlockState blockstate = this.getBlockState(blockpos); +- FluidState fluidstate = blockstate.getFluidState(); +- if (!fluidstate.isEmpty()) { +- fluidstate.tick(this.level, blockpos); - } - -- if (!(blockstate.m_60734_() instanceof LiquidBlock)) { -- BlockState blockstate1 = Block.m_49931_(blockstate, this.f_62776_, blockpos); -- this.f_62776_.m_7731_(blockpos, blockstate1, 20); +- if (!(blockstate.getBlock() instanceof LiquidBlock)) { +- BlockState blockstate1 = Block.updateFromNeighbourShapes(blockstate, this.level, blockpos); +- this.level.setBlock(blockpos, blockstate1, 20); - } - } - -- this.f_187602_[i].clear(); +- this.postProcessing[i].clear(); - } - } - -- for(BlockPos blockpos1 : ImmutableList.copyOf(this.f_187609_.keySet())) { -- this.m_7702_(blockpos1); +- for(BlockPos blockpos1 : ImmutableList.copyOf(this.pendingBlockEntities.keySet())) { +- this.getBlockEntity(blockpos1); - } - -- this.f_187609_.clear(); -- this.f_187606_.m_63341_(this); +- this.pendingBlockEntities.clear(); +- this.upgradeData.upgrade(this); - } - - @Nullable -- private BlockEntity m_62870_(BlockPos p_62871_, CompoundTag p_62872_) { -- BlockState blockstate = this.m_8055_(p_62871_); +- private BlockEntity promotePendingBlockEntity(BlockPos p_62871_, CompoundTag p_62872_) { +- BlockState blockstate = this.getBlockState(p_62871_); - BlockEntity blockentity; -- if ("DUMMY".equals(p_62872_.m_128461_("id"))) { -- if (blockstate.m_155947_()) { -- blockentity = ((EntityBlock)blockstate.m_60734_()).m_142194_(p_62871_, blockstate); +- if ("DUMMY".equals(p_62872_.getString("id"))) { +- if (blockstate.hasBlockEntity()) { +- blockentity = ((EntityBlock)blockstate.getBlock()).newBlockEntity(p_62871_, blockstate); - } else { + } + -+ public BlockPos m_142689_() { -+ return BlockPos.f_121853_; ++ public BlockPos getPos() { ++ return BlockPos.ZERO; + } + -+ public String m_142280_() { ++ public String getType() { + return ""; + } + }; -+ private final Map f_156362_ = Maps.newHashMap(); -+ public boolean f_62775_; //Magma - private -> public -+ private boolean f_196848_ = false; -+ public final Level f_62776_; ++ private final Map tickersInLevel = Maps.newHashMap(); ++ public boolean loaded; //Magma - private -> public ++ private boolean clientLightReady = false; ++ public final Level level; + public final ServerLevel levelCB; + @Nullable -+ private Supplier f_62790_; ++ private Supplier fullStatus; + @Nullable -+ private LevelChunk.PostLoadProcessor f_62791_; -+ private final Int2ObjectMap f_156363_; -+ private final LevelChunkTicks f_62784_; -+ private final LevelChunkTicks f_187943_; ++ private LevelChunk.PostLoadProcessor postLoad; ++ private final Int2ObjectMap gameEventDispatcherSections; ++ private final LevelChunkTicks blockTicks; ++ private final LevelChunkTicks fluidTicks; + + // CraftBukkit start + public org.bukkit.Chunk bukkitChunk; @@ -497,32 +497,32 @@ + + + public LevelChunk(Level p_187945_, ChunkPos p_187946_) { -+ this( p_187945_, p_187946_, UpgradeData.f_63320_, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null ); ++ this( p_187945_, p_187946_, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null ); + } + + public LevelChunk(Level p_196854_, ChunkPos p_196855_, UpgradeData p_196856_, LevelChunkTicks p_196857_, LevelChunkTicks p_196858_, long p_196859_, @Nullable LevelChunkSection[] p_196860_, @Nullable LevelChunk.PostLoadProcessor p_196861_, @Nullable BlendingData p_196862_) { -+ super( p_196855_, p_196856_, p_196854_, p_196854_.m_5962_().m_175515_( Registry.f_122885_ ), p_196859_, p_196860_, p_196862_ ); -+ this.f_62776_ = p_196854_; ++ super( p_196855_, p_196856_, p_196854_, p_196854_.registryAccess().registryOrThrow( Registry.BIOME_REGISTRY ), p_196859_, p_196860_, p_196862_ ); ++ this.level = p_196854_; + + //Magma start - craftbukkit + ServerLevel levelCB = null; + try { -+ levelCB = (ServerLevel) f_62776_; ++ levelCB = (ServerLevel) level; + } catch (ClassCastException ignored) {} + this.levelCB = levelCB; + //Magma end + -+ this.f_156363_ = new Int2ObjectOpenHashMap<>(); ++ this.gameEventDispatcherSections = new Int2ObjectOpenHashMap<>(); + + for (Heightmap.Types heightmap$types : Heightmap.Types.values()) { -+ if (ChunkStatus.f_62326_.m_62500_().contains( heightmap$types )) { -+ this.f_187608_.put( heightmap$types, new Heightmap( this, heightmap$types ) ); ++ if (ChunkStatus.FULL.heightmapsAfter().contains( heightmap$types )) { ++ this.heightmaps.put( heightmap$types, new Heightmap( this, heightmap$types ) ); + } + } + -+ this.f_62791_ = p_196861_; -+ this.f_62784_ = p_196857_; -+ this.f_187943_ = p_196858_; ++ this.postLoad = p_196861_; ++ this.blockTicks = p_196857_; ++ this.fluidTicks = p_196858_; + this.capProvider.initInternal(); + // CraftBukkit start + if (p_196855_ != null) //Magma - a null chunk holder does not need a CraftChunk @@ -530,110 +530,110 @@ + } + + public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) { -+ this( p_196850_, p_196851_.m_7697_(), p_196851_.m_7387_(), p_196851_.m_188181_(), p_196851_.m_188182_(), p_196851_.m_6319_(), p_196851_.m_7103_(), p_196852_, p_196851_.m_183407_() ); ++ this( p_196850_, p_196851_.getPos(), p_196851_.getUpgradeData(), p_196851_.unpackBlockTicks(), p_196851_.unpackFluidTicks(), p_196851_.getInhabitedTime(), p_196851_.getSections(), p_196852_, p_196851_.getBlendingData() ); + -+ for (BlockEntity blockentity : p_196851_.m_63292_().values()) { -+ this.m_142169_( blockentity ); ++ for (BlockEntity blockentity : p_196851_.getBlockEntities().values()) { ++ this.setBlockEntity( blockentity ); + } + -+ this.f_187609_.putAll( p_196851_.m_63294_() ); ++ this.pendingBlockEntities.putAll( p_196851_.getBlockEntityNbts() ); + -+ for (int i = 0; i < p_196851_.m_6720_().length; ++i) { -+ this.f_187602_[i] = p_196851_.m_6720_()[i]; ++ for (int i = 0; i < p_196851_.getPostProcessing().length; ++i) { ++ this.postProcessing[i] = p_196851_.getPostProcessing()[i]; + } + -+ this.m_8040_( p_196851_.m_6633_() ); -+ this.m_7946_( p_196851_.m_7049_() ); ++ this.setAllStarts( p_196851_.getAllStarts() ); ++ this.setAllReferences( p_196851_.getAllReferences() ); + -+ for (Entry entry : p_196851_.m_6890_()) { -+ if (ChunkStatus.f_62326_.m_62500_().contains( entry.getKey() )) { -+ this.m_6511_( entry.getKey(), entry.getValue().m_64239_() ); ++ for (Entry entry : p_196851_.getHeightmaps()) { ++ if (ChunkStatus.FULL.heightmapsAfter().contains( entry.getKey() )) { ++ this.setHeightmap( entry.getKey(), entry.getValue().getRawData() ); + } + } + -+ this.m_8094_( p_196851_.m_6332_() ); -+ this.f_187603_ = true; ++ this.setLightCorrect( p_196851_.isLightCorrect() ); ++ this.unsaved = true; + this.needsDecoration = true; // CraftBukkit + // CraftBukkit start + this.persistentDataContainer = p_196851_.persistentDataContainer; // SPIGOT-6814: copy PDC to account for 1.17 to 1.18 chunk upgrading. + // CraftBukkit end + } + -+ public TickContainerAccess m_183531_() { -+ return this.f_62784_; ++ public TickContainerAccess getBlockTicks() { ++ return this.blockTicks; + } + -+ public TickContainerAccess m_183526_() { -+ return this.f_187943_; ++ public TickContainerAccess getFluidTicks() { ++ return this.fluidTicks; + } + -+ public ChunkAccess.TicksToSave m_183568_() { -+ return new ChunkAccess.TicksToSave( this.f_62784_, this.f_187943_ ); ++ public ChunkAccess.TicksToSave getTicksForSerialization() { ++ return new ChunkAccess.TicksToSave( this.blockTicks, this.fluidTicks ); + } + -+ public GameEventDispatcher m_142336_(int p_156372_) { -+ return this.f_156363_.computeIfAbsent( p_156372_, (p_156395_) -> { -+ return new EuclideanGameEventDispatcher( this.f_62776_ ); ++ public GameEventDispatcher getEventDispatcher(int p_156372_) { ++ return this.gameEventDispatcherSections.computeIfAbsent( p_156372_, (p_156395_) -> { ++ return new EuclideanGameEventDispatcher( this.level ); + } ); + } + -+ public BlockState m_8055_(BlockPos p_62923_) { -+ int i = p_62923_.m_123341_(); -+ int j = p_62923_.m_123342_(); -+ int k = p_62923_.m_123343_(); -+ if (this.f_62776_.m_46659_()) { ++ public BlockState getBlockState(BlockPos p_62923_) { ++ int i = p_62923_.getX(); ++ int j = p_62923_.getY(); ++ int k = p_62923_.getZ(); ++ if (this.level.isDebug()) { + BlockState blockstate = null; + if (j == 60) { -+ blockstate = Blocks.f_50375_.m_49966_(); ++ blockstate = Blocks.BARRIER.defaultBlockState(); + } + + if (j == 70) { -+ blockstate = DebugLevelSource.m_64148_( i, k ); ++ blockstate = DebugLevelSource.getBlockStateFor( i, k ); + } + -+ return blockstate == null ? Blocks.f_50016_.m_49966_() : blockstate; ++ return blockstate == null ? Blocks.AIR.defaultBlockState() : blockstate; + } else { + try { -+ int l = this.m_151564_( j ); -+ if (l >= 0 && l < this.f_187612_.length) { -+ LevelChunkSection levelchunksection = this.f_187612_[l]; -+ if (!levelchunksection.m_188008_()) { -+ return levelchunksection.m_62982_( i & 15, j & 15, k & 15 ); ++ int l = this.getSectionIndex( j ); ++ if (l >= 0 && l < this.sections.length) { ++ LevelChunkSection levelchunksection = this.sections[l]; ++ if (!levelchunksection.hasOnlyAir()) { ++ return levelchunksection.getBlockState( i & 15, j & 15, k & 15 ); + } + } + -+ return Blocks.f_50016_.m_49966_(); ++ return Blocks.AIR.defaultBlockState(); + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Getting block state" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Block being got" ); -+ crashreportcategory.m_128165_( "Location", () -> { -+ return CrashReportCategory.m_178942_( this, i, j, k ); ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Getting block state" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Block being got" ); ++ crashreportcategory.setDetail( "Location", () -> { ++ return CrashReportCategory.formatLocation( this, i, j, k ); + } ); + throw new ReportedException( crashreport ); + } + } + } + -+ public FluidState m_6425_(BlockPos p_62895_) { -+ return this.m_62814_( p_62895_.m_123341_(), p_62895_.m_123342_(), p_62895_.m_123343_() ); ++ public FluidState getFluidState(BlockPos p_62895_) { ++ return this.getFluidState( p_62895_.getX(), p_62895_.getY(), p_62895_.getZ() ); + } + -+ public FluidState m_62814_(int p_62815_, int p_62816_, int p_62817_) { ++ public FluidState getFluidState(int p_62815_, int p_62816_, int p_62817_) { + try { -+ int i = this.m_151564_( p_62816_ ); -+ if (i >= 0 && i < this.f_187612_.length) { -+ LevelChunkSection levelchunksection = this.f_187612_[i]; -+ if (!levelchunksection.m_188008_()) { -+ return levelchunksection.m_63007_( p_62815_ & 15, p_62816_ & 15, p_62817_ & 15 ); ++ int i = this.getSectionIndex( p_62816_ ); ++ if (i >= 0 && i < this.sections.length) { ++ LevelChunkSection levelchunksection = this.sections[i]; ++ if (!levelchunksection.hasOnlyAir()) { ++ return levelchunksection.getFluidState( p_62815_ & 15, p_62816_ & 15, p_62817_ & 15 ); + } + } + -+ return Fluids.f_76191_.m_76145_(); ++ return Fluids.EMPTY.defaultFluidState(); + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Getting fluid state" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Block being got" ); -+ crashreportcategory.m_128165_( "Location", () -> { -+ return CrashReportCategory.m_178942_( this, p_62815_, p_62816_, p_62817_ ); ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Getting fluid state" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Block being got" ); ++ crashreportcategory.setDetail( "Location", () -> { ++ return CrashReportCategory.formatLocation( this, p_62815_, p_62816_, p_62817_ ); + } ); + throw new ReportedException( crashreport ); + } @@ -642,59 +642,59 @@ + //Magma start - move to original method + private boolean setBlockState_doPlace = true; + @Nullable -+ public BlockState m_6978_(BlockPos p_62865_, BlockState p_62866_, boolean p_62867_) { -+ int i = p_62865_.m_123342_(); -+ LevelChunkSection levelchunksection = this.m_183278_( this.m_151564_( i ) ); -+ boolean flag = levelchunksection.m_188008_(); -+ if (flag && p_62866_.m_60795_()) { ++ public BlockState setBlockState(BlockPos p_62865_, BlockState p_62866_, boolean p_62867_) { ++ int i = p_62865_.getY(); ++ LevelChunkSection levelchunksection = this.getSection( this.getSectionIndex( i ) ); ++ boolean flag = levelchunksection.hasOnlyAir(); ++ if (flag && p_62866_.isAir()) { + return null; + } else { -+ int j = p_62865_.m_123341_() & 15; ++ int j = p_62865_.getX() & 15; + int k = i & 15; -+ int l = p_62865_.m_123343_() & 15; -+ BlockState blockstate = levelchunksection.m_62986_( j, k, l, p_62866_ ); ++ int l = p_62865_.getZ() & 15; ++ BlockState blockstate = levelchunksection.setBlockState( j, k, l, p_62866_ ); + if (blockstate == p_62866_) { + return null; + } else { -+ Block block = p_62866_.m_60734_(); -+ this.f_187608_.get( Heightmap.Types.MOTION_BLOCKING ).m_64249_( j, i, l, p_62866_ ); -+ this.f_187608_.get( Heightmap.Types.MOTION_BLOCKING_NO_LEAVES ).m_64249_( j, i, l, p_62866_ ); -+ this.f_187608_.get( Heightmap.Types.OCEAN_FLOOR ).m_64249_( j, i, l, p_62866_ ); -+ this.f_187608_.get( Heightmap.Types.WORLD_SURFACE ).m_64249_( j, i, l, p_62866_ ); -+ boolean flag1 = levelchunksection.m_188008_(); ++ Block block = p_62866_.getBlock(); ++ this.heightmaps.get( Heightmap.Types.MOTION_BLOCKING ).update( j, i, l, p_62866_ ); ++ this.heightmaps.get( Heightmap.Types.MOTION_BLOCKING_NO_LEAVES ).update( j, i, l, p_62866_ ); ++ this.heightmaps.get( Heightmap.Types.OCEAN_FLOOR ).update( j, i, l, p_62866_ ); ++ this.heightmaps.get( Heightmap.Types.WORLD_SURFACE ).update( j, i, l, p_62866_ ); ++ boolean flag1 = levelchunksection.hasOnlyAir(); + if (flag != flag1) { -+ this.f_62776_.m_7726_().m_7827_().m_75834_( p_62865_, flag1 ); ++ this.level.getChunkSource().getLightEngine().updateSectionStatus( p_62865_, flag1 ); + } + -+ boolean flag2 = blockstate.m_155947_(); -+ if (!this.f_62776_.f_46443_) { -+ blockstate.m_60753_( this.f_62776_, p_62865_, p_62866_, p_62867_ ); -+ } else if ((!blockstate.m_60713_( block ) || !p_62866_.m_155947_()) && flag2) { -+ this.m_8114_( p_62865_ ); ++ boolean flag2 = blockstate.hasBlockEntity(); ++ if (!this.level.isClientSide) { ++ blockstate.onRemove( this.level, p_62865_, p_62866_, p_62867_ ); ++ } else if ((!blockstate.is( block ) || !p_62866_.hasBlockEntity()) && flag2) { ++ this.removeBlockEntity( p_62865_ ); + } + -+ if (!levelchunksection.m_62982_( j, k, l ).m_60713_( block )) { ++ if (!levelchunksection.getBlockState( j, k, l ).is( block )) { + return null; + } else { + // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. -+ if (!this.f_62776_.f_46443_ && doPlace() && (!this.f_62776_.captureBlockSnapshots || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { -+ p_62866_.m_60696_( this.f_62776_, p_62865_, blockstate, p_62867_ ); ++ if (!this.level.isClientSide && doPlace() && (!this.level.captureBlockSnapshots || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { ++ p_62866_.onPlace( this.level, p_62865_, blockstate, p_62867_ ); + } + -+ if (p_62866_.m_155947_()) { -+ BlockEntity blockentity = this.m_5685_( p_62865_, LevelChunk.EntityCreationType.CHECK ); ++ if (p_62866_.hasBlockEntity()) { ++ BlockEntity blockentity = this.getBlockEntity( p_62865_, LevelChunk.EntityCreationType.CHECK ); + if (blockentity == null) { -+ blockentity = ((EntityBlock) block).m_142194_( p_62865_, p_62866_ ); ++ blockentity = ((EntityBlock) block).newBlockEntity( p_62865_, p_62866_ ); + if (blockentity != null) { -+ this.m_142170_( blockentity ); ++ this.addAndRegisterBlockEntity( blockentity ); + } + } else { -+ blockentity.m_155250_( p_62866_ ); -+ this.m_156406_( blockentity ); ++ blockentity.setBlockState( p_62866_ ); ++ this.updateBlockEntityTicker( blockentity ); + } + } + -+ this.f_187603_ = true; ++ this.unsaved = true; + return blockstate; + } + } @@ -710,7 +710,7 @@ + @Nullable + public BlockState setBlockState(BlockPos p_62865_, BlockState p_62866_, boolean p_62867_, boolean doPlace) { + setBlockState_doPlace = doPlace; -+ return m_6978_(p_62865_, p_62866_, p_62867_); ++ return setBlockState(p_62865_, p_62866_, p_62867_); + } + //Magma end + @@ -718,118 +718,118 @@ + * @deprecated + */ + @Deprecated -+ public void m_6286_(Entity p_62826_) { ++ public void addEntity(Entity p_62826_) { + } + + @Nullable -+ private BlockEntity m_62934_(BlockPos p_62935_) { -+ BlockState blockstate = this.m_8055_( p_62935_ ); -+ return !blockstate.m_155947_() ? null : ((EntityBlock) blockstate.m_60734_()).m_142194_( p_62935_, blockstate ); ++ private BlockEntity createBlockEntity(BlockPos p_62935_) { ++ BlockState blockstate = this.getBlockState( p_62935_ ); ++ return !blockstate.hasBlockEntity() ? null : ((EntityBlock) blockstate.getBlock()).newBlockEntity( p_62935_, blockstate ); + } + + @Nullable -+ public BlockEntity m_7702_(BlockPos p_62912_) { -+ return this.m_5685_( p_62912_, LevelChunk.EntityCreationType.CHECK ); ++ public BlockEntity getBlockEntity(BlockPos p_62912_) { ++ return this.getBlockEntity( p_62912_, LevelChunk.EntityCreationType.CHECK ); + } + + @Nullable -+ public BlockEntity m_5685_(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { ++ public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { + // CraftBukkit start -+ BlockEntity blockentity = f_62776_.capturedTileEntities.get( p_62868_ ); ++ BlockEntity blockentity = level.capturedTileEntities.get( p_62868_ ); + if (blockentity == null) { -+ blockentity = (BlockEntity) this.f_187610_.get( p_62868_ ); ++ blockentity = (BlockEntity) this.blockEntities.get( p_62868_ ); + } + // CraftBukkit end -+ if (blockentity != null && blockentity.m_58901_()) { -+ f_187610_.remove( p_62868_ ); ++ if (blockentity != null && blockentity.isRemoved()) { ++ blockEntities.remove( p_62868_ ); blockentity = null; -- f_62771_.warn("Tried to load a DUMMY block entity @ {} but found not block entity block {} at location", p_62871_, blockstate); +- LOGGER.warn("Tried to load a DUMMY block entity @ {} but found not block entity block {} at location", p_62871_, blockstate); - } - } else { -- blockentity = BlockEntity.m_155241_(p_62871_, blockstate, p_62872_); +- blockentity = BlockEntity.loadStatic(p_62871_, blockstate, p_62872_); - } - - if (blockentity != null) { -- blockentity.m_142339_(this.f_62776_); -- this.m_142170_(blockentity); +- blockentity.setLevel(this.level); +- this.addAndRegisterBlockEntity(blockentity); - } else { -- f_62771_.warn("Tried to load a block entity for block {} but failed at location {}", blockstate, p_62871_); +- LOGGER.warn("Tried to load a block entity for block {} but failed at location {}", blockstate, p_62871_); - } - - return blockentity; - } - -- public void m_187985_(long p_187986_) { -- this.f_62784_.m_193171_(p_187986_); -- this.f_187943_.m_193171_(p_187986_); +- public void unpackTicks(long p_187986_) { +- this.blockTicks.unpack(p_187986_); +- this.fluidTicks.unpack(p_187986_); - } - -- public void m_187958_(ServerLevel p_187959_) { -- p_187959_.m_183326_().m_193231_(this.f_187604_, this.f_62784_); -- p_187959_.m_183324_().m_193231_(this.f_187604_, this.f_187943_); +- public void registerTickContainerInLevel(ServerLevel p_187959_) { +- p_187959_.getBlockTicks().addContainer(this.chunkPos, this.blockTicks); +- p_187959_.getFluidTicks().addContainer(this.chunkPos, this.fluidTicks); - } - -- public void m_187979_(ServerLevel p_187980_) { -- p_187980_.m_183326_().m_193229_(this.f_187604_); -- p_187980_.m_183324_().m_193229_(this.f_187604_); +- public void unregisterTickContainerFromLevel(ServerLevel p_187980_) { +- p_187980_.getBlockTicks().removeContainer(this.chunkPos); +- p_187980_.getFluidTicks().removeContainer(this.chunkPos); - } - -- public ChunkStatus m_6415_() { -- return ChunkStatus.f_62326_; +- public ChunkStatus getStatus() { +- return ChunkStatus.FULL; - } - -- public ChunkHolder.FullChunkStatus m_6708_() { -- return this.f_62790_ == null ? ChunkHolder.FullChunkStatus.BORDER : this.f_62790_.get(); +- public ChunkHolder.FullChunkStatus getFullStatus() { +- return this.fullStatus == null ? ChunkHolder.FullChunkStatus.BORDER : this.fullStatus.get(); - } - -- public void m_62879_(Supplier p_62880_) { -- this.f_62790_ = p_62880_; +- public void setFullStatus(Supplier p_62880_) { +- this.fullStatus = p_62880_; - } - -- public void m_187957_() { -- this.f_187610_.values().forEach(BlockEntity::m_7651_); -- this.f_187610_.clear(); -- this.f_156362_.values().forEach((p_187966_) -> { -- p_187966_.m_156449_(f_156361_); +- public void clearAllBlockEntities() { +- this.blockEntities.values().forEach(BlockEntity::setRemoved); +- this.blockEntities.clear(); +- this.tickersInLevel.values().forEach((p_187966_) -> { +- p_187966_.rebind(NULL_TICKER); - }); -- this.f_156362_.clear(); +- this.tickersInLevel.clear(); - } - -- public void m_156369_() { -- this.f_187610_.values().forEach((p_187988_) -> { -- this.m_156404_(p_187988_); -- this.m_156406_(p_187988_); +- public void registerAllBlockEntitiesAfterLevelLoad() { +- this.blockEntities.values().forEach((p_187988_) -> { +- this.addGameEventListener(p_187988_); +- this.updateBlockEntityTicker(p_187988_); - }); - } - -- private void m_156404_(T p_156405_) { -- if (!this.f_62776_.f_46443_) { -- Block block = p_156405_.m_58900_().m_60734_(); +- private void addGameEventListener(T p_156405_) { +- if (!this.level.isClientSide) { +- Block block = p_156405_.getBlockState().getBlock(); - if (block instanceof EntityBlock) { -- GameEventListener gameeventlistener = ((EntityBlock)block).m_142226_(this.f_62776_, p_156405_); +- GameEventListener gameeventlistener = ((EntityBlock)block).getListener(this.level, p_156405_); - if (gameeventlistener != null) { -- GameEventDispatcher gameeventdispatcher = this.m_142336_(SectionPos.m_123171_(p_156405_.m_58899_().m_123342_())); -- gameeventdispatcher.m_142501_(gameeventlistener); +- GameEventDispatcher gameeventdispatcher = this.getEventDispatcher(SectionPos.blockToSectionCoord(p_156405_.getBlockPos().getY())); +- gameeventdispatcher.register(gameeventlistener); - } - } - - } - } - -- private void m_156406_(T p_156407_) { -- BlockState blockstate = p_156407_.m_58900_(); -- BlockEntityTicker blockentityticker = blockstate.m_155944_(this.f_62776_, (BlockEntityType)p_156407_.m_58903_()); +- private void updateBlockEntityTicker(T p_156407_) { +- BlockState blockstate = p_156407_.getBlockState(); +- BlockEntityTicker blockentityticker = blockstate.getTicker(this.level, (BlockEntityType)p_156407_.getType()); - if (blockentityticker == null) { -- this.m_156412_(p_156407_.m_58899_()); +- this.removeBlockEntityTicker(p_156407_.getBlockPos()); - } else { -- this.f_156362_.compute(p_156407_.m_58899_(), (p_187963_, p_187964_) -> { -- TickingBlockEntity tickingblockentity = this.m_156375_(p_156407_, blockentityticker); +- this.tickersInLevel.compute(p_156407_.getBlockPos(), (p_187963_, p_187964_) -> { +- TickingBlockEntity tickingblockentity = this.createTicker(p_156407_, blockentityticker); - if (p_187964_ != null) { -- p_187964_.m_156449_(tickingblockentity); +- p_187964_.rebind(tickingblockentity); - return p_187964_; -- } else if (this.m_156370_()) { +- } else if (this.isInLevel()) { - LevelChunk.RebindableTickingBlockEntityWrapper levelchunk$rebindabletickingblockentitywrapper = new LevelChunk.RebindableTickingBlockEntityWrapper(tickingblockentity); -- this.f_62776_.m_151525_(levelchunk$rebindabletickingblockentitywrapper); +- this.level.addBlockEntityTicker(levelchunk$rebindabletickingblockentitywrapper); - return levelchunk$rebindabletickingblockentitywrapper; - } else { - return null; @@ -839,49 +839,49 @@ - - } - -- private TickingBlockEntity m_156375_(T p_156376_, BlockEntityTicker p_156377_) { +- private TickingBlockEntity createTicker(T p_156376_, BlockEntityTicker p_156377_) { - return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); - } - -- public boolean m_196863_() { -- return this.f_196848_; +- public boolean isClientLightReady() { +- return this.clientLightReady; - } - -- public void m_196864_(boolean p_196865_) { -- this.f_196848_ = p_196865_; +- public void setClientLightReady(boolean p_196865_) { +- this.clientLightReady = p_196865_; - } - - class BoundTickingBlockEntity implements TickingBlockEntity { -- private final T f_156428_; -- private final BlockEntityTicker f_156429_; -- private boolean f_156430_; +- private final T blockEntity; +- private final BlockEntityTicker ticker; +- private boolean loggedInvalidBlockState; - - BoundTickingBlockEntity(T p_156433_, BlockEntityTicker p_156434_) { -- this.f_156428_ = p_156433_; -- this.f_156429_ = p_156434_; +- this.blockEntity = p_156433_; +- this.ticker = p_156434_; - } - -- public void m_142224_() { -- if (!this.f_156428_.m_58901_() && this.f_156428_.m_58898_()) { -- BlockPos blockpos = this.f_156428_.m_58899_(); -- if (LevelChunk.this.m_156410_(blockpos)) { +- public void tick() { +- if (!this.blockEntity.isRemoved() && this.blockEntity.hasLevel()) { +- BlockPos blockpos = this.blockEntity.getBlockPos(); +- if (LevelChunk.this.isTicking(blockpos)) { - try { -- ProfilerFiller profilerfiller = LevelChunk.this.f_62776_.m_46473_(); -- profilerfiller.m_6521_(this::m_142280_); -- BlockState blockstate = LevelChunk.this.m_8055_(blockpos); -- if (this.f_156428_.m_58903_().m_155262_(blockstate)) { -- this.f_156429_.m_155252_(LevelChunk.this.f_62776_, this.f_156428_.m_58899_(), blockstate, this.f_156428_); -- this.f_156430_ = false; -- } else if (!this.f_156430_) { -- this.f_156430_ = true; -- LevelChunk.f_62771_.warn("Block entity {} @ {} state {} invalid for ticking:", LogUtils.defer(this::m_142280_), LogUtils.defer(this::m_142689_), blockstate); +- ProfilerFiller profilerfiller = LevelChunk.this.level.getProfiler(); +- profilerfiller.push(this::getType); +- BlockState blockstate = LevelChunk.this.getBlockState(blockpos); +- if (this.blockEntity.getType().isValid(blockstate)) { +- this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockstate, this.blockEntity); +- this.loggedInvalidBlockState = false; +- } else if (!this.loggedInvalidBlockState) { +- this.loggedInvalidBlockState = true; +- LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", LogUtils.defer(this::getType), LogUtils.defer(this::getPos), blockstate); - } - -- profilerfiller.m_7238_(); +- profilerfiller.pop(); - } catch (Throwable throwable) { -- CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking block entity"); -- CrashReportCategory crashreportcategory = crashreport.m_127514_("Block entity being ticked"); -- this.f_156428_.m_58886_(crashreportcategory); +- CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); +- CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); +- this.blockEntity.fillCrashReportCategory(crashreportcategory); - throw new ReportedException(crashreport); - } - } @@ -889,20 +889,20 @@ - - } - -- public boolean m_142220_() { -- return this.f_156428_.m_58901_(); +- public boolean isRemoved() { +- return this.blockEntity.isRemoved(); - } - -- public BlockPos m_142689_() { -- return this.f_156428_.m_58899_(); +- public BlockPos getPos() { +- return this.blockEntity.getBlockPos(); - } - -- public String m_142280_() { -- return BlockEntityType.m_58954_(this.f_156428_.m_58903_()).toString(); +- public String getType() { +- return BlockEntityType.getKey(this.blockEntity.getType()).toString(); - } - - public String toString() { -- return "Level ticker for " + this.m_142280_() + "@" + this.m_142689_(); +- return "Level ticker for " + this.getType() + "@" + this.getPos(); - } - } - @@ -914,45 +914,45 @@ - - @FunctionalInterface - public interface PostLoadProcessor { -- void m_196866_(LevelChunk p_196867_); +- void run(LevelChunk p_196867_); - } - - class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { -- private TickingBlockEntity f_156444_; +- private TickingBlockEntity ticker; - - RebindableTickingBlockEntityWrapper(TickingBlockEntity p_156447_) { -- this.f_156444_ = p_156447_; +- this.ticker = p_156447_; - } - -- void m_156449_(TickingBlockEntity p_156450_) { -- this.f_156444_ = p_156450_; +- void rebind(TickingBlockEntity p_156450_) { +- this.ticker = p_156450_; - } - -- public void m_142224_() { -- this.f_156444_.m_142224_(); +- public void tick() { +- this.ticker.tick(); - } - -- public boolean m_142220_() { -- return this.f_156444_.m_142220_(); +- public boolean isRemoved() { +- return this.ticker.isRemoved(); - } - -- public BlockPos m_142689_() { -- return this.f_156444_.m_142689_(); +- public BlockPos getPos() { +- return this.ticker.getPos(); - } - -- public String m_142280_() { -- return this.f_156444_.m_142280_(); +- public String getType() { +- return this.ticker.getType(); - } - - public String toString() { -- return this.f_156444_.toString() + " "; +- return this.ticker.toString() + " "; - } - } + } + if (blockentity == null) { -+ CompoundTag compoundtag = this.f_187609_.remove( p_62868_ ); ++ CompoundTag compoundtag = this.pendingBlockEntities.remove( p_62868_ ); + if (compoundtag != null) { -+ BlockEntity blockentity1 = this.m_62870_( p_62868_, compoundtag ); ++ BlockEntity blockentity1 = this.promotePendingBlockEntity( p_62868_, compoundtag ); + if (blockentity1 != null) { + return blockentity1; + } @@ -961,9 +961,9 @@ + + if (blockentity == null) { + if (p_62869_ == LevelChunk.EntityCreationType.IMMEDIATE) { -+ blockentity = this.m_62934_( p_62868_ ); ++ blockentity = this.createBlockEntity( p_62868_ ); + if (blockentity != null) { -+ this.m_142170_( blockentity ); ++ this.addAndRegisterBlockEntity( blockentity ); + } + } + } @@ -971,106 +971,106 @@ + return blockentity; + } + -+ public void m_142170_(BlockEntity p_156391_) { -+ this.m_142169_( p_156391_ ); -+ if (this.m_156370_()) { -+ this.m_156404_( p_156391_ ); -+ this.m_156406_( p_156391_ ); ++ public void addAndRegisterBlockEntity(BlockEntity p_156391_) { ++ this.setBlockEntity( p_156391_ ); ++ if (this.isInLevel()) { ++ this.addGameEventListener( p_156391_ ); ++ this.updateBlockEntityTicker( p_156391_ ); + p_156391_.onLoad(); + } + + } + -+ private boolean m_156370_() { -+ return this.f_62775_ || this.f_62776_.m_5776_(); ++ private boolean isInLevel() { ++ return this.loaded || this.level.isClientSide(); + } + -+ boolean m_156410_(BlockPos p_156411_) { -+ if (!this.f_62776_.m_6857_().m_61937_( p_156411_ )) { ++ boolean isTicking(BlockPos p_156411_) { ++ if (!this.level.getWorldBorder().isWithinBounds( p_156411_ )) { + return false; + } else { -+ Level level = this.f_62776_; ++ Level level = this.level; + if (!(level instanceof ServerLevel)) { + return true; + } else { + ServerLevel serverlevel = (ServerLevel) level; -+ return this.m_6708_().m_140114_( ChunkHolder.FullChunkStatus.TICKING ) && serverlevel.m_143319_( ChunkPos.m_151388_( p_156411_ ) ); ++ return this.getFullStatus().isOrAfter( ChunkHolder.FullChunkStatus.TICKING ) && serverlevel.areEntitiesLoaded( ChunkPos.asLong( p_156411_ ) ); + } + } + } + -+ public void m_142169_(BlockEntity p_156374_) { -+ BlockPos blockpos = p_156374_.m_58899_(); -+ if (this.m_8055_( blockpos ).m_155947_()) { -+ p_156374_.m_142339_( this.f_62776_ ); -+ p_156374_.m_6339_(); -+ BlockEntity blockentity = this.f_187610_.put( blockpos.m_7949_(), p_156374_ ); ++ public void setBlockEntity(BlockEntity p_156374_) { ++ BlockPos blockpos = p_156374_.getBlockPos(); ++ if (this.getBlockState( blockpos ).hasBlockEntity()) { ++ p_156374_.setLevel( this.level ); ++ p_156374_.clearRemoved(); ++ BlockEntity blockentity = this.blockEntities.put( blockpos.immutable(), p_156374_ ); + if (blockentity != null && blockentity != p_156374_) { -+ blockentity.m_7651_(); ++ blockentity.setRemoved(); + } + // CraftBukkit start + } else { -+ System.out.println( "Attempted to place a tile entity (" + p_156374_ + ") at " + p_156374_.m_58899_().m_123341_() + "," + p_156374_.m_58899_().m_123342_() + "," + p_156374_.m_58899_().m_123343_() -+ + " (" + m_8055_( blockpos ) + ") where there was no entity tile!" ); -+ System.out.println( "Chunk coordinates: " + (this.f_187604_.f_45578_ * 16) + "," + (this.f_187604_.f_45579_ * 16) ); ++ System.out.println( "Attempted to place a tile entity (" + p_156374_ + ") at " + p_156374_.getBlockPos().getX() + "," + p_156374_.getBlockPos().getY() + "," + p_156374_.getBlockPos().getZ() ++ + " (" + getBlockState( blockpos ) + ") where there was no entity tile!" ); ++ System.out.println( "Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16) ); + new Exception().printStackTrace(); + // CraftBukkit end + } + } + + @Nullable -+ public CompoundTag m_8051_(BlockPos p_62932_) { -+ BlockEntity blockentity = this.m_7702_( p_62932_ ); -+ if (blockentity != null && !blockentity.m_58901_()) { ++ public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_) { ++ BlockEntity blockentity = this.getBlockEntity( p_62932_ ); ++ if (blockentity != null && !blockentity.isRemoved()) { + try { -+ CompoundTag compoundtag1 = blockentity.m_187480_(); -+ compoundtag1.m_128379_( "keepPacked", false ); ++ CompoundTag compoundtag1 = blockentity.saveWithFullMetadata(); ++ compoundtag1.putBoolean( "keepPacked", false ); + return compoundtag1; + } catch (Exception e) { -+ f_62771_.error( "A BlockEntity type {} has thrown an exception trying to write state. It will not persist, Report this to the mod author", blockentity.getClass().getName(), e ); ++ LOGGER.error( "A BlockEntity type {} has thrown an exception trying to write state. It will not persist, Report this to the mod author", blockentity.getClass().getName(), e ); + return null; + } + } else { -+ CompoundTag compoundtag = this.f_187609_.get( p_62932_ ); ++ CompoundTag compoundtag = this.pendingBlockEntities.get( p_62932_ ); + if (compoundtag != null) { -+ compoundtag = compoundtag.m_6426_(); -+ compoundtag.m_128379_( "keepPacked", true ); ++ compoundtag = compoundtag.copy(); ++ compoundtag.putBoolean( "keepPacked", true ); + } + + return compoundtag; + } + } + -+ public void m_8114_(BlockPos p_62919_) { -+ if (this.m_156370_()) { -+ BlockEntity blockentity = this.f_187610_.remove( p_62919_ ); ++ public void removeBlockEntity(BlockPos p_62919_) { ++ if (this.isInLevel()) { ++ BlockEntity blockentity = this.blockEntities.remove( p_62919_ ); + + // CraftBukkit start - SPIGOT-5561: Also remove from pending map -+ if (!f_187609_.isEmpty()) { -+ f_187609_.remove( p_62919_ ); ++ if (!pendingBlockEntities.isEmpty()) { ++ pendingBlockEntities.remove( p_62919_ ); + } + // CraftBukkit end + + if (blockentity != null) { -+ this.m_156396_( blockentity ); -+ blockentity.m_7651_(); ++ this.removeGameEventListener( blockentity ); ++ blockentity.setRemoved(); + } + } + -+ this.m_156412_( p_62919_ ); ++ this.removeBlockEntityTicker( p_62919_ ); + } + -+ private void m_156396_(T p_156397_) { -+ if (!this.f_62776_.f_46443_) { -+ Block block = p_156397_.m_58900_().m_60734_(); ++ private void removeGameEventListener(T p_156397_) { ++ if (!this.level.isClientSide) { ++ Block block = p_156397_.getBlockState().getBlock(); + if (block instanceof EntityBlock) { -+ GameEventListener gameeventlistener = ((EntityBlock) block).m_142226_( this.f_62776_, p_156397_ ); ++ GameEventListener gameeventlistener = ((EntityBlock) block).getListener( this.level, p_156397_ ); + if (gameeventlistener != null) { -+ int i = SectionPos.m_123171_( p_156397_.m_58899_().m_123342_() ); -+ GameEventDispatcher gameeventdispatcher = this.m_142336_( i ); -+ gameeventdispatcher.m_142500_( gameeventlistener ); -+ if (gameeventdispatcher.m_142086_()) { -+ this.f_156363_.remove( i ); ++ int i = SectionPos.blockToSectionCoord( p_156397_.getBlockPos().getY() ); ++ GameEventDispatcher gameeventdispatcher = this.getEventDispatcher( i ); ++ gameeventdispatcher.unregister( gameeventlistener ); ++ if (gameeventdispatcher.isEmpty()) { ++ this.gameEventDispatcherSections.remove( i ); + } + } + } @@ -1078,25 +1078,25 @@ + } + } + -+ private void m_156412_(BlockPos p_156413_) { -+ LevelChunk.RebindableTickingBlockEntityWrapper levelchunk$rebindabletickingblockentitywrapper = this.f_156362_.remove( p_156413_ ); ++ private void removeBlockEntityTicker(BlockPos p_156413_) { ++ LevelChunk.RebindableTickingBlockEntityWrapper levelchunk$rebindabletickingblockentitywrapper = this.tickersInLevel.remove( p_156413_ ); + if (levelchunk$rebindabletickingblockentitywrapper != null) { -+ levelchunk$rebindabletickingblockentitywrapper.m_156449_( f_156361_ ); ++ levelchunk$rebindabletickingblockentitywrapper.rebind( NULL_TICKER ); + } + + } + -+ public void m_62952_() { -+ if (this.f_62791_ != null) { -+ this.f_62791_.m_196866_( this ); -+ this.f_62791_ = null; ++ public void runPostLoad() { ++ if (this.postLoad != null) { ++ this.postLoad.run( this ); ++ this.postLoad = null; + } + + } + + // CraftBukkit start + public void loadCallback() { -+ org.bukkit.Server server = this.f_62776_.getCraftServer(); ++ org.bukkit.Server server = this.level.getCraftServer(); + if (server != null) { + /* + * If it's a new world, the first few chunks are generated inside @@ -1105,23 +1105,23 @@ + */ + server.getPluginManager().callEvent( new org.bukkit.event.world.ChunkLoadEvent( this.bukkitChunk, this.needsDecoration ) ); + if (this.needsDecoration) { -+ try (co.aikar.timings.Timing ignored = this.f_62776_.timings.chunkLoadPopulate.startTiming()) { // Paper ++ try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper + this.needsDecoration = false; + java.util.Random random = new java.util.Random(); -+ ServerLevel level = ((ServerLevel) this.f_62776_); -+ random.setSeed( level.m_7328_() ); ++ ServerLevel level = ((ServerLevel) this.level); ++ random.setSeed( level.getSeed() ); + long xRand = random.nextLong() / 2L * 2L + 1L; + long zRand = random.nextLong() / 2L * 2L + 1L; -+ random.setSeed( (long) this.f_187604_.f_45578_ * xRand + (long) this.f_187604_.f_45579_ * zRand ^ level.m_7328_() ); ++ random.setSeed( (long) this.chunkPos.x * xRand + (long) this.chunkPos.z * zRand ^ level.getSeed() ); + org.bukkit.World world = level.getWorld(); + if (world != null) { -+ this.f_62776_.populating = true; ++ this.level.populating = true; + try { + for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { + populator.populate( world, random, bukkitChunk ); + } + } finally { -+ this.f_62776_.populating = false; ++ this.level.populating = false; + } + } + server.getPluginManager().callEvent( new org.bukkit.event.world.ChunkPopulateEvent( bukkitChunk ) ); @@ -1131,193 +1131,193 @@ + } + + public void unloadCallback() { -+ org.bukkit.Server server = this.f_62776_.getCraftServer(); -+ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent( this.bukkitChunk, this.m_6344_() ); ++ org.bukkit.Server server = this.level.getCraftServer(); ++ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent( this.bukkitChunk, this.isUnsaved() ); + server.getPluginManager().callEvent( unloadEvent ); + // note: saving can be prevented, but not forced if no saving is actually required + this.mustNotSave = !unloadEvent.isSaveChunk(); + } + + @Override -+ public boolean m_6344_() { -+ return super.m_6344_() && !this.mustNotSave; ++ public boolean isUnsaved() { ++ return super.isUnsaved() && !this.mustNotSave; + } +// CraftBukkit end + -+ public boolean m_6430_() { ++ public boolean isEmpty() { + return false; + } + -+ public void m_187971_(FriendlyByteBuf p_187972_, CompoundTag p_187973_, Consumer p_187974_) { -+ this.m_187957_(); ++ public void replaceWithPacketData(FriendlyByteBuf p_187972_, CompoundTag p_187973_, Consumer p_187974_) { ++ this.clearAllBlockEntities(); + -+ for (LevelChunkSection levelchunksection : this.f_187612_) { -+ levelchunksection.m_63004_( p_187972_ ); ++ for (LevelChunkSection levelchunksection : this.sections) { ++ levelchunksection.read( p_187972_ ); + } + + for (Heightmap.Types heightmap$types : Heightmap.Types.values()) { -+ String s = heightmap$types.m_64294_(); -+ if (p_187973_.m_128425_( s, 12 )) { -+ this.m_6511_( heightmap$types, p_187973_.m_128467_( s ) ); ++ String s = heightmap$types.getSerializationKey(); ++ if (p_187973_.contains( s, 12 )) { ++ this.setHeightmap( heightmap$types, p_187973_.getLongArray( s ) ); + } + } + + p_187974_.accept( (p_187968_, p_187969_, p_187970_) -> { -+ BlockEntity blockentity = this.m_5685_( p_187968_, LevelChunk.EntityCreationType.IMMEDIATE ); -+ if (blockentity != null && p_187970_ != null && blockentity.m_58903_() == p_187969_) { ++ BlockEntity blockentity = this.getBlockEntity( p_187968_, LevelChunk.EntityCreationType.IMMEDIATE ); ++ if (blockentity != null && p_187970_ != null && blockentity.getType() == p_187969_) { + blockentity.handleUpdateTag( p_187970_ ); + } + + } ); + } + -+ public void m_62913_(boolean p_62914_) { -+ this.f_62775_ = p_62914_; ++ public void setLoaded(boolean p_62914_) { ++ this.loaded = p_62914_; + } + -+ public Level m_62953_() { -+ return this.f_62776_; ++ public Level getLevel() { ++ return this.level; + } + -+ public Map m_62954_() { -+ return this.f_187610_; ++ public Map getBlockEntities() { ++ return this.blockEntities; + } + -+ public Stream m_6267_() { -+ return StreamSupport.stream( BlockPos.m_121976_( this.f_187604_.m_45604_(), this.m_141937_(), this.f_187604_.m_45605_(), this.f_187604_.m_45608_(), this.m_151558_() - 1, this.f_187604_.m_45609_() ).spliterator(), false ).filter( (p_187990_) -> { -+ return this.m_8055_( p_187990_ ).getLightEmission( m_62953_(), p_187990_ ) != 0; ++ public Stream getLights() { ++ return StreamSupport.stream( BlockPos.betweenClosed( this.chunkPos.getMinBlockX(), this.getMinBuildHeight(), this.chunkPos.getMinBlockZ(), this.chunkPos.getMaxBlockX(), this.getMaxBuildHeight() - 1, this.chunkPos.getMaxBlockZ() ).spliterator(), false ).filter( (p_187990_) -> { ++ return this.getBlockState( p_187990_ ).getLightEmission( getLevel(), p_187990_ ) != 0; + } ); + } + -+ public void m_62812_() { -+ ChunkPos chunkpos = this.m_7697_(); -+ -+ for (int i = 0; i < this.f_187602_.length; ++i) { -+ if (this.f_187602_[i] != null) { -+ for (Short oshort : this.f_187602_[i]) { -+ BlockPos blockpos = ProtoChunk.m_63227_( oshort, this.m_151568_( i ), chunkpos ); -+ BlockState blockstate = this.m_8055_( blockpos ); -+ FluidState fluidstate = blockstate.m_60819_(); -+ if (!fluidstate.m_76178_()) { -+ fluidstate.m_76163_( this.f_62776_, blockpos ); ++ public void postProcessGeneration() { ++ ChunkPos chunkpos = this.getPos(); ++ ++ for (int i = 0; i < this.postProcessing.length; ++i) { ++ if (this.postProcessing[i] != null) { ++ for (Short oshort : this.postProcessing[i]) { ++ BlockPos blockpos = ProtoChunk.unpackOffsetCoordinates( oshort, this.getSectionYFromSectionIndex( i ), chunkpos ); ++ BlockState blockstate = this.getBlockState( blockpos ); ++ FluidState fluidstate = blockstate.getFluidState(); ++ if (!fluidstate.isEmpty()) { ++ fluidstate.tick( this.level, blockpos ); + } + -+ if (!(blockstate.m_60734_() instanceof LiquidBlock)) { -+ BlockState blockstate1 = Block.m_49931_( blockstate, this.f_62776_, blockpos ); -+ this.f_62776_.m_7731_( blockpos, blockstate1, 20 ); ++ if (!(blockstate.getBlock() instanceof LiquidBlock)) { ++ BlockState blockstate1 = Block.updateFromNeighbourShapes( blockstate, this.level, blockpos ); ++ this.level.setBlock( blockpos, blockstate1, 20 ); + } + } + -+ this.f_187602_[i].clear(); ++ this.postProcessing[i].clear(); + } + } + -+ for (BlockPos blockpos1 : ImmutableList.copyOf( this.f_187609_.keySet() )) { -+ this.m_7702_( blockpos1 ); ++ for (BlockPos blockpos1 : ImmutableList.copyOf( this.pendingBlockEntities.keySet() )) { ++ this.getBlockEntity( blockpos1 ); + } + -+ this.f_187609_.clear(); -+ this.f_187606_.m_63341_( this ); ++ this.pendingBlockEntities.clear(); ++ this.upgradeData.upgrade( this ); + } + + @Nullable -+ private BlockEntity m_62870_(BlockPos p_62871_, CompoundTag p_62872_) { -+ BlockState blockstate = this.m_8055_( p_62871_ ); ++ private BlockEntity promotePendingBlockEntity(BlockPos p_62871_, CompoundTag p_62872_) { ++ BlockState blockstate = this.getBlockState( p_62871_ ); + BlockEntity blockentity; -+ if ("DUMMY".equals( p_62872_.m_128461_( "id" ) )) { -+ if (blockstate.m_155947_()) { -+ blockentity = ((EntityBlock) blockstate.m_60734_()).m_142194_( p_62871_, blockstate ); ++ if ("DUMMY".equals( p_62872_.getString( "id" ) )) { ++ if (blockstate.hasBlockEntity()) { ++ blockentity = ((EntityBlock) blockstate.getBlock()).newBlockEntity( p_62871_, blockstate ); + } else { + blockentity = null; -+ f_62771_.warn( "Tried to load a DUMMY block entity @ {} but found not block entity block {} at location", p_62871_, blockstate ); ++ LOGGER.warn( "Tried to load a DUMMY block entity @ {} but found not block entity block {} at location", p_62871_, blockstate ); + } + } else { -+ blockentity = BlockEntity.m_155241_( p_62871_, blockstate, p_62872_ ); ++ blockentity = BlockEntity.loadStatic( p_62871_, blockstate, p_62872_ ); + } + + if (blockentity != null) { -+ blockentity.m_142339_( this.f_62776_ ); -+ this.m_142170_( blockentity ); ++ blockentity.setLevel( this.level ); ++ this.addAndRegisterBlockEntity( blockentity ); + } else { -+ f_62771_.warn( "Tried to load a block entity for block {} but failed at location {}", blockstate, p_62871_ ); ++ LOGGER.warn( "Tried to load a block entity for block {} but failed at location {}", blockstate, p_62871_ ); + } + + return blockentity; + } + -+ public void m_187985_(long p_187986_) { -+ this.f_62784_.m_193171_( p_187986_ ); -+ this.f_187943_.m_193171_( p_187986_ ); ++ public void unpackTicks(long p_187986_) { ++ this.blockTicks.unpack( p_187986_ ); ++ this.fluidTicks.unpack( p_187986_ ); + } + -+ public void m_187958_(ServerLevel p_187959_) { -+ p_187959_.m_183326_().m_193231_( this.f_187604_, this.f_62784_ ); -+ p_187959_.m_183324_().m_193231_( this.f_187604_, this.f_187943_ ); ++ public void registerTickContainerInLevel(ServerLevel p_187959_) { ++ p_187959_.getBlockTicks().addContainer( this.chunkPos, this.blockTicks ); ++ p_187959_.getFluidTicks().addContainer( this.chunkPos, this.fluidTicks ); + } + -+ public void m_187979_(ServerLevel p_187980_) { -+ p_187980_.m_183326_().m_193229_( this.f_187604_ ); -+ p_187980_.m_183324_().m_193229_( this.f_187604_ ); ++ public void unregisterTickContainerFromLevel(ServerLevel p_187980_) { ++ p_187980_.getBlockTicks().removeContainer( this.chunkPos ); ++ p_187980_.getFluidTicks().removeContainer( this.chunkPos ); + } + -+ public ChunkStatus m_6415_() { -+ return ChunkStatus.f_62326_; ++ public ChunkStatus getStatus() { ++ return ChunkStatus.FULL; + } + -+ public ChunkHolder.FullChunkStatus m_6708_() { -+ return this.f_62790_ == null ? ChunkHolder.FullChunkStatus.BORDER : this.f_62790_.get(); ++ public ChunkHolder.FullChunkStatus getFullStatus() { ++ return this.fullStatus == null ? ChunkHolder.FullChunkStatus.BORDER : this.fullStatus.get(); + } + -+ public void m_62879_(Supplier p_62880_) { -+ this.f_62790_ = p_62880_; ++ public void setFullStatus(Supplier p_62880_) { ++ this.fullStatus = p_62880_; + } + -+ public void m_187957_() { -+ this.f_187610_.values().forEach( BlockEntity::onChunkUnloaded ); -+ this.f_187610_.values().forEach( BlockEntity::m_7651_ ); -+ this.f_187610_.clear(); -+ this.f_156362_.values().forEach( (p_187966_) -> { -+ p_187966_.m_156449_( f_156361_ ); ++ public void clearAllBlockEntities() { ++ this.blockEntities.values().forEach( BlockEntity::onChunkUnloaded ); ++ this.blockEntities.values().forEach( BlockEntity::setRemoved ); ++ this.blockEntities.clear(); ++ this.tickersInLevel.values().forEach( (p_187966_) -> { ++ p_187966_.rebind( NULL_TICKER ); + } ); -+ this.f_156362_.clear(); ++ this.tickersInLevel.clear(); + } + -+ public void m_156369_() { -+ this.f_62776_.addFreshBlockEntities( this.f_187610_.values() ); -+ this.f_187610_.values().forEach( (p_187988_) -> { -+ this.m_156404_( p_187988_ ); -+ this.m_156406_( p_187988_ ); ++ public void registerAllBlockEntitiesAfterLevelLoad() { ++ this.level.addFreshBlockEntities( this.blockEntities.values() ); ++ this.blockEntities.values().forEach( (p_187988_) -> { ++ this.addGameEventListener( p_187988_ ); ++ this.updateBlockEntityTicker( p_187988_ ); + } ); + } + -+ private void m_156404_(T p_156405_) { -+ if (!this.f_62776_.f_46443_) { -+ Block block = p_156405_.m_58900_().m_60734_(); ++ private void addGameEventListener(T p_156405_) { ++ if (!this.level.isClientSide) { ++ Block block = p_156405_.getBlockState().getBlock(); + if (block instanceof EntityBlock) { -+ GameEventListener gameeventlistener = ((EntityBlock) block).m_142226_( this.f_62776_, p_156405_ ); ++ GameEventListener gameeventlistener = ((EntityBlock) block).getListener( this.level, p_156405_ ); + if (gameeventlistener != null) { -+ GameEventDispatcher gameeventdispatcher = this.m_142336_( SectionPos.m_123171_( p_156405_.m_58899_().m_123342_() ) ); -+ gameeventdispatcher.m_142501_( gameeventlistener ); ++ GameEventDispatcher gameeventdispatcher = this.getEventDispatcher( SectionPos.blockToSectionCoord( p_156405_.getBlockPos().getY() ) ); ++ gameeventdispatcher.register( gameeventlistener ); + } + } + + } + } + -+ private void m_156406_(T p_156407_) { -+ BlockState blockstate = p_156407_.m_58900_(); -+ BlockEntityTicker blockentityticker = blockstate.m_155944_( this.f_62776_, (BlockEntityType) p_156407_.m_58903_() ); ++ private void updateBlockEntityTicker(T p_156407_) { ++ BlockState blockstate = p_156407_.getBlockState(); ++ BlockEntityTicker blockentityticker = blockstate.getTicker( this.level, (BlockEntityType) p_156407_.getType() ); + if (blockentityticker == null) { -+ this.m_156412_( p_156407_.m_58899_() ); ++ this.removeBlockEntityTicker( p_156407_.getBlockPos() ); + } else { -+ this.f_156362_.compute( p_156407_.m_58899_(), (p_187963_, p_187964_) -> { -+ TickingBlockEntity tickingblockentity = this.m_156375_( p_156407_, blockentityticker ); ++ this.tickersInLevel.compute( p_156407_.getBlockPos(), (p_187963_, p_187964_) -> { ++ TickingBlockEntity tickingblockentity = this.createTicker( p_156407_, blockentityticker ); + if (p_187964_ != null) { -+ p_187964_.m_156449_( tickingblockentity ); ++ p_187964_.rebind( tickingblockentity ); + return p_187964_; -+ } else if (this.m_156370_()) { ++ } else if (this.isInLevel()) { + LevelChunk.RebindableTickingBlockEntityWrapper levelchunk$rebindabletickingblockentitywrapper = new LevelChunk.RebindableTickingBlockEntityWrapper( tickingblockentity ); -+ this.f_62776_.m_151525_( levelchunk$rebindabletickingblockentitywrapper ); ++ this.level.addBlockEntityTicker( levelchunk$rebindabletickingblockentitywrapper ); + return levelchunk$rebindabletickingblockentitywrapper; + } else { + return null; @@ -1327,16 +1327,16 @@ + + } + -+ private TickingBlockEntity m_156375_(T p_156376_, BlockEntityTicker p_156377_) { ++ private TickingBlockEntity createTicker(T p_156376_, BlockEntityTicker p_156377_) { + return new LevelChunk.BoundTickingBlockEntity<>( p_156376_, p_156377_ ); + } + -+ public boolean m_196863_() { -+ return this.f_196848_; ++ public boolean isClientLightReady() { ++ return this.clientLightReady; + } + -+ public void m_196864_(boolean p_196865_) { -+ this.f_196848_ = p_196865_; ++ public void setClientLightReady(boolean p_196865_) { ++ this.clientLightReady = p_196865_; + } + + // FORGE START @@ -1371,48 +1371,48 @@ + // FORGE END + + class BoundTickingBlockEntity implements TickingBlockEntity { -+ private final T f_156428_; -+ private final BlockEntityTicker f_156429_; -+ private boolean f_156430_; ++ private final T blockEntity; ++ private final BlockEntityTicker ticker; ++ private boolean loggedInvalidBlockState; + + BoundTickingBlockEntity(T p_156433_, BlockEntityTicker p_156434_) { -+ this.f_156428_ = p_156433_; -+ this.f_156429_ = p_156434_; ++ this.blockEntity = p_156433_; ++ this.ticker = p_156434_; + } + -+ public void m_142224_() { -+ if (!this.f_156428_.m_58901_() && this.f_156428_.m_58898_()) { -+ BlockPos blockpos = this.f_156428_.m_58899_(); -+ if (LevelChunk.this.m_156410_( blockpos )) { ++ public void tick() { ++ if (!this.blockEntity.isRemoved() && this.blockEntity.hasLevel()) { ++ BlockPos blockpos = this.blockEntity.getBlockPos(); ++ if (LevelChunk.this.isTicking( blockpos )) { + try { -+ ProfilerFiller profilerfiller = LevelChunk.this.f_62776_.m_46473_(); -+ net.minecraftforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart( f_156428_ ); -+ profilerfiller.m_6521_( this::m_142280_ ); -+ this.f_156428_.tickTimer.startTiming(); // Spigot -+ BlockState blockstate = LevelChunk.this.m_8055_( blockpos ); -+ if (this.f_156428_.m_58903_().m_155262_( blockstate )) { -+ this.f_156429_.m_155252_( LevelChunk.this.f_62776_, this.f_156428_.m_58899_(), blockstate, this.f_156428_ ); -+ this.f_156430_ = false; -+ } else if (!this.f_156430_) { -+ this.f_156430_ = true; -+ LevelChunk.f_62771_.warn( "Block entity {} @ {} state {} invalid for ticking:", LogUtils.defer( this::m_142280_ ), LogUtils.defer( this::m_142689_ ), blockstate ); ++ ProfilerFiller profilerfiller = LevelChunk.this.level.getProfiler(); ++ net.minecraftforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart( blockEntity ); ++ profilerfiller.push( this::getType ); ++ this.blockEntity.tickTimer.startTiming(); // Spigot ++ BlockState blockstate = LevelChunk.this.getBlockState( blockpos ); ++ if (this.blockEntity.getType().isValid( blockstate )) { ++ this.ticker.tick( LevelChunk.this.level, this.blockEntity.getBlockPos(), blockstate, this.blockEntity ); ++ this.loggedInvalidBlockState = false; ++ } else if (!this.loggedInvalidBlockState) { ++ this.loggedInvalidBlockState = true; ++ LevelChunk.LOGGER.warn( "Block entity {} @ {} state {} invalid for ticking:", LogUtils.defer( this::getType ), LogUtils.defer( this::getPos ), blockstate ); + } + -+ profilerfiller.m_7238_(); ++ profilerfiller.pop(); + } catch (Throwable throwable) { -+ CrashReport crashreport = CrashReport.m_127521_( throwable, "Ticking block entity" ); -+ CrashReportCategory crashreportcategory = crashreport.m_127514_( "Block entity being ticked" ); -+ this.f_156428_.m_58886_( crashreportcategory ); ++ CrashReport crashreport = CrashReport.forThrowable( throwable, "Ticking block entity" ); ++ CrashReportCategory crashreportcategory = crashreport.addCategory( "Block entity being ticked" ); ++ this.blockEntity.fillCrashReportCategory( crashreportcategory ); + + if (net.minecraftforge.common.ForgeConfig.SERVER.removeErroringBlockEntities.get()) { -+ f_62771_.error( "{}", crashreport.m_127526_() ); -+ f_156428_.m_7651_(); -+ LevelChunk.this.m_8114_( f_156428_.m_58899_() ); ++ LOGGER.error( "{}", crashreport.getFriendlyReport() ); ++ blockEntity.setRemoved(); ++ LevelChunk.this.removeBlockEntity( blockEntity.getBlockPos() ); + } else + throw new ReportedException( crashreport ); + // Spigot start + } finally { -+ this.f_156428_.tickTimer.stopTiming(); ++ this.blockEntity.tickTimer.stopTiming(); + // Spigot end + } + } @@ -1420,20 +1420,20 @@ + + } + -+ public boolean m_142220_() { -+ return this.f_156428_.m_58901_(); ++ public boolean isRemoved() { ++ return this.blockEntity.isRemoved(); + } + -+ public BlockPos m_142689_() { -+ return this.f_156428_.m_58899_(); ++ public BlockPos getPos() { ++ return this.blockEntity.getBlockPos(); + } + -+ public String m_142280_() { -+ return BlockEntityType.m_58954_( this.f_156428_.m_58903_() ).toString(); ++ public String getType() { ++ return BlockEntityType.getKey( this.blockEntity.getType() ).toString(); + } + + public String toString() { -+ return "Level ticker for " + this.m_142280_() + "@" + this.m_142689_(); ++ return "Level ticker for " + this.getType() + "@" + this.getPos(); + } + } + @@ -1467,43 +1467,43 @@ + + @Override + public Level getWorldForge() { -+ return m_62953_(); ++ return getLevel(); + } + + @FunctionalInterface + public interface PostLoadProcessor { -+ void m_196866_(LevelChunk p_196867_); ++ void run(LevelChunk p_196867_); + } + + class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { -+ private TickingBlockEntity f_156444_; ++ private TickingBlockEntity ticker; + + RebindableTickingBlockEntityWrapper(TickingBlockEntity p_156447_) { -+ this.f_156444_ = p_156447_; ++ this.ticker = p_156447_; + } + -+ void m_156449_(TickingBlockEntity p_156450_) { -+ this.f_156444_ = p_156450_; ++ void rebind(TickingBlockEntity p_156450_) { ++ this.ticker = p_156450_; + } + -+ public void m_142224_() { -+ this.f_156444_.m_142224_(); ++ public void tick() { ++ this.ticker.tick(); + } + -+ public boolean m_142220_() { -+ return this.f_156444_.m_142220_(); ++ public boolean isRemoved() { ++ return this.ticker.isRemoved(); + } + -+ public BlockPos m_142689_() { -+ return this.f_156444_.m_142689_(); ++ public BlockPos getPos() { ++ return this.ticker.getPos(); + } + -+ public String m_142280_() { -+ return this.f_156444_.m_142280_(); ++ public String getType() { ++ return this.ticker.getType(); + } + + public String toString() { -+ return this.f_156444_.toString() + " "; ++ return this.ticker.toString() + " "; + } + } } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunkSection.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunkSection.java.patch index 0eaf5404..20efe323 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunkSection.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunkSection.java.patch @@ -7,7 +7,7 @@ + + // CraftBukkit start + public void setBiome(int i, int j, int k, Holder biome) { -+ this.f_187995_.m_156470_(i, j, k, biome); ++ this.biomes.set(i, j, k, biome); + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch index fcd0aaca..da23e6d2 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -5,6 +5,6 @@ public class PalettedContainer implements PaletteResize { + // TODO: forceBits-parametered setBits function. -C - private static final int f_188031_ = 0; - private final PaletteResize f_63070_ = (p_63139_, p_63140_) -> { + private static final int MIN_PALETTE_BITS = 0; + private final PaletteResize dummyPaletteResize = (p_63139_, p_63140_) -> { return 0; diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch index bbe33a02..79e724e7 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java @@ -123,13 +_,13 @@ - if (this.f_187612_[l].m_188008_() && p_63218_.m_60713_(Blocks.f_50016_)) { + if (this.sections[l].hasOnlyAir() && p_63218_.is(Blocks.AIR)) { return p_63218_; } else { -- if (p_63218_.m_60791_() > 0) { +- if (p_63218_.getLightEmission() > 0) { + if (p_63218_.getLightEmission(this, p_63217_) > 0) { - this.f_63158_.add(new BlockPos((i & 15) + this.m_7697_().m_45604_(), j, (k & 15) + this.m_7697_().m_45605_())); + this.lights.add(new BlockPos((i & 15) + this.getPos().getMinBlockX(), j, (k & 15) + this.getPos().getMinBlockZ())); } - LevelChunkSection levelchunksection = this.m_183278_(l); - BlockState blockstate = levelchunksection.m_62986_(i & 15, j & 15, k & 15, p_63218_); -- if (this.f_63153_.m_62427_(ChunkStatus.f_62322_) && p_63218_ != blockstate && (p_63218_.m_60739_(this, p_63217_) != blockstate.m_60739_(this, p_63217_) || p_63218_.m_60791_() != blockstate.m_60791_() || p_63218_.m_60787_() || blockstate.m_60787_())) { -+ if (this.f_63153_.m_62427_(ChunkStatus.f_62322_) && p_63218_ != blockstate && (p_63218_.m_60739_(this, p_63217_) != blockstate.m_60739_(this, p_63217_) || p_63218_.getLightEmission(this, p_63217_) != blockstate.getLightEmission(this, p_63217_) || p_63218_.m_60787_() || blockstate.m_60787_())) { - this.f_63151_.m_142202_(p_63217_); + LevelChunkSection levelchunksection = this.getSection(l); + BlockState blockstate = levelchunksection.setBlockState(i & 15, j & 15, k & 15, p_63218_); +- if (this.status.isOrAfter(ChunkStatus.FEATURES) && p_63218_ != blockstate && (p_63218_.getLightBlock(this, p_63217_) != blockstate.getLightBlock(this, p_63217_) || p_63218_.getLightEmission() != blockstate.getLightEmission() || p_63218_.useShapeForLightOcclusion() || blockstate.useShapeForLightOcclusion())) { ++ if (this.status.isOrAfter(ChunkStatus.FEATURES) && p_63218_ != blockstate && (p_63218_.getLightBlock(this, p_63217_) != blockstate.getLightBlock(this, p_63217_) || p_63218_.getLightEmission(this, p_63217_) != blockstate.getLightEmission(this, p_63217_) || p_63218_.useShapeForLightOcclusion() || blockstate.useShapeForLightOcclusion())) { + this.lightEngine.checkBlock(p_63217_); } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch index 8c9459ba..565419e7 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch @@ -1,43 +1,43 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -146,6 +_,7 @@ - return Registry.f_122822_.m_6612_(ResourceLocation.m_135820_(p_188285_)); + return Registry.FLUID.getOptional(ResourceLocation.tryParse(p_188285_)); }, p_188233_); - chunkaccess = new LevelChunk(p_188231_.m_6018_(), p_188233_, upgradedata, levelchunkticks, levelchunkticks1, j1, alevelchunksection, m_196890_(p_188231_, p_188234_), blendingdata); -+ if (p_188234_.m_128441_("ForgeCaps")) ((LevelChunk)chunkaccess).readCapsFromNBT(p_188234_.m_128469_("ForgeCaps")); + chunkaccess = new LevelChunk(p_188231_.getLevel(), p_188233_, upgradedata, levelchunkticks, levelchunkticks1, j1, alevelchunksection, postLoadChunk(p_188231_, p_188234_), blendingdata); ++ if (p_188234_.contains("ForgeCaps")) ((LevelChunk)chunkaccess).readCapsFromNBT(p_188234_.getCompound("ForgeCaps")); } else { - ProtoChunkTicks protochunkticks = ProtoChunkTicks.m_193302_(p_188234_.m_128437_("block_ticks", 10), (p_196906_) -> { - return Registry.f_122824_.m_6612_(ResourceLocation.m_135820_(p_196906_)); + ProtoChunkTicks protochunkticks = ProtoChunkTicks.load(p_188234_.getList("block_ticks", 10), (p_196906_) -> { + return Registry.BLOCK.getOptional(ResourceLocation.tryParse(p_196906_)); @@ -170,13 +_,20 @@ - boolean flag2 = chunkstatus.m_62427_(ChunkStatus.f_62323_) || belowzeroretrogen != null && belowzeroretrogen.m_188466_().m_62427_(ChunkStatus.f_62323_); + boolean flag2 = chunkstatus.isOrAfter(ChunkStatus.LIGHT) || belowzeroretrogen != null && belowzeroretrogen.targetStatus().isOrAfter(ChunkStatus.LIGHT); if (!flag && flag2) { - for(BlockPos blockpos : BlockPos.m_121976_(p_188233_.m_45604_(), p_188231_.m_141937_(), p_188233_.m_45605_(), p_188233_.m_45608_(), p_188231_.m_151558_() - 1, p_188233_.m_45609_())) { -- if (chunkaccess.m_8055_(blockpos).m_60791_() != 0) { -+ if (chunkaccess.m_8055_(blockpos).getLightEmission(chunkaccess, blockpos) != 0) { - protochunk.m_63277_(blockpos); + for(BlockPos blockpos : BlockPos.betweenClosed(p_188233_.getMinBlockX(), p_188231_.getMinBuildHeight(), p_188233_.getMinBlockZ(), p_188233_.getMaxBlockX(), p_188231_.getMaxBuildHeight() - 1, p_188233_.getMaxBlockZ())) { +- if (chunkaccess.getBlockState(blockpos).getLightEmission() != 0) { ++ if (chunkaccess.getBlockState(blockpos).getLightEmission(chunkaccess, blockpos) != 0) { + protochunk.addLight(blockpos); } } } } + // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading. -+ net.minecraft.nbt.Tag persistentBase = p_188234_.m_128423_("ChunkBukkitValues"); ++ net.minecraft.nbt.Tag persistentBase = p_188234_.get("ChunkBukkitValues"); + if (persistentBase instanceof CompoundTag) { + ((ChunkAccess) chunkaccess).persistentDataContainer.putAll((CompoundTag) persistentBase); + } + // CraftBukkit end + - chunkaccess.m_8094_(flag); - CompoundTag compoundtag2 = p_188234_.m_128469_("Heightmaps"); + chunkaccess.setLightCorrect(flag); + CompoundTag compoundtag2 = p_188234_.getCompound("Heightmaps"); EnumSet enumset = EnumSet.noneOf(Heightmap.Types.class); @@ -193,7 +_,7 @@ - Heightmap.m_64256_(chunkaccess, enumset); - CompoundTag compoundtag3 = p_188234_.m_128469_("structures"); - chunkaccess.m_8040_(m_188254_(StructurePieceSerializationContext.m_192770_(p_188231_), compoundtag3, p_188231_.m_7328_())); -- chunkaccess.m_7946_(m_208154_(p_188231_.m_5962_(), p_188233_, compoundtag3)); -+ net.minecraftforge.common.ForgeHooks.fixNullStructureReferences(chunkaccess, m_208154_(p_188231_.m_5962_(), p_188233_, compoundtag3)); - if (p_188234_.m_128471_("shouldSave")) { - chunkaccess.m_8092_(true); + Heightmap.primeHeightmaps(chunkaccess, enumset); + CompoundTag compoundtag3 = p_188234_.getCompound("structures"); + chunkaccess.setAllStarts(unpackStructureStart(StructurePieceSerializationContext.fromLevel(p_188231_), compoundtag3, p_188231_.getSeed())); +- chunkaccess.setAllReferences(unpackStructureReferences(p_188231_.registryAccess(), p_188233_, compoundtag3)); ++ net.minecraftforge.common.ForgeHooks.fixNullStructureReferences(chunkaccess, unpackStructureReferences(p_188231_.registryAccess(), p_188233_, compoundtag3)); + if (p_188234_.getBoolean("shouldSave")) { + chunkaccess.setUnsaved(true); } @@ -209,6 +_,7 @@ } @@ -48,7 +48,7 @@ } else { ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; @@ -242,6 +_,7 @@ - protochunk1.m_188186_(generationstep$carving, new CarvingMask(compoundtag4.m_128467_(s1), chunkaccess.m_141937_())); + protochunk1.setCarvingMask(generationstep$carving, new CarvingMask(compoundtag4.getLongArray(s1), chunkaccess.getMinBuildHeight())); } + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_188234_, chunkstatus$chunktype)); @@ -57,27 +57,27 @@ } @@ -350,6 +_,15 @@ - compoundtag.m_128365_("CarvingMasks", compoundtag4); + compoundtag.put("CarvingMasks", compoundtag4); } + else { + LevelChunk levelChunk = (LevelChunk) p_63456_; + try { + final CompoundTag capTag = levelChunk.writeCapsToNBT(); -+ if (capTag != null) compoundtag.m_128365_("ForgeCaps", capTag); ++ if (capTag != null) compoundtag.put("ForgeCaps", capTag); + } catch (Exception exception) { -+ f_63449_.error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", 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); + } + } - m_188235_(p_63455_, compoundtag, p_63456_.m_183568_()); - compoundtag.m_128365_("PostProcessing", m_63490_(p_63456_.m_6720_())); + saveTicks(p_63455_, compoundtag, p_63456_.getTicksForSerialization()); + compoundtag.put("PostProcessing", packOffsets(p_63456_.getPostProcessing())); @@ -363,6 +_,11 @@ - compoundtag.m_128365_("Heightmaps", compoundtag2); - compoundtag.m_128365_("structures", m_188249_(StructurePieceSerializationContext.m_192770_(p_63455_), chunkpos, p_63456_.m_6633_(), p_63456_.m_7049_())); + compoundtag.put("Heightmaps", compoundtag2); + compoundtag.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(p_63455_), chunkpos, p_63456_.getAllStarts(), p_63456_.getAllReferences())); + // CraftBukkit start - store chunk persistent data in nbt + if (!p_63456_.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. -+ compoundtag.m_128365_("ChunkBukkitValues", p_63456_.persistentDataContainer.toTagCompound()); ++ compoundtag.put("ChunkBukkitValues", p_63456_.persistentDataContainer.toTagCompound()); + } + // CraftBukkit end return compoundtag; diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch index ff48836a..33177177 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java @@ -30,8 +_,48 @@ - this.f_63495_ = new IOWorker(p_196912_, p_196914_, "chunk"); + this.worker = new IOWorker(p_196912_, p_196914_, "chunk"); } -- public CompoundTag m_188288_(ResourceKey p_188289_, Supplier p_188290_, CompoundTag p_188291_, Optional>> p_188292_) { +- public CompoundTag upgradeChunkTag(ResourceKey p_188289_, Supplier p_188290_, CompoundTag p_188291_, Optional>> p_188292_) { + // CraftBukkit start + private boolean check(net.minecraft.server.level.ServerChunkCache cps, int x, int z) throws IOException { + ChunkPos pos = new ChunkPos(x, z); + if (cps != null) { + com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread"); -+ if (cps.m_5563_(x, z)) { ++ if (cps.hasChunk(x, z)) { + return true; + } + } -+ CompoundTag nbt = m_63512_(pos); ++ CompoundTag nbt = read(pos); + if (nbt != null) { -+ CompoundTag level = nbt.m_128469_("Level"); -+ if (level.m_128471_("TerrainPopulated")) { ++ CompoundTag level = nbt.getCompound("Level"); ++ if (level.getBoolean("TerrainPopulated")) { + return true; + } -+ net.minecraft.world.level.chunk.ChunkStatus status = net.minecraft.world.level.chunk.ChunkStatus.m_62397_(level.m_128461_("Status")); -+ if (status != null && status.m_62427_(net.minecraft.world.level.chunk.ChunkStatus.f_62322_)) { ++ net.minecraft.world.level.chunk.ChunkStatus status = net.minecraft.world.level.chunk.ChunkStatus.byName(level.getString("Status")); ++ if (status != null && status.isOrAfter(net.minecraft.world.level.chunk.ChunkStatus.FEATURES)) { + return true; + } + } @@ -31,25 +31,25 @@ + //Magma start - move to original method + private @Nullable ChunkPos upgradeChunkTag_pos; + private @Nullable net.minecraft.world.level.LevelAccessor upgradeChunkTag_generatoraccess; -+ public CompoundTag m_188288_(ResourceKey p_188289_, Supplier p_188290_, CompoundTag p_188291_, Optional>> p_188292_) throws IOException { ++ public CompoundTag upgradeChunkTag(ResourceKey p_188289_, Supplier p_188290_, CompoundTag p_188291_, Optional>> p_188292_) throws IOException { + // CraftBukkit end - int i = m_63505_(p_188291_); + int i = getVersion(p_188291_); + + // CraftBukkit start + if (i < 1466 && upgradeChunkTag_pos != null) { //Magma - null check -+ CompoundTag level = p_188291_.m_128469_("Level"); -+ if (level.m_128471_("TerrainPopulated") && !level.m_128471_("LightPopulated")) { -+ net.minecraft.server.level.ServerChunkCache cps = (upgradeChunkTag_generatoraccess == null) ? null : ((net.minecraft.server.level.ServerLevel) upgradeChunkTag_generatoraccess).m_7726_(); -+ if (check(cps, upgradeChunkTag_pos.f_45578_ - 1, upgradeChunkTag_pos.f_45579_) && check(cps, upgradeChunkTag_pos.f_45578_ - 1, upgradeChunkTag_pos.f_45579_ - 1) && check(cps, upgradeChunkTag_pos.f_45578_, upgradeChunkTag_pos.f_45579_ - 1)) { -+ level.m_128379_("LightPopulated", true); ++ CompoundTag level = p_188291_.getCompound("Level"); ++ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { ++ net.minecraft.server.level.ServerChunkCache cps = (upgradeChunkTag_generatoraccess == null) ? null : ((net.minecraft.server.level.ServerLevel) upgradeChunkTag_generatoraccess).getChunkSource(); ++ if (check(cps, upgradeChunkTag_pos.x - 1, upgradeChunkTag_pos.z) && check(cps, upgradeChunkTag_pos.x - 1, upgradeChunkTag_pos.z - 1) && check(cps, upgradeChunkTag_pos.x, upgradeChunkTag_pos.z - 1)) { ++ level.putBoolean("LightPopulated", true); + } + } + } + // CraftBukkit end + if (i < 1493) { - p_188291_ = NbtUtils.m_129218_(this.f_63496_, DataFixTypes.CHUNK, p_188291_, i, 1493); - if (p_188291_.m_128469_("Level").m_128471_("hasLegacyStructureData")) { + p_188291_ = NbtUtils.update(this.fixerUpper, DataFixTypes.CHUNK, p_188291_, i, 1493); + if (p_188291_.getCompound("Level").getBoolean("hasLegacyStructureData")) { @@ -43,15 +_,42 @@ } } @@ -59,23 +59,23 @@ + boolean belowZeroGenerationInExistingChunks = (upgradeChunkTag_generatoraccess != null) ? ((net.minecraft.server.level.ServerLevel) upgradeChunkTag_generatoraccess).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; + + if (i <= 2730 && !belowZeroGenerationInExistingChunks) { -+ stopBelowZero = net.minecraft.world.level.chunk.ChunkStatus.f_62326_.m_62467_().equals(p_188291_.m_128469_("Level").m_128461_("Status")); ++ stopBelowZero = net.minecraft.world.level.chunk.ChunkStatus.FULL.getName().equals(p_188291_.getCompound("Level").getString("Status")); + } + // Spigot end + - m_196918_(p_188291_, p_188289_, p_188292_); - p_188291_ = NbtUtils.m_129213_(this.f_63496_, DataFixTypes.CHUNK, p_188291_, Math.max(1493, i)); - if (i < SharedConstants.m_183709_().getWorldVersion()) { - p_188291_.m_128405_("DataVersion", SharedConstants.m_183709_().getWorldVersion()); + injectDatafixingContext(p_188291_, p_188289_, p_188292_); + p_188291_ = NbtUtils.update(this.fixerUpper, DataFixTypes.CHUNK, p_188291_, Math.max(1493, i)); + if (i < SharedConstants.getCurrentVersion().getWorldVersion()) { + p_188291_.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); } + // Spigot start + if (stopBelowZero) { -+ p_188291_.m_128359_("Status", net.minecraft.world.level.chunk.ChunkStatus.f_62325_.m_62467_()); ++ p_188291_.putString("Status", net.minecraft.world.level.chunk.ChunkStatus.HEIGHTMAPS.getName()); + } + // Spigot end + - p_188291_.m_128473_("__context"); + p_188291_.remove("__context"); return p_188291_; } + @@ -83,7 +83,7 @@ + upgradeChunkTag_pos = pos; + upgradeChunkTag_generatoraccess = generatoraccess; + try { -+ return m_188288_(p_188289_, p_188290_, p_188291_, p_188292_); ++ return upgradeChunkTag(p_188289_, p_188290_, p_188291_, p_188292_); + } finally { + upgradeChunkTag_pos = null; + upgradeChunkTag_generatoraccess = null; @@ -91,5 +91,5 @@ + } + //Magma end - public static void m_196918_(CompoundTag p_196919_, ResourceKey p_196920_, Optional>> p_196921_) { + public static void injectDatafixingContext(CompoundTag p_196919_, ResourceKey p_196920_, Optional>> p_196921_) { CompoundTag compoundtag = new CompoundTag(); 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 a7711466..15893082 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 @@ -2,14 +2,14 @@ +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java @@ -90,8 +_,12 @@ ListTag listtag = new ListTag(); - p_156559_.m_156792_().forEach((p_156567_) -> { + p_156559_.getEntities().forEach((p_156567_) -> { CompoundTag compoundtag1 = new CompoundTag(); + try { - if (p_156567_.m_20223_(compoundtag1)) { + if (p_156567_.save(compoundtag1)) { listtag.add(compoundtag1); + } + } catch (Exception e) { -+ f_156535_.error("An Entity type {} has thrown an exception trying to write state. It will not persist. Report this to the mod author", p_156567_.m_6095_(), e); ++ LOGGER.error("An Entity type {} has thrown an exception trying to write state. It will not persist. Report this to the mod author", p_156567_.getType(), e); } }); diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch index 323b0086..e118f1ec 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch @@ -1,56 +1,56 @@ --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -25,7 +_,7 @@ - this.f_63701_ = p_196955_; + this.sync = p_196955_; } -- private RegionFile m_63711_(ChunkPos p_63712_) throws IOException { +- private RegionFile getRegionFile(ChunkPos p_63712_) throws IOException { + private RegionFile getRegionFile(ChunkPos p_63712_, boolean existingOnly) throws IOException { // CraftBukkit - long i = ChunkPos.m_45589_(p_63712_.m_45610_(), p_63712_.m_45612_()); - RegionFile regionfile = this.f_63699_.getAndMoveToFirst(i); + long i = ChunkPos.asLong(p_63712_.getRegionX(), p_63712_.getRegionZ()); + RegionFile regionfile = this.regionCache.getAndMoveToFirst(i); if (regionfile != null) { @@ -37,6 +_,7 @@ - Files.createDirectories(this.f_63700_); - Path path = this.f_63700_.resolve("r." + p_63712_.m_45610_() + "." + p_63712_.m_45612_() + ".mca"); + Files.createDirectories(this.folder); + Path path = this.folder.resolve("r." + p_63712_.getRegionX() + "." + p_63712_.getRegionZ() + ".mca"); + if (existingOnly && !Files.exists(path)) return null; // CraftBukkit - RegionFile regionfile1 = new RegionFile(path, this.f_63700_, this.f_63701_); - this.f_63699_.putAndMoveToFirst(i, regionfile1); + RegionFile regionfile1 = new RegionFile(path, this.folder, this.sync); + this.regionCache.putAndMoveToFirst(i, regionfile1); return regionfile1; @@ -45,7 +_,12 @@ @Nullable - public CompoundTag m_63706_(ChunkPos p_63707_) throws IOException { -- RegionFile regionfile = this.m_63711_(p_63707_); + public CompoundTag read(ChunkPos p_63707_) throws IOException { +- RegionFile regionfile = this.getRegionFile(p_63707_); + // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing + RegionFile regionfile = this.getRegionFile(p_63707_, true); + if (regionfile == null) { + return null; + } + // CraftBukkit end - DataInputStream datainputstream = regionfile.m_63645_(p_63707_); + DataInputStream datainputstream = regionfile.getChunkDataInputStream(p_63707_); CompoundTag compoundtag; @@ -84,7 +_,12 @@ } - public void m_196956_(ChunkPos p_196957_, StreamTagVisitor p_196958_) throws IOException { -- RegionFile regionfile = this.m_63711_(p_196957_); + public void scanChunk(ChunkPos p_196957_, StreamTagVisitor p_196958_) throws IOException { +- RegionFile regionfile = this.getRegionFile(p_196957_); + // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing + RegionFile regionfile = this.getRegionFile(p_196957_, true); + if (regionfile == null) { + return; + } + // CraftBukkit end - DataInputStream datainputstream = regionfile.m_63645_(p_196957_); + DataInputStream datainputstream = regionfile.getChunkDataInputStream(p_196957_); try { @@ -110,7 +_,7 @@ } - protected void m_63708_(ChunkPos p_63709_, @Nullable CompoundTag p_63710_) throws IOException { -- RegionFile regionfile = this.m_63711_(p_63709_); + protected void write(ChunkPos p_63709_, @Nullable CompoundTag p_63710_) throws IOException { +- RegionFile regionfile = this.getRegionFile(p_63709_); + RegionFile regionfile = this.getRegionFile(p_63709_, false); // CraftBukkit if (p_63710_ == null) { - regionfile.m_156613_(p_63709_); + regionfile.clear(p_63709_); } else { diff --git a/patches/minecraft/net/minecraft/world/level/dimension/LevelStem.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/LevelStem.java.patch index d906ff03..4a3929df 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/LevelStem.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/LevelStem.java.patch @@ -3,15 +3,15 @@ @@ -23,7 +_,9 @@ public final class LevelStem { - public static final Codec f_63970_ = RecordCodecBuilder.create((p_63986_) -> { + public static final Codec CODEC = RecordCodecBuilder.create((p_63986_) -> { + return net.minecraftforge.common.ForgeHooks.expandLevelStemCodec(p_63986_, () -> { // forge: reroute the codec builder here to add extra json fields - return p_63986_.group(DimensionType.f_63853_.fieldOf("type").forGetter(LevelStem::m_204521_), ChunkGenerator.f_62136_.fieldOf("generator").forGetter(LevelStem::m_63990_)).apply(p_63986_, p_63986_.stable(LevelStem::new)); + return p_63986_.group(DimensionType.CODEC.fieldOf("type").forGetter(LevelStem::typeHolder), ChunkGenerator.CODEC.fieldOf("generator").forGetter(LevelStem::generator)).apply(p_63986_, p_63986_.stable(LevelStem::new)); + }); // forge: we're wrapping the original codec builder in our expansion up there }); - public static final ResourceKey f_63971_ = ResourceKey.m_135785_(Registry.f_122820_, new ResourceLocation("overworld")); - public static final ResourceKey f_63972_ = ResourceKey.m_135785_(Registry.f_122820_, new ResourceLocation("the_nether")); + public static final ResourceKey OVERWORLD = ResourceKey.create(Registry.LEVEL_STEM_REGISTRY, new ResourceLocation("overworld")); + public static final ResourceKey NETHER = ResourceKey.create(Registry.LEVEL_STEM_REGISTRY, new ResourceLocation("the_nether")); @@ -33,6 +_,12 @@ - private final ChunkGenerator f_63976_; + private final ChunkGenerator generator; public LevelStem(Holder p_204519_, ChunkGenerator p_204520_) { + this(p_204519_, p_204520_, false); // forge: by default, dimension jsons use the fixed seed required by the vanilla format @@ -20,6 +20,6 @@ + public boolean useServerSeed() { return this.useServerSeed; } + public LevelStem(Holder p_204519_, ChunkGenerator p_204520_, boolean useServerSeed) { // forge: allow dimension jsons to specify that they should use the server seed instead of the fixed seed field + this.useServerSeed = useServerSeed; // forge - this.f_63975_ = p_204519_; - this.f_63976_ = p_204520_; + this.type = p_204519_; + this.generator = p_204520_; } diff --git a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index d131027e..bbf31c28 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -2,40 +2,40 @@ +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java @@ -100,6 +_,7 @@ - this.f_64068_ = p_64080_.m_128471_("DragonKilled"); - this.f_64069_ = p_64080_.m_128471_("PreviouslyKilled"); -+ this.f_64071_ = !p_64080_.m_128471_("LegacyScanPerformed"); // Forge: fix MC-105080 - if (p_64080_.m_128471_("IsRespawning")) { - this.f_64073_ = DragonRespawnAnimation.START; + this.dragonKilled = p_64080_.getBoolean("DragonKilled"); + this.previouslyKilled = p_64080_.getBoolean("PreviouslyKilled"); ++ this.needsStateScanning = !p_64080_.getBoolean("LegacyScanPerformed"); // Forge: fix MC-105080 + if (p_64080_.getBoolean("IsRespawning")) { + this.respawnStage = DragonRespawnAnimation.START; } @@ -131,13 +_,14 @@ - compoundtag.m_128379_("NeedsStateScanning", this.f_64071_); - if (this.f_64070_ != null) { - compoundtag.m_128362_("Dragon", this.f_64070_); + compoundtag.putBoolean("NeedsStateScanning", this.needsStateScanning); + if (this.dragonUUID != null) { + compoundtag.putUUID("Dragon", this.dragonUUID); - } - compoundtag.m_128379_("DragonKilled", this.f_64068_); - compoundtag.m_128379_("PreviouslyKilled", this.f_64069_); -+ compoundtag.m_128379_("LegacyScanPerformed", !this.f_64071_); // Forge: fix MC-105080 - if (this.f_64072_ != null) { - compoundtag.m_128365_("ExitPortalLocation", NbtUtils.m_129224_(this.f_64072_)); + compoundtag.putBoolean("DragonKilled", this.dragonKilled); + compoundtag.putBoolean("PreviouslyKilled", this.previouslyKilled); ++ compoundtag.putBoolean("LegacyScanPerformed", !this.needsStateScanning); // Forge: fix MC-105080 + if (this.portalLocation != null) { + compoundtag.put("ExitPortalLocation", NbtUtils.writeBlockPos(this.portalLocation)); } + } ListTag listtag = new ListTag(); @@ -507,6 +_,13 @@ - endcrystal.m_31052_((BlockPos)null); + endcrystal.setBeamTarget((BlockPos)null); } } - + } + + public void addPlayer(ServerPlayer player) { -+ this.f_64060_.m_6543_(player); ++ this.dragonEvent.addPlayer(player); + } + + public void removePlayer(ServerPlayer player) { -+ this.f_64060_.m_6539_(player); ++ this.dragonEvent.removePlayer(player); } } diff --git a/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch index 619e7458..703e84e9 100644 --- a/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch +++ b/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch @@ -1,50 +1,50 @@ --- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java @@ -52,6 +_,16 @@ - this.f_157496_ = new LevelEntityGetterAdapter<>(this.f_157494_, this.f_157495_); + this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); } + // CraftBukkit start - add method to get all entities in chunk + public List getEntities(ChunkPos chunkCoordIntPair) { -+ return f_157495_.m_156888_(chunkCoordIntPair.m_45588_()).flatMap(EntitySection::m_156845_).map(entity -> (Entity) entity).collect(Collectors.toList()); ++ return sectionStorage.getExistingSectionsInChunk(chunkCoordIntPair.toLong()).flatMap(EntitySection::getEntities).map(entity -> (Entity) entity).collect(Collectors.toList()); + } + + public boolean isPending(long pair) { -+ return f_157498_.get(pair) == ChunkLoadStatus.PENDING; ++ return chunkLoadStatuses.get(pair) == ChunkLoadStatus.PENDING; + } + // CraftBukkit end + - void m_157509_(long p_157510_, EntitySection p_157511_) { - if (p_157511_.m_156833_()) { - this.f_157495_.m_156897_(p_157510_); + void removeSectionIfEmpty(long p_157510_, EntitySection p_157511_) { + if (p_157511_.isEmpty()) { + this.sectionStorage.remove(p_157510_); @@ -72,7 +_,16 @@ - return this.m_157538_(p_157534_, false); + return this.addEntity(p_157534_, false); } + public boolean addNewEntityWithoutEvent(T entity) { + return this.addEntityWithoutEvent(entity, false); + } + - private boolean m_157538_(T p_157539_, boolean p_157540_) { -+ if (p_157539_ instanceof Entity entity && net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entity, entity.f_19853_, p_157540_))) return false; + private boolean addEntity(T p_157539_, boolean p_157540_) { ++ if (p_157539_ instanceof Entity entity && net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entity, entity.level, p_157540_))) return false; + return addEntityWithoutEvent(p_157539_, p_157540_); + } + + private boolean addEntityWithoutEvent(T p_157539_, boolean p_157540_) { - if (!this.m_157557_(p_157539_)) { + if (!this.addEntityUuid(p_157539_)) { return false; } else { @@ -104,12 +_,14 @@ - public void m_157552_(Stream p_157553_) { + public void addLegacyChunkEntities(Stream p_157553_) { p_157553_.forEach((p_157607_) -> { - this.m_157538_(p_157607_, true); + this.addEntity(p_157607_, true); + if (p_157607_ instanceof Entity entity) entity.onAddedToWorld(); }); } - public void m_157559_(Stream p_157560_) { + public void addWorldGenChunkEntities(Stream p_157560_) { p_157560_.forEach((p_157605_) -> { - this.m_157538_(p_157605_, false); + this.addEntity(p_157605_, false); + if (p_157605_ instanceof Entity entity) entity.onAddedToWorld(); }); } @@ -52,54 +52,51 @@ @@ -187,6 +_,12 @@ } - private boolean m_157512_(long p_157513_, Consumer p_157514_) { + private boolean storeChunkSections(long p_157513_, Consumer p_157514_) { + // CraftBukkit start - add boolean for event call + return storeChunkSections(p_157513_, p_157514_, false); + } + + private boolean storeChunkSections(long p_157513_, Consumer p_157514_, boolean callEvent) { + // CraftBukkit end - PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager$chunkloadstatus = this.f_157498_.get(p_157513_); + PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager$chunkloadstatus = this.chunkLoadStatuses.get(p_157513_); if (persistententitysectionmanager$chunkloadstatus == PersistentEntitySectionManager.ChunkLoadStatus.PENDING) { return false; @@ -196,6 +_,7 @@ }).collect(Collectors.toList()); if (list.isEmpty()) { if (persistententitysectionmanager$chunkloadstatus == PersistentEntitySectionManager.ChunkLoadStatus.LOADED) { -+ if (callEvent) org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) f_157493_).f_156538_, new ChunkPos(p_157513_), ImmutableList.of()); // CraftBukkit - this.f_157493_.m_141971_(new ChunkEntities<>(new ChunkPos(p_157513_), ImmutableList.of())); ++ if (callEvent) org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) permanentStorage).level, new ChunkPos(p_157513_), ImmutableList.of()); // CraftBukkit + this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(p_157513_), ImmutableList.of())); } @@ -204,6 +_,7 @@ - this.m_157562_(p_157513_); + this.requestChunkLoad(p_157513_); return false; } else { -+ if (callEvent) org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) f_157493_).f_156538_, new ChunkPos(p_157513_), list.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit - this.f_157493_.m_141971_(new ChunkEntities<>(new ChunkPos(p_157513_), list)); ++ if (callEvent) org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) permanentStorage).level, new ChunkPos(p_157513_), list.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit + this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(p_157513_), list)); list.forEach(p_157514_); return true; -@@ -221,9 +_,9 @@ - } - - private boolean m_157568_(long p_157569_) { -- boolean flag = this.m_157512_(p_157569_, (p_157595_) -> { -+ boolean flag = this.storeChunkSections(p_157569_, (p_157595_) -> { - p_157595_.m_142429_().forEach(this::m_157585_); +@@ -223,7 +_,7 @@ + private boolean processChunkUnload(long p_157569_) { + boolean flag = this.storeChunkSections(p_157569_, (p_157595_) -> { + p_157595_.getPassengersAndSelf().forEach(this::unloadEntity); - }); + }, true); // CraftBukkit - add boolean for event call if (!flag) { return false; } else { @@ -248,8 +_,13 @@ - while((chunkentities = this.f_157500_.poll()) != null) { - chunkentities.m_156792_().forEach((p_157593_) -> { - this.m_157538_(p_157593_, true); + while((chunkentities = this.loadingInbox.poll()) != null) { + chunkentities.getEntities().forEach((p_157593_) -> { + this.addEntity(p_157593_, true); + if (p_157593_ instanceof Entity entity) entity.onAddedToWorld(); }); - this.f_157498_.put(chunkentities.m_156791_().m_45588_(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED); + this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED); + // CraftBukkit start - call entity load event -+ List entities = getEntities(chunkentities.m_156791_()); -+ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntitiesLoadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) f_157493_).f_156538_, chunkentities.m_156791_(), entities); ++ List entities = getEntities(chunkentities.getPos()); ++ org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callEntitiesLoadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) permanentStorage).level, chunkentities.getPos(), entities); + // CraftBukkit end } @@ -108,41 +105,41 @@ } public void close() throws IOException { -- this.m_157561_(); +- this.saveAll(); + // CraftBukkit start - add save boolean + close(true); + } + + public void close(boolean save) throws IOException { + if (save) { -+ this.m_157561_(); ++ this.saveAll(); + } + // CraftBukkit end - this.f_157493_.close(); + this.permanentStorage.close(); } @@ -350,11 +_,13 @@ class Callback implements EntityInLevelCallback { - private final T f_157609_; + private final T entity; + private final Entity realEntity; - private long f_157610_; - private EntitySection f_157611_; + private long currentSectionKey; + private EntitySection currentSection; Callback(T p_157614_, long p_157615_, EntitySection p_157616_) { - this.f_157609_ = p_157614_; + this.entity = p_157614_; + this.realEntity = p_157614_ instanceof Entity ? (Entity) p_157614_ : null; - this.f_157610_ = p_157615_; - this.f_157611_ = p_157616_; + this.currentSectionKey = p_157615_; + this.currentSection = p_157616_; } @@ -371,9 +_,11 @@ - PersistentEntitySectionManager.this.m_157509_(this.f_157610_, this.f_157611_); - EntitySection entitysection = PersistentEntitySectionManager.this.f_157495_.m_156893_(i); - entitysection.m_188346_(this.f_157609_); -+ long oldSectionKey = f_157610_; - this.f_157611_ = entitysection; - this.f_157610_ = i; - this.m_157620_(visibility, entitysection.m_156848_()); + PersistentEntitySectionManager.this.removeSectionIfEmpty(this.currentSectionKey, this.currentSection); + EntitySection entitysection = PersistentEntitySectionManager.this.sectionStorage.getOrCreateSection(i); + entitysection.add(this.entity); ++ long oldSectionKey = currentSectionKey; + this.currentSection = entitysection; + this.currentSectionKey = i; + this.updateStatus(visibility, entitysection.getStatus()); + if (this.realEntity != null) net.minecraftforge.common.ForgeHooks.onEntityEnterSection(this.realEntity, oldSectionKey, i); } diff --git a/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch b/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch index 862b212b..860704e9 100644 --- a/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch +++ b/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch @@ -3,27 +3,27 @@ @@ -92,11 +_,13 @@ class Callback implements EntityInLevelCallback { - private final T f_157668_; + private final T entity; + private final Entity realEntity; - private long f_157669_; - private EntitySection f_157670_; + private long currentSectionKey; + private EntitySection currentSection; Callback(T p_157673_, long p_157674_, EntitySection p_157675_) { - this.f_157668_ = p_157673_; + this.entity = p_157673_; + this.realEntity = p_157673_ instanceof Entity ? (Entity) p_157673_ : null; - this.f_157669_ = p_157674_; - this.f_157670_ = p_157675_; + this.currentSectionKey = p_157674_; + this.currentSection = p_157675_; } @@ -113,6 +_,7 @@ - TransientEntitySectionManager.this.m_157648_(this.f_157669_, this.f_157670_); - EntitySection entitysection = TransientEntitySectionManager.this.f_157638_.m_156893_(i); - entitysection.m_188346_(this.f_157668_); -+ long oldSectionKey = f_157669_; - this.f_157670_ = entitysection; - this.f_157669_ = i; - if (!this.f_157668_.m_142389_()) { + TransientEntitySectionManager.this.removeSectionIfEmpty(this.currentSectionKey, this.currentSection); + EntitySection entitysection = TransientEntitySectionManager.this.sectionStorage.getOrCreateSection(i); + entitysection.add(this.entity); ++ long oldSectionKey = currentSectionKey; + this.currentSection = entitysection; + this.currentSectionKey = i; + if (!this.entity.isAlwaysTicking()) { @@ -124,6 +_,7 @@ - TransientEntitySectionManager.this.f_157636_.m_141987_(this.f_157668_); + TransientEntitySectionManager.this.callbacks.onTickingStart(this.entity); } } + if (this.realEntity != null) net.minecraftforge.common.ForgeHooks.onEntityEnterSection(this.realEntity, oldSectionKey, i); diff --git a/patches/minecraft/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java.patch b/patches/minecraft/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java.patch index 3234d807..660e1ea4 100644 --- a/patches/minecraft/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java.patch +++ b/patches/minecraft/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java.patch @@ -4,14 +4,14 @@ return false; } else { BlockPos blockpos = optional.get(); -- if (!this.f_157889_.m_142008_(p_157901_, this, p_157904_, p_157902_, p_157903_)) { +- if (!this.config.shouldListen(p_157901_, this, p_157904_, p_157902_, p_157903_)) { + // CraftBukkit start -+ boolean defaultCancel = !this.f_157889_.m_142008_(p_157901_, this, p_157904_, p_157902_, p_157903_); -+ org.bukkit.event.block.BlockReceiveGameEvent event = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.f_175412_.m_7981_(p_157902_))), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_157901_, blockpos), (p_157903_ == null) ? null : p_157903_.getBukkitEntity()); ++ boolean defaultCancel = !this.config.shouldListen(p_157901_, this, p_157904_, p_157902_, p_157903_); ++ org.bukkit.event.block.BlockReceiveGameEvent event = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.GAME_EVENT.getKey(p_157902_))), org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_157901_, blockpos), (p_157903_ == null) ? null : p_157903_.getBukkitEntity()); + event.setCancelled(defaultCancel); + p_157901_.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + // CraftBukkit end return false; - } else if (this.m_157910_(p_157901_, p_157904_, blockpos)) { + } else if (this.isOccluded(p_157901_, p_157904_, blockpos)) { return false; 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 baef5b7f..4e81083a 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch @@ -6,10 +6,10 @@ } + + public static void initValidStates() { -+ f_64114_ = StreamSupport.stream(Registry.f_122824_.spliterator(), false).flatMap(block -> block.m_49965_().m_61056_().stream()).collect(Collectors.toList()); -+ f_64115_ = Mth.m_14167_(Mth.m_14116_(f_64114_.size())); -+ f_64116_ = Mth.m_14167_((float) (f_64114_.size() / f_64115_)); ++ ALL_BLOCKS = StreamSupport.stream(Registry.BLOCK.spliterator(), false).flatMap(block -> block.getStateDefinition().getPossibleStates().stream()).collect(Collectors.toList()); ++ GRID_WIDTH = Mth.ceil(Mth.sqrt(ALL_BLOCKS.size())); ++ GRID_HEIGHT = Mth.ceil((float) (ALL_BLOCKS.size() / GRID_WIDTH)); + } - public Climate.Sampler m_183403_() { - return Climate.m_207841_(); + public Climate.Sampler climateSampler() { + return Climate.empty(); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index d36a4ce2..32d93dc9 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -3,10 +3,10 @@ @@ -104,7 +_,9 @@ } - patrollingmonster.m_6034_((double)p_64566_.m_123341_(), (double)p_64566_.m_123342_(), (double)p_64566_.m_123343_()); -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(patrollingmonster, p_64565_, p_64566_.m_123341_(), p_64566_.m_123342_(), p_64566_.m_123343_(), null, MobSpawnType.PATROL) == -1) return false; - patrollingmonster.m_6518_(p_64565_, p_64565_.m_6436_(p_64566_), MobSpawnType.PATROL, (SpawnGroupData)null, (CompoundTag)null); + patrollingmonster.setPos((double)p_64566_.getX(), (double)p_64566_.getY(), (double)p_64566_.getZ()); ++ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(patrollingmonster, p_64565_, p_64566_.getX(), p_64566_.getY(), p_64566_.getZ(), null, MobSpawnType.PATROL) == -1) return false; + patrollingmonster.finalizeSpawn(p_64565_, p_64565_.getCurrentDifficultyAt(p_64566_), MobSpawnType.PATROL, (SpawnGroupData)null, (CompoundTag)null); + p_64565_.prepareEntity(patrollingmonster, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); //Magma - add spawn reason - p_64565_.m_47205_(patrollingmonster); + p_64565_.addFreshEntityWithPassengers(patrollingmonster); return true; } else { 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 2a559b92..39e85311 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java @@ -60,7 +_,9 @@ for(int i1 = 0; i1 < l; ++i1) { - Phantom phantom = EntityType.f_20509_.m_20615_(p_64576_); - phantom.m_20035_(blockpos1, 0.0F, 0.0F); -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(phantom, p_64576_, blockpos1.m_123341_(), blockpos1.m_123342_(), blockpos1.m_123343_(), null, MobSpawnType.NATURAL) == -1) return 0; - spawngroupdata = phantom.m_6518_(p_64576_, difficultyinstance, MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); + Phantom phantom = EntityType.PHANTOM.create(p_64576_); + phantom.moveTo(blockpos1, 0.0F, 0.0F); ++ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(phantom, p_64576_, blockpos1.getX(), blockpos1.getY(), blockpos1.getZ(), null, MobSpawnType.NATURAL) == -1) return 0; + spawngroupdata = phantom.finalizeSpawn(p_64576_, difficultyinstance, MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); + p_64576_.prepareEntity(phantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); - p_64576_.m_47205_(phantom); + p_64576_.addFreshEntityWithPassengers(phantom); } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch index abfbb0d7..d53d041f 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/levelgen/WorldGenSettings.java +++ b/net/minecraft/world/level/levelgen/WorldGenSettings.java @@ -39,6 +_,7 @@ - return p_64626_.group(Codec.LONG.fieldOf("seed").stable().forGetter(WorldGenSettings::m_64619_), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldGenSettings::m_64657_), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldGenSettings::m_64660_), RegistryCodecs.m_206318_(Registry.f_122820_, Lifecycle.stable(), LevelStem.f_63970_).xmap(LevelStem::m_204525_, Function.identity()).fieldOf("dimensions").forGetter(WorldGenSettings::m_204655_), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((p_158959_) -> { - return p_158959_.f_64606_; + return p_64626_.group(Codec.LONG.fieldOf("seed").stable().forGetter(WorldGenSettings::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldGenSettings::generateFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldGenSettings::generateBonusChest), RegistryCodecs.dataPackAwareCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), LevelStem.CODEC).xmap(LevelStem::sortMap, Function.identity()).fieldOf("dimensions").forGetter(WorldGenSettings::dimensions), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((p_158959_) -> { + return p_158959_.legacyCustomOptions; })).apply(p_64626_, p_64626_.stable(WorldGenSettings::new)); + }).xmap(net.minecraftforge.common.ForgeHooks::loadDimensionsWithServerSeed, wgs -> {return wgs; // forge: when loading/registering json dimensions, replace hardcoded seeds of custom dimensions with the server/overworld's seed, where requested; fixes MC-195717 - }).comapFlatMap(WorldGenSettings::m_64674_, Function.identity()); - private static final Logger f_64601_ = LogUtils.getLogger(); - private final long f_64602_; + }).comapFlatMap(WorldGenSettings::guardExperimental, Function.identity()); + private static final Logger LOGGER = LogUtils.getLogger(); + private final long seed; @@ -194,6 +_,8 @@ - Registry registry2 = p_209717_.m_175515_(Registry.f_211073_); - Registry registry3 = DimensionType.m_204490_(p_209717_, i); - String s = p_209718_.f_207545_(); + Registry registry2 = p_209717_.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY); + Registry registry3 = DimensionType.defaultDimensions(p_209717_, i); + String s = p_209718_.levelType(); + net.minecraftforge.common.world.ForgeWorldPreset type = net.minecraftforge.registries.ForgeRegistries.WORLD_TYPES.get().getValue(new net.minecraft.resources.ResourceLocation(s)); -+ if (type != null) return type.createSettings(p_209717_, i, p_209718_.f_207544_(), false, s); ++ if (type != null) return type.createSettings(p_209717_, i, p_209718_.generateStructures(), false, s); switch(s) { case "flat": - Dynamic dynamic = new Dynamic<>(JsonOps.INSTANCE, p_209718_.f_207543_()); + Dynamic dynamic = new Dynamic<>(JsonOps.INSTANCE, p_209718_.generatorSettings()); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch index 2901f98b..901b44df 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch @@ -6,6 +6,6 @@ -public abstract class WorldCarver { +public abstract class WorldCarver extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final WorldCarver f_64974_ = m_65065_("cave", new CaveWorldCarver(CaveCarverConfiguration.f_159154_)); - public static final WorldCarver f_64975_ = m_65065_("nether_cave", new NetherWorldCarver(CaveCarverConfiguration.f_159154_)); - public static final WorldCarver f_64976_ = m_65065_("canyon", new CanyonWorldCarver(CanyonCarverConfiguration.f_158966_)); + public static final WorldCarver CAVE = register("cave", new CaveWorldCarver(CaveCarverConfiguration.CODEC)); + public static final WorldCarver NETHER_CAVE = register("nether_cave", new NetherWorldCarver(CaveCarverConfiguration.CODEC)); + public static final WorldCarver CANYON = register("canyon", new CanyonWorldCarver(CanyonCarverConfiguration.CODEC)); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch index d08ad717..01806e83 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch @@ -6,15 +6,15 @@ -public abstract class Feature { +public abstract class Feature extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final Feature f_65759_ = m_65807_("no_op", new NoOpFeature(NoneFeatureConfiguration.f_67815_)); - public static final Feature f_65760_ = m_65807_("tree", new TreeFeature(TreeConfiguration.f_68184_)); - public static final Feature f_65761_ = m_65807_("flower", new RandomPatchFeature(RandomPatchConfiguration.f_67902_)); + public static final Feature NO_OP = register("no_op", new NoOpFeature(NoneFeatureConfiguration.CODEC)); + public static final Feature TREE = register("tree", new TreeFeature(TreeConfiguration.CODEC)); + public static final Feature FLOWER = register("flower", new RandomPatchFeature(RandomPatchConfiguration.CODEC)); @@ -154,7 +_,7 @@ } - protected static boolean m_159747_(BlockState p_159748_) { -- return p_159748_.m_204336_(BlockTags.f_13061_); -+ return p_159748_.m_204336_(net.minecraftforge.common.Tags.Blocks.STONE); + protected static boolean isStone(BlockState p_159748_) { +- return p_159748_.is(BlockTags.BASE_STONE_OVERWORLD); ++ return p_159748_.is(net.minecraftforge.common.Tags.Blocks.STONE); } - public static boolean m_159759_(BlockState p_159760_) { + public static boolean isDirt(BlockState p_159760_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch index 8084049f..65d37348 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch @@ -3,8 +3,8 @@ @@ -129,6 +_,6 @@ } - private EntityType m_66358_(Random p_66359_) { -- return Util.m_137545_(f_66341_, p_66359_); + private EntityType randomEntityId(Random p_66359_) { +- return Util.getRandom(MOBS, p_66359_); + return net.minecraftforge.common.DungeonHooks.getRandomDungeonMob(p_66359_); } } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch index 46c18e7f..c09f8101 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch @@ -6,6 +6,6 @@ -public class StructureFeature { +public abstract class StructureFeature extends net.minecraftforge.registries.ForgeRegistryEntry> { - private static final Map, GenerationStep.Decoration> f_67032_ = Maps.newHashMap(); - private static final Logger f_67033_ = LogUtils.getLogger(); - public static final StructureFeature f_67013_ = m_67089_("pillager_outpost", new PillagerOutpostFeature(JigsawConfiguration.f_67756_), GenerationStep.Decoration.SURFACE_STRUCTURES); + private static final Map, GenerationStep.Decoration> STEP = Maps.newHashMap(); + private static final Logger LOGGER = LogUtils.getLogger(); + public static final StructureFeature PILLAGER_OUTPOST = register("pillager_outpost", new PillagerOutpostFeature(JigsawConfiguration.CODEC), GenerationStep.Decoration.SURFACE_STRUCTURES); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch index 30e4e039..b370a075 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java +++ b/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java @@ -33,6 +_,7 @@ - return p_161232_.f_161215_; + return p_161232_.forceDirt; })).apply(p_191347_, TreeConfiguration::new); }); + //TODO: Review this, see if we can hook in the sapling into the Codec - public final BlockStateProvider f_68185_; - public final BlockStateProvider f_161212_; - public final TrunkPlacer f_68190_; + public final BlockStateProvider trunkProvider; + public final BlockStateProvider dirtProvider; + public final TrunkPlacer trunkPlacer; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch index 94f0fc1e..dc63758e 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/foliageplacers/FoliagePlacerType.java.patch @@ -6,6 +6,6 @@ -public class FoliagePlacerType

{ +public class FoliagePlacerType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final FoliagePlacerType f_68591_ = m_68605_("blob_foliage_placer", BlobFoliagePlacer.f_68392_); - public static final FoliagePlacerType f_68592_ = m_68605_("spruce_foliage_placer", SpruceFoliagePlacer.f_68713_); - public static final FoliagePlacerType f_68593_ = m_68605_("pine_foliage_placer", PineFoliagePlacer.f_68676_); + public static final FoliagePlacerType BLOB_FOLIAGE_PLACER = register("blob_foliage_placer", BlobFoliagePlacer.CODEC); + public static final FoliagePlacerType SPRUCE_FOLIAGE_PLACER = register("spruce_foliage_placer", SpruceFoliagePlacer.CODEC); + public static final FoliagePlacerType PINE_FOLIAGE_PLACER = register("pine_foliage_placer", PineFoliagePlacer.CODEC); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch index 98be01c4..55aeb1c6 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch @@ -6,6 +6,6 @@ -public class BlockStateProviderType

{ +public class BlockStateProviderType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final BlockStateProviderType f_68752_ = m_68762_("simple_state_provider", SimpleStateProvider.f_68797_); - public static final BlockStateProviderType f_68753_ = m_68762_("weighted_state_provider", WeightedStateProvider.f_68808_); - public static final BlockStateProviderType f_191386_ = m_68762_("noise_threshold_provider", NoiseThresholdProvider.f_191463_); + public static final BlockStateProviderType SIMPLE_STATE_PROVIDER = register("simple_state_provider", SimpleStateProvider.CODEC); + public static final BlockStateProviderType WEIGHTED_STATE_PROVIDER = register("weighted_state_provider", WeightedStateProvider.CODEC); + public static final BlockStateProviderType NOISE_THRESHOLD_PROVIDER = register("noise_threshold_provider", NoiseThresholdProvider.CODEC); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch index 55faf71b..31971016 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/TreeDecoratorType.java.patch @@ -6,6 +6,6 @@ -public class TreeDecoratorType

{ +public class TreeDecoratorType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final TreeDecoratorType f_70042_ = m_70052_("trunk_vine", TrunkVineDecorator.f_70055_); - public static final TreeDecoratorType f_70043_ = m_70052_("leave_vine", LeaveVineDecorator.f_69996_); - public static final TreeDecoratorType f_70044_ = m_70052_("cocoa", CocoaDecorator.f_69972_); + public static final TreeDecoratorType TRUNK_VINE = register("trunk_vine", TrunkVineDecorator.CODEC); + public static final TreeDecoratorType LEAVE_VINE = register("leave_vine", LeaveVineDecorator.CODEC); + public static final TreeDecoratorType COCOA = register("cocoa", CocoaDecorator.CODEC); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch index ea2a13ea..940aff01 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch @@ -4,8 +4,8 @@ } } -- return Holder.m_205709_(Biome.BiomeBuilder.m_204185_(biome).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47592_()); -+ return Holder.m_205709_(Biome.BiomeBuilder.m_204185_(biome).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47592_().setRegistryName(biome.getRegistryName())); +- return Holder.direct(Biome.BiomeBuilder.from(biome).generationSettings(biomegenerationsettings$builder.build()).build()); ++ return Holder.direct(Biome.BiomeBuilder.from(biome).generationSettings(biomegenerationsettings$builder.build()).build().setRegistryName(biome.getRegistryName())); } - public Optional> m_209810_() { + public Optional> structureOverrides() { 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 40998037..01a27751 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 @@ -3,10 +3,10 @@ @@ -72,6 +_,9 @@ } - public final CompoundTag m_192644_(StructurePieceSerializationContext p_192645_) { -+ if (Registry.f_122843_.m_7981_(this.m_210000_()) == null) { // FORGE: Friendlier error then the Null String error below. -+ throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.m_210000_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + public final CompoundTag createTag(StructurePieceSerializationContext p_192645_) { ++ if (Registry.STRUCTURE_PIECE.getKey(this.getType()) == null) { // FORGE: Friendlier error then the Null String error below. ++ throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.getType() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + } CompoundTag compoundtag = new CompoundTag(); - compoundtag.m_128359_("id", Registry.f_122843_.m_7981_(this.m_210000_()).toString()); - BoundingBox.f_162354_.encodeStart(NbtOps.f_128958_, this.f_73383_).resultOrPartial(f_163536_::error).ifPresent((p_163579_) -> { + compoundtag.putString("id", Registry.STRUCTURE_PIECE.getKey(this.getType()).toString()); + BoundingBox.CODEC.encodeStart(NbtOps.INSTANCE, this.boundingBox).resultOrPartial(LOGGER::error).ifPresent((p_163579_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index b7d012c2..e4d5b9e4 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java @@ -61,6 +_,9 @@ - public CompoundTag m_192660_(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { + public CompoundTag createTag(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); - if (this.m_73603_()) { -+ if (p_192661_.f_192763_().m_175515_(Registry.f_122882_).m_7981_(this.m_210081_()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below -+ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.m_210081_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + if (this.isValid()) { ++ if (p_192661_.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).getKey(this.getFeature()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.getFeature() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + } - compoundtag.m_128359_("id", p_192661_.f_192763_().m_175515_(Registry.f_122882_).m_7981_(this.f_73565_).toString()); - compoundtag.m_128405_("ChunkX", p_192662_.f_45578_); - compoundtag.m_128405_("ChunkZ", p_192662_.f_45579_); + compoundtag.putString("id", p_192661_.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).getKey(this.feature).toString()); + compoundtag.putInt("ChunkX", p_192662_.x); + compoundtag.putInt("ChunkZ", p_192662_.z); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/SwamplandHutPiece.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/SwamplandHutPiece.java.patch index 365b110a..6fd67226 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/SwamplandHutPiece.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/SwamplandHutPiece.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/levelgen/structure/SwamplandHutPiece.java +++ b/net/minecraft/world/level/levelgen/structure/SwamplandHutPiece.java @@ -91,6 +_,7 @@ - witch.m_21530_(); - witch.m_7678_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_(), (double)blockpos.m_123343_() + 0.5D, 0.0F, 0.0F); - witch.m_6518_(p_192666_, p_192666_.m_6436_(blockpos), MobSpawnType.STRUCTURE, (SpawnGroupData)null, (CompoundTag)null); + witch.setPersistenceRequired(); + witch.moveTo((double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F); + witch.finalizeSpawn(p_192666_, p_192666_.getCurrentDifficultyAt(blockpos), MobSpawnType.STRUCTURE, (SpawnGroupData)null, (CompoundTag)null); + p_192666_.prepareEntity(witch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); //Magma - add spawn reason - p_192666_.m_47205_(witch); + p_192666_.addFreshEntityWithPassengers(witch); } } @@ -108,6 +_,7 @@ - cat.m_21530_(); - cat.m_7678_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_(), (double)blockpos.m_123343_() + 0.5D, 0.0F, 0.0F); - cat.m_6518_(p_73644_, p_73644_.m_6436_(blockpos), MobSpawnType.STRUCTURE, (SpawnGroupData)null, (CompoundTag)null); + cat.setPersistenceRequired(); + cat.moveTo((double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F); + cat.finalizeSpawn(p_73644_, p_73644_.getCurrentDifficultyAt(blockpos), MobSpawnType.STRUCTURE, (SpawnGroupData)null, (CompoundTag)null); + p_73644_.prepareEntity(cat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); //Magma - add spawn reason - p_73644_.m_47205_(cat); + p_73644_.addFreshEntityWithPassengers(cat); } } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch index 3dd1db14..e7e516f4 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch @@ -5,12 +5,12 @@ if (i == 0) { throw new IllegalStateException("No palettes"); + // CraftBukkit start -+ } else if (this.f_74369_ > 0) { -+ if (this.f_74369_ >= i) { -+ throw new IllegalArgumentException("Palette index out of bounds. Got " + this.f_74369_ + " where there are only " + i + " palettes available."); ++ } else if (this.palette > 0) { ++ if (this.palette >= i) { ++ throw new IllegalArgumentException("Palette index out of bounds. Got " + this.palette + " where there are only " + i + " palettes available."); + } -+ return p_74388_.get(this.f_74369_); ++ return p_74388_.get(this.palette); + // CraftBukkit end } else { - return p_74388_.get(this.m_74399_(p_74389_).nextInt(i)); + return p_74388_.get(this.getRandom(p_74389_).nextInt(i)); } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch index a48f683f..23222f7c 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureProcessor.java.patch @@ -4,17 +4,17 @@ public abstract class StructureProcessor { @Nullable -- public abstract StructureTemplate.StructureBlockInfo m_7382_(LevelReader p_74416_, BlockPos p_74417_, BlockPos p_74418_, StructureTemplate.StructureBlockInfo p_74419_, StructureTemplate.StructureBlockInfo p_74420_, StructurePlaceSettings p_74421_); +- public abstract StructureTemplate.StructureBlockInfo processBlock(LevelReader p_74416_, BlockPos p_74417_, BlockPos p_74418_, StructureTemplate.StructureBlockInfo p_74419_, StructureTemplate.StructureBlockInfo p_74420_, StructurePlaceSettings p_74421_); + @Deprecated //Forge: Use process below, with the Template context -+ public StructureTemplate.StructureBlockInfo m_7382_(LevelReader p_74416_, BlockPos p_74417_, BlockPos p_74418_, StructureTemplate.StructureBlockInfo p_74419_, StructureTemplate.StructureBlockInfo p_74420_, StructurePlaceSettings p_74421_) { ++ public StructureTemplate.StructureBlockInfo processBlock(LevelReader p_74416_, BlockPos p_74417_, BlockPos p_74418_, StructureTemplate.StructureBlockInfo p_74419_, StructureTemplate.StructureBlockInfo p_74420_, StructurePlaceSettings p_74421_) { + return p_74420_; + } - protected abstract StructureProcessorType m_6953_(); + protected abstract StructureProcessorType getType(); + + @Nullable + public StructureTemplate.StructureBlockInfo process(LevelReader p_74140_, BlockPos p_74141_, BlockPos p_74142_, StructureTemplate.StructureBlockInfo p_74143_, StructureTemplate.StructureBlockInfo p_74144_, StructurePlaceSettings p_74145_, @Nullable StructureTemplate template) { -+ return m_7382_(p_74140_, p_74141_, p_74142_, p_74143_, p_74144_, p_74145_); ++ return processBlock(p_74140_, p_74141_, p_74142_, p_74143_, p_74144_, p_74145_); + } + + /** 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 43684e82..deeff5c4 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,42 +1,42 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java @@ -68,6 +_,11 @@ - private Vec3i f_74484_ = Vec3i.f_123288_; - private String f_74485_ = "?"; + private Vec3i size = Vec3i.ZERO; + private String author = "?"; + // CraftBukkit start - data containers + private static final org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataTypeRegistry(); + public org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + // CraftBukkit end + - public Vec3i m_163801_() { - return this.f_74484_; + public Vec3i getSize() { + return this.size; } @@ -200,6 +_,10 @@ - return m_74593_(p_74565_, p_74564_.m_74401_(), p_74564_.m_74404_(), p_74564_.m_74407_()); + return transform(p_74565_, p_74564_.getMirror(), p_74564_.getRotation(), p_74564_.getRotationPivot()); } + public static Vec3 transformedVec3d(StructurePlaceSettings placementIn, Vec3 pos) { -+ return m_74578_(pos, placementIn.m_74401_(), placementIn.m_74404_(), placementIn.m_74407_()); ++ return transform(pos, placementIn.getMirror(), placementIn.getRotation(), placementIn.getRotationPivot()); + } + - public boolean m_74536_(ServerLevelAccessor p_74537_, BlockPos p_74538_, BlockPos p_74539_, StructurePlaceSettings p_74540_, Random p_74541_, int p_74542_) { - if (this.f_74482_.isEmpty()) { + public boolean placeInWorld(ServerLevelAccessor p_74537_, BlockPos p_74538_, BlockPos p_74539_, StructurePlaceSettings p_74540_, Random p_74541_, int p_74542_) { + if (this.palettes.isEmpty()) { return false; @@ -217,7 +_,7 @@ int i1 = Integer.MIN_VALUE; int j1 = Integer.MIN_VALUE; -- for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : m_74517_(p_74537_, p_74538_, p_74539_, p_74540_, list)) { +- for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : processBlockInfos(p_74537_, p_74538_, p_74539_, p_74540_, list)) { + for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : processBlockInfos(p_74537_, p_74538_, p_74539_, p_74540_, list, this)) { - BlockPos blockpos = structuretemplate$structureblockinfo.f_74675_; - if (boundingbox == null || boundingbox.m_71051_(blockpos)) { - FluidState fluidstate = p_74540_.m_74413_() ? p_74537_.m_6425_(blockpos) : null; + BlockPos blockpos = structuretemplate$structureblockinfo.pos; + if (boundingbox == null || boundingbox.isInside(blockpos)) { + FluidState fluidstate = p_74540_.shouldKeepLiquids() ? p_74537_.getFluidState(blockpos) : null; @@ -329,7 +_,7 @@ } - if (!p_74540_.m_74408_()) { -- this.m_74523_(p_74537_, p_74538_, p_74540_.m_74401_(), p_74540_.m_74404_(), p_74540_.m_74407_(), boundingbox, p_74540_.m_74414_()); + if (!p_74540_.isIgnoreEntities()) { +- this.placeEntities(p_74537_, p_74538_, p_74540_.getMirror(), p_74540_.getRotation(), p_74540_.getRotationPivot(), boundingbox, p_74540_.shouldFinalizeEntities()); + this.addEntitiesToWorld(p_74537_, p_74538_, p_74540_); } @@ -46,7 +46,7 @@ } + @Deprecated //Use Forge version - public static List m_74517_(LevelAccessor p_74518_, BlockPos p_74519_, BlockPos p_74520_, StructurePlaceSettings p_74521_, List p_74522_) { + public static List processBlockInfos(LevelAccessor p_74518_, BlockPos p_74519_, BlockPos p_74520_, StructurePlaceSettings p_74521_, List p_74522_) { + return processBlockInfos(p_74518_, p_74519_, p_74520_, p_74521_, p_74522_, null); + } + @@ -54,11 +54,11 @@ List list = Lists.newArrayList(); for(StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : p_74522_) { - BlockPos blockpos = m_74563_(p_74521_, structuretemplate$structureblockinfo.f_74675_).m_141952_(p_74519_); - StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo1 = new StructureTemplate.StructureBlockInfo(blockpos, structuretemplate$structureblockinfo.f_74676_, structuretemplate$structureblockinfo.f_74677_ != null ? structuretemplate$structureblockinfo.f_74677_.m_6426_() : null); + BlockPos blockpos = calculateRelativePosition(p_74521_, structuretemplate$structureblockinfo.pos).offset(p_74519_); + StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo1 = new StructureTemplate.StructureBlockInfo(blockpos, structuretemplate$structureblockinfo.state, structuretemplate$structureblockinfo.nbt != null ? structuretemplate$structureblockinfo.nbt.copy() : null); -- for(Iterator iterator = p_74521_.m_74411_().iterator(); structuretemplate$structureblockinfo1 != null && iterator.hasNext(); structuretemplate$structureblockinfo1 = iterator.next().m_7382_(p_74518_, p_74519_, p_74520_, structuretemplate$structureblockinfo, structuretemplate$structureblockinfo1, p_74521_)) { -+ for(Iterator iterator = p_74521_.m_74411_().iterator(); structuretemplate$structureblockinfo1 != null && iterator.hasNext(); structuretemplate$structureblockinfo1 = iterator.next().process(p_74518_, p_74519_, p_74520_, structuretemplate$structureblockinfo, structuretemplate$structureblockinfo1, p_74521_, template)) { +- for(Iterator iterator = p_74521_.getProcessors().iterator(); structuretemplate$structureblockinfo1 != null && iterator.hasNext(); structuretemplate$structureblockinfo1 = iterator.next().processBlock(p_74518_, p_74519_, p_74520_, structuretemplate$structureblockinfo, structuretemplate$structureblockinfo1, p_74521_)) { ++ for(Iterator iterator = p_74521_.getProcessors().iterator(); structuretemplate$structureblockinfo1 != null && iterator.hasNext(); structuretemplate$structureblockinfo1 = iterator.next().process(p_74518_, p_74519_, p_74520_, structuretemplate$structureblockinfo, structuretemplate$structureblockinfo1, p_74521_, template)) { } if (structuretemplate$structureblockinfo1 != null) { @@ -66,17 +66,17 @@ return list; } -- private void m_74523_(ServerLevelAccessor p_74524_, BlockPos p_74525_, Mirror p_74526_, Rotation p_74527_, BlockPos p_74528_, @Nullable BoundingBox p_74529_, boolean p_74530_) { -- for(StructureTemplate.StructureEntityInfo structuretemplate$structureentityinfo : this.f_74483_) { -- BlockPos blockpos = m_74593_(structuretemplate$structureentityinfo.f_74684_, p_74526_, p_74527_, p_74528_).m_141952_(p_74525_); -- if (p_74529_ == null || p_74529_.m_71051_(blockpos)) { +- private void placeEntities(ServerLevelAccessor p_74524_, BlockPos p_74525_, Mirror p_74526_, Rotation p_74527_, BlockPos p_74528_, @Nullable BoundingBox p_74529_, boolean p_74530_) { +- for(StructureTemplate.StructureEntityInfo structuretemplate$structureentityinfo : this.entityInfoList) { +- BlockPos blockpos = transform(structuretemplate$structureentityinfo.blockPos, p_74526_, p_74527_, p_74528_).offset(p_74525_); +- if (p_74529_ == null || p_74529_.isInside(blockpos)) { + public static List processEntityInfos(@Nullable StructureTemplate template, LevelAccessor p_215387_0_, BlockPos p_215387_1_, StructurePlaceSettings p_215387_2_, List p_215387_3_) { + List list = Lists.newArrayList(); + for(StructureTemplate.StructureEntityInfo entityInfo : p_215387_3_) { -+ Vec3 pos = transformedVec3d(p_215387_2_, entityInfo.f_74683_).m_82549_(Vec3.m_82528_(p_215387_1_)); -+ BlockPos blockpos = m_74563_(p_215387_2_, entityInfo.f_74684_).m_141952_(p_215387_1_); -+ StructureTemplate.StructureEntityInfo info = new StructureTemplate.StructureEntityInfo(pos, blockpos, entityInfo.f_74685_); -+ for (StructureProcessor proc : p_215387_2_.m_74411_()) { ++ Vec3 pos = transformedVec3d(p_215387_2_, entityInfo.pos).add(Vec3.atLowerCornerOf(p_215387_1_)); ++ BlockPos blockpos = calculateRelativePosition(p_215387_2_, entityInfo.blockPos).offset(p_215387_1_); ++ StructureTemplate.StructureEntityInfo info = new StructureTemplate.StructureEntityInfo(pos, blockpos, entityInfo.nbt); ++ for (StructureProcessor proc : p_215387_2_.getProcessors()) { + info = proc.processEntity(p_215387_0_, p_215387_1_, entityInfo, info, p_215387_2_, template); + if (info == null) + break; @@ -88,66 +88,66 @@ + } + + private void addEntitiesToWorld(ServerLevelAccessor p_74524_, BlockPos p_74525_, StructurePlaceSettings placementIn) { -+ for(StructureTemplate.StructureEntityInfo structuretemplate$structureentityinfo : processEntityInfos(this, p_74524_, p_74525_, placementIn, this.f_74483_)) { -+ BlockPos blockpos = m_74593_(structuretemplate$structureentityinfo.f_74684_, placementIn.m_74401_(), placementIn.m_74404_(), placementIn.m_74407_()).m_141952_(p_74525_); -+ blockpos = structuretemplate$structureentityinfo.f_74684_; // FORGE: Position will have already been transformed by processEntityInfos -+ if (placementIn.m_74409_() == null || placementIn.m_74409_().m_71051_(blockpos)) { - CompoundTag compoundtag = structuretemplate$structureentityinfo.f_74685_.m_6426_(); -- Vec3 vec3 = m_74578_(structuretemplate$structureentityinfo.f_74683_, p_74526_, p_74527_, p_74528_); -- Vec3 vec31 = vec3.m_82520_((double)p_74525_.m_123341_(), (double)p_74525_.m_123342_(), (double)p_74525_.m_123343_()); -+ Vec3 vec31 = structuretemplate$structureentityinfo.f_74683_; // FORGE: Position will have already been transformed by processEntityInfos ++ for(StructureTemplate.StructureEntityInfo structuretemplate$structureentityinfo : processEntityInfos(this, p_74524_, p_74525_, placementIn, this.entityInfoList)) { ++ BlockPos blockpos = transform(structuretemplate$structureentityinfo.blockPos, placementIn.getMirror(), placementIn.getRotation(), placementIn.getRotationPivot()).offset(p_74525_); ++ blockpos = structuretemplate$structureentityinfo.blockPos; // FORGE: Position will have already been transformed by processEntityInfos ++ if (placementIn.getBoundingBox() == null || placementIn.getBoundingBox().isInside(blockpos)) { + CompoundTag compoundtag = structuretemplate$structureentityinfo.nbt.copy(); +- Vec3 vec3 = transform(structuretemplate$structureentityinfo.pos, p_74526_, p_74527_, p_74528_); +- Vec3 vec31 = vec3.add((double)p_74525_.getX(), (double)p_74525_.getY(), (double)p_74525_.getZ()); ++ Vec3 vec31 = structuretemplate$structureentityinfo.pos; // FORGE: Position will have already been transformed by processEntityInfos ListTag listtag = new ListTag(); - listtag.add(DoubleTag.m_128500_(vec31.f_82479_)); - listtag.add(DoubleTag.m_128500_(vec31.f_82480_)); + listtag.add(DoubleTag.valueOf(vec31.x)); + listtag.add(DoubleTag.valueOf(vec31.y)); @@ -390,10 +_,10 @@ - compoundtag.m_128365_("Pos", listtag); - compoundtag.m_128473_("UUID"); - m_74543_(p_74524_, compoundtag).ifPresent((p_205061_) -> { -- float f = p_205061_.m_7890_(p_74527_); -- f += p_205061_.m_6961_(p_74526_) - p_205061_.m_146908_(); -+ float f = p_205061_.m_7890_(placementIn.m_74404_()); -+ f += (p_205061_.m_6961_(placementIn.m_74401_()) - p_205061_.m_146908_()); - p_205061_.m_7678_(vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, f, p_205061_.m_146909_()); + compoundtag.put("Pos", listtag); + compoundtag.remove("UUID"); + createEntityIgnoreException(p_74524_, compoundtag).ifPresent((p_205061_) -> { +- float f = p_205061_.rotate(p_74527_); +- f += p_205061_.mirror(p_74526_) - p_205061_.getYRot(); ++ float f = p_205061_.rotate(placementIn.getRotation()); ++ f += (p_205061_.mirror(placementIn.getMirror()) - p_205061_.getYRot()); + p_205061_.moveTo(vec31.x, vec31.y, vec31.z, f, p_205061_.getXRot()); - if (p_74530_ && p_205061_ instanceof Mob) { -+ if (placementIn.m_74414_() && p_205061_ instanceof Mob) { - ((Mob)p_205061_).m_6518_(p_74524_, p_74524_.m_6436_(new BlockPos(vec31)), MobSpawnType.STRUCTURE, (SpawnGroupData)null, compoundtag); ++ if (placementIn.shouldFinalizeEntities() && p_205061_ instanceof Mob) { + ((Mob)p_205061_).finalizeSpawn(p_74524_, p_74524_.getCurrentDifficultyAt(new BlockPos(vec31)), MobSpawnType.STRUCTURE, (SpawnGroupData)null, compoundtag); } @@ -405,11 +_,9 @@ } - private static Optional m_74543_(ServerLevelAccessor p_74544_, CompoundTag p_74545_) { + private static Optional createEntityIgnoreException(ServerLevelAccessor p_74544_, CompoundTag p_74545_) { - try { -- return EntityType.m_20642_(p_74545_, p_74544_.m_6018_()); +- return EntityType.create(p_74545_, p_74544_.getLevel()); - } catch (Exception exception) { - return Optional.empty(); - } + // CraftBukkit start -+ return EntityType.m_20642_(p_74545_, p_74544_.m_6018_()); ++ return EntityType.create(p_74545_, p_74544_.getLevel()); + // CraftBukkit end } - public Vec3i m_163808_(Rotation p_163809_) { + public Vec3i getSize(Rotation p_163809_) { @@ -601,6 +_,12 @@ - p_74619_.m_128365_("entities", listtag); - p_74619_.m_128365_("size", this.m_74625_(this.f_74484_.m_123341_(), this.f_74484_.m_123342_(), this.f_74484_.m_123343_())); - p_74619_.m_128405_("DataVersion", SharedConstants.m_183709_().getWorldVersion()); + p_74619_.put("entities", listtag); + p_74619_.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); + p_74619_.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); + + // CraftBukkit Start - PDC + if (!this.persistentDataContainer.isEmpty()) { -+ p_74619_.m_128365_("BukkitValues", this.persistentDataContainer.toTagCompound()); ++ p_74619_.put("BukkitValues", this.persistentDataContainer.toTagCompound()); + } + // CraftBukkit end return p_74619_; } @@ -633,6 +_,13 @@ - this.f_74483_.add(new StructureTemplate.StructureEntityInfo(vec3, blockpos, compoundtag1)); + this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(vec3, blockpos, compoundtag1)); } } + + // CraftBukkit start - PDC -+ net.minecraft.nbt.Tag base = p_74639_.m_128423_("BukkitValues"); ++ net.minecraft.nbt.Tag base = p_74639_.get("BukkitValues"); + if (base instanceof CompoundTag) { + this.persistentDataContainer.putAll((CompoundTag) base); + } 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 58d64ebe..9cf7c395 100644 --- a/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch +++ b/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/lighting/BlockLightEngine.java +++ b/net/minecraft/world/level/lighting/BlockLightEngine.java @@ -117,4 +_,9 @@ - this.f_75632_.m_75785_(); - this.m_75576_(Long.MAX_VALUE, p_75502_.m_121878_(), 15 - p_75503_, true); + this.storage.runAllUpdates(); + this.checkEdge(Long.MAX_VALUE, p_75502_.asLong(), 15 - p_75503_, true); } + + @Override + public int queuedUpdateSize() { -+ return f_75632_.queuedUpdateSize(); ++ return storage.queuedUpdateSize(); + } } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch index 69b8ad20..1a47dd91 100644 --- a/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch +++ b/patches/minecraft/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/level/lighting/DynamicGraphMinFixedPoint.java @@ -26,6 +_,7 @@ for(int i = 0; i < p_75543_; ++i) { - this.f_75538_[i] = new LongLinkedOpenHashSet(p_75544_, 0.5F) { + this.queues[i] = new LongLinkedOpenHashSet(p_75544_, 0.5F) { protected void rehash(int p_75611_) { + if (size < 0 || p_75611_ < 0) return; //Magma if (p_75611_ > p_75544_) { @@ -10,18 +10,18 @@ } @@ -36,6 +_,7 @@ - this.f_75539_ = new Long2ByteOpenHashMap(p_75545_, 0.5F) { + this.computedLevels = new Long2ByteOpenHashMap(p_75545_, 0.5F) { protected void rehash(int p_75620_) { + if (size < (containsNullKey ? 1 : 0) || p_75620_ < 0) return; //Magma if (p_75620_ > p_75545_) { super.rehash(p_75620_); } @@ -229,4 +_,8 @@ - protected abstract void m_7351_(long p_75552_, int p_75553_); + protected abstract void setLevel(long p_75552_, int p_75553_); - protected abstract int m_6359_(long p_75590_, long p_75591_, int p_75592_); + protected abstract int computeLevelFromNeighbor(long p_75590_, long p_75591_, int p_75592_); + + protected int queuedUpdateSize() { -+ return f_75539_.size(); ++ return computedLevels.size(); + } } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch index d08eff25..79952630 100644 --- a/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch +++ b/patches/minecraft/net/minecraft/world/level/lighting/LayerLightEngine.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/lighting/LayerLightEngine.java +++ b/net/minecraft/world/level/lighting/LayerLightEngine.java @@ -214,4 +_,6 @@ - long i = SectionPos.m_123240_(SectionPos.m_123209_(p_75700_.f_45578_, 0, p_75700_.f_45579_)); - this.f_75632_.m_75782_(i, p_75701_); + long i = SectionPos.getZeroNode(SectionPos.asLong(p_75700_.x, 0, p_75700_.z)); + this.storage.retainData(i, p_75701_); } + + public abstract int queuedUpdateSize(); diff --git a/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch index 17283ca1..434bf419 100644 --- a/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch +++ b/patches/minecraft/net/minecraft/world/level/lighting/SkyLightEngine.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/lighting/SkyLightEngine.java +++ b/net/minecraft/world/level/lighting/SkyLightEngine.java @@ -174,4 +_,9 @@ - public String m_6647_(long p_75853_) { - return super.m_6647_(p_75853_) + (this.f_75632_.m_75890_(p_75853_) ? "*" : ""); + public String getDebugData(long p_75853_) { + return super.getDebugData(p_75853_) + (this.storage.isAboveData(p_75853_) ? "*" : ""); } + + @Override 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 49eb4ea2..1fe8b21a 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java @@ -117,6 +_,15 @@ - BlockState blockstate1 = p_76011_.m_8055_(blockpos); - FluidState fluidstate = this.m_76035_(p_76011_, blockpos, blockstate1); - if (this.m_75977_(p_76011_, p_76012_, blockstate, Direction.DOWN, blockpos, blockstate1, p_76011_.m_6425_(blockpos), fluidstate.m_76152_())) { + BlockState blockstate1 = p_76011_.getBlockState(blockpos); + FluidState fluidstate = this.getNewLiquid(p_76011_, blockpos, blockstate1); + if (this.canSpreadTo(p_76011_, p_76012_, blockstate, Direction.DOWN, blockpos, blockstate1, p_76011_.getFluidState(blockpos), fluidstate.getType())) { + // CraftBukkit start + org.bukkit.block.Block source = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_76011_, p_76012_); + org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(source, org.bukkit.block.BlockFace.DOWN); @@ -13,13 +13,13 @@ + return; + } + // CraftBukkit end - this.m_6364_(p_76011_, blockpos, blockstate1, Direction.DOWN, fluidstate); - if (this.m_76019_(p_76011_, p_76012_) >= 3) { - this.m_76014_(p_76011_, p_76012_, p_76013_, blockstate); + this.spreadTo(p_76011_, blockpos, blockstate1, Direction.DOWN, fluidstate); + if (this.sourceNeighborCount(p_76011_, p_76012_) >= 3) { + this.spreadToSides(p_76011_, p_76012_, p_76013_, blockstate); @@ -143,6 +_,14 @@ - BlockPos blockpos = p_76016_.m_142300_(direction); - BlockState blockstate = p_76015_.m_8055_(blockpos); - if (this.m_75977_(p_76015_, p_76016_, p_76018_, direction, blockpos, blockstate, p_76015_.m_6425_(blockpos), fluidstate.m_76152_())) { + BlockPos blockpos = p_76016_.relative(direction); + BlockState blockstate = p_76015_.getBlockState(blockpos); + if (this.canSpreadTo(p_76015_, p_76016_, p_76018_, direction, blockpos, blockstate, p_76015_.getFluidState(blockpos), fluidstate.getType())) { + // CraftBukkit start + org.bukkit.block.Block source = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.at(p_76015_, blockpos); + org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(source, org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.notchToBlockFace(direction)); @@ -28,15 +28,15 @@ + continue; + } + // CraftBukkit end - this.m_6364_(p_76015_, blockpos, blockstate, direction, fluidstate); + this.spreadTo(p_76015_, blockpos, blockstate, direction, fluidstate); } } @@ -159,7 +_,7 @@ - BlockState blockstate = p_76036_.m_8055_(blockpos); - FluidState fluidstate = blockstate.m_60819_(); - if (fluidstate.m_76152_().m_6212_(this) && this.m_76061_(direction, p_76036_, p_76037_, p_76038_, blockpos, blockstate)) { -- if (fluidstate.m_76170_()) { -+ if (fluidstate.m_76170_() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_76036_, blockpos, blockstate, this.m_6760_())) { + BlockState blockstate = p_76036_.getBlockState(blockpos); + FluidState fluidstate = blockstate.getFluidState(); + if (fluidstate.getType().isSame(this) && this.canPassThroughWall(direction, p_76036_, p_76037_, p_76038_, blockpos, blockstate)) { +- if (fluidstate.isSource()) { ++ if (fluidstate.isSource() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_76036_, blockpos, blockstate, this.canConvertToSource())) { ++j; } @@ -44,34 +44,34 @@ } } -- if (this.m_6760_() && j >= 2) { +- if (this.canConvertToSource() && j >= 2) { + if (j >= 2) { - BlockState blockstate1 = p_76036_.m_8055_(p_76037_.m_7495_()); - FluidState fluidstate1 = blockstate1.m_60819_(); - if (blockstate1.m_60767_().m_76333_() || this.m_76096_(fluidstate1)) { + BlockState blockstate1 = p_76036_.getBlockState(p_76037_.below()); + FluidState fluidstate1 = blockstate1.getFluidState(); + if (blockstate1.getMaterial().isSolid() || this.isSourceBlockOfThisType(fluidstate1)) { @@ -397,11 +_,23 @@ - int i = this.m_6886_(p_75995_, p_75996_, p_75997_, fluidstate); - if (fluidstate.m_76178_()) { + int i = this.getSpreadDelay(p_75995_, p_75996_, p_75997_, fluidstate); + if (fluidstate.isEmpty()) { p_75997_ = fluidstate; -- p_75995_.m_7731_(p_75996_, Blocks.f_50016_.m_49966_(), 3); +- p_75995_.setBlock(p_75996_, Blocks.AIR.defaultBlockState(), 3); + // CraftBukkit start -+ org.bukkit.event.block.FluidLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFluidLevelChangeEvent(p_75995_, p_75996_, Blocks.f_50016_.m_49966_()); ++ org.bukkit.event.block.FluidLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFluidLevelChangeEvent(p_75995_, p_75996_, Blocks.AIR.defaultBlockState()); + if (event.isCancelled()) { + return; + } -+ p_75995_.m_7731_(p_75996_, ((org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData) event.getNewData()).getState(), 3); ++ p_75995_.setBlock(p_75996_, ((org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData) event.getNewData()).getState(), 3); + // CraftBukkit end } else if (!fluidstate.equals(p_75997_)) { p_75997_ = fluidstate; - BlockState blockstate = fluidstate.m_76188_(); -- p_75995_.m_7731_(p_75996_, blockstate, 2); + BlockState blockstate = fluidstate.createLegacyBlock(); +- p_75995_.setBlock(p_75996_, blockstate, 2); + // CraftBukkit start + org.bukkit.event.block.FluidLevelChangeEvent event = org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callFluidLevelChangeEvent(p_75995_, p_75996_, blockstate); + if (event.isCancelled()) { + return; + } -+ p_75995_.m_7731_(p_75996_, ((org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData) event.getNewData()).getState(), 2); ++ p_75995_.setBlock(p_75996_, ((org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData) event.getNewData()).getState(), 2); + // CraftBukkit end - p_75995_.m_186469_(p_75996_, fluidstate.m_76152_(), i); - p_75995_.m_46672_(p_75996_, blockstate.m_60734_()); + p_75995_.scheduleTick(p_75996_, fluidstate.getType(), i); + p_75995_.updateNeighborsAt(p_75996_, blockstate.getBlock()); } 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 2475fd8f..7abfd10b 100644 --- a/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch @@ -6,13 +6,13 @@ -public abstract class Fluid { +public abstract class Fluid extends net.minecraftforge.registries.ForgeRegistryEntry implements net.minecraftforge.common.extensions.IForgeFluid { - public static final IdMapper f_76104_ = new IdMapper<>(); - protected final StateDefinition f_76105_; - private FluidState f_76103_; + public static final IdMapper FLUID_STATE_REGISTRY = new IdMapper<>(); + protected final StateDefinition stateDefinition; + private FluidState defaultFluidState; @@ -101,6 +_,22 @@ } - public abstract VoxelShape m_7999_(FluidState p_76137_, BlockGetter p_76138_, BlockPos p_76139_); + public abstract VoxelShape getShape(FluidState p_76137_, BlockGetter p_76138_, BlockPos p_76139_); + + /** + * Creates the fluid attributes object, which wilAl contain all the extended values for the fluid that aren't part of the vanilla system. @@ -30,5 +30,5 @@ + return forgeFluidAttributes; + } - public Optional m_142520_() { + public Optional getPickupSound() { return Optional.empty(); 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 0568b8e8..78e1e8ae 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch @@ -6,14 +6,14 @@ -public final class FluidState extends StateHolder { +public final class FluidState extends StateHolder implements net.minecraftforge.common.extensions.IForgeFluidState { - public static final Codec f_76146_ = m_61127_(Registry.f_122822_.m_194605_(), Fluid::m_76145_).stable(); - public static final int f_164510_ = 9; - public static final int f_164511_ = 8; + public static final Codec CODEC = codec(Registry.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); + public static final int AMOUNT_MAX = 9; + public static final int AMOUNT_FULL = 8; @@ -113,6 +_,7 @@ - return this.m_76152_() == p_192918_; + return this.getType() == p_192918_; } + @Deprecated //Forge: Use more sensitive version - public float m_76190_() { - return this.m_76152_().m_6752_(); + public float getExplosionResistance() { + return this.getType().getExplosionResistance(); } 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 38446933..a2198b83 100644 --- a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,46 +1,46 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java @@ -72,7 +_,14 @@ - BlockState blockstate = p_76239_.m_8055_(blockpos); - if (blockstate.m_60795_()) { - if (this.m_76227_(p_76239_, blockpos)) { -- p_76239_.m_46597_(blockpos, BaseFireBlock.m_49245_(p_76239_, blockpos)); + BlockState blockstate = p_76239_.getBlockState(blockpos); + if (blockstate.isAir()) { + if (this.hasFlammableNeighbours(p_76239_, blockpos)) { +- p_76239_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_76239_, blockpos)); + // CraftBukkit start - Prevent lava putting something on fire -+ if (p_76239_.m_8055_(blockpos).m_60734_() != Blocks.f_50083_) { ++ if (p_76239_.getBlockState(blockpos).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(p_76239_, blockpos, p_76240_).isCancelled()) { + continue; + } + } + // CraftBukkit end -+ p_76239_.m_46597_(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76239_, blockpos, p_76240_, Blocks.f_50083_.m_49966_())); ++ p_76239_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76239_, blockpos, p_76240_, Blocks.FIRE.defaultBlockState())); return; } - } else if (blockstate.m_60767_().m_76334_()) { + } else if (blockstate.getMaterial().blocksMotion()) { @@ -86,8 +_,16 @@ return; } -- if (p_76239_.m_46859_(blockpos1.m_7494_()) && this.m_76245_(p_76239_, blockpos1)) { -- p_76239_.m_46597_(blockpos1.m_7494_(), BaseFireBlock.m_49245_(p_76239_, blockpos1)); -+ if (p_76239_.m_46859_(blockpos1.m_7494_()) && this.isFlammable(p_76239_, blockpos1, Direction.UP)) { +- if (p_76239_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_76239_, blockpos1)) { +- p_76239_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_76239_, blockpos1)); ++ if (p_76239_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_76239_, blockpos1, Direction.UP)) { + // CraftBukkit start - Prevent lava putting something on fire -+ BlockPos up = blockpos1.m_7494_(); -+ if (p_76239_.m_8055_(up).m_60734_() != Blocks.f_50083_) { ++ BlockPos up = blockpos1.above(); ++ if (p_76239_.getBlockState(up).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callBlockIgniteEvent(p_76239_, up, p_76240_).isCancelled()) { + continue; + } + } + // CraftBukkit end -+ p_76239_.m_46597_(blockpos1.m_7494_(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76239_, blockpos1.m_7494_(), p_76240_, Blocks.f_50083_.m_49966_())); ++ p_76239_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76239_, blockpos1.above(), p_76240_, Blocks.FIRE.defaultBlockState())); } } } @@ -97,7 +_,7 @@ - private boolean m_76227_(LevelReader p_76228_, BlockPos p_76229_) { + private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for(Direction direction : Direction.values()) { -- if (this.m_76245_(p_76228_, p_76229_.m_142300_(direction))) { -+ if (this.isFlammable(p_76228_, p_76229_.m_142300_(direction), direction.m_122424_())) { +- if (this.isFlammable(p_76228_, p_76229_.relative(direction))) { ++ if (this.isFlammable(p_76228_, p_76229_.relative(direction), direction.getOpposite())) { return true; } } @@ -50,27 +50,27 @@ + /** @deprecated Forge: use {@link LavaFluid#isFlammable(LevelReader,BlockPos,Direction)} instead */ + @Deprecated - private boolean m_76245_(LevelReader p_76246_, BlockPos p_76247_) { - return p_76247_.m_123342_() >= p_76246_.m_141937_() && p_76247_.m_123342_() < p_76246_.m_151558_() && !p_76246_.m_46805_(p_76247_) ? false : p_76246_.m_8055_(p_76247_).m_60767_().m_76335_(); + 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_).getMaterial().isFlammable(); } + private boolean isFlammable(LevelReader level, BlockPos pos, Direction face) { -+ return pos.m_123342_() >= level.m_141937_() && pos.m_123342_() < level.m_151558_() && !level.m_46805_(pos) ? false : level.m_8055_(pos).isFlammable(level, pos, face); ++ return pos.getY() >= level.getMinBuildHeight() && pos.getY() < level.getMaxBuildHeight() && !level.hasChunkAt(pos) ? false : level.getBlockState(pos).isFlammable(level, pos, face); + } + @Nullable - public ParticleOptions m_7792_() { - return ParticleTypes.f_123800_; + public ParticleOptions getDripParticle() { + return ParticleTypes.DRIPPING_LAVA; @@ -164,7 +_,11 @@ - FluidState fluidstate = p_76220_.m_6425_(p_76221_); - if (this.m_205067_(FluidTags.f_13132_) && fluidstate.m_205070_(FluidTags.f_13131_)) { - if (p_76222_.m_60734_() instanceof LiquidBlock) { -- p_76220_.m_7731_(p_76221_, Blocks.f_50069_.m_49966_(), 3); + FluidState fluidstate = p_76220_.getFluidState(p_76221_); + if (this.is(FluidTags.LAVA) && fluidstate.is(FluidTags.WATER)) { + if (p_76222_.getBlock() instanceof LiquidBlock) { +- p_76220_.setBlock(p_76221_, Blocks.STONE.defaultBlockState(), 3); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_76220_.getMinecraftWorld(), p_76221_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76220_, p_76221_, p_76221_, Blocks.f_50069_.m_49966_()), 3)) { ++ if (!org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.handleBlockFormEvent(p_76220_.getMinecraftWorld(), p_76221_, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_76220_, p_76221_, p_76221_, Blocks.STONE.defaultBlockState()), 3)) { + return; + } + // CraftBukkit end } - this.m_76212_(p_76220_, p_76221_); + this.fizz(p_76220_, p_76221_); diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch index 5e2274dc..8ffdf44b 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java @@ -45,7 +_,7 @@ - BlockPathTypes blockpathtypes1 = this.m_77567_(this.f_77313_, p_164677_.f_77271_, p_164677_.f_77272_, p_164677_.f_77273_); + BlockPathTypes blockpathtypes1 = this.getCachedBlockType(this.mob, p_164677_.x, p_164677_.y, p_164677_.z); int j; - if (this.f_77313_.m_21439_(blockpathtypes) >= 0.0F && blockpathtypes1 != BlockPathTypes.STICKY_HONEY) { -- j = Mth.m_14143_(Math.max(1.0F, this.f_77313_.f_19793_)); -+ j = Mth.m_14143_(Math.max(1.0F, this.f_77313_.getStepHeight())); + if (this.mob.getPathfindingMalus(blockpathtypes) >= 0.0F && blockpathtypes1 != BlockPathTypes.STICKY_HONEY) { +- j = Mth.floor(Math.max(1.0F, this.mob.maxUpStep)); ++ j = Mth.floor(Math.max(1.0F, this.mob.getStepHeight())); } else { j = 0; } diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch index 41a07941..22b840f9 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/BlockPathTypes.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/pathfinder/BlockPathTypes.java +++ b/net/minecraft/world/level/pathfinder/BlockPathTypes.java @@ -37,4 +_,13 @@ - public float m_77124_() { - return this.f_77117_; + public float getMalus() { + return this.malus; } + + @javax.annotation.Nullable diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index 0c0d2e2d..ff635752 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java @@ -113,7 +_,7 @@ - BlockPathTypes blockpathtypes = this.m_77567_(this.f_77313_, p_77641_.f_77271_, p_77641_.f_77272_ + 1, p_77641_.f_77273_); - BlockPathTypes blockpathtypes1 = this.m_77567_(this.f_77313_, p_77641_.f_77271_, p_77641_.f_77272_, p_77641_.f_77273_); - if (this.f_77313_.m_21439_(blockpathtypes) >= 0.0F && blockpathtypes1 != BlockPathTypes.STICKY_HONEY) { -- j = Mth.m_14143_(Math.max(1.0F, this.f_77313_.f_19793_)); -+ j = Mth.m_14143_(Math.max(1.0F, this.f_77313_.getStepHeight())); + BlockPathTypes blockpathtypes = this.getCachedBlockType(this.mob, p_77641_.x, p_77641_.y + 1, p_77641_.z); + BlockPathTypes blockpathtypes1 = this.getCachedBlockType(this.mob, p_77641_.x, p_77641_.y, p_77641_.z); + if (this.mob.getPathfindingMalus(blockpathtypes) >= 0.0F && blockpathtypes1 != BlockPathTypes.STICKY_HONEY) { +- j = Mth.floor(Math.max(1.0F, this.mob.maxUpStep)); ++ j = Mth.floor(Math.max(1.0F, this.mob.getStepHeight())); } - double d0 = this.m_142213_(new BlockPos(p_77641_.f_77271_, p_77641_.f_77272_, p_77641_.f_77273_)); + double d0 = this.getFloorLevel(new BlockPos(p_77641_.x, p_77641_.y, p_77641_.z)); @@ -476,6 +_,8 @@ - protected static BlockPathTypes m_77643_(BlockGetter p_77644_, BlockPos p_77645_) { - BlockState blockstate = p_77644_.m_8055_(p_77645_); + protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter p_77644_, BlockPos p_77645_) { + BlockState blockstate = p_77644_.getBlockState(p_77645_); + BlockPathTypes type = blockstate.getBlockPathType(p_77644_, p_77645_); + if (type != null) return type; - Block block = blockstate.m_60734_(); - Material material = blockstate.m_60767_(); - if (blockstate.m_60795_()) { + Block block = blockstate.getBlock(); + Material material = blockstate.getMaterial(); + if (blockstate.isAir()) { diff --git a/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch b/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch index 476d06f3..9eebf4f4 100644 --- a/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -5,87 +5,87 @@ import net.minecraft.world.level.levelgen.Heightmap; -public class PortalForcer { -- private static final int f_164734_ = 3; -- private static final int f_164735_ = 128; -- private static final int f_164736_ = 16; -- private static final int f_164737_ = 5; -- private static final int f_164738_ = 4; -- private static final int f_164739_ = 3; -- private static final int f_164740_ = -1; -- private static final int f_164741_ = 4; -- private static final int f_164742_ = -1; -- private static final int f_164743_ = 3; -- private static final int f_164744_ = -1; -- private static final int f_164745_ = 2; -- private static final int f_164746_ = -1; -- protected final ServerLevel f_77648_; +- private static final int TICKET_RADIUS = 3; +- private static final int SEARCH_RADIUS = 128; +- private static final int CREATE_RADIUS = 16; +- private static final int FRAME_HEIGHT = 5; +- private static final int FRAME_WIDTH = 4; +- private static final int FRAME_BOX = 3; +- private static final int FRAME_HEIGHT_START = -1; +- private static final int FRAME_HEIGHT_END = 4; +- private static final int FRAME_WIDTH_START = -1; +- private static final int FRAME_WIDTH_END = 3; +- private static final int FRAME_BOX_START = -1; +- private static final int FRAME_BOX_END = 2; +- private static final int NOTHING_FOUND = -1; +- protected final ServerLevel level; - - public PortalForcer(ServerLevel p_77650_) { -- this.f_77648_ = p_77650_; +- this.level = p_77650_; - } - -- public Optional m_192985_(BlockPos p_192986_, boolean p_192987_, WorldBorder p_192988_) { -- PoiManager poimanager = this.f_77648_.m_8904_(); +- public Optional findPortalAround(BlockPos p_192986_, boolean p_192987_, WorldBorder p_192988_) { +- PoiManager poimanager = this.level.getPoiManager(); - int i = p_192987_ ? 16 : 128; -- poimanager.m_27056_(this.f_77648_, p_192986_, i); -- Optional optional = poimanager.m_27166_((p_77654_) -> { -- return p_77654_ == PoiType.f_27350_; +- poimanager.ensureLoadedAndValid(this.level, p_192986_, i); +- Optional optional = poimanager.getInSquare((p_77654_) -> { +- return p_77654_ == PoiType.NETHER_PORTAL; - }, p_192986_, i, PoiManager.Occupancy.ANY).filter((p_192981_) -> { -- return p_192988_.m_61937_(p_192981_.m_27257_()); +- return p_192988_.isWithinBounds(p_192981_.getPos()); - }).sorted(Comparator.comparingDouble((p_192984_) -> { -- return p_192984_.m_27257_().m_123331_(p_192986_); +- return p_192984_.getPos().distSqr(p_192986_); - }).thenComparingInt((p_192992_) -> { -- return p_192992_.m_27257_().m_123342_(); +- return p_192992_.getPos().getY(); - })).filter((p_192990_) -> { -- return this.f_77648_.m_8055_(p_192990_.m_27257_()).m_61138_(BlockStateProperties.f_61364_); +- return this.level.getBlockState(p_192990_.getPos()).hasProperty(BlockStateProperties.HORIZONTAL_AXIS); - }).findFirst(); - return optional.map((p_192975_) -> { -- BlockPos blockpos = p_192975_.m_27257_(); -- this.f_77648_.m_7726_().m_8387_(TicketType.f_9447_, new ChunkPos(blockpos), 3, blockpos); -- BlockState blockstate = this.f_77648_.m_8055_(blockpos); -- return BlockUtil.m_124334_(blockpos, blockstate.m_61143_(BlockStateProperties.f_61364_), 21, Direction.Axis.Y, 21, (p_192978_) -> { -- return this.f_77648_.m_8055_(p_192978_) == blockstate; +- BlockPos blockpos = p_192975_.getPos(); +- this.level.getChunkSource().addRegionTicket(TicketType.PORTAL, new ChunkPos(blockpos), 3, blockpos); +- BlockState blockstate = this.level.getBlockState(blockpos); +- return BlockUtil.getLargestRectangleAround(blockpos, blockstate.getValue(BlockStateProperties.HORIZONTAL_AXIS), 21, Direction.Axis.Y, 21, (p_192978_) -> { +- return this.level.getBlockState(p_192978_) == blockstate; - }); - }); - } - -- public Optional m_77666_(BlockPos p_77667_, Direction.Axis p_77668_) { -- Direction direction = Direction.m_122390_(Direction.AxisDirection.POSITIVE, p_77668_); +- public Optional createPortal(BlockPos p_77667_, Direction.Axis p_77668_) { +- Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, p_77668_); - double d0 = -1.0D; - BlockPos blockpos = null; - double d1 = -1.0D; - BlockPos blockpos1 = null; -- WorldBorder worldborder = this.f_77648_.m_6857_(); -- int i = Math.min(this.f_77648_.m_151558_(), this.f_77648_.m_141937_() + this.f_77648_.m_143344_()) - 1; -- BlockPos.MutableBlockPos blockpos$mutableblockpos = p_77667_.m_122032_(); +- WorldBorder worldborder = this.level.getWorldBorder(); +- int i = Math.min(this.level.getMaxBuildHeight(), this.level.getMinBuildHeight() + this.level.getLogicalHeight()) - 1; +- BlockPos.MutableBlockPos blockpos$mutableblockpos = p_77667_.mutable(); - -- for(BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.m_121935_(p_77667_, 16, Direction.EAST, Direction.SOUTH)) { -- int j = Math.min(i, this.f_77648_.m_6924_(Heightmap.Types.MOTION_BLOCKING, blockpos$mutableblockpos1.m_123341_(), blockpos$mutableblockpos1.m_123343_())); +- for(BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.spiralAround(p_77667_, 16, Direction.EAST, Direction.SOUTH)) { +- int j = Math.min(i, this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getZ())); - int k = 1; -- if (worldborder.m_61937_(blockpos$mutableblockpos1) && worldborder.m_61937_(blockpos$mutableblockpos1.m_122175_(direction, 1))) { -- blockpos$mutableblockpos1.m_122175_(direction.m_122424_(), 1); +- if (worldborder.isWithinBounds(blockpos$mutableblockpos1) && worldborder.isWithinBounds(blockpos$mutableblockpos1.move(direction, 1))) { +- blockpos$mutableblockpos1.move(direction.getOpposite(), 1); - -- for(int l = j; l >= this.f_77648_.m_141937_(); --l) { -- blockpos$mutableblockpos1.m_142448_(l); -- if (this.f_77648_.m_46859_(blockpos$mutableblockpos1)) { +- for(int l = j; l >= this.level.getMinBuildHeight(); --l) { +- blockpos$mutableblockpos1.setY(l); +- if (this.level.isEmptyBlock(blockpos$mutableblockpos1)) { - int i1; -- for(i1 = l; l > this.f_77648_.m_141937_() && this.f_77648_.m_46859_(blockpos$mutableblockpos1.m_122173_(Direction.DOWN)); --l) { +- for(i1 = l; l > this.level.getMinBuildHeight() && this.level.isEmptyBlock(blockpos$mutableblockpos1.move(Direction.DOWN)); --l) { - } - - if (l + 4 <= i) { - int j1 = i1 - l; - if (j1 <= 0 || j1 >= 3) { -- blockpos$mutableblockpos1.m_142448_(l); -- if (this.m_77661_(blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 0)) { -- double d2 = p_77667_.m_123331_(blockpos$mutableblockpos1); -- if (this.m_77661_(blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, -1) && this.m_77661_(blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 1) && (d0 == -1.0D || d0 > d2)) { +- blockpos$mutableblockpos1.setY(l); +- if (this.canHostFrame(blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 0)) { +- double d2 = p_77667_.distSqr(blockpos$mutableblockpos1); +- if (this.canHostFrame(blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, -1) && this.canHostFrame(blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 1) && (d0 == -1.0D || d0 > d2)) { - d0 = d2; -- blockpos = blockpos$mutableblockpos1.m_7949_(); +- blockpos = blockpos$mutableblockpos1.immutable(); - } - - if (d0 == -1.0D && (d1 == -1.0D || d1 > d2)) { - d1 = d2; -- blockpos1 = blockpos$mutableblockpos1.m_7949_(); +- blockpos1 = blockpos$mutableblockpos1.immutable(); - } - } - } @@ -101,24 +101,24 @@ - } - - if (d0 == -1.0D) { -- int k1 = Math.max(this.f_77648_.m_141937_() - -1, 70); +- int k1 = Math.max(this.level.getMinBuildHeight() - -1, 70); - int i2 = i - 9; - if (i2 < k1) { - return Optional.empty(); - } - -- blockpos = (new BlockPos(p_77667_.m_123341_(), Mth.m_14045_(p_77667_.m_123342_(), k1, i2), p_77667_.m_123343_())).m_7949_(); -- Direction direction1 = direction.m_122427_(); -- if (!worldborder.m_61937_(blockpos)) { +- blockpos = (new BlockPos(p_77667_.getX(), Mth.clamp(p_77667_.getY(), k1, i2), p_77667_.getZ())).immutable(); +- Direction direction1 = direction.getClockWise(); +- if (!worldborder.isWithinBounds(blockpos)) { - return Optional.empty(); - } - - for(int i3 = -1; i3 < 2; ++i3) { - for(int j3 = 0; j3 < 2; ++j3) { - for(int k3 = -1; k3 < 3; ++k3) { -- BlockState blockstate1 = k3 < 0 ? Blocks.f_50080_.m_49966_() : Blocks.f_50016_.m_49966_(); -- blockpos$mutableblockpos.m_122154_(blockpos, j3 * direction.m_122429_() + i3 * direction1.m_122429_(), k3, j3 * direction.m_122431_() + i3 * direction1.m_122431_()); -- this.f_77648_.m_46597_(blockpos$mutableblockpos, blockstate1); +- BlockState blockstate1 = k3 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); +- blockpos$mutableblockpos.setWithOffset(blockpos, j3 * direction.getStepX() + i3 * direction1.getStepX(), k3, j3 * direction.getStepZ() + i3 * direction1.getStepZ()); +- this.level.setBlockAndUpdate(blockpos$mutableblockpos, blockstate1); - } - } - } @@ -127,35 +127,35 @@ - for(int l1 = -1; l1 < 3; ++l1) { - for(int j2 = -1; j2 < 4; ++j2) { - if (l1 == -1 || l1 == 2 || j2 == -1 || j2 == 3) { -- blockpos$mutableblockpos.m_122154_(blockpos, l1 * direction.m_122429_(), j2, l1 * direction.m_122431_()); -- this.f_77648_.m_7731_(blockpos$mutableblockpos, Blocks.f_50080_.m_49966_(), 3); +- blockpos$mutableblockpos.setWithOffset(blockpos, l1 * direction.getStepX(), j2, l1 * direction.getStepZ()); +- this.level.setBlock(blockpos$mutableblockpos, Blocks.OBSIDIAN.defaultBlockState(), 3); - } - } - } - -- BlockState blockstate = Blocks.f_50142_.m_49966_().m_61124_(NetherPortalBlock.f_54904_, p_77668_); +- BlockState blockstate = Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, p_77668_); - - for(int k2 = 0; k2 < 2; ++k2) { - for(int l2 = 0; l2 < 3; ++l2) { -- blockpos$mutableblockpos.m_122154_(blockpos, k2 * direction.m_122429_(), l2, k2 * direction.m_122431_()); -- this.f_77648_.m_7731_(blockpos$mutableblockpos, blockstate, 18); +- blockpos$mutableblockpos.setWithOffset(blockpos, k2 * direction.getStepX(), l2, k2 * direction.getStepZ()); +- this.level.setBlock(blockpos$mutableblockpos, blockstate, 18); - } - } - -- return Optional.of(new BlockUtil.FoundRectangle(blockpos.m_7949_(), 2, 3)); +- return Optional.of(new BlockUtil.FoundRectangle(blockpos.immutable(), 2, 3)); - } - -- private boolean m_77661_(BlockPos p_77662_, BlockPos.MutableBlockPos p_77663_, Direction p_77664_, int p_77665_) { -- Direction direction = p_77664_.m_122427_(); +- private boolean canHostFrame(BlockPos p_77662_, BlockPos.MutableBlockPos p_77663_, Direction p_77664_, int p_77665_) { +- Direction direction = p_77664_.getClockWise(); - - for(int i = -1; i < 3; ++i) { - for(int j = -1; j < 4; ++j) { -- p_77663_.m_122154_(p_77662_, p_77664_.m_122429_() * i + direction.m_122429_() * p_77665_, j, p_77664_.m_122431_() * i + direction.m_122431_() * p_77665_); -- if (j < 0 && !this.f_77648_.m_8055_(p_77663_).m_60767_().m_76333_()) { +- p_77663_.setWithOffset(p_77662_, p_77664_.getStepX() * i + direction.getStepX() * p_77665_, j, p_77664_.getStepZ() * i + direction.getStepZ() * p_77665_); +- if (j < 0 && !this.level.getBlockState(p_77663_).getMaterial().isSolid()) { - return false; - } - -- if (j >= 0 && !this.f_77648_.m_46859_(p_77663_)) { +- if (j >= 0 && !this.level.isEmptyBlock(p_77663_)) { - return false; - } - } @@ -165,58 +165,58 @@ - } + +public class PortalForcer implements net.minecraftforge.common.util.ITeleporter { -+ private static final int f_164734_ = 3; -+ private static final int f_164735_ = 128; -+ private static final int f_164736_ = 16; -+ private static final int f_164737_ = 5; -+ private static final int f_164738_ = 4; -+ private static final int f_164739_ = 3; -+ private static final int f_164740_ = -1; -+ private static final int f_164741_ = 4; -+ private static final int f_164742_ = -1; -+ private static final int f_164743_ = 3; -+ private static final int f_164744_ = -1; -+ private static final int f_164745_ = 2; -+ private static final int f_164746_ = -1; -+ protected final ServerLevel f_77648_; ++ private static final int TICKET_RADIUS = 3; ++ private static final int SEARCH_RADIUS = 128; ++ private static final int CREATE_RADIUS = 16; ++ private static final int FRAME_HEIGHT = 5; ++ private static final int FRAME_WIDTH = 4; ++ private static final int FRAME_BOX = 3; ++ private static final int FRAME_HEIGHT_START = -1; ++ private static final int FRAME_HEIGHT_END = 4; ++ private static final int FRAME_WIDTH_START = -1; ++ private static final int FRAME_WIDTH_END = 3; ++ private static final int FRAME_BOX_START = -1; ++ private static final int FRAME_BOX_END = 2; ++ private static final int NOTHING_FOUND = -1; ++ protected final ServerLevel level; + + public PortalForcer(ServerLevel p_77650_) { -+ this.f_77648_ = p_77650_; ++ this.level = p_77650_; + } + -+ public Optional m_192985_(BlockPos p_192986_, boolean p_192987_, WorldBorder p_192988_) { ++ public Optional findPortalAround(BlockPos p_192986_, boolean p_192987_, WorldBorder p_192988_) { + //CraftBukkit start + return findPortalAround( p_192986_, p_192988_, p_192987_ ? 16 : 128 ); + } + + public Optional findPortalAround(BlockPos p_192986_, WorldBorder p_192988_, int i) { -+ PoiManager poimanager = this.f_77648_.m_8904_(); ++ PoiManager poimanager = this.level.getPoiManager(); + // int i = p_192987_ ? 16 : 128; + //CraftBukkit end + -+ poimanager.m_27056_( this.f_77648_, p_192986_, i ); -+ Optional optional = poimanager.m_27166_( (p_77654_) -> { -+ return p_77654_ == PoiType.f_27350_; ++ poimanager.ensureLoadedAndValid( this.level, p_192986_, i ); ++ Optional optional = poimanager.getInSquare( (p_77654_) -> { ++ return p_77654_ == PoiType.NETHER_PORTAL; + }, p_192986_, i, PoiManager.Occupancy.ANY ).filter( (p_192981_) -> { -+ return p_192988_.m_61937_( p_192981_.m_27257_() ); ++ return p_192988_.isWithinBounds( p_192981_.getPos() ); + } ).sorted( Comparator.comparingDouble( (p_192984_) -> { -+ return p_192984_.m_27257_().m_123331_( p_192986_ ); ++ return p_192984_.getPos().distSqr( p_192986_ ); + } ).thenComparingInt( (p_192992_) -> { -+ return p_192992_.m_27257_().m_123342_(); ++ return p_192992_.getPos().getY(); + } ) ).filter( (p_192990_) -> { -+ return this.f_77648_.m_8055_( p_192990_.m_27257_() ).m_61138_( BlockStateProperties.f_61364_ ); ++ return this.level.getBlockState( p_192990_.getPos() ).hasProperty( BlockStateProperties.HORIZONTAL_AXIS ); + } ).findFirst(); + return optional.map( (p_192975_) -> { -+ BlockPos blockpos = p_192975_.m_27257_(); -+ this.f_77648_.m_7726_().m_8387_( TicketType.f_9447_, new ChunkPos( blockpos ), 3, blockpos ); -+ BlockState blockstate = this.f_77648_.m_8055_( blockpos ); -+ return BlockUtil.m_124334_( blockpos, blockstate.m_61143_( BlockStateProperties.f_61364_ ), 21, Direction.Axis.Y, 21, (p_192978_) -> { -+ return this.f_77648_.m_8055_( p_192978_ ) == blockstate; ++ BlockPos blockpos = p_192975_.getPos(); ++ this.level.getChunkSource().addRegionTicket( TicketType.PORTAL, new ChunkPos( blockpos ), 3, blockpos ); ++ BlockState blockstate = this.level.getBlockState( blockpos ); ++ return BlockUtil.getLargestRectangleAround( blockpos, blockstate.getValue( BlockStateProperties.HORIZONTAL_AXIS ), 21, Direction.Axis.Y, 21, (p_192978_) -> { ++ return this.level.getBlockState( p_192978_ ) == blockstate; + } ); + } ); + } + -+ public Optional m_77666_(BlockPos p_77667_, Direction.Axis p_77668_) { ++ public Optional createPortal(BlockPos p_77667_, Direction.Axis p_77668_) { + //CraftBukkit start + return createPortal( p_77667_, p_77668_, null, 16 ); + } @@ -224,42 +224,42 @@ + public Optional createPortal(BlockPos p_77667_, Direction.Axis p_77668_, net.minecraft.world.entity.Entity entity, int createRadius) { + //CraftBukkit end + -+ Direction direction = Direction.m_122390_( Direction.AxisDirection.POSITIVE, p_77668_ ); ++ Direction direction = Direction.get( Direction.AxisDirection.POSITIVE, p_77668_ ); + double d0 = -1.0D; + BlockPos blockpos = null; + double d1 = -1.0D; + BlockPos blockpos1 = null; -+ WorldBorder worldborder = this.f_77648_.m_6857_(); -+ int i = Math.min( this.f_77648_.m_151558_(), this.f_77648_.m_141937_() + this.f_77648_.m_143344_() ) - 1; -+ BlockPos.MutableBlockPos blockpos$mutableblockpos = p_77667_.m_122032_(); ++ WorldBorder worldborder = this.level.getWorldBorder(); ++ int i = Math.min( this.level.getMaxBuildHeight(), this.level.getMinBuildHeight() + this.level.getLogicalHeight() ) - 1; ++ BlockPos.MutableBlockPos blockpos$mutableblockpos = p_77667_.mutable(); + -+ for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.m_121935_( p_77667_, createRadius, Direction.EAST, Direction.SOUTH )) { -+ int j = Math.min( i, this.f_77648_.m_6924_( Heightmap.Types.MOTION_BLOCKING, blockpos$mutableblockpos1.m_123341_(), blockpos$mutableblockpos1.m_123343_() ) ); ++ for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.spiralAround( p_77667_, createRadius, Direction.EAST, Direction.SOUTH )) { ++ int j = Math.min( i, this.level.getHeight( Heightmap.Types.MOTION_BLOCKING, blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getZ() ) ); + int k = 1; -+ if (worldborder.m_61937_( blockpos$mutableblockpos1 ) && worldborder.m_61937_( blockpos$mutableblockpos1.m_122175_( direction, 1 ) )) { -+ blockpos$mutableblockpos1.m_122175_( direction.m_122424_(), 1 ); ++ if (worldborder.isWithinBounds( blockpos$mutableblockpos1 ) && worldborder.isWithinBounds( blockpos$mutableblockpos1.move( direction, 1 ) )) { ++ blockpos$mutableblockpos1.move( direction.getOpposite(), 1 ); + -+ for (int l = j; l >= this.f_77648_.m_141937_(); --l) { -+ blockpos$mutableblockpos1.m_142448_( l ); -+ if (this.f_77648_.m_46859_( blockpos$mutableblockpos1 )) { ++ for (int l = j; l >= this.level.getMinBuildHeight(); --l) { ++ blockpos$mutableblockpos1.setY( l ); ++ if (this.level.isEmptyBlock( blockpos$mutableblockpos1 )) { + int i1; -+ for (i1 = l; l > this.f_77648_.m_141937_() && this.f_77648_.m_46859_( blockpos$mutableblockpos1.m_122173_( Direction.DOWN ) ); --l) { ++ for (i1 = l; l > this.level.getMinBuildHeight() && this.level.isEmptyBlock( blockpos$mutableblockpos1.move( Direction.DOWN ) ); --l) { + } + + if (l + 4 <= i) { + int j1 = i1 - l; + if (j1 <= 0 || j1 >= 3) { -+ blockpos$mutableblockpos1.m_142448_( l ); -+ if (this.m_77661_( blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 0 )) { -+ double d2 = p_77667_.m_123331_( blockpos$mutableblockpos1 ); -+ if (this.m_77661_( blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, -1 ) && this.m_77661_( blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 1 ) && (d0 == -1.0D || d0 > d2)) { ++ blockpos$mutableblockpos1.setY( l ); ++ if (this.canHostFrame( blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 0 )) { ++ double d2 = p_77667_.distSqr( blockpos$mutableblockpos1 ); ++ if (this.canHostFrame( blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, -1 ) && this.canHostFrame( blockpos$mutableblockpos1, blockpos$mutableblockpos, direction, 1 ) && (d0 == -1.0D || d0 > d2)) { + d0 = d2; -+ blockpos = blockpos$mutableblockpos1.m_7949_(); ++ blockpos = blockpos$mutableblockpos1.immutable(); + } + + if (d0 == -1.0D && (d1 == -1.0D || d1 > d2)) { + d1 = d2; -+ blockpos1 = blockpos$mutableblockpos1.m_7949_(); ++ blockpos1 = blockpos$mutableblockpos1.immutable(); + } + } + } @@ -274,26 +274,26 @@ + d0 = d1; + } + -+ org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator( this.f_77648_ ); // CraftBukkit - Use BlockStateListPopulator ++ org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator( this.level ); // CraftBukkit - Use BlockStateListPopulator + if (d0 == -1.0D) { -+ int k1 = Math.max( this.f_77648_.m_141937_() - -1, 70 ); ++ int k1 = Math.max( this.level.getMinBuildHeight() - -1, 70 ); + int i2 = i - 9; + if (i2 < k1) { + return Optional.empty(); + } + -+ blockpos = (new BlockPos( p_77667_.m_123341_(), Mth.m_14045_( p_77667_.m_123342_(), k1, i2 ), p_77667_.m_123343_() )).m_7949_(); -+ Direction direction1 = direction.m_122427_(); -+ if (!worldborder.m_61937_( blockpos )) { ++ blockpos = (new BlockPos( p_77667_.getX(), Mth.clamp( p_77667_.getY(), k1, i2 ), p_77667_.getZ() )).immutable(); ++ Direction direction1 = direction.getClockWise(); ++ if (!worldborder.isWithinBounds( blockpos )) { + return Optional.empty(); + } + + for (int i3 = -1; i3 < 2; ++i3) { + for (int j3 = 0; j3 < 2; ++j3) { + for (int k3 = -1; k3 < 3; ++k3) { -+ BlockState blockstate1 = k3 < 0 ? Blocks.f_50080_.m_49966_() : Blocks.f_50016_.m_49966_(); -+ blockpos$mutableblockpos.m_122154_( blockpos, j3 * direction.m_122429_() + i3 * direction1.m_122429_(), k3, j3 * direction.m_122431_() + i3 * direction1.m_122431_() ); -+ blockList.m_7731_( blockpos$mutableblockpos, blockstate1, 3 ); // CraftBukkit ++ BlockState blockstate1 = k3 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); ++ blockpos$mutableblockpos.setWithOffset( blockpos, j3 * direction.getStepX() + i3 * direction1.getStepX(), k3, j3 * direction.getStepZ() + i3 * direction1.getStepZ() ); ++ blockList.setBlock( blockpos$mutableblockpos, blockstate1, 3 ); // CraftBukkit + } + } + } @@ -302,45 +302,45 @@ + for (int l1 = -1; l1 < 3; ++l1) { + for (int j2 = -1; j2 < 4; ++j2) { + if (l1 == -1 || l1 == 2 || j2 == -1 || j2 == 3) { -+ blockpos$mutableblockpos.m_122154_( blockpos, l1 * direction.m_122429_(), j2, l1 * direction.m_122431_() ); -+ blockList.m_7731_( blockpos$mutableblockpos, Blocks.f_50080_.m_49966_(), 3 ); // CraftBukkit ++ blockpos$mutableblockpos.setWithOffset( blockpos, l1 * direction.getStepX(), j2, l1 * direction.getStepZ() ); ++ blockList.setBlock( blockpos$mutableblockpos, Blocks.OBSIDIAN.defaultBlockState(), 3 ); // CraftBukkit + } + } + } + -+ BlockState blockstate = Blocks.f_50142_.m_49966_().m_61124_( NetherPortalBlock.f_54904_, p_77668_ ); ++ BlockState blockstate = Blocks.NETHER_PORTAL.defaultBlockState().setValue( NetherPortalBlock.AXIS, p_77668_ ); + + for (int k2 = 0; k2 < 2; ++k2) { + for (int l2 = 0; l2 < 3; ++l2) { -+ blockpos$mutableblockpos.m_122154_( blockpos, k2 * direction.m_122429_(), l2, k2 * direction.m_122431_() ); -+ blockList.m_7731_( blockpos$mutableblockpos, blockstate, 18 ); ++ blockpos$mutableblockpos.setWithOffset( blockpos, k2 * direction.getStepX(), l2, k2 * direction.getStepZ() ); ++ blockList.setBlock( blockpos$mutableblockpos, blockstate, 18 ); + } + } + + // CraftBukkit start -+ org.bukkit.World bworld = this.f_77648_.world; ++ org.bukkit.World bworld = this.level.world; + org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent( (java.util.List) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR ); -+ this.f_77648_.getCraftServer().getPluginManager().callEvent( event ); ++ this.level.getCraftServer().getPluginManager().callEvent( event ); + if (event.isCancelled()) { + return Optional.empty(); + } + + blockList.updateList(); + // CraftBukkit end -+ return Optional.of( new BlockUtil.FoundRectangle( blockpos.m_7949_(), 2, 3 ) ); ++ return Optional.of( new BlockUtil.FoundRectangle( blockpos.immutable(), 2, 3 ) ); + } + -+ private boolean m_77661_(BlockPos p_77662_, BlockPos.MutableBlockPos p_77663_, Direction p_77664_, int p_77665_) { -+ Direction direction = p_77664_.m_122427_(); ++ private boolean canHostFrame(BlockPos p_77662_, BlockPos.MutableBlockPos p_77663_, Direction p_77664_, int p_77665_) { ++ Direction direction = p_77664_.getClockWise(); + + for (int i = -1; i < 3; ++i) { + for (int j = -1; j < 4; ++j) { -+ p_77663_.m_122154_( p_77662_, p_77664_.m_122429_() * i + direction.m_122429_() * p_77665_, j, p_77664_.m_122431_() * i + direction.m_122431_() * p_77665_ ); -+ if (j < 0 && !this.f_77648_.m_8055_( p_77663_ ).m_60767_().m_76333_()) { ++ p_77663_.setWithOffset( p_77662_, p_77664_.getStepX() * i + direction.getStepX() * p_77665_, j, p_77664_.getStepZ() * i + direction.getStepZ() * p_77665_ ); ++ if (j < 0 && !this.level.getBlockState( p_77663_ ).getMaterial().isSolid()) { + return false; + } + -+ if (j >= 0 && !this.f_77648_.m_46859_( p_77663_ )) { ++ if (j >= 0 && !this.level.isEmptyBlock( p_77663_ )) { + return false; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/portal/PortalInfo.java.patch b/patches/minecraft/net/minecraft/world/level/portal/PortalInfo.java.patch index 4ccc3468..93e4b7ae 100644 --- a/patches/minecraft/net/minecraft/world/level/portal/PortalInfo.java.patch +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalInfo.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/portal/PortalInfo.java +++ b/net/minecraft/world/level/portal/PortalInfo.java @@ -8,6 +_,16 @@ - public final float f_77678_; - public final float f_77679_; + public final float yRot; + public final float xRot; + // CraftBukkit start + public net.minecraft.server.level.ServerLevel world; @@ -15,5 +15,5 @@ + // CraftBukkit end + public PortalInfo(Vec3 p_77681_, Vec3 p_77682_, float p_77683_, float p_77684_) { - this.f_77676_ = p_77681_; - this.f_77677_ = p_77682_; + this.pos = p_77681_; + this.speed = p_77682_; 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 b51be16d..df7d6c46 100644 --- a/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,61 +1,61 @@ --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java @@ -24,7 +_,7 @@ - private static final int f_164753_ = 3; - public static final int f_164751_ = 21; - private static final BlockBehaviour.StatePredicate f_77685_ = (p_77720_, p_77721_, p_77722_) -> { -- return p_77720_.m_60713_(Blocks.f_50080_); + private static final int MIN_HEIGHT = 3; + public static final int MAX_HEIGHT = 21; + private static final BlockBehaviour.StatePredicate FRAME = (p_77720_, p_77721_, p_77722_) -> { +- return p_77720_.is(Blocks.OBSIDIAN); + return p_77720_.isPortalFrame(p_77721_, p_77722_); }; - private final LevelAccessor f_77686_; - private final Direction.Axis f_77687_; + private final LevelAccessor level; + private final Direction.Axis axis; @@ -34,6 +_,7 @@ - private BlockPos f_77690_; - private int f_77691_; - private final int f_77692_; + private BlockPos bottomLeft; + private int height; + private final int width; + org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator blocks; // CraftBukkit - add field - public static Optional m_77708_(LevelAccessor p_77709_, BlockPos p_77710_, Direction.Axis p_77711_) { - return m_77712_(p_77709_, p_77710_, (p_77727_) -> { + public static Optional findEmptyPortalShape(LevelAccessor p_77709_, BlockPos p_77710_, Direction.Axis p_77711_) { + return findPortalShape(p_77709_, p_77710_, (p_77727_) -> { @@ -52,6 +_,7 @@ } public PortalShape(LevelAccessor p_77695_, BlockPos p_77696_, Direction.Axis p_77697_) { + this.blocks = new org.bukkit.craftbukkit.v1_18_R2.util.BlockStateListPopulator( p_77695_.getMinecraftWorld() ); // CraftBukkit - add field - this.f_77686_ = p_77695_; - this.f_77687_ = p_77697_; - this.f_77688_ = p_77697_ == Direction.Axis.X ? Direction.WEST : Direction.SOUTH; + this.level = p_77695_; + this.axis = p_77697_; + this.rightDir = p_77697_ == Direction.Axis.X ? Direction.WEST : Direction.SOUTH; @@ -92,6 +_,7 @@ - BlockState blockstate = this.f_77686_.m_8055_(blockpos$mutableblockpos); - if (!m_77717_(blockstate)) { - if (f_77685_.m_61035_(blockstate, this.f_77686_, blockpos$mutableblockpos)) { -+ blocks.m_7731_(blockpos$mutableblockpos, blockstate, 18 ); // CraftBukkit - lower left / right + BlockState blockstate = this.level.getBlockState(blockpos$mutableblockpos); + if (!isEmpty(blockstate)) { + if (FRAME.test(blockstate, this.level, blockpos$mutableblockpos)) { ++ blocks.setBlock(blockpos$mutableblockpos, blockstate, 18 ); // CraftBukkit - lower left / right return i; } break; @@ -101,6 +_,7 @@ - if (!f_77685_.m_61035_(blockstate1, this.f_77686_, blockpos$mutableblockpos)) { + if (!FRAME.test(blockstate1, this.level, blockpos$mutableblockpos)) { break; } -+ blocks.m_7731_(blockpos$mutableblockpos, blockstate1, 18); // CraftBukkit - bottom row ++ blocks.setBlock(blockpos$mutableblockpos, blockstate1, 18); // CraftBukkit - bottom row } return 0; @@ -118,6 +_,7 @@ - if (!f_77685_.m_61035_(this.f_77686_.m_8055_(blockpos$mutableblockpos), this.f_77686_, blockpos$mutableblockpos)) { + if (!FRAME.test(this.level.getBlockState(blockpos$mutableblockpos), this.level, blockpos$mutableblockpos)) { return false; } -+ blocks.m_7731_(blockpos$mutableblockpos, this.f_77686_.m_8055_(blockpos$mutableblockpos), 18); // CraftBukkit - upper row ++ blocks.setBlock(blockpos$mutableblockpos, this.level.getBlockState(blockpos$mutableblockpos), 18); // CraftBukkit - upper row } return true; @@ -146,6 +_,10 @@ - ++this.f_77689_; + ++this.numPortalBlocks; } } + // CraftBukkit start - left and right -+ blocks.m_7731_(p_77729_.m_122190_(this.f_77690_).m_122175_(Direction.UP, i).m_122175_(this.f_77688_, -1), this.f_77686_.m_8055_(p_77729_), 18); -+ blocks.m_7731_(p_77729_.m_122190_(this.f_77690_).m_122175_(Direction.UP, i).m_122175_(this.f_77688_, this.f_77692_), this.f_77686_.m_8055_(p_77729_), 18); ++ blocks.setBlock(p_77729_.set(this.bottomLeft).move(Direction.UP, i).move(this.rightDir, -1), this.level.getBlockState(p_77729_), 18); ++ blocks.setBlock(p_77729_.set(this.bottomLeft).move(Direction.UP, i).move(this.rightDir, this.width), this.level.getBlockState(p_77729_), 18); + // CraftBukkit end } @@ -63,49 +63,49 @@ @@ -160,10 +_,30 @@ } - public void m_77743_() { + public void createPortalBlocks() { + CBcreatePortalBlocks(); + } + + // CraftBukkit start - return boolean + public boolean CBcreatePortalBlocks() { -+ org.bukkit.World bworld = this.f_77686_.getMinecraftWorld().getWorld(); ++ org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld(); + + // Copy below for loop - BlockState blockstate = Blocks.f_50142_.m_49966_().m_61124_(NetherPortalBlock.f_54904_, this.f_77687_); - BlockPos.m_121940_(this.f_77690_, this.f_77690_.m_5484_(Direction.UP, this.f_77691_ - 1).m_5484_(this.f_77688_, this.f_77692_ - 1)).forEach((p_77725_) -> { -+ blocks.m_7731_( p_77725_, blockstate, 18 ); + BlockState blockstate = Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis); + BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((p_77725_) -> { ++ blocks.setBlock( p_77725_, blockstate, 18 ); + } ); + + org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, null, org.bukkit.event.world.PortalCreateEvent.CreateReason.FIRE); -+ this.f_77686_.getMinecraftWorld().m_142572_().server.getPluginManager().callEvent(event); ++ this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + // CraftBukkit end -+ BlockPos.m_121940_(this.f_77690_, this.f_77690_.m_5484_(Direction.UP, this.f_77691_ - 1).m_5484_(this.f_77688_, this.f_77692_ - 1)).forEach((p_77725_) -> { - this.f_77686_.m_7731_(p_77725_, blockstate, 18); ++ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((p_77725_) -> { + this.level.setBlock(p_77725_, blockstate, 18); }); + return true; // CraftBukkit } - public boolean m_77744_() { + public boolean isComplete() { @@ -196,6 +_,10 @@ } - public static PortalInfo m_77699_(ServerLevel p_77700_, BlockUtil.FoundRectangle p_77701_, Direction.Axis p_77702_, Vec3 p_77703_, EntityDimensions p_77704_, Vec3 p_77705_, float p_77706_, float p_77707_) { + public static PortalInfo createPortalInfo(ServerLevel p_77700_, BlockUtil.FoundRectangle p_77701_, Direction.Axis p_77702_, Vec3 p_77703_, EntityDimensions p_77704_, Vec3 p_77705_, float p_77706_, float p_77707_) { + return createPortalInfo( p_77700_, p_77701_, p_77702_, p_77703_, p_77704_, p_77705_, p_77706_, p_77707_, null ); + } + + public static PortalInfo createPortalInfo(ServerLevel p_77700_, BlockUtil.FoundRectangle p_77701_, Direction.Axis p_77702_, Vec3 p_77703_, EntityDimensions p_77704_, Vec3 p_77705_, float p_77706_, float p_77707_, org.bukkit.craftbukkit.v1_18_R2.event.CraftPortalEvent event) { - BlockPos blockpos = p_77701_.f_124348_; - BlockState blockstate = p_77700_.m_8055_(blockpos); - Direction.Axis direction$axis = blockstate.m_61145_(BlockStateProperties.f_61364_).orElse(Direction.Axis.X); + BlockPos blockpos = p_77701_.minCorner; + BlockState blockstate = p_77700_.getBlockState(blockpos); + Direction.Axis direction$axis = blockstate.getOptionalValue(BlockStateProperties.HORIZONTAL_AXIS).orElse(Direction.Axis.X); @@ -208,6 +_,8 @@ - double d4 = 0.5D + p_77703_.m_7094_(); + double d4 = 0.5D + p_77703_.z(); boolean flag = direction$axis == Direction.Axis.X; - Vec3 vec31 = new Vec3((double)blockpos.m_123341_() + (flag ? d2 : d4), (double)blockpos.m_123342_() + d3, (double)blockpos.m_123343_() + (flag ? d4 : d2)); + Vec3 vec31 = new Vec3((double)blockpos.getX() + (flag ? d2 : d4), (double)blockpos.getY() + d3, (double)blockpos.getZ() + (flag ? d4 : d2)); - return new PortalInfo(vec31, vec3, p_77706_ + (float)i, p_77707_); + PortalInfo info = new PortalInfo( vec31, vec3, p_77706_ + (float) i, p_77707_ ); + info.setCBPortalEvent( p_77700_, event ); diff --git a/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch index e1862ead..a8679d02 100644 --- a/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch +++ b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/saveddata/maps/MapDecoration.java +++ b/net/minecraft/world/level/saveddata/maps/MapDecoration.java @@ -69,6 +_,15 @@ - return 31 * i + Objects.hashCode(this.f_77795_); + return 31 * i + Objects.hashCode(this.name); } + /** diff --git a/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch index 6fdbc216..0734d3f9 100644 --- a/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java @@ -43,13 +_,20 @@ - public byte f_77890_; - public byte[] f_77891_ = new byte[16384]; - public boolean f_77892_; -- private final List f_77893_ = Lists.newArrayList(); -- private final Map f_77896_ = Maps.newHashMap(); -+ public final List f_77893_ = Lists.newArrayList(); -+ public final Map f_77896_ = Maps.newHashMap(); - private final Map f_77897_ = Maps.newHashMap(); - public final Map f_77894_ = Maps.newLinkedHashMap(); - private final Map f_77898_ = Maps.newHashMap(); - private int f_181308_; + public byte scale; + public byte[] colors = new byte[16384]; + public boolean locked; +- private final List carriedBy = Lists.newArrayList(); +- private final Map carriedByPlayers = Maps.newHashMap(); ++ public final List carriedBy = Lists.newArrayList(); ++ public final Map carriedByPlayers = Maps.newHashMap(); + private final Map bannerMarkers = Maps.newHashMap(); + public final Map decorations = Maps.newLinkedHashMap(); + private final Map frameMarkers = Maps.newHashMap(); + private int trackedDecorationCount; + // CraftBukkit start + public final org.bukkit.craftbukkit.v1_18_R2.map.CraftMapView mapView; @@ -21,12 +21,12 @@ + // CraftBukkit end + private MapItemSavedData(int p_164768_, int p_164769_, byte p_164770_, boolean p_164771_, boolean p_164772_, boolean p_164773_, ResourceKey p_164774_) { - this.f_77890_ = p_164770_; - this.f_77885_ = p_164768_; + this.scale = p_164770_; + this.x = p_164768_; @@ -59,6 +_,11 @@ - this.f_77889_ = p_164772_; - this.f_77892_ = p_164773_; - this.m_77762_(); + this.unlimitedTracking = p_164772_; + this.locked = p_164773_; + this.setDirty(); + + // CraftBukkit start + mapView = new org.bukkit.craftbukkit.v1_18_R2.map.CraftMapView(this); @@ -34,17 +34,17 @@ + // CraftBukkit end } - public static MapItemSavedData m_164780_(double p_164781_, double p_164782_, byte p_164783_, boolean p_164784_, boolean p_164785_, ResourceKey p_164786_) { + public static MapItemSavedData createFresh(double p_164781_, double p_164782_, byte p_164783_, boolean p_164784_, boolean p_164785_, ResourceKey p_164786_) { @@ -75,8 +_,25 @@ } - public static MapItemSavedData m_164807_(CompoundTag p_164808_) { -- ResourceKey resourcekey = DimensionType.m_63911_(new Dynamic<>(NbtOps.f_128958_, p_164808_.m_128423_("dimension"))).resultOrPartial(f_77895_::error).orElseThrow(() -> { -- return new IllegalArgumentException("Invalid map dimension: " + p_164808_.m_128423_("dimension")); + public static MapItemSavedData load(CompoundTag p_164808_) { +- ResourceKey resourcekey = DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, p_164808_.get("dimension"))).resultOrPartial(LOGGER::error).orElseThrow(() -> { +- return new IllegalArgumentException("Invalid map dimension: " + p_164808_.get("dimension")); + // CraftBukkit start -+ ResourceKey resourcekey = DimensionType.m_63911_(new Dynamic<>(NbtOps.f_128958_, p_164808_.m_128423_("dimension"))).resultOrPartial(f_77895_::error).orElseGet(() -> { -+ long least = p_164808_.m_128454_("UUIDLeast"); -+ long most = p_164808_.m_128454_("UUIDMost"); ++ ResourceKey resourcekey = DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, p_164808_.get("dimension"))).resultOrPartial(LOGGER::error).orElseGet(() -> { ++ long least = p_164808_.getLong("UUIDLeast"); ++ long most = p_164808_.getLong("UUIDMost"); + + if (least != 0L && most != 0L) { + java.util.UUID uniqueId = new java.util.UUID(most, least); @@ -55,24 +55,24 @@ + This is to prevent them being corrupted with the wrong map data. */ + // PAIL: Use Vanilla exception handling for now + } else { -+ return world.getHandle().m_46472_(); ++ return world.getHandle().dimension(); + } + } -+ throw new IllegalArgumentException("Invalid map dimension: " + p_164808_.m_128423_("dimension")); ++ throw new IllegalArgumentException("Invalid map dimension: " + p_164808_.get("dimension")); + // CraftBukkit end }); - int i = p_164808_.m_128451_("xCenter"); - int j = p_164808_.m_128451_("zCenter"); + int i = p_164808_.getInt("xCenter"); + int j = p_164808_.getInt("zCenter"); @@ -113,6 +_,25 @@ - ResourceLocation.f_135803_.encodeStart(NbtOps.f_128958_, this.f_77887_.m_135782_()).resultOrPartial(f_77895_::error).ifPresent((p_77954_) -> { - p_77956_.m_128365_("dimension", p_77954_); + ResourceLocation.CODEC.encodeStart(NbtOps.INSTANCE, this.dimension.location()).resultOrPartial(LOGGER::error).ifPresent((p_77954_) -> { + p_77956_.put("dimension", p_77954_); }); + // CraftBukkit start + if (true) { + if (this.uniqueId == null) { + for (org.bukkit.World world : server.getWorlds()) { + org.bukkit.craftbukkit.v1_18_R2.CraftWorld cWorld = (org.bukkit.craftbukkit.v1_18_R2.CraftWorld) world; -+ if (cWorld.getHandle().m_46472_() == this.f_77887_) { ++ if (cWorld.getHandle().dimension() == this.dimension) { + this.uniqueId = cWorld.getUID(); + break; + } @@ -81,56 +81,56 @@ + /* Perform a second check to see if a matching world was found, this is a necessary + change incase Maps are forcefully unlinked from a World and lack a UID.*/ + if (this.uniqueId != null) { -+ p_77956_.m_128356_("UUIDLeast", this.uniqueId.getLeastSignificantBits()); -+ p_77956_.m_128356_("UUIDMost", this.uniqueId.getMostSignificantBits()); ++ p_77956_.putLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); ++ p_77956_.putLong("UUIDMost", this.uniqueId.getMostSignificantBits()); + } + } + // CraftBukkit end - p_77956_.m_128405_("xCenter", this.f_77885_); - p_77956_.m_128405_("zCenter", this.f_77886_); - p_77956_.m_128344_("scale", this.f_77890_); + p_77956_.putInt("xCenter", this.x); + p_77956_.putInt("zCenter", this.z); + p_77956_.putByte("scale", this.scale); @@ -448,7 +_,7 @@ - this.f_77959_ = p_77970_; + this.player = p_77970_; } -- private MapItemSavedData.MapPatch m_164814_() { +- private MapItemSavedData.MapPatch createPatch() { + private MapItemSavedData.MapPatch createPatch(byte[] buffer) { // CraftBukkit - int i = this.f_77963_; - int j = this.f_77964_; - int k = this.f_77965_ + 1 - this.f_77963_; + int i = this.minDirtyX; + int j = this.minDirtyY; + int k = this.maxDirtyX + 1 - this.minDirtyX; @@ -457,7 +_,7 @@ for(int i1 = 0; i1 < k; ++i1) { for(int j1 = 0; j1 < l; ++j1) { -- abyte[i1 + j1 * k] = MapItemSavedData.this.f_77891_[i + i1 + (j + j1) * 128]; +- abyte[i1 + j1 * k] = MapItemSavedData.this.colors[i + i1 + (j + j1) * 128]; + abyte[i1 + j1 * k] = buffer[i + i1 + (j + j1) * 128]; // CraftBukkit } } @@ -467,9 +_,11 @@ @Nullable - Packet m_164815_(int p_164816_) { + Packet nextUpdatePacket(int p_164816_) { MapItemSavedData.MapPatch mapitemsaveddata$mappatch; -+ org.bukkit.craftbukkit.v1_18_R2.map.RenderData render = MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) this.f_77959_.getBukkitEntity()); // CraftBukkit ++ org.bukkit.craftbukkit.v1_18_R2.map.RenderData render = MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) this.player.getBukkitEntity()); // CraftBukkit + - if (this.f_77962_) { - this.f_77962_ = false; -- mapitemsaveddata$mappatch = this.m_164814_(); + if (this.dirtyData) { + this.dirtyData = false; +- mapitemsaveddata$mappatch = this.createPatch(); + mapitemsaveddata$mappatch = this.createPatch(render.buffer); } else { mapitemsaveddata$mappatch = null; } @@ -477,7 +_,16 @@ Collection collection; - if (this.f_164813_ && this.f_77967_++ % 5 == 0) { - this.f_164813_ = false; -- collection = MapItemSavedData.this.f_77894_.values(); + if (this.dirtyDecorations && this.tick++ % 5 == 0) { + this.dirtyDecorations = false; +- collection = MapItemSavedData.this.decorations.values(); + // CraftBukkit start + java.util.Collection icons = new java.util.ArrayList(); + + for (org.bukkit.map.MapCursor cursor : render.cursors) { + if (cursor.isVisible()) { -+ icons.add(new MapDecoration(MapDecoration.Type.m_77854_(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromStringOrNull(cursor.getCaption()))); ++ icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage.fromStringOrNull(cursor.getCaption()))); + } + } + collection = icons; diff --git a/patches/minecraft/net/minecraft/world/level/storage/DerivedLevelData.java.patch b/patches/minecraft/net/minecraft/world/level/storage/DerivedLevelData.java.patch index e3451a80..4ff1059b 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/DerivedLevelData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/DerivedLevelData.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/level/storage/DerivedLevelData.java +++ b/net/minecraft/world/level/storage/DerivedLevelData.java @@ -15,9 +_,19 @@ - private final WorldData f_78076_; - private final ServerLevelData f_78077_; + private final WorldData worldData; + private final ServerLevelData wrapped; + //Magma start - add level name + private String levelName; + public DerivedLevelData(WorldData p_78079_, ServerLevelData p_78080_) { - this.f_78076_ = p_78079_; - this.f_78077_ = p_78080_; + this.worldData = p_78079_; + this.wrapped = p_78080_; + -+ this.levelName = f_78076_.m_5462_(); ++ this.levelName = worldData.getLevelName(); + //Magma end + } + + public ServerLevelData getWrapped() { -+ return f_78077_; ++ return wrapped; } - public int m_6789_() { + public int getXSpawn() { @@ -44,9 +_,15 @@ - return this.f_78077_.m_6792_(); + return this.wrapped.getDayTime(); } + //Magma start - add level name @@ -29,11 +29,11 @@ + this.levelName = levelName; + } + - public String m_5462_() { -- return this.f_78076_.m_5462_(); + public String getLevelName() { +- return this.worldData.getLevelName(); + return levelName; } + //Magma end - public int m_6537_() { - return this.f_78077_.m_6537_(); + public int getClearWeatherTime() { + return this.wrapped.getClearWeatherTime(); 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 5e1566f8..06fa6b08 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -3,22 +3,22 @@ @@ -22,7 +_,7 @@ public class DimensionDataStorage { - private static final Logger f_78143_ = LogUtils.getLogger(); -- private final Map f_78144_ = Maps.newHashMap(); -+ public final Map f_78144_ = Maps.newHashMap(); - private final DataFixer f_78145_; - private final File f_78146_; + private static final Logger LOGGER = LogUtils.getLogger(); +- private final Map cache = Maps.newHashMap(); ++ public final Map cache = Maps.newHashMap(); + private final DataFixer fixerUpper; + private final File dataFolder; @@ -49,9 +_,13 @@ @Nullable - public T m_164858_(Function p_164859_, String p_164860_) { - SavedData saveddata = this.f_78144_.get(p_164860_); + public T get(Function p_164859_, String p_164860_) { + SavedData saveddata = this.cache.get(p_164860_); + if (saveddata == net.minecraftforge.common.util.DummySavedData.DUMMY) return null; - if (saveddata == null && !this.f_78144_.containsKey(p_164860_)) { - saveddata = this.m_164868_(p_164859_, p_164860_); - this.f_78144_.put(p_164860_, saveddata); + if (saveddata == null && !this.cache.containsKey(p_164860_)) { + saveddata = this.readSavedData(p_164859_, p_164860_); + this.cache.put(p_164860_, saveddata); + } else if (saveddata == null) { -+ this.f_78144_.put(p_164860_, net.minecraftforge.common.util.DummySavedData.DUMMY); ++ this.cache.put(p_164860_, net.minecraftforge.common.util.DummySavedData.DUMMY); + return null; } diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch index c9ffdf98..c41f8442 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java @@ -203,7 +_,12 @@ - LevelVersion levelversion = LevelVersion.m_78390_(dynamic); - LevelSettings levelsettings = LevelSettings.m_46924_(dynamic, p_211739_); + LevelVersion levelversion = LevelVersion.parse(dynamic); + LevelSettings levelsettings = LevelSettings.parse(dynamic, p_211739_); Lifecycle lifecycle = pair.getSecond().add(p_211740_); -- return PrimaryLevelData.m_78530_(dynamic, p_211746_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), lifecycle); +- return PrimaryLevelData.parse(dynamic, p_211746_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), lifecycle); + + // CraftBukkit start - Add PDC to world -+ PrimaryLevelData worldDataServer = PrimaryLevelData.m_78530_(dynamic, p_211746_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), lifecycle); -+ worldDataServer.pdc = compoundtag1.m_128423_("BukkitValues"); ++ PrimaryLevelData worldDataServer = PrimaryLevelData.parse(dynamic, p_211746_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), lifecycle); ++ worldDataServer.pdc = compoundtag1.get("BukkitValues"); + return worldDataServer; + // CraftBukkit end } catch (Exception exception) { - f_78191_.error("Exception reading {}", p_211745_, exception); + LOGGER.error("Exception reading {}", p_211745_, exception); return null; @@ -272,7 +_,11 @@ } - public LevelStorageSource.LevelStorageAccess m_78260_(String p_78261_) throws IOException { + public LevelStorageSource.LevelStorageAccess createAccess(String p_78261_) throws IOException { - return new LevelStorageSource.LevelStorageAccess(p_78261_); + return createAccess(p_78261_, null); + } @@ -28,59 +28,59 @@ public class LevelStorageAccess implements AutoCloseable { @@ -281,9 +_,13 @@ - private final String f_78272_; - private final Map f_78273_ = Maps.newHashMap(); + private final String levelId; + private final Map resources = Maps.newHashMap(); - public LevelStorageAccess(String p_78276_) throws IOException { -- this.f_78272_ = p_78276_; -- this.f_78271_ = LevelStorageSource.this.f_78194_.resolve(p_78276_); +- this.levelId = p_78276_; +- this.levelPath = LevelStorageSource.this.baseDir.resolve(p_78276_); + // CraftBukkit start + public final @Nullable ResourceKey dimensionType; + + public LevelStorageAccess(String s, @Nullable ResourceKey dimensionType) throws IOException { + this.dimensionType = dimensionType; -+ this.f_78272_ = s; -+ this.f_78271_ = LevelStorageSource.this.f_78194_.resolve(s); - this.f_78270_ = DirectoryLock.m_13640_(this.f_78271_); ++ this.levelId = s; ++ this.levelPath = LevelStorageSource.this.baseDir.resolve(s); + this.lock = DirectoryLock.create(this.levelPath); } @@ -324,6 +_,19 @@ - return LevelStorageSource.this.m_78229_(this.f_78271_.toFile(), LevelStorageSource.m_211737_(p_211748_, p_211749_, p_211750_)); + return LevelStorageSource.this.readLevelData(this.levelPath.toFile(), LevelStorageSource.getLevelData(p_211748_, p_211749_, p_211750_)); } + public void readAdditionalLevelSaveData() { -+ m_78313_(); -+ LevelStorageSource.this.m_78229_(this.f_78271_.toFile(), (file, dataFixer) -> { ++ checkLock(); ++ LevelStorageSource.this.readLevelData(this.levelPath.toFile(), (file, dataFixer) -> { + try { -+ CompoundTag compoundTag = NbtIo.m_128937_(file); -+ net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(compoundTag, this.f_78271_); ++ CompoundTag compoundTag = NbtIo.readCompressed(file); ++ net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(compoundTag, this.levelPath); + } catch (Exception e) { -+ f_78191_.error("Exception reading {}", file, e); ++ LOGGER.error("Exception reading {}", file, e); + } + return ""; // Return non-null to prevent level.dat-old inject + }); + } + @Nullable - public DataPackConfig m_78309_() { - this.m_78313_(); + public DataPackConfig getDataPacks() { + this.checkLock(); @@ -340,6 +_,8 @@ CompoundTag compoundtag1 = new CompoundTag(); - compoundtag1.m_128365_("Data", compoundtag); + compoundtag1.put("Data", compoundtag); + net.minecraftforge.common.ForgeHooks.writeAdditionalLevelSaveData(p_78292_, compoundtag1); + try { File file2 = File.createTempFile("level", ".dat", file1); - NbtIo.m_128944_(compoundtag1, file2); + NbtIo.writeCompressed(compoundtag1, file2); @@ -354,6 +_,10 @@ - public Optional m_182514_() { - return !this.f_78270_.m_13639_() ? Optional.empty() : Optional.of(this.f_78271_.resolve("icon.png")); + public Optional getIconFile() { + return !this.lock.isValid() ? Optional.empty() : Optional.of(this.levelPath.resolve("icon.png")); + } + + public Path getWorldDir() { -+ return f_78271_; ++ return levelPath; } - public void m_78311_() throws IOException { + public void deleteLevel() throws IOException { diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch index 7e9eccac..94660232 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch @@ -5,7 +5,7 @@ } + public boolean isExperimental() { -+ return this.f_78344_.getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental()); ++ return this.settings.getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental()); + } + public static enum BackupStatus { diff --git a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index db1d2a1f..062198f7 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -3,19 +3,19 @@ @@ -24,6 +_,7 @@ } - public void m_78433_(Player p_78434_) { + public void save(Player p_78434_) { + if (org.spigotmc.SpigotConfig.disablePlayerDataSaving) return; // Spigot try { - CompoundTag compoundtag = p_78434_.m_20240_(new CompoundTag()); - File file1 = File.createTempFile(p_78434_.m_20149_() + "-", ".dat", this.f_78427_); + CompoundTag compoundtag = p_78434_.saveWithoutId(new CompoundTag()); + File file1 = File.createTempFile(p_78434_.getStringUUID() + "-", ".dat", this.playerDir); @@ -31,8 +_,9 @@ - File file2 = new File(this.f_78427_, p_78434_.m_20149_() + ".dat"); - File file3 = new File(this.f_78427_, p_78434_.m_20149_() + ".dat_old"); - Util.m_137462_(file2, file1, file3); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerSavingEvent(p_78434_, f_78427_, p_78434_.m_20149_()); + File file2 = new File(this.playerDir, p_78434_.getStringUUID() + ".dat"); + File file3 = new File(this.playerDir, p_78434_.getStringUUID() + ".dat_old"); + Util.safeReplaceFile(file2, file1, file3); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerSavingEvent(p_78434_, playerDir, p_78434_.getStringUUID()); } catch (Exception exception) { -- f_78426_.warn("Failed to save player data for {}", (Object)p_78434_.m_7755_().getString()); -+ f_78426_.warn("Failed to save player data for {}: {}", (Object)p_78434_.m_7755_().getString(), exception.getMessage()); +- LOGGER.warn("Failed to save player data for {}", (Object)p_78434_.getName().getString()); ++ LOGGER.warn("Failed to save player data for {}: {}", (Object)p_78434_.getName().getString(), exception.getMessage()); } } @@ -23,26 +23,26 @@ CompoundTag compoundtag = null; try { -- File file1 = new File(this.f_78427_, p_78436_.m_20149_() + ".dat"); +- File file1 = new File(this.playerDir, p_78436_.getStringUUID() + ".dat"); - if (file1.exists() && file1.isFile()) { -- compoundtag = NbtIo.m_128937_(file1); +- compoundtag = NbtIo.readCompressed(file1); - } -+ File file = new File(this.f_78427_, p_78436_.m_20149_() + ".dat"); ++ File file = new File(this.playerDir, p_78436_.getStringUUID() + ".dat"); + // Spigot Start + boolean usingWrongFile = false; + if ( !file.exists() ) + { -+ file = new File( this.f_78427_, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + p_78436_.m_6302_() ).getBytes( "UTF-8" ) ).toString() + ".dat"); ++ file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + p_78436_.getScoreboardName() ).getBytes( "UTF-8" ) ).toString() + ".dat"); + if ( file.exists() ) + { + usingWrongFile = true; -+ org.bukkit.Bukkit.getServer().getLogger().warning( "Using offline mode UUID file for player " + p_78436_.m_6302_() + " as it is the only copy we can find." ); ++ org.bukkit.Bukkit.getServer().getLogger().warning( "Using offline mode UUID file for player " + p_78436_.getScoreboardName() + " as it is the only copy we can find." ); + } + } + // Spigot End + + if (file.exists() && file.isFile()) { -+ compoundtag = NbtIo.m_128937_(file); ++ compoundtag = NbtIo.readCompressed(file); + } + // Spigot Start + if ( usingWrongFile ) @@ -51,7 +51,7 @@ + } + // Spigot End } catch (Exception exception) { - f_78426_.warn("Failed to load player data for {}", (Object)p_78436_.m_7755_().getString()); + LOGGER.warn("Failed to load player data for {}", (Object)p_78436_.getName().getString()); } if (compoundtag != null) { @@ -59,16 +59,16 @@ + if (p_78436_ instanceof net.minecraft.server.level.ServerPlayer) { + org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer player = (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) p_78436_.getBukkitEntity(); + // Only update first played if it is older than the one we have -+ long modified = new File(this.f_78427_, p_78436_.m_142081_().toString() + ".dat").lastModified(); ++ long modified = new File(this.playerDir, p_78436_.getUUID().toString() + ".dat").lastModified(); + if (modified < player.getFirstPlayed()) { + player.setFirstPlayed(modified); + } + } + // CraftBukkit end - int i = compoundtag.m_128425_("DataVersion", 3) ? compoundtag.m_128451_("DataVersion") : -1; - p_78436_.m_20258_(NbtUtils.m_129213_(this.f_78425_, DataFixTypes.PLAYER, compoundtag, i)); + int i = compoundtag.contains("DataVersion", 3) ? compoundtag.getInt("DataVersion") : -1; + p_78436_.load(NbtUtils.update(this.fixerUpper, DataFixTypes.PLAYER, compoundtag, i)); } -+ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_78436_, f_78427_, p_78436_.m_20149_()); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_78436_, playerDir, p_78436_.getStringUUID()); return compoundtag; } @@ -76,19 +76,19 @@ + // CraftBukkit start + public CompoundTag getPlayerData(String s) { + try { -+ File file1 = new File(this.f_78427_, s + ".dat"); ++ File file1 = new File(this.playerDir, s + ".dat"); + if (file1.exists()) { -+ return NbtIo.m_128939_((java.io.InputStream) (new java.io.FileInputStream(file1))); ++ return NbtIo.readCompressed((java.io.InputStream) (new java.io.FileInputStream(file1))); + } + } catch (Exception exception) { -+ f_78426_.warn("Failed to load player data for " + s); ++ LOGGER.warn("Failed to load player data for " + s); + } + return null; + } + // CraftBukkit end + - public String[] m_78432_() { - String[] astring = this.f_78427_.list(); + public String[] getSeenPlayers() { + String[] astring = this.playerDir.list(); if (astring == null) { @@ -72,4 +_,15 @@ @@ -96,7 +96,7 @@ } + + public File getPlayerDataFolder() { -+ return f_78427_; ++ return playerDir; + } + + //CraftBukkit start diff --git a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index aa690122..c0219e17 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/storage/PrimaryLevelData.java +++ b/net/minecraft/world/level/storage/PrimaryLevelData.java @@ -76,6 +_,21 @@ - private final Set f_78439_; - private boolean f_78440_; - private final TimerQueue f_78441_; + private final Set knownServerBrands; + private boolean wasModded; + private final TimerQueue scheduledEvents; + private boolean confirmedExperimentalWarning = false; + + // CraftBukkit start - Add world and pdc @@ -21,51 +21,51 @@ + // CraftBukkit end private PrimaryLevelData(@Nullable DataFixer p_164942_, int p_164943_, @Nullable CompoundTag p_164944_, boolean p_164945_, int p_164946_, int p_164947_, int p_164948_, float p_164949_, long p_164950_, long p_164951_, int p_164952_, int p_164953_, int p_164954_, boolean p_164955_, int p_164956_, boolean p_164957_, boolean p_164958_, boolean p_164959_, WorldBorder.Settings p_164960_, int p_164961_, int p_164962_, @Nullable UUID p_164963_, Set p_164964_, TimerQueue p_164965_, @Nullable CompoundTag p_164966_, CompoundTag p_164967_, LevelSettings p_164968_, WorldGenSettings p_164969_, Lifecycle p_164970_) { - this.f_78452_ = p_164942_; + this.fixerUpper = p_164942_; @@ -104,7 +_,9 @@ - this.f_78441_ = p_164965_; - this.f_78466_ = p_164966_; - this.f_78465_ = p_164967_; -- this.f_78443_ = p_164968_; -+ this.f_78443_ = p_164968_.withLifecycle(p_164970_); + this.scheduledEvents = p_164965_; + this.customBossEvents = p_164966_; + this.endDragonFightData = p_164967_; +- this.settings = p_164968_; ++ this.settings = p_164968_.withLifecycle(p_164970_); + if (p_164970_ == Lifecycle.stable()) //Reset to unconfirmed if the lifecycle goes back to stable + this.confirmedExperimentalWarning = false; - this.f_78444_ = p_164969_; - this.f_78445_ = p_164970_; + this.worldGenSettings = p_164969_; + this.worldGenSettingsLifecycle = p_164970_; } @@ -120,7 +_,7 @@ }); - return new PrimaryLevelData(p_78532_, p_78533_, p_78534_, p_78531_.get("WasModded").asBoolean(false), p_78531_.get("SpawnX").asInt(0), p_78531_.get("SpawnY").asInt(0), p_78531_.get("SpawnZ").asInt(0), p_78531_.get("SpawnAngle").asFloat(0.0F), i, p_78531_.get("DayTime").asLong(i), p_78536_.m_78389_(), p_78531_.get("clearWeatherTime").asInt(0), p_78531_.get("rainTime").asInt(0), p_78531_.get("raining").asBoolean(false), p_78531_.get("thunderTime").asInt(0), p_78531_.get("thundering").asBoolean(false), p_78531_.get("initialized").asBoolean(true), p_78531_.get("DifficultyLocked").asBoolean(false), WorldBorder.Settings.m_62037_(p_78531_, WorldBorder.f_61907_), p_78531_.get("WanderingTraderSpawnDelay").asInt(0), p_78531_.get("WanderingTraderSpawnChance").asInt(0), p_78531_.get("WanderingTraderId").read(SerializableUUID.f_123272_).result().orElse((UUID)null), p_78531_.get("ServerBrands").asStream().flatMap((p_78529_) -> { + return new PrimaryLevelData(p_78532_, p_78533_, p_78534_, p_78531_.get("WasModded").asBoolean(false), p_78531_.get("SpawnX").asInt(0), p_78531_.get("SpawnY").asInt(0), p_78531_.get("SpawnZ").asInt(0), p_78531_.get("SpawnAngle").asFloat(0.0F), i, p_78531_.get("DayTime").asLong(i), p_78536_.levelDataVersion(), p_78531_.get("clearWeatherTime").asInt(0), p_78531_.get("rainTime").asInt(0), p_78531_.get("raining").asBoolean(false), p_78531_.get("thunderTime").asInt(0), p_78531_.get("thundering").asBoolean(false), p_78531_.get("initialized").asBoolean(true), p_78531_.get("DifficultyLocked").asBoolean(false), WorldBorder.Settings.read(p_78531_, WorldBorder.DEFAULT_SETTINGS), p_78531_.get("WanderingTraderSpawnDelay").asInt(0), p_78531_.get("WanderingTraderSpawnChance").asInt(0), p_78531_.get("WanderingTraderId").read(SerializableUUID.CODEC).result().orElse((UUID)null), p_78531_.get("ServerBrands").asStream().flatMap((p_78529_) -> { return p_78529_.asString().result().stream(); -- }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.f_82226_, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_78537_, p_78538_); -+ }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.f_82226_, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_78537_, p_78538_).withConfirmedWarning(p_78538_ != Lifecycle.stable() && p_78531_.get("confirmedExperimentalSettings").asBoolean(false)); +- }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.SERVER_CALLBACKS, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_78537_, p_78538_); ++ }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.SERVER_CALLBACKS, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_78537_, p_78538_).withConfirmedWarning(p_78538_ != Lifecycle.stable() && p_78531_.get("confirmedExperimentalSettings").asBoolean(false)); } - public CompoundTag m_6626_(RegistryAccess p_78543_, @Nullable CompoundTag p_78544_) { + public CompoundTag createTag(RegistryAccess p_78543_, @Nullable CompoundTag p_78544_) { @@ -191,6 +_,13 @@ - p_78547_.m_128362_("WanderingTraderId", this.f_78438_); + p_78547_.putUUID("WanderingTraderId", this.wanderingTraderId); } + if (org.bukkit.Bukkit.getServer() != null) { -+ p_78547_.m_128359_("Bukkit.Version", org.bukkit.Bukkit.getName() + "/" + org.bukkit.Bukkit.getVersion() + "/" + org.bukkit.Bukkit.getBukkitVersion()); // CraftBukkit ++ p_78547_.putString("Bukkit.Version", org.bukkit.Bukkit.getName() + "/" + org.bukkit.Bukkit.getVersion() + "/" + org.bukkit.Bukkit.getBukkitVersion()); // CraftBukkit + world.getWorld().storeBukkitValues(p_78547_); // CraftBukkit - add pdc + } + -+ p_78547_.m_128359_("forgeLifecycle", net.minecraftforge.common.ForgeHooks.encodeLifecycle(this.f_78443_.getLifecycle())); -+ p_78547_.m_128379_("confirmedExperimentalSettings", this.confirmedExperimentalWarning); ++ p_78547_.putString("forgeLifecycle", net.minecraftforge.common.ForgeHooks.encodeLifecycle(this.settings.getLifecycle())); ++ p_78547_.putBoolean("confirmedExperimentalSettings", this.confirmedExperimentalWarning); } - public int m_6789_() { + public int getXSpawn() { @@ -288,6 +_,20 @@ } - public void m_5557_(boolean p_78562_) { + public void setThundering(boolean p_78562_) { + // CraftBukkit start -+ if (this.f_78460_ == p_78562_) { ++ if (this.thundering == p_78562_) { + return; + } + -+ org.bukkit.World world = org.bukkit.Bukkit.getWorld(m_5462_()); ++ org.bukkit.World world = org.bukkit.Bukkit.getWorld(getLevelName()); + if (world != null) { + org.bukkit.event.weather.ThunderChangeEvent thunder = new org.bukkit.event.weather.ThunderChangeEvent(world, p_78562_); + org.bukkit.Bukkit.getServer().getPluginManager().callEvent(thunder); @@ -74,19 +74,19 @@ + } + } + // CraftBukkit end - this.f_78460_ = p_78562_; + this.thundering = p_78562_; } @@ -304,6 +_,20 @@ } - public void m_5565_(boolean p_78576_) { + public void setRaining(boolean p_78576_) { + // CraftBukkit start -+ if (this.f_78458_ == p_78576_) { ++ if (this.raining == p_78576_) { + return; + } + -+ org.bukkit.World world = org.bukkit.Bukkit.getWorld(m_5462_()); ++ org.bukkit.World world = org.bukkit.Bukkit.getWorld(getLevelName()); + if (world != null) { + org.bukkit.event.weather.WeatherChangeEvent weather = new org.bukkit.event.weather.WeatherChangeEvent(world, p_78576_); + org.bukkit.Bukkit.getServer().getPluginManager().callEvent(weather); @@ -95,13 +95,13 @@ + } + } + // CraftBukkit end - this.f_78458_ = p_78576_; + this.raining = p_78576_; } @@ -357,6 +_,14 @@ - public void m_6166_(Difficulty p_78521_) { - this.f_78443_ = this.f_78443_.m_46918_(p_78521_); + public void setDifficulty(Difficulty p_78521_) { + this.settings = this.settings.withDifficulty(p_78521_); + /* Magma todo add back once full world patches + // CraftBukkit start + net.minecraft.network.protocol.game.ClientboundChangeDifficultyPacket packet = new net.minecraft.network.protocol.game.ClientboundChangeDifficultyPacket(this.getDifficulty(), this.isDifficultyLocked()); @@ -112,17 +112,17 @@ + */ } - public boolean m_5474_() { + public boolean isDifficultyLocked() { @@ -453,5 +_,22 @@ - public LevelSettings m_5926_() { - return this.f_78443_.m_46935_(); + public LevelSettings getLevelSettings() { + return this.settings.copy(); + } + + // CraftBukkit start - Check if the name stored in NBT is the correct one + public void checkName(String name) { -+ if (!this.f_78443_.f_46902_.equals(name)) { -+ this.f_78443_.f_46902_ = name; ++ if (!this.settings.levelName.equals(name)) { ++ this.settings.levelName = name; + } + } + // CraftBukkit end 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 b4922646..929a548b 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 @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/storage/loot/LootContext.java +++ b/net/minecraft/world/level/storage/loot/LootContext.java @@ -107,17 +_,47 @@ - return this.f_78909_; + return this.level; } + // ============================== FORGE START ============================== + public int getLootingModifier() { -+ return net.minecraftforge.common.ForgeHooks.getLootingLevel(m_78953_(LootContextParams.f_81455_), m_78953_(LootContextParams.f_81458_), m_78953_(LootContextParams.f_81457_)); ++ return net.minecraftforge.common.ForgeHooks.getLootingLevel(getParamOrNull(LootContextParams.THIS_ENTITY), getParamOrNull(LootContextParams.KILLER_ENTITY), getParamOrNull(LootContextParams.DAMAGE_SOURCE)); + } + + private ResourceLocation queriedLootTableId; @@ -25,46 +25,46 @@ + // =============================== FORGE END =============================== + public static class Builder { - private final ServerLevel f_78955_; - private final Map, Object> f_78956_ = Maps.newIdentityHashMap(); - private final Map f_78957_ = Maps.newHashMap(); - private Random f_78958_; - private float f_78959_; + private final ServerLevel level; + private final Map, Object> params = Maps.newIdentityHashMap(); + private final Map dynamicDrops = Maps.newHashMap(); + private Random random; + private float luck; + private ResourceLocation queriedLootTableId; // Forge: correctly pass around loot table ID with copy constructor public Builder(ServerLevel p_78961_) { - this.f_78955_ = p_78961_; + this.level = p_78961_; } + public Builder(LootContext context) { -+ this.f_78955_ = context.f_78909_; -+ this.f_78956_.putAll(context.f_78914_); -+ this.f_78957_.putAll(context.f_78915_); -+ this.f_78958_ = context.f_78907_; -+ this.f_78959_ = context.f_78908_; ++ this.level = context.level; ++ this.params.putAll(context.params); ++ this.dynamicDrops.putAll(context.dynamicDrops); ++ this.random = context.random; ++ this.luck = context.luck; + this.queriedLootTableId = context.queriedLootTableId; + } + - public LootContext.Builder m_78977_(Random p_78978_) { - this.f_78958_ = p_78978_; + public LootContext.Builder withRandom(Random p_78978_) { + this.random = p_78978_; return this; @@ -190,7 +_,7 @@ - public LootContext m_78975_(LootContextParamSet p_78976_) { - Set> set = Sets.difference(this.f_78956_.keySet(), p_78976_.m_81398_()); + public LootContext create(LootContextParamSet p_78976_) { + Set> set = Sets.difference(this.params.keySet(), p_78976_.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_78976_.m_81394_(), this.f_78956_.keySet()); + Set> set1 = Sets.difference(p_78976_.getRequired(), this.params.keySet()); @@ -203,12 +_,26 @@ } - MinecraftServer minecraftserver = this.f_78955_.m_142572_(); -- return new LootContext(random, this.f_78959_, this.f_78955_, minecraftserver.m_129898_()::m_79217_, minecraftserver.m_129899_()::m_79252_, this.f_78956_, this.f_78957_); + MinecraftServer minecraftserver = this.level.getServer(); +- return new LootContext(random, this.luck, this.level, minecraftserver.getLootTables()::get, minecraftserver.getPredicateManager()::get, this.params, this.dynamicDrops); + //Magma start - check if params are empty, prevents crash with bukkit loot generate event and forge mods -+ LootContext context = new LootContext(random, this.f_78959_, this.f_78955_, minecraftserver.m_129898_()::m_79217_, minecraftserver.m_129899_()::m_79252_, this.f_78956_, this.f_78957_, this.queriedLootTableId); -+ if (p_78976_ == net.minecraft.world.level.storage.loot.parameters.LootContextParamSets.f_81410_ || (p_78976_.m_81394_().isEmpty() && p_78976_.m_81398_().isEmpty())) ++ LootContext context = new LootContext(random, this.luck, this.level, minecraftserver.getLootTables()::get, minecraftserver.getPredicateManager()::get, this.params, this.dynamicDrops, this.queriedLootTableId); ++ if (p_78976_ == net.minecraft.world.level.storage.loot.parameters.LootContextParamSets.EMPTY || (p_78976_.getRequired().isEmpty() && p_78976_.getAllowed().isEmpty())) + context.setEmptyParams(); + return context; } @@ -84,16 +84,16 @@ + @FunctionalInterface public interface DynamicDrop { - void m_78987_(LootContext p_78988_, Consumer p_78989_); + void add(LootContext p_78988_, Consumer p_78989_); @@ -230,6 +_,11 @@ - public LootContextParam m_79003_() { - return this.f_78995_; + public LootContextParam getParam() { + return this.param; + } + + // Forge: This method is patched in to expose the same name used in getByName so that ContextNbtProvider#forEntity serializes it properly + public String getName() { -+ return this.f_78994_; ++ return this.name; } - public static LootContext.EntityTarget m_79006_(String p_79007_) { + public static LootContext.EntityTarget getByName(String p_79007_) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch index 86525e89..1b63c043 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch @@ -5,22 +5,22 @@ public class LootPool { + private final String name; - final LootPoolEntryContainer[] f_79023_; - final LootItemCondition[] f_79024_; - private final Predicate f_79025_; + final LootPoolEntryContainer[] entries; + final LootItemCondition[] conditions; + private final Predicate compositeCondition; @@ -39,7 +_,8 @@ - NumberProvider f_79028_; - NumberProvider f_79029_; + NumberProvider rolls; + NumberProvider bonusRolls; - LootPool(LootPoolEntryContainer[] p_165128_, LootItemCondition[] p_165129_, LootItemFunction[] p_165130_, NumberProvider p_165131_, NumberProvider p_165132_) { + LootPool(LootPoolEntryContainer[] p_165128_, LootItemCondition[] p_165129_, LootItemFunction[] p_165130_, NumberProvider p_165131_, NumberProvider p_165132_, String name) { + this.name = name; - this.f_79023_ = p_165128_; - this.f_79024_ = p_165129_; - this.f_79025_ = LootItemConditions.m_81834_(p_165129_); + this.entries = p_165128_; + this.conditions = p_165129_; + this.compositeCondition = LootItemConditions.andConditions(p_165129_); @@ -112,6 +_,20 @@ - this.f_79028_.m_6169_(p_79052_.m_79365_(".rolls")); - this.f_79029_.m_6169_(p_79052_.m_79365_(".bonusRolls")); + this.rolls.validate(p_79052_.forChild(".rolls")); + this.bonusRolls.validate(p_79052_.forChild(".bonusRolls")); } + //======================== FORGE START ============================================= + private boolean isFrozen = false; @@ -31,22 +31,22 @@ + throw new RuntimeException("Attempted to modify LootPool after being frozen!"); + } + public String getName(){ return this.name; } -+ public NumberProvider getRolls() { return this.f_79028_; } -+ public NumberProvider getBonusRolls() { return this.f_79029_; } -+ public void setRolls (NumberProvider v){ checkFrozen(); this.f_79028_ = v; } -+ public void setBonusRolls(NumberProvider v){ checkFrozen(); this.f_79029_ = v; } ++ public NumberProvider getRolls() { return this.rolls; } ++ public NumberProvider getBonusRolls() { return this.bonusRolls; } ++ public void setRolls (NumberProvider v){ checkFrozen(); this.rolls = v; } ++ public void setBonusRolls(NumberProvider v){ checkFrozen(); this.bonusRolls = v; } + //======================== FORGE END =============================================== - public static LootPool.Builder m_79043_() { + public static LootPool.Builder lootPool() { return new LootPool.Builder(); @@ -123,6 +_,7 @@ - private final List f_79069_ = Lists.newArrayList(); - private NumberProvider f_79070_ = ConstantValue.m_165692_(1.0F); - private NumberProvider f_79071_ = ConstantValue.m_165692_(0.0F); + private final List functions = Lists.newArrayList(); + private NumberProvider rolls = ConstantValue.exactly(1.0F); + private NumberProvider bonusRolls = ConstantValue.exactly(0.0F); + private String name; - public LootPool.Builder m_165133_(NumberProvider p_165134_) { - this.f_79070_ = p_165134_; + public LootPool.Builder setRolls(NumberProvider p_165134_) { + this.rolls = p_165134_; @@ -153,11 +_,16 @@ return this; } @@ -56,19 +56,19 @@ + return this; + } + - public LootPool m_79082_() { - if (this.f_79070_ == null) { + public LootPool build() { + if (this.rolls == null) { throw new IllegalArgumentException("Rolls not set"); } else { -- return new LootPool(this.f_79067_.toArray(new LootPoolEntryContainer[0]), this.f_79068_.toArray(new LootItemCondition[0]), this.f_79069_.toArray(new LootItemFunction[0]), this.f_79070_, this.f_79071_); -+ return new LootPool(this.f_79067_.toArray(new LootPoolEntryContainer[0]), this.f_79068_.toArray(new LootItemCondition[0]), this.f_79069_.toArray(new LootItemFunction[0]), this.f_79070_, this.f_79071_, name); +- return new LootPool(this.entries.toArray(new LootPoolEntryContainer[0]), this.conditions.toArray(new LootItemCondition[0]), this.functions.toArray(new LootItemFunction[0]), this.rolls, this.bonusRolls); ++ return new LootPool(this.entries.toArray(new LootPoolEntryContainer[0]), this.conditions.toArray(new LootItemCondition[0]), this.functions.toArray(new LootItemFunction[0]), this.rolls, this.bonusRolls, name); } } } @@ -170,11 +_,13 @@ - LootItemFunction[] alootitemfunction = GsonHelper.m_13845_(jsonobject, "functions", new LootItemFunction[0], p_79092_, LootItemFunction[].class); - NumberProvider numberprovider = GsonHelper.m_13836_(jsonobject, "rolls", p_79092_, NumberProvider.class); - NumberProvider numberprovider1 = GsonHelper.m_13845_(jsonobject, "bonus_rolls", ConstantValue.m_165692_(0.0F), p_79092_, NumberProvider.class); + LootItemFunction[] alootitemfunction = GsonHelper.getAsObject(jsonobject, "functions", new LootItemFunction[0], p_79092_, LootItemFunction[].class); + NumberProvider numberprovider = GsonHelper.getAsObject(jsonobject, "rolls", p_79092_, NumberProvider.class); + NumberProvider numberprovider1 = GsonHelper.getAsObject(jsonobject, "bonus_rolls", ConstantValue.exactly(0.0F), p_79092_, NumberProvider.class); - return new LootPool(alootpoolentrycontainer, alootitemcondition, alootitemfunction, numberprovider, numberprovider1); + return new LootPool(alootpoolentrycontainer, alootitemcondition, alootitemfunction, numberprovider, numberprovider1, net.minecraftforge.common.ForgeHooks.readPoolName(jsonobject)); } @@ -77,6 +77,6 @@ JsonObject jsonobject = new JsonObject(); + if (p_79094_.name != null && !p_79094_.name.startsWith("custom#")) + jsonobject.add("name", p_79096_.serialize(p_79094_.name)); - jsonobject.add("rolls", p_79096_.serialize(p_79094_.f_79028_)); - jsonobject.add("bonus_rolls", p_79096_.serialize(p_79094_.f_79029_)); - jsonobject.add("entries", p_79096_.serialize(p_79094_.f_79023_)); + jsonobject.add("rolls", p_79096_.serialize(p_79094_.rolls)); + jsonobject.add("bonus_rolls", p_79096_.serialize(p_79094_.bonusRolls)); + jsonobject.add("entries", p_79096_.serialize(p_79094_.entries)); 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 65823900..d7e18ad4 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 @@ -1,33 +1,33 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java @@ -34,13 +_,13 @@ - public static final LootTable f_79105_ = new LootTable(LootContextParamSets.f_81410_, new LootPool[0], new LootItemFunction[0]); - public static final LootContextParamSet f_79106_ = LootContextParamSets.f_81420_; - final LootContextParamSet f_79108_; -- final LootPool[] f_79109_; -+ private final List f_79109_; - final LootItemFunction[] f_79110_; - private final BiFunction f_79111_; + public static final LootTable EMPTY = new LootTable(LootContextParamSets.EMPTY, new LootPool[0], new LootItemFunction[0]); + public static final LootContextParamSet DEFAULT_PARAM_SET = LootContextParamSets.ALL_PARAMS; + final LootContextParamSet paramSet; +- final LootPool[] pools; ++ private final List pools; + final LootItemFunction[] functions; + private final BiFunction compositeFunction; LootTable(LootContextParamSet p_79114_, LootPool[] p_79115_, LootItemFunction[] p_79116_) { - this.f_79108_ = p_79114_; -- this.f_79109_ = p_79115_; -+ this.f_79109_ = Lists.newArrayList(p_79115_); - this.f_79110_ = p_79116_; - this.f_79111_ = LootItemFunctions.m_80770_(p_79116_); + this.paramSet = p_79114_; +- this.pools = p_79115_; ++ this.pools = Lists.newArrayList(p_79115_); + this.functions = p_79116_; + this.compositeFunction = LootItemFunctions.compose(p_79116_); } @@ -78,6 +_,7 @@ } + @Deprecated //Use other method or manually call ForgeHooks.modifyLoot - public void m_79148_(LootContext p_79149_, Consumer p_79150_) { - this.m_79131_(p_79149_, m_79142_(p_79150_)); + public void getRandomItems(LootContext p_79149_, Consumer p_79150_) { + this.getRandomItemsRaw(p_79149_, createStackSplitter(p_79150_)); } @@ -85,6 +_,7 @@ - public List m_79129_(LootContext p_79130_) { + public List getRandomItems(LootContext p_79130_) { List list = Lists.newArrayList(); - this.m_79148_(p_79130_, list::add); + this.getRandomItems(p_79130_, list::add); + list = net.minecraftforge.common.ForgeHooks.modifyLoot(this.getLootTableId(), list, p_79130_); return list; } @@ -35,26 +35,26 @@ @@ -93,8 +_,8 @@ } - public void m_79136_(ValidationContext p_79137_) { -- for(int i = 0; i < this.f_79109_.length; ++i) { -- this.f_79109_[i].m_79051_(p_79137_.m_79365_(".pools[" + i + "]")); -+ for(int i = 0; i < this.f_79109_.size(); ++i) { -+ this.f_79109_.get(i).m_79051_(p_79137_.m_79365_(".pools[" + i + "]")); + public void validate(ValidationContext p_79137_) { +- for(int i = 0; i < this.pools.length; ++i) { +- this.pools[i].validate(p_79137_.forChild(".pools[" + i + "]")); ++ for(int i = 0; i < this.pools.size(); ++i) { ++ this.pools.get(i).validate(p_79137_.forChild(".pools[" + i + "]")); } - for(int j = 0; j < this.f_79110_.length; ++j) { + for(int j = 0; j < this.functions.length; ++j) { @@ -104,8 +_,29 @@ } - public void m_79123_(Container p_79124_, LootContext p_79125_) { + public void fill(Container p_79124_, LootContext p_79125_) { + // CraftBukkit start + this.fillInventory(p_79124_, p_79125_, false); + } + + public void fillInventory(Container p_79124_, LootContext p_79125_, boolean plugin) { + // CraftBukkit end - List list = this.m_79129_(p_79125_); - Random random = p_79125_.m_78933_(); + List list = this.getRandomItems(p_79125_); + Random random = p_79125_.getRandom(); + + //Magma start - don't fire event if loot context has empty params + if (!p_79125_.isEmptyParams()) { @@ -70,8 +70,8 @@ + // CraftBukkit end + } + //Magma end - List list1 = this.m_79126_(p_79124_, random); - this.m_79138_(list, list1.size(), random); + List list1 = this.getAvailableSlots(p_79124_, random); + this.shuffleAndSplitItems(list, list1.size(), random); @@ -176,6 +_,48 @@ return new LootTable.Builder(); @@ -81,7 +81,7 @@ + private boolean isFrozen = false; + public void freeze() { + this.isFrozen = true; -+ this.f_79109_.forEach(LootPool::freeze); ++ this.pools.forEach(LootPool::freeze); + } + public boolean isFrozen(){ return this.isFrozen; } + private void checkFrozen() { @@ -97,14 +97,14 @@ + public ResourceLocation getLootTableId() { return this.lootTableId; } + + public LootPool getPool(String name) { -+ return f_79109_.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null); ++ return pools.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null); + } + + public LootPool removePool(String name) { + checkFrozen(); -+ for (LootPool pool : this.f_79109_) { ++ for (LootPool pool : this.pools) { + if (name.equals(pool.getName())) { -+ this.f_79109_.remove(pool); ++ this.pools.remove(pool); + return pool; + } + } @@ -113,21 +113,21 @@ + + public void addPool(LootPool pool) { + checkFrozen(); -+ if (f_79109_.stream().anyMatch(e -> e == pool || e.getName() != null && e.getName().equals(pool.getName()))) ++ if (pools.stream().anyMatch(e -> e == pool || e.getName() != null && e.getName().equals(pool.getName()))) + throw new RuntimeException("Attempted to add a duplicate pool to loot table: " + pool.getName()); -+ this.f_79109_.add(pool); ++ this.pools.add(pool); + } + //======================== FORGE END =============================================== + public static class Builder implements FunctionUserBuilder { - private final List f_79156_ = Lists.newArrayList(); - private final List f_79157_ = Lists.newArrayList(); + private final List pools = Lists.newArrayList(); + private final List functions = Lists.newArrayList(); @@ -230,7 +_,7 @@ } } -- if (p_79177_.f_79109_.length > 0) { -+ if (!p_79177_.f_79109_.isEmpty()) { - jsonobject.add("pools", p_79179_.serialize(p_79177_.f_79109_)); +- if (p_79177_.pools.length > 0) { ++ if (!p_79177_.pools.isEmpty()) { + jsonobject.add("pools", p_79179_.serialize(p_79177_.pools)); } diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTables.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTables.java.patch index 74d6f5f2..48b84953 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTables.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTables.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/level/storage/loot/LootTables.java +++ b/net/minecraft/world/level/storage/loot/LootTables.java @@ -18,6 +_,7 @@ - private static final Logger f_79188_ = LogUtils.getLogger(); - private static final Gson f_79189_ = Deserializers.m_78800_().create(); - private Map f_79190_ = ImmutableMap.of(); + private static final Logger LOGGER = LogUtils.getLogger(); + private static final Gson GSON = Deserializers.createLootTableSerializer().create(); + private Map tables = ImmutableMap.of(); + public Map lootTableToKey = ImmutableMap.of(); // CraftBukkit - private final PredicateManager f_79191_; + private final PredicateManager predicateManager; public LootTables(PredicateManager p_79194_) { @@ -29,6 +_,18 @@ - return this.f_79190_.getOrDefault(p_79218_, LootTable.f_79105_); + return this.tables.getOrDefault(p_79218_, LootTable.EMPTY); } + // CraftBukkit start + public ResourceLocation getKey(LootTable p_186521_1_) { -+ ResourceLocation key = ResourceLocation.m_135820_(""); -+ for (Map.Entry tableMap : f_79190_.entrySet()) { ++ ResourceLocation key = ResourceLocation.tryParse(""); ++ for (Map.Entry tableMap : tables.entrySet()) { + if (p_186521_1_.equals(tableMap.getValue())) { + key = tableMap.getKey(); + } @@ -24,29 +24,29 @@ + } + // CraftBukkit end + - protected void m_5787_(Map p_79214_, ResourceManager p_79215_, ProfilerFiller p_79216_) { + protected void apply(Map p_79214_, ResourceManager p_79215_, ProfilerFiller p_79216_) { Builder builder = ImmutableMap.builder(); - JsonElement jsonelement = p_79214_.remove(BuiltInLootTables.f_78712_); + JsonElement jsonelement = p_79214_.remove(BuiltInLootTables.EMPTY); @@ -37,8 +_,8 @@ } p_79214_.forEach((p_79198_, p_79199_) -> { - try { -- LootTable loottable = f_79189_.fromJson(p_79199_, LootTable.class); -+ try (net.minecraft.server.packs.resources.Resource res = p_79215_.m_142591_(getPreparedPath(p_79198_));){ -+ LootTable loottable = net.minecraftforge.common.ForgeHooks.loadLootTable(f_79189_, p_79198_, p_79199_, res == null || !res.m_7816_().equals("Default"), this); +- LootTable loottable = GSON.fromJson(p_79199_, LootTable.class); ++ try (net.minecraft.server.packs.resources.Resource res = p_79215_.getResource(getPreparedPath(p_79198_));){ ++ LootTable loottable = net.minecraftforge.common.ForgeHooks.loadLootTable(GSON, p_79198_, p_79199_, res == null || !res.getSourceName().equals("Default"), this); builder.put(p_79198_, loottable); } catch (Exception exception) { - f_79188_.error("Couldn't parse loot table {}", p_79198_, exception); + LOGGER.error("Couldn't parse loot table {}", p_79198_, exception); @@ -55,6 +_,11 @@ - f_79188_.warn("Found validation problem in {}: {}", p_79211_, p_79212_); + LOGGER.warn("Found validation problem in {}: {}", p_79211_, p_79212_); }); - this.f_79190_ = immutablemap; + this.tables = immutablemap; + // CraftBukkit start - build a reversed registry map + ImmutableMap.Builder lootTableToKeyBuilder = ImmutableMap.builder(); -+ this.f_79190_.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); ++ this.tables.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); + this.lootTableToKey = lootTableToKeyBuilder.build(); + // CraftBukkit end } - public static void m_79202_(ValidationContext p_79203_, ResourceLocation p_79204_, LootTable p_79205_) { + public static void validate(ValidationContext p_79203_, ResourceLocation p_79204_, LootTable p_79205_) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch index 7ec65c9e..ddfa0d90 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java @@ -43,7 +_,12 @@ - public ItemStack m_7372_(ItemStack p_80789_, LootContext p_80790_) { - Entity entity = p_80790_.m_78953_(LootContextParams.f_81458_); + public ItemStack run(ItemStack p_80789_, LootContext p_80790_) { + Entity entity = p_80790_.getParamOrNull(LootContextParams.KILLER_ENTITY); if (entity instanceof LivingEntity) { -- int i = EnchantmentHelper.m_44930_((LivingEntity)entity); +- int i = EnchantmentHelper.getMobLooting((LivingEntity)entity); + int i = p_80790_.getLootingModifier(); + // CraftBukkit start - use lootingModifier if set by plugin -+ if (p_80790_.m_78936_(LootContextParams.LOOTING_MOD)) { -+ i = p_80790_.m_78953_(LootContextParams.LOOTING_MOD); ++ if (p_80790_.hasParam(LootContextParams.LOOTING_MOD)) { ++ i = p_80790_.getParamOrNull(LootContextParams.LOOTING_MOD); + } + // CraftBukkit end if (i == 0) { 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 a866765c..41e076ed 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,11 +1,11 @@ --- a/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java @@ -32,7 +_,7 @@ - ItemStack itemstack = optional.get().m_8043_(); - if (!itemstack.m_41619_()) { - ItemStack itemstack1 = itemstack.m_41777_(); -- itemstack1.m_41764_(p_81268_.m_41613_()); -+ itemstack1.m_41764_(p_81268_.m_41613_() * itemstack.m_41613_()); //Forge: Support smelting returning multiple + ItemStack itemstack = optional.get().getResultItem(); + if (!itemstack.isEmpty()) { + ItemStack itemstack1 = itemstack.copy(); +- itemstack1.setCount(p_81268_.getCount()); ++ itemstack1.setCount(p_81268_.getCount() * itemstack.getCount()); //Forge: Support smelting returning multiple return itemstack1; } } 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 325d5fbe..5e583ec5 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 @@ -2,17 +2,17 @@ +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java @@ -12,6 +_,7 @@ }); - public static final LootContextParamSet f_81411_ = m_81428_("chest", (p_81452_) -> { - p_81452_.m_81406_(LootContextParams.f_81460_).m_81408_(LootContextParams.f_81455_); -+ p_81452_.m_81408_(LootContextParams.f_81458_); //Forge: Chest Minecarts can have killers. + public static final LootContextParamSet CHEST = register("chest", (p_81452_) -> { + p_81452_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY); ++ p_81452_.optional(LootContextParams.KILLER_ENTITY); //Forge: Chest Minecarts can have killers. }); - public static final LootContextParamSet f_81412_ = m_81428_("command", (p_81450_) -> { - p_81450_.m_81406_(LootContextParams.f_81460_).m_81408_(LootContextParams.f_81455_); + public static final LootContextParamSet COMMAND = register("command", (p_81450_) -> { + p_81450_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY); @@ -21,6 +_,7 @@ }); - public static final LootContextParamSet f_81414_ = m_81428_("fishing", (p_81446_) -> { - p_81446_.m_81406_(LootContextParams.f_81460_).m_81406_(LootContextParams.f_81463_).m_81408_(LootContextParams.f_81455_); -+ p_81446_.m_81408_(LootContextParams.f_81458_).m_81408_(LootContextParams.f_81455_); //Forge: Allow fisher, and bobber + public static final LootContextParamSet FISHING = register("fishing", (p_81446_) -> { + p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY); ++ p_81446_.optional(LootContextParams.KILLER_ENTITY).optional(LootContextParams.THIS_ENTITY); //Forge: Allow fisher, and bobber }); - public static final LootContextParamSet f_81415_ = m_81428_("entity", (p_81444_) -> { - p_81444_.m_81406_(LootContextParams.f_81455_).m_81406_(LootContextParams.f_81460_).m_81406_(LootContextParams.f_81457_).m_81408_(LootContextParams.f_81458_).m_81408_(LootContextParams.f_81459_).m_81408_(LootContextParams.f_81456_); + public static final LootContextParamSet ENTITY = register("entity", (p_81444_) -> { + p_81444_.required(LootContextParams.THIS_ENTITY).required(LootContextParams.ORIGIN).required(LootContextParams.DAMAGE_SOURCE).optional(LootContextParams.KILLER_ENTITY).optional(LootContextParams.DIRECT_KILLER_ENTITY).optional(LootContextParams.LAST_DAMAGE_PLAYER); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParams.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParams.java.patch index f720c04f..9df469bf 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParams.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParams.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParams.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParams.java @@ -20,6 +_,7 @@ - public static final LootContextParam f_81462_ = m_81466_("block_entity"); - public static final LootContextParam f_81463_ = m_81466_("tool"); - public static final LootContextParam f_81464_ = m_81466_("explosion_radius"); + public static final LootContextParam BLOCK_ENTITY = create("block_entity"); + public static final LootContextParam TOOL = create("tool"); + public static final LootContextParam EXPLOSION_RADIUS = create("explosion_radius"); + public static final LootContextParam LOOTING_MOD = new LootContextParam<>(new ResourceLocation("bukkit:looting_mod")); // CraftBukkit - private static LootContextParam m_81466_(String p_81467_) { + private static LootContextParam create(String p_81467_) { return new LootContextParam<>(new ResourceLocation(p_81467_)); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/ExplosionCondition.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/ExplosionCondition.java.patch index 087a89cf..4ca1a87b 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/ExplosionCondition.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/ExplosionCondition.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/level/storage/loot/predicates/ExplosionCondition.java @@ -29,7 +_,8 @@ if (f != null) { - Random random = p_81659_.m_78933_(); + Random random = p_81659_.getRandom(); float f1 = 1.0F / f; - return random.nextFloat() <= f1; + // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch index 41870a99..36f73684 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceCondition.java.patch @@ -4,9 +4,9 @@ } public boolean test(LootContext p_81930_) { -- return p_81930_.m_78933_().nextFloat() < this.f_81921_; +- return p_81930_.getRandom().nextFloat() < this.probability; + int i = p_81930_.getLootingModifier(); -+ return p_81930_.m_78933_().nextFloat() < this.f_81921_ + (float) i; ++ return p_81930_.getRandom().nextFloat() < this.probability + (float) i; } - public static LootItemCondition.Builder m_81927_(float p_81928_) { + public static LootItemCondition.Builder randomChance(float p_81928_) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch index 07167145..672f5235 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch @@ -4,17 +4,17 @@ } public boolean test(LootContext p_81967_) { -- Entity entity = p_81967_.m_78953_(LootContextParams.f_81458_); +- Entity entity = p_81967_.getParamOrNull(LootContextParams.KILLER_ENTITY); - int i = 0; - if (entity instanceof LivingEntity) { -- i = EnchantmentHelper.m_44930_((LivingEntity)entity); +- i = EnchantmentHelper.getMobLooting((LivingEntity)entity); + int i = p_81967_.getLootingModifier(); + // CraftBukkit start - only use lootingModifier if set by Bukkit -+ if (p_81967_.m_78936_(LootContextParams.LOOTING_MOD)) { -+ i = p_81967_.m_78953_(LootContextParams.LOOTING_MOD); ++ if (p_81967_.hasParam(LootContextParams.LOOTING_MOD)) { ++ i = p_81967_.getParamOrNull(LootContextParams.LOOTING_MOD); } - + // CraftBukkit end - return p_81967_.m_78933_().nextFloat() < this.f_81953_ + (float)i * this.f_81954_; + return p_81967_.getRandom().nextFloat() < this.percent + (float)i * this.lootingMultiplier; } 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 be17438b..44d1a604 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 @@ -3,9 +3,9 @@ @@ -46,7 +_,7 @@ } - public String m_142016_() { + public String getId() { - return p_165578_.name(); + return p_165578_.getName(); } - public Set> m_142524_() { + public Set> getReferencedContextParams() {