Skip to content

Commit

Permalink
Merge pull request #26 from C0D3-M4513R/main
Browse files Browse the repository at this point in the history
Switch away from srg to mojang patches
  • Loading branch information
TonimatasDEV authored Mar 16, 2024
2 parents ec205cc + 18a1ea8 commit 05f7383
Show file tree
Hide file tree
Showing 900 changed files with 24,529 additions and 24,640 deletions.
36 changes: 35 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -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 ================================================*/
Expand All @@ -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);
+ }
+
+ /**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
--- 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_;
+ lastBrightnessY = p_84163_;
+ }
}

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_) {
18 changes: 9 additions & 9 deletions patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
@@ -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();
+ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand All @@ -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) {
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
}
}
+
+ public ImmutableMap<String, VertexFormatElement> 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<String, VertexFormatElement> 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); }
}
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
8 changes: 4 additions & 4 deletions patches/minecraft/com/mojang/math/Matrix3f.java.patch
Original file line number Diff line number Diff line change
@@ -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);
+ }
}
54 changes: 27 additions & 27 deletions patches/minecraft/com/mojang/math/Matrix4f.java.patch
Original file line number Diff line number Diff line change
@@ -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;
+ }
}
Loading

0 comments on commit 05f7383

Please sign in to comment.