Fixed dev time compilation using J9+ producing incorrect bytecode.

This commit is contained in:
LexManos 2020-04-14 23:54:32 -07:00
parent aa5b9d12ea
commit 5a552b9f8d
10 changed files with 35 additions and 32 deletions

View file

@ -66,7 +66,7 @@ ext {
MAPPING_CHANNEL = 'snapshot'
MAPPING_VERSION = '20200225-1.15.1'
MC_VERSION = '1.15.2'
MCP_VERSION = '20200307.202953'
MCP_VERSION = '20200414.225201'
}
project(':mcp') {

3
gradlew.bat vendored
View file

@ -14,7 +14,8 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem All these are added to make the groovy compiler shut up!
set DEFAULT_JVM_OPTS=--add-opens=java.base/sun.util.calendar=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-opens=java.base/javax.net.ssl=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View file

@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/platform/GlStateManager.java
+++ b/com/mojang/blaze3d/platform/GlStateManager.java
@@ -578,10 +578,17 @@
@@ -579,10 +579,17 @@
GL13.glClientActiveTexture(p_227747_0_);
}

View file

@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/vertex/IVertexBuilder.java
+++ b/com/mojang/blaze3d/vertex/IVertexBuilder.java
@@ -17,7 +17,7 @@
@@ -18,7 +18,7 @@
import org.lwjgl.system.MemoryStack;
@OnlyIn(Dist.CLIENT)
@ -9,7 +9,7 @@
Logger field_227884_f_ = LogManager.getLogger();
IVertexBuilder func_225582_a_(double p_225582_1_, double p_225582_3_, double p_225582_5_);
@@ -95,11 +95,12 @@
@@ -96,11 +96,12 @@
f5 = p_227890_3_[k] * p_227890_6_;
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/BufferBuilder.java
+++ b/net/minecraft/client/renderer/BufferBuilder.java
@@ -121,7 +121,6 @@
@@ -122,7 +122,6 @@
bitset.set(l);
}
@ -8,22 +8,22 @@
}
private void func_227829_a_(FloatBuffer p_227829_1_, int p_227829_2_) {
@@ -297,6 +296,7 @@
@@ -298,6 +297,7 @@
}
ByteBuffer bytebuffer = this.field_179001_a.slice();
+ bytebuffer.order(this.field_179001_a.order()); // FORGE: Fix incorrect byte order
this.field_179001_a.clear();
((Buffer)this.field_179001_a).clear();
return Pair.of(bufferbuilder$drawstate, bytebuffer);
}
@@ -364,4 +364,15 @@
@@ -365,4 +365,15 @@
this.field_179018_e = p_i225907_2_;
}
}
+
+ public void putBulkData(ByteBuffer buffer) {
+ func_181670_b(buffer.limit() + this.field_179011_q.func_177338_f());
+ this.field_179001_a.position(this.field_178997_d * this.field_179011_q.func_177338_f());
+ ((Buffer)this.field_179001_a).position(this.field_178997_d * this.field_179011_q.func_177338_f());
+ this.field_179001_a.put(buffer);
+ this.field_178997_d += buffer.limit() / this.field_179011_q.func_177338_f();
+ this.field_227824_l_ += buffer.limit();

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/texture/NativeImage.java
+++ b/net/minecraft/client/renderer/texture/NativeImage.java
@@ -179,7 +179,7 @@
@@ -180,7 +180,7 @@
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
if (this.field_211680_b != NativeImage.PixelFormat.RGBA) {
throw new IllegalArgumentException(String.format("getPixelRGBA only works on RGBA images; have %s", this.field_211680_b));
@ -9,7 +9,7 @@
this.func_195696_g();
long i = (long)((p_195709_1_ + p_195709_2_ * this.field_195719_a) * 4);
return MemoryUtil.memGetInt(this.field_195722_d + i);
@@ -191,7 +191,7 @@
@@ -192,7 +192,7 @@
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
if (this.field_211680_b != NativeImage.PixelFormat.RGBA) {
throw new IllegalArgumentException(String.format("getPixelRGBA only works on RGBA images; have %s", this.field_211680_b));
@ -18,7 +18,7 @@
this.func_195696_g();
long i = (long)((p_195700_1_ + p_195700_2_ * this.field_195719_a) * 4);
MemoryUtil.memPutInt(this.field_195722_d + i, p_195700_3_);
@@ -203,7 +203,7 @@
@@ -204,7 +204,7 @@
public byte func_211675_e(int p_211675_1_, int p_211675_2_) {
if (!this.field_211680_b.func_211653_r()) {
throw new IllegalArgumentException(String.format("no luminance or alpha in %s", this.field_211680_b));

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/chunk/storage/RegionFile.java
+++ b/net/minecraft/world/chunk/storage/RegionFile.java
@@ -32,6 +32,7 @@
@@ -33,6 +33,7 @@
private final IntBuffer field_76716_d;
private final IntBuffer field_227127_h_;
private final RegionBitmap field_227128_i_ = new RegionBitmap();
@ -8,7 +8,7 @@
public RegionFile(File p_i225784_1_, File p_i225784_2_) throws IOException {
this(p_i225784_1_.toPath(), p_i225784_2_.toPath(), RegionFileVersion.field_227159_b_);
@@ -39,6 +40,7 @@
@@ -40,6 +41,7 @@
public RegionFile(Path p_i225785_1_, Path p_i225785_2_, RegionFileVersion p_i225785_3_) throws IOException {
this.field_227125_e_ = p_i225785_3_;
@ -16,7 +16,7 @@
if (!Files.isDirectory(p_i225785_2_)) {
throw new IllegalArgumentException("Expected directory, got " + p_i225785_2_.toAbsolutePath());
} else {
@@ -61,6 +63,8 @@
@@ -62,6 +64,8 @@
if (k != 0) {
int l = func_227142_b_(k);
int i1 = func_227131_a_(k);
@ -25,7 +25,7 @@
this.field_227128_i_.func_227120_a_(l, i1);
}
}
@@ -69,6 +73,66 @@
@@ -70,6 +74,66 @@
}
}
@ -35,7 +35,7 @@
+
+ ByteBuffer header = ByteBuffer.allocate(5);
+ this.field_76719_c.read(header, offset * 4096);
+ header.flip();
+ ((Buffer)header).flip();
+
+ if (header.remaining() < 5) {
+ field_227122_a_.error("Chunk {},{} in {} header is truncated: expected 5 but read {}", chunkX, chunkZ, this.filePath.getFileName(), header.remaining());
@ -63,7 +63,7 @@
+
+ ByteBuffer header = ByteBuffer.allocate(5);
+ this.field_76719_c.read(header, offset * 4096);
+ header.flip();
+ ((Buffer)header).flip();
+
+ if (header.remaining() < 5) {
+ field_227122_a_.error("Chunk {} in {} header is truncated: expected 5 but read {}", chunk, this.filePath.getFileName(), header.remaining());
@ -78,7 +78,7 @@
+
+ ByteBuffer data = ByteBuffer.allocate(length + 4);
+ this.field_76719_c.read(data, offset * 4096);
+ data.flip();
+ ((Buffer)data).flip();
+
+ if (data.remaining() < length + 4) {
+ field_227122_a_.error("Chunk {} in {} is truncated: expected {} but read {}", chunk, this.filePath.getFileName(), length + 4, data.remaining());
@ -92,7 +92,7 @@
private Path func_227145_e_(ChunkPos p_227145_1_) {
String s = "c." + p_227145_1_.field_77276_a + "." + p_227145_1_.field_77275_b + ".mcc";
return this.field_227124_d_.resolve(s);
@@ -224,6 +288,7 @@
@@ -225,6 +289,7 @@
int j = this.field_76716_d.get(i);
int k = func_227142_b_(j);
int l = func_227131_a_(j);

View file

@ -39,6 +39,7 @@ import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
import java.io.File;
import java.lang.reflect.Field;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@ -431,7 +432,7 @@ public class ForgeHooksClient
VertexFormatElement attr = format.getElements().get(element);
int count = attr.getElementCount();
int constant = attr.getType().getGlConstant();
buffer.position(format.getOffset(element));
((Buffer)buffer).position(format.getOffset(element));
switch(attrType)
{
case POSITION:

View file

@ -34,6 +34,7 @@ import net.minecraftforge.client.model.pipeline.LightUtil;
import org.lwjgl.system.MemoryStack;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@ -71,7 +72,7 @@ public interface IForgeVertexBuilder
IntBuffer intbuffer = bytebuffer.asIntBuffer();
for(int v = 0; v < vertexCount; ++v) {
intbuffer.clear();
((Buffer)intbuffer).clear();
intbuffer.put(aint, v * 8, 8);
float f = bytebuffer.getFloat(0);
float f1 = bytebuffer.getFloat(4);
@ -106,7 +107,7 @@ public interface IForgeVertexBuilder
}
}
}
default int applyBakedLighting(int lightmapCoord, ByteBuffer data) {
int bl = LightTexture.getLightBlock(lightmapCoord);
int sl = LightTexture.getLightSky(lightmapCoord);
@ -117,7 +118,7 @@ public interface IForgeVertexBuilder
sl = Math.max(sl, slBaked);
return LightTexture.packLight(bl, sl);
}
default void applyBakedNormals(Vector3f generated, ByteBuffer data, Matrix3f normalTransform) {
byte nx = data.get(28);
byte ny = data.get(29);

View file

@ -22,6 +22,7 @@ package net.minecraftforge.client.model.b3d;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
@ -41,7 +42,6 @@ import javax.annotation.Nullable;
import net.minecraft.client.renderer.*;
import net.minecraft.util.math.Vec2f;
import net.minecraftforge.versions.forge.ForgeVersion;
import net.minecraftforge.common.model.TransformationHelper;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
@ -100,11 +100,11 @@ public class B3DModel
int l = ByteBuffer.wrap(tmp).order(ByteOrder.LITTLE_ENDIAN).getInt();
if(l < 0 || l + 8 < 0) throw new IOException("File is too large");
buf = ByteBuffer.allocate(l + 8).order(ByteOrder.LITTLE_ENDIAN);
buf.clear();
((Buffer)buf).clear();
buf.put(tag);
buf.put(tmp);
buf.put(IOUtils.toByteArray(in, l));
buf.flip();
((Buffer)buf).flip();
}
}
@ -193,7 +193,7 @@ public class B3DModel
while(buf.get() != 0);
int end = buf.position();
byte[] tmp = new byte[end - start - 1];
buf.position(start);
((Buffer)buf).position(start);
buf.get(tmp);
buf.get();
return new String(tmp, "UTF8");
@ -204,12 +204,12 @@ public class B3DModel
private void pushLimit()
{
limitStack.push(buf.limit());
buf.limit(buf.position() + length);
((Buffer)buf).limit(buf.position() + length);
}
private void popLimit()
{
buf.limit(limitStack.pop());
((Buffer)buf).limit(limitStack.pop());
}
private B3DModel bb3d() throws IOException
@ -501,7 +501,7 @@ public class B3DModel
private void skip()
{
buf.position(buf.position() + length);
((Buffer)buf).position(buf.position() + length);
}
}