Update #48 - Added some features from OptiFine

This commit is contained in:
lax1dude
2025-01-24 18:39:36 -08:00
parent 1f0d593a8c
commit e83a912e38
1056 changed files with 17706 additions and 898 deletions

View File

@ -0,0 +1,326 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package net.lax1dude.eaglercraft.v1_8;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Properties;
public class EaglerProperties extends Properties {
public void load(Reader reader) throws IOException {
load0(new LineReader(reader));
}
public void load(InputStream inStream) throws IOException {
load0(new LineReader(inStream));
}
private void load0(LineReader lr) throws IOException {
StringBuilder outBuffer = new StringBuilder();
int limit;
int keyLen;
int valueStart;
boolean hasSep;
boolean precedingBackslash;
boolean first = true;
while ((limit = lr.readLine()) >= 0) {
keyLen = 0;
valueStart = limit;
hasSep = false;
if(first && limit > 0) {
if(lr.lineBuf[0] == 65279) {
keyLen = 1;
}
}
first = false;
// System.out.println("line=<" + new String(lineBuf, 0, limit) + ">");
precedingBackslash = false;
while (keyLen < limit) {
char c = lr.lineBuf[keyLen];
// need check if escaped.
if ((c == '=' || c == ':') && !precedingBackslash) {
valueStart = keyLen + 1;
hasSep = true;
break;
} else if ((c == ' ' || c == '\t' || c == '\f') && !precedingBackslash) {
valueStart = keyLen + 1;
break;
}
if (c == '\\') {
precedingBackslash = !precedingBackslash;
} else {
precedingBackslash = false;
}
keyLen++;
}
while (valueStart < limit) {
char c = lr.lineBuf[valueStart];
if (c != ' ' && c != '\t' && c != '\f') {
if (!hasSep && (c == '=' || c == ':')) {
hasSep = true;
} else {
break;
}
}
valueStart++;
}
String key = loadConvert(lr.lineBuf, 0, keyLen, outBuffer);
String value = loadConvert(lr.lineBuf, valueStart, limit - valueStart, outBuffer);
put(key, value);
}
}
/*
* Read in a "logical line" from an InputStream/Reader, skip all comment and
* blank lines and filter out those leading whitespace characters (\u0020,
* \u0009 and \u000c) from the beginning of a "natural line". Method returns the
* char length of the "logical line" and stores the line in "lineBuf".
*/
private static class LineReader {
LineReader(InputStream inStream) {
this.inStream = inStream;
inByteBuf = new byte[8192];
}
LineReader(Reader reader) {
this.reader = reader;
inCharBuf = new char[8192];
}
char[] lineBuf = new char[1024];
private byte[] inByteBuf;
private char[] inCharBuf;
private int inLimit = 0;
private int inOff = 0;
private InputStream inStream;
private Reader reader;
int readLine() throws IOException {
// use locals to optimize for interpreted performance
int len = 0;
int off = inOff;
int limit = inLimit;
boolean skipWhiteSpace = true;
boolean appendedLineBegin = false;
boolean precedingBackslash = false;
boolean fromStream = inStream != null;
byte[] byteBuf = inByteBuf;
char[] charBuf = inCharBuf;
char[] lineBuf = this.lineBuf;
char c;
while (true) {
if (off >= limit) {
inLimit = limit = fromStream ? inStream.read(byteBuf) : reader.read(charBuf);
if (limit <= 0) {
if (len == 0) {
return -1;
}
return precedingBackslash ? len - 1 : len;
}
off = 0;
}
// (char)(byte & 0xFF) is equivalent to calling a ISO8859-1 decoder.
c = (fromStream) ? (char) (byteBuf[off++] & 0xFF) : charBuf[off++];
if (skipWhiteSpace) {
if (c == ' ' || c == '\t' || c == '\f') {
continue;
}
if (!appendedLineBegin && (c == '\r' || c == '\n')) {
continue;
}
skipWhiteSpace = false;
appendedLineBegin = false;
}
if (len == 0) { // Still on a new logical line
if (c == '#' || c == '!') {
// Comment, quickly consume the rest of the line
// When checking for new line characters a range check,
// starting with the higher bound ('\r') means one less
// branch in the common case.
commentLoop: while (true) {
if (fromStream) {
byte b;
while (off < limit) {
b = byteBuf[off++];
if (b <= '\r' && (b == '\r' || b == '\n'))
break commentLoop;
}
if (off == limit) {
inLimit = limit = inStream.read(byteBuf);
if (limit <= 0) { // EOF
return -1;
}
off = 0;
}
} else {
while (off < limit) {
c = charBuf[off++];
if (c <= '\r' && (c == '\r' || c == '\n'))
break commentLoop;
}
if (off == limit) {
inLimit = limit = reader.read(charBuf);
if (limit <= 0) { // EOF
return -1;
}
off = 0;
}
}
}
skipWhiteSpace = true;
continue;
}
}
if (c != '\n' && c != '\r') {
lineBuf[len++] = c;
if (len == lineBuf.length) {
lineBuf = new char[len + (len << 1)];
System.arraycopy(this.lineBuf, 0, lineBuf, 0, len);
this.lineBuf = lineBuf;
}
// flip the preceding backslash flag
precedingBackslash = (c == '\\') ? !precedingBackslash : false;
} else {
// reached EOL
if (len == 0) {
skipWhiteSpace = true;
continue;
}
if (off >= limit) {
inLimit = limit = fromStream ? inStream.read(byteBuf) : reader.read(charBuf);
off = 0;
if (limit <= 0) { // EOF
return precedingBackslash ? len - 1 : len;
}
}
if (precedingBackslash) {
// backslash at EOL is not part of the line
len -= 1;
// skip leading whitespace characters in the following line
skipWhiteSpace = true;
appendedLineBegin = true;
precedingBackslash = false;
// take care not to include any subsequent \n
if (c == '\r') {
if (fromStream) {
if (byteBuf[off] == '\n') {
off++;
}
} else {
if (charBuf[off] == '\n') {
off++;
}
}
}
} else {
inOff = off;
return len;
}
}
}
}
}
/*
* Converts encoded &#92;uxxxx to unicode chars and changes special saved chars
* to their original forms
*/
private String loadConvert(char[] in, int off, int len, StringBuilder out) {
char aChar;
int end = off + len;
int start = off;
while (off < end) {
aChar = in[off++];
if (aChar == '\\') {
break;
}
}
if (off == end) { // No backslash
return new String(in, start, len);
}
// backslash found at off - 1, reset the shared buffer, rewind offset
out.setLength(0);
off--;
out.append(in, start, off - start);
while (off < end) {
aChar = in[off++];
if (aChar == '\\') {
// No need to bounds check since LineReader::readLine excludes
// unescaped \s at the end of the line
aChar = in[off++];
if (aChar == 'u') {
// Read the xxxx
if (off > end - 4)
throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
int value = 0;
for (int i = 0; i < 4; i++) {
aChar = in[off++];
switch (aChar) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
value = (value << 4) + aChar - '0';
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
value = (value << 4) + 10 + aChar - 'a';
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
value = (value << 4) + 10 + aChar - 'A';
break;
default:
throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
};
}
out.append((char) value);
} else {
if (aChar == 't')
aChar = '\t';
else if (aChar == 'r')
aChar = '\r';
else if (aChar == 'n')
aChar = '\n';
else if (aChar == 'f')
aChar = '\f';
out.append(aChar);
}
} else {
out.append(aChar);
}
}
return out.toString();
}
}

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u47";
public static final String projectForkVersion = "u48";
public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,20 +20,20 @@ public class EaglercraftVersion {
public static final String projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u47";
public static final String projectOriginVersion = "u48";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
// EPK Version Identifier
public static final String EPKVersionIdentifier = "u47"; // Set to null to disable EPK version check
public static final String EPKVersionIdentifier = "u48"; // Set to null to disable EPK version check
// Updating configuration
public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 47;
public static final int updateBundlePackageVersionInt = 48;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -64,7 +65,12 @@ public class IOUtils {
while((s = rd.readLine()) != null) {
b.append(s).append('\n');
}
return b.toString();
// Handle BOM
if(c == StandardCharsets.UTF_8 && b.length() > 0 && b.charAt(0) == 65279) {
return b.substring(1, b.length());
}else {
return b.toString();
}
}finally {
is.close();
}

View File

@ -17,4 +17,10 @@ package net.lax1dude.eaglercraft.v1_8.internal;
*/
public interface ITextureGL extends IObjectGL {
void setCacheSize(int w, int h);
int getWidth();
int getHeight();
}

View File

@ -3,6 +3,7 @@ package net.lax1dude.eaglercraft.v1_8.minecraft;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@ -19,6 +20,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.crypto.SHA1Digest;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
@ -28,7 +30,7 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.minecraft.client.resources.AbstractResourcePack;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
* Copyright (c) 2024-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -70,6 +72,80 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
this.prefix = prefix;
this.domains = domains;
this.timestamp = timestamp;
this.resourceIndex = new ResourceIndex() {
@Override
protected Collection<String> getPropertiesFiles0() {
VFile2 file = new VFile2(prefix, resourcePackFile, "assets/minecraft/optifine/_property_files_index.json");
String str = file.getAllChars();
Collection<String> propertyFiles = null;
if(str != null) {
propertyFiles = loadPropertyFileList(str);
if(propertyFiles != null) {
return propertyFiles;
}
}
VFile2 mcDir = new VFile2(prefix, resourcePackFile, "assets/minecraft");
int pfxLen = mcDir.getPath().length() + 1;
List<String> philes = mcDir.listFilenames(true);
propertyFiles = new ArrayList<>();
JSONArray arr = new JSONArray();
for(int i = 0, l = philes.size(); i < l; ++i) {
String name = philes.get(i);
if(name.length() > pfxLen && name.endsWith(".properties")) {
name = name.substring(pfxLen);
propertyFiles.add(name);
arr.put(name);
}
}
JSONObject json = new JSONObject();
json.put("propertyFiles", arr);
file.setAllChars(json.toString());
return propertyFiles;
}
@Override
protected Collection<String> getCITPotionsFiles0() {
VFile2 file = new VFile2(prefix, resourcePackFile, "assets/minecraft/mcpatcher/cit/potion/_potions_files_index.json");
String str = file.getAllChars();
Collection<String> propertyFiles = null;
if(str != null) {
propertyFiles = loadPotionsFileList(str);
if(propertyFiles != null) {
return propertyFiles;
}
}
VFile2 mcDir = new VFile2(prefix, resourcePackFile, "assets/minecraft/mcpatcher/cit/potion");
int pfxLen = mcDir.getPath().length() - 20;
List<String> philes = mcDir.listFilenames(true);
propertyFiles = new ArrayList<>();
JSONArray arr = new JSONArray();
for(int i = 0, l = philes.size(); i < l; ++i) {
String name = philes.get(i);
if(name.length() > pfxLen && name.endsWith(".png")) {
name = name.substring(pfxLen);
propertyFiles.add(name);
arr.put(name);
}
}
mcDir = new VFile2(prefix, resourcePackFile, "assets/minecraft/optifine/cit/potion");
pfxLen = mcDir.getPath().length() - 19;
philes = mcDir.listFilenames(true);
for(int i = 0, l = philes.size(); i < l; ++i) {
String name = philes.get(i);
if(name.length() > pfxLen && name.endsWith(".png")) {
name = name.substring(pfxLen);
propertyFiles.add(name);
arr.put(name);
}
}
JSONObject json = new JSONObject();
json.put("potionsFiles", arr);
file.setAllChars(json.toString());
return propertyFiles;
}
};
}
@Override
@ -177,6 +253,8 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
}
Set<String> domainsList = Sets.newHashSet();
JSONArray propertyFiles = new JSONArray();
JSONArray potionsFiles = new JSONArray();
String fn;
for(int i = 0, l = fileNames.size(); i < l; ++i) {
fn = fileNames.get(i);
@ -184,7 +262,18 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
fn = fn.substring(prefixLen + 7);
int j = fn.indexOf('/');
if(j != -1) {
domainsList.add(fn.substring(0, j));
String dm = fn.substring(0, j);
domainsList.add(dm);
if("minecraft".equals(dm)) {
if(fn.endsWith(".properties")) {
propertyFiles.put(fn.substring(10));
}else if((fn.startsWith("minecraft/mcpatcher/cit/potion/")
|| fn.startsWith("minecraft/mcpatcher/cit/Potion/")) && fn.endsWith(".png")) {
potionsFiles.put(fn.substring(10));
}else if(fn.startsWith("minecraft/optifine/cit/potion/") && fn.endsWith(".png")) {
potionsFiles.put(fn.substring(10));
}
}
}
}
}
@ -234,9 +323,19 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
}
throw ex;
}
logger.info("Updating manifest...");
JSONObject json = new JSONObject();
json.put("propertyFiles", propertyFiles);
(new VFile2(prefix, folderName, "assets/minecraft/optifine/_property_files_index.json"))
.setAllChars(json.toString());
json = new JSONObject();
json.put("potionsFiles", propertyFiles);
(new VFile2(prefix, folderName, "assets/minecraft/mcpatcher/cit/potion/_potions_files_index.json"))
.setAllChars(json.toString());
VFile2 manifestFile = new VFile2(prefix, "manifest.json");
String str = manifestFile.getAllChars();
JSONArray arr = null;
@ -363,4 +462,37 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
}
}
}
public static Collection<String> loadPropertyFileList(String str) {
try {
JSONObject json = new JSONObject(str);
JSONArray arr = json.getJSONArray("propertyFiles");
int l = arr.length();
Collection<String> ret = new ArrayList<>(l);
for(int i = 0; i < l; ++i) {
ret.add(arr.getString(i));
}
return ret;
}catch(JSONException ex) {
EagRuntime.debugPrintStackTrace(ex);
return null;
}
}
public static Collection<String> loadPotionsFileList(String str) {
try {
JSONObject json = new JSONObject(str);
JSONArray arr = json.getJSONArray("potionsFiles");
int l = arr.length();
Collection<String> ret = new ArrayList<>(l);
for(int i = 0; i < l; ++i) {
ret.add(arr.getString(i));
}
return ret;
}catch(JSONException ex) {
EagRuntime.debugPrintStackTrace(ex);
return null;
}
}
}

View File

@ -8,10 +8,10 @@ import com.carrotsearch.hppc.cursors.IntCursor;
import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureClock;
import net.minecraft.client.renderer.texture.TextureCompass;
import net.minecraft.client.renderer.texture.TextureUtil;
@ -21,9 +21,10 @@ import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
import net.optifine.util.CounterInt;
/**
* Copyright (c) 2022 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -56,11 +57,14 @@ public class EaglerTextureAtlasSprite {
protected float maxV;
protected int frameCounter;
protected int tickCounter;
private int indexInMap = -1;
protected static String locationNameClock = "builtin/clock";
protected static String locationNameCompass = "builtin/compass";
protected TextureAnimationCache animationCache = null;
public String optifineBaseTextureName = null;
public EaglerTextureAtlasSprite(String spriteName) {
this.iconName = spriteName;
}
@ -101,6 +105,9 @@ public class EaglerTextureAtlasSprite {
this.maxU = atlasSpirit.maxU;
this.minV = atlasSpirit.minV;
this.maxV = atlasSpirit.maxV;
if (atlasSpirit != Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()) {
this.indexInMap = atlasSpirit.indexInMap;
}
}
public int getOriginX() {
@ -149,7 +156,13 @@ public class EaglerTextureAtlasSprite {
return this.iconName;
}
public void updateAnimation(IFramebufferGL[] copyColorFramebuffer) {
protected static interface IAnimCopyFunction {
void updateAnimation(int mapWidth, int mapHeight, int mapLevel);
}
protected IAnimCopyFunction currentAnimUpdater = null;
public void updateAnimation() {
if(animationCache == null) {
throw new IllegalStateException("Animation cache for '" + this.iconName + "' was never baked!");
}
@ -162,7 +175,12 @@ public class EaglerTextureAtlasSprite {
this.tickCounter = 0;
int k = this.animationMetadata.getFrameIndex(this.frameCounter);
if (i != k && k >= 0 && k < this.framesTextureData.size()) {
animationCache.copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCache.copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel, this.originY >> mapLevel,
this.width >> mapLevel, this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdater = null;
}
} else if (this.animationMetadata.isInterpolate()) {
float f = 1.0f - (float) this.tickCounter / (float) this.animationMetadata.getFrameTimeSingle(this.frameCounter);
@ -171,8 +189,22 @@ public class EaglerTextureAtlasSprite {
: this.animationMetadata.getFrameCount();
int k = this.animationMetadata.getFrameIndex((this.frameCounter + 1) % j);
if (i != k && k >= 0 && k < this.framesTextureData.size()) {
animationCache.copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCache.copyInterpolatedFrameToTex2D(i, k, f, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
}else {
currentAnimUpdater = null;
}
} else {
currentAnimUpdater = null;
}
}
public void copyAnimationFrame(int mapWidth, int mapHeight, int mapLevel) {
if(currentAnimUpdater != null) {
currentAnimUpdater.updateAnimation(mapWidth, mapHeight, mapLevel);
}
}
@ -367,7 +399,7 @@ public class EaglerTextureAtlasSprite {
}
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialTexOffset) {
public void updateAnimationPBR() {
Throwable t = new UnsupportedOperationException("PBR is not enabled");
try {
throw t;
@ -375,4 +407,37 @@ public class EaglerTextureAtlasSprite {
logger.error(t);
}
}
public void copyAnimationFramePBR(int pass, int width, int height, int level) {
Throwable t = new UnsupportedOperationException("PBR is not enabled");
try {
throw t;
}catch(Throwable tt) {
logger.error(t);
}
}
public int getIndexInMap() {
return this.indexInMap;
}
public void setIndexInMap(int p_setIndexInMap_1_) {
this.indexInMap = p_setIndexInMap_1_;
}
public void updateIndexInMap(CounterInt p_updateIndexInMap_1_) {
if (this.indexInMap < 0) {
this.indexInMap = p_updateIndexInMap_1_.nextValue();
}
}
public double getSpriteU16(float p_getSpriteU16_1_) {
float f = this.maxU - this.minU;
return (double) ((p_getSpriteU16_1_ - this.minU) / f * 16.0F);
}
public double getSpriteV16(float p_getSpriteV16_1_) {
float f = this.maxV - this.minV;
return (double) ((p_getSpriteV16_1_ - this.minV) / f * 16.0F);
}
}

View File

@ -0,0 +1,43 @@
package net.lax1dude.eaglercraft.v1_8.minecraft;
import java.util.Collection;
/**
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public abstract class ResourceIndex {
protected Collection<String> propertiesCache = null;
protected Collection<String> citPotionsCache = null;
public Collection<String> getPropertiesFiles() {
if(propertiesCache == null) {
propertiesCache = getPropertiesFiles0();
}
return propertiesCache;
}
protected abstract Collection<String> getPropertiesFiles0();
public Collection<String> getCITPotionsFiles() {
if(citPotionsCache == null) {
citPotionsCache = getCITPotionsFiles0();
}
return citPotionsCache;
}
protected abstract Collection<String> getCITPotionsFiles0();
}

View File

@ -1,22 +1,19 @@
package net.lax1dude.eaglercraft.v1_8.minecraft;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.SpriteLevelMixer;
import net.lax1dude.eaglercraft.v1_8.opengl.TextureCopyUtil;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix3f;
import net.minecraft.client.renderer.GLAllocation;
/**
* Copyright (c) 2022 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -40,8 +37,6 @@ public class TextureAnimationCache {
private int[] cacheTextures = null;
public static final int _GL_FRAMEBUFFER = 0x8D40;
public TextureAnimationCache(int width, int height, int mipLevels) {
this.width = width;
this.height = height;
@ -105,76 +100,40 @@ public class TextureAnimationCache {
}
}
public void copyFrameLevelsToTex2D(int animationFrame, int dx, int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
copyFrameLevelsToTex2D(animationFrame, mipLevels, dx, dy, w, h, dstFramebuffers);
}
/**
* WARNING: call <code>_wglBindFramebuffer(_GL_FRAMEBUFFER, null);</code> when complete
*/
public void copyFrameLevelsToTex2D(int animationFrame, int levels, int dx, int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
for(int i = 0; i < levels; ++i) {
_wglBindFramebuffer(_GL_FRAMEBUFFER, dstFramebuffers[i]);
copyFrameToTex2D(animationFrame, i, dx >> i, dy >> i, w >> i, h >> i);
}
}
public void copyFrameToTex2D(int animationFrame, int level, int dx, int dy, int w, int h) {
public void copyFrameToTex2D(int animationFrame, int level, int dx, int dy, int w, int h, int mapWidth, int mapHeight) {
if(cacheTextures == null) {
throw new IllegalStateException("Cannot copy from uninitialized TextureAnimationCache");
}
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
GlStateManager.bindTexture(cacheTextures[level]);
TextureCopyUtil.srcSize(width >> level, (height >> level) * frameCount);
TextureCopyUtil.blitTextureUsingViewports(0, h * animationFrame, dx, dy, w, h);
}
public void copyInterpolatedFrameLevelsToTex2D(int animationFrameFrom, int animationFrameTo, float factor, int dx,
int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
copyInterpolatedFrameLevelsToTex2D(animationFrameFrom, animationFrameTo, factor, mipLevels, dx, dy, w, h, dstFramebuffers);
}
/**
* WARNING: call <code>_wglBindFramebuffer(_GL_FRAMEBUFFER, null);</code> when complete
*/
public void copyInterpolatedFrameLevelsToTex2D(int animationFrameFrom, int animationFrameTo, float factor,
int levels, int dx, int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
for(int i = 0; i < levels; ++i) {
_wglBindFramebuffer(_GL_FRAMEBUFFER, dstFramebuffers[i]);
copyInterpolatedFrameToTex2D(animationFrameFrom, animationFrameTo, factor, i, dx >> i, dy >> i, w >> i, h >> i);
}
TextureCopyUtil.dstSize(mapWidth, mapHeight);
TextureCopyUtil.blitTexture(0, h * animationFrame, dx, dy, w, h);
}
public void copyInterpolatedFrameToTex2D(int animationFrameFrom, int animationFrameTo, float factor, int level,
int dx, int dy, int w, int h) {
int dx, int dy, int w, int h, int mapWidth, int mapHeight) {
if(cacheTextures == null) {
throw new IllegalStateException("Cannot copy from uninitialized TextureAnimationCache");
}
GlStateManager.viewport(dx, dy, w, h);
GlStateManager.bindTexture(cacheTextures[level]);
GlStateManager.disableBlend();
Matrix3f matrix = new Matrix3f();
matrix.m11 = 1.0f / frameCount;
matrix.m21 = matrix.m11 * animationFrameFrom;
SpriteLevelMixer.setMatrix3f(matrix);
SpriteLevelMixer.srcSize(width >> level, (height >> level) * frameCount);
SpriteLevelMixer.dstSize(mapWidth, mapHeight);
SpriteLevelMixer.setBlendColor(factor, factor, factor, factor);
SpriteLevelMixer.setBiasColor(0.0f, 0.0f, 0.0f, 0.0f);
SpriteLevelMixer.drawSprite(0);
SpriteLevelMixer.drawSprite(0, 0, h * animationFrameFrom, w, h, dx, dy, w, h);
matrix.m21 = matrix.m11 * animationFrameTo;
SpriteLevelMixer.setMatrix3f(matrix);
float fac1 = 1.0f - factor;
SpriteLevelMixer.setBlendColor(fac1, fac1, fac1, fac1);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL_ONE, GL_ONE);
SpriteLevelMixer.drawSprite(0);
SpriteLevelMixer.drawSprite(0, 0, h * animationFrameTo, w, h, dx, dy, w, h);
GlStateManager.disableBlend();
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View File

@ -246,6 +246,7 @@ public class EaglercraftGPU {
public static final void glTexImage2D(int target, int level, int internalFormat, int w, int h, int unused,
int format, int type, ByteBuffer pixels) {
GlStateManager.setTextureCachedSize(target, w, h);
if(glesVers >= 300) {
_wglTexImage2D(target, level, internalFormat, w, h, unused, format, type, pixels);
}else {
@ -256,6 +257,7 @@ public class EaglercraftGPU {
public static final void glTexImage2D(int target, int level, int internalFormat, int w, int h, int unused,
int format, int type, IntBuffer pixels) {
GlStateManager.setTextureCachedSize(target, w, h);
if(glesVers >= 300) {
_wglTexImage2D(target, level, internalFormat, w, h, unused, format, type, pixels);
}else {
@ -270,6 +272,7 @@ public class EaglercraftGPU {
}
public static final void glTexStorage2D(int target, int levels, int internalFormat, int w, int h) {
GlStateManager.setTextureCachedSize(target, w, h);
if(texStorageCapable && (glesVers >= 300 || levels == 1 || (MathHelper.calculateLogBaseTwo(Math.max(w, h)) + 1) == levels)) {
_wglTexStorage2D(target, levels, internalFormat, w, h);
}else {
@ -914,7 +917,6 @@ public class EaglercraftGPU {
PlatformOpenGL.enterVAOEmulationHook();
GLSLHeader.init();
DrawUtils.init();
SpriteLevelMixer.initialize();
if(instancingCapable) {
InstancedFontRenderer.initialize();
InstancedParticleRenderer.initialize();
@ -928,7 +930,6 @@ public class EaglercraftGPU {
public static final void destroyCache() {
GLSLHeader.destroy();
DrawUtils.destroy();
SpriteLevelMixer.destroy();
InstancedFontRenderer.destroy();
InstancedParticleRenderer.destroy();
EffectPipelineFXAA.destroy();

View File

@ -1,11 +1,13 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.ITextureGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import net.minecraft.util.MathHelper;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
@ -159,8 +161,8 @@ public class GlStateManager {
static final Matrix4f[][] textureMatrixStack = new Matrix4f[8][8];
static final int[][] textureMatrixStackAccessSerial = new int[8][8];
static int[] textureMatrixAccessSerial = new int[8];
static int[] textureMatrixStackPointer = new int[8];
static final int[] textureMatrixAccessSerial = new int[8];
static final int[] textureMatrixStackPointer = new int[8];
static boolean stateUseExtensionPipeline = false;
@ -821,6 +823,32 @@ public class GlStateManager {
}
}
private static Matrix4f getMatrixIncr() {
Matrix4f mat;
int _i, _j;
switch(stateMatrixMode) {
case GL_MODELVIEW:
_j = modelMatrixStackPointer;
mat = modelMatrixStack[_j];
modelMatrixStackAccessSerial[_j] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
_j = projectionMatrixStackPointer;
mat = projectionMatrixStack[_j];
projectionMatrixStackAccessSerial[_j] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
_i = activeTexture;
_j = textureMatrixStackPointer[_i];
mat = textureMatrixStack[_i][_j];
textureMatrixStackAccessSerial[_i][_j] = ++textureCoordsAccessSerial[_i];
break;
default:
throw new IllegalStateException();
}
return mat;
}
public static final void getFloat(int pname, float[] params) {
switch(pname) {
case GL_MODELVIEW_MATRIX:
@ -854,24 +882,7 @@ public class GlStateManager {
}
public static final void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
default:
matrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
paramMatrix.m00 = 2.0f / (float)(right - left);
paramMatrix.m01 = 0.0f;
paramMatrix.m02 = 0.0f;
@ -894,169 +905,200 @@ public class GlStateManager {
private static final Vector3f paramVector = new Vector3f();
private static final float toRad = 0.0174532925f;
public static final void rotate(float angle, float x, float y, float z) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].rotate(angle * toRad, paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].rotate(angle * toRad, paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].rotate(angle * toRad, paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
Matrix4f matrix = getMatrixIncr();
if(x == 0.0f) {
if(y == 0.0f) {
if(z == 1.0f || z == -1.0f) {
_glRotatefZ(matrix, toRad * angle * z);
return;
}
}else if((y == 1.0f || y == -1.0f) && z == 0.0f) {
_glRotatefY(matrix, toRad * angle * y);
return;
}
}else if((x == 1.0f || x == -1.0f) && y == 0.0f && z == 0.0f) {
_glRotatefX(matrix, toRad * angle * x);
return;
}
_glRotatef(matrix, toRad * angle, x, y, z);
}
public static final void rotateXYZ(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(x != 0.0f) _glRotatefX(matrix, toRad * x);
if(y != 0.0f) _glRotatefY(matrix, toRad * y);
if(z != 0.0f) _glRotatefZ(matrix, toRad * z);
}
public static final void rotateZYX(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(z != 0.0f) _glRotatefZ(matrix, toRad * z);
if(y != 0.0f) _glRotatefY(matrix, toRad * y);
if(x != 0.0f) _glRotatefX(matrix, toRad * x);
}
public static final void rotateXYZRad(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(x != 0.0f) _glRotatefX(matrix, x);
if(y != 0.0f) _glRotatefY(matrix, y);
if(z != 0.0f) _glRotatefZ(matrix, z);
}
public static final void rotateZYXRad(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(z != 0.0f) _glRotatefZ(matrix, z);
if(y != 0.0f) _glRotatefY(matrix, y);
if(x != 0.0f) _glRotatefX(matrix, x);
}
private static void _glRotatefX(Matrix4f mat, float angle) {
float sin = MathHelper.sin(angle);
float cos = MathHelper.cos(angle);
float lm10 = mat.m10, lm11 = mat.m11, lm12 = mat.m12, lm13 = mat.m13, lm20 = mat.m20, lm21 = mat.m21,
lm22 = mat.m22, lm23 = mat.m23;
mat.m20 = lm10 * -sin + lm20 * cos;
mat.m21 = lm11 * -sin + lm21 * cos;
mat.m22 = lm12 * -sin + lm22 * cos;
mat.m23 = lm13 * -sin + lm23 * cos;
mat.m10 = lm10 * cos + lm20 * sin;
mat.m11 = lm11 * cos + lm21 * sin;
mat.m12 = lm12 * cos + lm22 * sin;
mat.m13 = lm13 * cos + lm23 * sin;
}
private static void _glRotatefY(Matrix4f mat, float angle) {
float sin = MathHelper.sin(angle);
float cos = MathHelper.cos(angle);
float nm00 = mat.m00 * cos + mat.m20 * -sin;
float nm01 = mat.m01 * cos + mat.m21 * -sin;
float nm02 = mat.m02 * cos + mat.m22 * -sin;
float nm03 = mat.m03 * cos + mat.m23 * -sin;
mat.m20 = mat.m00 * sin + mat.m20 * cos;
mat.m21 = mat.m01 * sin + mat.m21 * cos;
mat.m22 = mat.m02 * sin + mat.m22 * cos;
mat.m23 = mat.m03 * sin + mat.m23 * cos;
mat.m00 = nm00;
mat.m01 = nm01;
mat.m02 = nm02;
mat.m03 = nm03;
}
private static void _glRotatefZ(Matrix4f mat, float angle) {
float dirX = MathHelper.sin(angle);
float dirY = MathHelper.cos(angle);
float nm00 = mat.m00 * dirY + mat.m10 * dirX;
float nm01 = mat.m01 * dirY + mat.m11 * dirX;
float nm02 = mat.m02 * dirY + mat.m12 * dirX;
float nm03 = mat.m03 * dirY + mat.m13 * dirX;
mat.m10 = mat.m00 * -dirX + mat.m10 * dirY;
mat.m11 = mat.m01 * -dirX + mat.m11 * dirY;
mat.m12 = mat.m02 * -dirX + mat.m12 * dirY;
mat.m13 = mat.m03 * -dirX + mat.m13 * dirY;
mat.m00 = nm00;
mat.m01 = nm01;
mat.m02 = nm02;
mat.m03 = nm03;
}
private static void _glRotatef(Matrix4f mat, float angle, float x, float y, float z) {
float s = MathHelper.sin(angle);
float c = MathHelper.cos(angle);
float C = 1.0f - c;
float xx = x * x, xy = x * y, xz = x * z;
float yy = y * y, yz = y * z;
float zz = z * z;
float rm00 = xx * C + c;
float rm01 = xy * C + z * s;
float rm02 = xz * C - y * s;
float rm10 = xy * C - z * s;
float rm11 = yy * C + c;
float rm12 = yz * C + x * s;
float rm20 = xz * C + y * s;
float rm21 = yz * C - x * s;
float rm22 = zz * C + c;
float nm00 = mat.m00 * rm00 + mat.m10 * rm01 + mat.m20 * rm02;
float nm01 = mat.m01 * rm00 + mat.m11 * rm01 + mat.m21 * rm02;
float nm02 = mat.m02 * rm00 + mat.m12 * rm01 + mat.m22 * rm02;
float nm03 = mat.m03 * rm00 + mat.m13 * rm01 + mat.m23 * rm02;
float nm10 = mat.m00 * rm10 + mat.m10 * rm11 + mat.m20 * rm12;
float nm11 = mat.m01 * rm10 + mat.m11 * rm11 + mat.m21 * rm12;
float nm12 = mat.m02 * rm10 + mat.m12 * rm11 + mat.m22 * rm12;
float nm13 = mat.m03 * rm10 + mat.m13 * rm11 + mat.m23 * rm12;
mat.m20 = mat.m00 * rm20 + mat.m10 * rm21 + mat.m20 * rm22;
mat.m21 = mat.m01 * rm20 + mat.m11 * rm21 + mat.m21 * rm22;
mat.m22 = mat.m02 * rm20 + mat.m12 * rm21 + mat.m22 * rm22;
mat.m23 = mat.m03 * rm20 + mat.m13 * rm21 + mat.m23 * rm22;
mat.m00 = nm00;
mat.m01 = nm01;
mat.m02 = nm02;
mat.m03 = nm03;
mat.m10 = nm10;
mat.m11 = nm11;
mat.m12 = nm12;
mat.m13 = nm13;
}
public static final void scale(float x, float y, float z) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].scale(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].scale(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
matrix.m00 *= x;
matrix.m01 *= x;
matrix.m02 *= x;
matrix.m03 *= x;
matrix.m10 *= y;
matrix.m11 *= y;
matrix.m12 *= y;
matrix.m13 *= y;
matrix.m20 *= z;
matrix.m21 *= z;
matrix.m22 *= z;
matrix.m23 *= z;
}
public static final void scale(double x, double y, double z) {
paramVector.x = (float)x;
paramVector.y = (float)y;
paramVector.z = (float)z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].scale(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].scale(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
matrix.m00 *= x;
matrix.m01 *= x;
matrix.m02 *= x;
matrix.m03 *= x;
matrix.m10 *= y;
matrix.m11 *= y;
matrix.m12 *= y;
matrix.m13 *= y;
matrix.m20 *= z;
matrix.m21 *= z;
matrix.m22 *= z;
matrix.m23 *= z;
}
public static final void translate(float x, float y, float z) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].translate(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].translate(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
matrix.m30 = matrix.m00 * x + matrix.m10 * y + matrix.m20 * z + matrix.m30;
matrix.m31 = matrix.m01 * x + matrix.m11 * y + matrix.m21 * z + matrix.m31;
matrix.m32 = matrix.m02 * x + matrix.m12 * y + matrix.m22 * z + matrix.m32;
matrix.m33 = matrix.m03 * x + matrix.m13 * y + matrix.m23 * z + matrix.m33;
}
public static final void translate(double x, double y, double z) {
paramVector.x = (float)x;
paramVector.y = (float)y;
paramVector.z = (float)z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].translate(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].translate(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
float _x = (float)x;
float _y = (float)y;
float _z = (float)z;
Matrix4f matrix = getMatrixIncr();
matrix.m30 = matrix.m00 * _x + matrix.m10 * _y + matrix.m20 * _z + matrix.m30;
matrix.m31 = matrix.m01 * _x + matrix.m11 * _y + matrix.m21 * _z + matrix.m31;
matrix.m32 = matrix.m02 * _x + matrix.m12 * _y + matrix.m22 * _z + matrix.m32;
matrix.m33 = matrix.m03 * _x + matrix.m13 * _y + matrix.m23 * _z + matrix.m33;
}
private static final Matrix4f paramMatrix = new Matrix4f();
public static final void multMatrix(float[] matrix) {
Matrix4f modeMatrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modeMatrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
modeMatrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
modeMatrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
paramMatrix.load(matrix);
Matrix4f.mul(modeMatrix, paramMatrix, modeMatrix);
Matrix4f mat = getMatrixIncr();
Matrix4f.mul(mat, paramMatrix, mat);
}
public static final void multMatrix(Matrix4f matrix) {
Matrix4f modeMatrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modeMatrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
modeMatrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
modeMatrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f.mul(modeMatrix, matrix, modeMatrix);
Matrix4f mat = getMatrixIncr();
Matrix4f.mul(mat, matrix, mat);
}
public static final void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) {
@ -1088,24 +1130,7 @@ public class GlStateManager {
}
public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
default:
matrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f);
paramMatrix.m00 = cotangent / aspect;
paramMatrix.m01 = 0.0f;
@ -1127,24 +1152,7 @@ public class GlStateManager {
}
public static final void gluLookAt(Vector3f eye, Vector3f center, Vector3f up) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
default:
matrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
float x = center.x - eye.x;
float y = center.y - eye.y;
float z = center.z - eye.z;
@ -1262,4 +1270,18 @@ public class GlStateManager {
public static void recompileShaders() {
FixedFunctionPipeline.flushCache();
}
public static int getBoundTexture() {
return boundTexture[activeTexture];
}
static void setTextureCachedSize(int target, int w, int h) {
if(target == GL_TEXTURE_2D) {
ITextureGL tex = EaglercraftGPU.getNativeTexture(boundTexture[activeTexture]);
if(tex != null) {
tex.setCacheSize(w, h);
}
}
}
}

View File

@ -1,6 +1,9 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.List;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
@ -10,10 +13,11 @@ import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.VSHInputLayoutParser.ShaderInput;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix3f;
/**
* Copyright (c) 2022-2023 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -39,7 +43,8 @@ public class SpriteLevelMixer {
private static IUniformGL u_textureLod1f = null;
private static IUniformGL u_blendFactor4f = null;
private static IUniformGL u_blendBias4f = null;
private static IUniformGL u_matrixTransform = null;
private static IUniformGL u_srcCoords4f = null;
private static IUniformGL u_dstCoords4f = null;
private static FloatBuffer matrixCopyBuffer = null;
@ -55,12 +60,15 @@ public class SpriteLevelMixer {
private static float biasColorB = 0.0f;
private static float biasColorA = 0.0f;
private static boolean matrixChanged = true;
private static final Matrix3f transformMatrix = new Matrix3f();
private static float srcViewW = 100.0f;
private static float srcViewH = 100.0f;
private static float dstViewW = 50.0f;
private static float dstViewH = 50.0f;
private static final Matrix3f identityMatrix = new Matrix3f();
static void initialize() {
static void initialize(IShaderGL vertexShader, List<ShaderInput> vshSourceLayout) {
String fragmentSource = EagRuntime.getRequiredResourceString(fragmentShaderPath);
IShaderGL frag = _wglCreateShader(GL_FRAGMENT_SHADER);
@ -82,16 +90,16 @@ public class SpriteLevelMixer {
shaderProgram = _wglCreateProgram();
_wglAttachShader(shaderProgram, DrawUtils.vshLocal);
_wglAttachShader(shaderProgram, vertexShader);
_wglAttachShader(shaderProgram, frag);
if(EaglercraftGPU.checkOpenGLESVersion() == 200) {
VSHInputLayoutParser.applyLayout(shaderProgram, DrawUtils.vshLocalLayout);
VSHInputLayoutParser.applyLayout(shaderProgram, vshSourceLayout);
}
_wglLinkProgram(shaderProgram);
_wglDetachShader(shaderProgram, DrawUtils.vshLocal);
_wglDetachShader(shaderProgram, vertexShader);
_wglDetachShader(shaderProgram, frag);
_wglDeleteShader(frag);
@ -115,7 +123,8 @@ public class SpriteLevelMixer {
u_textureLod1f = _wglGetUniformLocation(shaderProgram, "u_textureLod1f");
u_blendFactor4f = _wglGetUniformLocation(shaderProgram, "u_blendFactor4f");
u_blendBias4f = _wglGetUniformLocation(shaderProgram, "u_blendBias4f");
u_matrixTransform = _wglGetUniformLocation(shaderProgram, "u_matrixTransform");
u_srcCoords4f = _wglGetUniformLocation(shaderProgram, "u_srcCoords4f");
u_dstCoords4f = _wglGetUniformLocation(shaderProgram, "u_dstCoords4f");
_wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_inputTexture"), 0);
@ -141,25 +150,31 @@ public class SpriteLevelMixer {
}
}
public static void setIdentityMatrix() {
setMatrix3f(identityMatrix);
public static void srcSize(int w, int h) {
srcViewW = w;
srcViewH = h;
}
public static void setMatrix3f(Matrix3f matrix) {
if(!matrix.equals(transformMatrix)) {
matrixChanged = true;
transformMatrix.load(matrix);
}
public static void dstSize(int w, int h) {
dstViewW = w * 0.5f;
dstViewH = h * 0.5f;
}
public static void drawSprite(float level) {
public static void srcDstSize(int w, int h) {
srcViewW = w;
srcViewH = h;
dstViewW = w * 0.5f;
dstViewH = h * 0.5f;
}
public static void drawSprite(int lvl, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
EaglercraftGPU.bindGLShaderProgram(shaderProgram);
if(EaglercraftGPU.checkTextureLODCapable()) {
_wglUniform1f(u_textureLod1f, level);
_wglUniform1f(u_textureLod1f, lvl);
}else {
if(level != 0.0f) {
LOGGER.error("Tried to copy from mipmap level {}, but this GPU does not support textureLod!", level);
if(lvl != 0) {
LOGGER.error("Tried to copy from mipmap level {}, but this GPU does not support textureLod!", lvl);
}
_wglUniform1f(u_textureLod1f, 0.0f);
}
@ -174,13 +189,9 @@ public class SpriteLevelMixer {
biasColorChanged = false;
}
if(matrixChanged) {
matrixCopyBuffer.clear();
transformMatrix.store(matrixCopyBuffer);
matrixCopyBuffer.flip();
_wglUniformMatrix3fv(u_matrixTransform, false, matrixCopyBuffer);
matrixChanged = false;
}
_wglUniform4f(u_srcCoords4f, (float)srcX / srcViewW, (float)srcY / srcViewH, (float)srcW / srcViewW, (float)srcH / srcViewH);
_wglUniform4f(u_dstCoords4f, (float) dstX / dstViewW - 1.0f, (float) dstY / dstViewH - 1.0f,
(float) dstW / dstViewW, (float) dstH / dstViewH);
DrawUtils.drawStandardQuad2D();
}
@ -197,7 +208,8 @@ public class SpriteLevelMixer {
u_textureLod1f = null;
u_blendFactor4f = null;
u_blendBias4f = null;
u_matrixTransform = null;
u_srcCoords4f = null;
u_dstCoords4f = null;
}
}

View File

@ -113,6 +113,8 @@ public class TextureCopyUtil {
if(EaglercraftGPU.checkOpenGLESVersion() == 200) {
vshSourceLayout = VSHInputLayoutParser.getShaderInputs(vshSource);
}
SpriteLevelMixer.initialize(vshShader, vshSourceLayout);
}
private static TextureCopyShader compileShader(boolean align, boolean depth) {
@ -283,18 +285,22 @@ public class TextureCopyUtil {
DrawUtils.drawStandardQuad2D();
}
@Deprecated
public static void blitTextureUsingViewports(int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureUsingViewports(0, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureUsingViewports(int lvl, int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureUsingViewports(lvl, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureUsingViewports(int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
blitTextureUsingViewports(0, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);
}
@Deprecated
public static void blitTextureUsingViewports(int lvl, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
TextureCopyShader shaderObj = getShaderObj(isAligned, false);
EaglercraftGPU.bindGLShaderProgram(shaderObj.shaderProgram);
@ -376,18 +382,22 @@ public class TextureCopyUtil {
DrawUtils.drawStandardQuad2D();
}
@Deprecated
public static void blitTextureDepthUsingViewports(int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureDepthUsingViewports(0, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureDepthUsingViewports(int lvl, int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureDepthUsingViewports(lvl, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureDepthUsingViewports(int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
blitTextureDepthUsingViewports(0, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);
}
@Deprecated
public static void blitTextureDepthUsingViewports(int lvl, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
TextureCopyShader shaderObj = getShaderObj(isAligned, true);
EaglercraftGPU.bindGLShaderProgram(shaderObj.shaderProgram);
@ -431,5 +441,6 @@ public class TextureCopyUtil {
textureBlitDepthAligned.destroy();
textureBlitDepthAligned = null;
}
SpriteLevelMixer.destroy();
}
}

View File

@ -12,8 +12,12 @@ import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.MathHelper;
import net.optifine.render.RenderEnv;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
@ -50,6 +54,9 @@ public class WorldRenderer {
private boolean hasBeenFreed = false;
private EnumWorldBlockLayer blockLayer = null;
public RenderEnv renderEnv = null;
public WorldRenderer(int bufferSizeIn) {
this.byteBuffer = GLAllocation.createDirectByteBuffer(bufferSizeIn << 2);
this.intBuffer = this.byteBuffer.asIntBuffer();
@ -555,6 +562,20 @@ public class WorldRenderer {
}
public RenderEnv getRenderEnv(IBlockState p_getRenderEnv_1_, BlockPos p_getRenderEnv_2_) {
if (this.renderEnv == null) {
this.renderEnv = new RenderEnv(p_getRenderEnv_1_, p_getRenderEnv_2_);
return this.renderEnv;
} else {
this.renderEnv.reset(p_getRenderEnv_1_, p_getRenderEnv_2_);
return this.renderEnv;
}
}
public EnumWorldBlockLayer getBlockLayer() {
return this.blockLayer;
}
public class State {
private final IntBuffer stateRawBuffer;
private final VertexFormat stateVertexFormat;

View File

@ -2440,6 +2440,15 @@ public class EaglerDeferredPipeline {
GlStateManager.setActiveTexture(GL_TEXTURE10);
GlStateManager.bindTexture(skyIrradianceTexture);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.disableDepth();
GlStateManager.disableBlend();
GlStateManager.depthMask(false);
GlStateManager.bindTexture(envMapSkyTexture);
GlStateManager.viewport(0, 0, 128, 256);
TextureCopyUtil.blitTexture();
GlStateManager.depthMask(true);
GlStateManager.enableBlend();
GlStateManager.enableDepth();
DeferredStateManager.checkGLError("Post: beginDrawEnvMap()");
}
@ -2470,7 +2479,7 @@ public class EaglerDeferredPipeline {
public void beginDrawEnvMapTranslucent() {
DeferredStateManager.checkGLError("Pre: beginDrawEnvMapTranslucent()");
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_ONE);
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
bindEnvMapBlockTexture();
DeferredStateManager.checkGLError("Post: beginDrawEnvMapTranslucent()");
}

View File

@ -8,7 +8,6 @@ import com.carrotsearch.hppc.cursors.IntCursor;
import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
@ -219,7 +218,9 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
}
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialTexOffset) {
protected IAnimCopyFunction currentAnimUpdaterPBR = null;
public void updateAnimationPBR() {
if(animationCachePBR[0] == null || (!dontAnimateNormals && animationCachePBR[1] == null)
|| (!dontAnimateMaterial && animationCachePBR[2] == null)) {
throw new IllegalStateException("Animation cache for '" + this.iconName + "' was never baked!");
@ -233,9 +234,28 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
this.tickCounter = 0;
int k = this.animationMetadata.getFrameIndex(this.frameCounter);
if (i != k && k >= 0 && k < this.frameTextureDataPBR[0].size()) {
animationCachePBR[0].copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
if(!dontAnimateNormals) animationCachePBR[1].copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height, copyMaterialFramebuffer);
if(!dontAnimateMaterial) animationCachePBR[2].copyFrameLevelsToTex2D(k, this.originX, this.originY + materialTexOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel,
(this.originY >> mapLevel) + (mapHeight >> 1), this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
} else if (this.animationMetadata.isInterpolate()) {
float f = 1.0f - (float) this.tickCounter / (float) this.animationMetadata.getFrameTimeSingle(this.frameCounter);
@ -244,9 +264,43 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
: this.animationMetadata.getFrameCount();
int k = this.animationMetadata.getFrameIndex((this.frameCounter + 1) % j);
if (i != k && k >= 0 && k < this.frameTextureDataPBR[0].size()) {
animationCachePBR[0].copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
if(!dontAnimateNormals) animationCachePBR[1].copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height, copyMaterialFramebuffer);
if(!dontAnimateMaterial) animationCachePBR[2].copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY + materialTexOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyInterpolatedFrameToTex2D(i, k, f, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyInterpolatedFrameToTex2D(i, k, f, mapLevel,
this.originX >> mapLevel, this.originY >> mapLevel, this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyInterpolatedFrameToTex2D(i, k, f, mapLevel,
this.originX >> mapLevel, (this.originY >> mapLevel) + (mapHeight >> 1),
this.width >> mapLevel, this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}
public void copyAnimationFramePBR(int pass, int mapWidth, int mapHeight, int mapLevel) {
if(pass == 0) {
if(currentAnimUpdater != null) {
currentAnimUpdater.updateAnimation(mapWidth, mapHeight, mapLevel);
}
}else {
if(currentAnimUpdaterPBR != null) {
currentAnimUpdaterPBR.updateAnimation(mapWidth, mapHeight, mapLevel);
}
}
}
@ -279,7 +333,7 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
}
}
public void updateAnimation(IFramebufferGL[] fb) {
public void updateAnimation() {
Throwable t = new UnsupportedOperationException("Cannot call regular updateAnimation in PBR mode, use updateAnimationPBR");
try {
throw t;
@ -288,6 +342,15 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
}
}
public void copyAnimationFrame(int mapWidth, int mapHeight, int mapLevel) {
Throwable t = new UnsupportedOperationException("Cannot call regular copyAnimationFrame in PBR mode, use updateAnimationPBR");
try {
throw t;
}catch(Throwable tt) {
logger.error(t);
}
}
protected void resetSprite() {
this.animationMetadata = null;
this.setFramesTextureDataPBR(new List[] { Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList() });

View File

@ -27,7 +27,7 @@ import net.minecraft.util.ResourceLocation;
*/
public class PBRTextureMapUtils {
public static final ImageData defaultNormalsTexture = new ImageData(1, 1, new int[] { 0 }, true);
public static final ImageData defaultNormalsTexture = new ImageData(1, 1, new int[] { 0xFFFF7F7F }, true);
public static final PBRMaterialConstants blockMaterialConstants = new PBRMaterialConstants(new ResourceLocation("eagler:glsl/deferred/material_block_constants.csv"));
@ -125,13 +125,17 @@ public class PBRTextureMapUtils {
}
}
public static ImageData generateMaterialTextureFor(String iconName) {
public static ImageData generateMaterialTextureFor(String iconName, String iconName2) {
if(iconName.startsWith("minecraft:")) {
iconName = iconName.substring(10);
}
Integer in = blockMaterialConstants.spriteNameToMaterialConstants.get(iconName);
if(in == null) {
return new ImageData(1, 1, new int[] { blockMaterialConstants.defaultMaterial }, true);
if(iconName2 != null) {
return generateMaterialTextureFor(iconName2, null);
}else {
return new ImageData(1, 1, new int[] { blockMaterialConstants.defaultMaterial }, true);
}
}else {
return new ImageData(1, 1, new int[] { in.intValue() }, true);
}
@ -150,8 +154,8 @@ public class PBRTextureMapUtils {
ret[i] = new int[len];
int x, y, s1, s2, s3, s4, c1, c2, c3, c4;
for(int j = 0; j < len; ++j) {
x = (j % len) << 1;
y = (j / len) << 1;
x = (j % lvlW) << 1;
y = (j / lvlW) << 1;
s1 = ret[i - 1][x + y * lvl2W];
s2 = ret[i - 1][x + y * lvl2W + 1];
s3 = ret[i - 1][x + y * lvl2W + lvl2W];

View File

@ -27,7 +27,7 @@ public class TextureClockPBRImpl extends EaglerTextureAtlasSpritePBR {
super(spriteName);
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialTexOffset) {
public void updateAnimationPBR() {
if (!this.frameTextureDataPBR[0].isEmpty()) {
Minecraft minecraft = Minecraft.getMinecraft();
double d0 = 0.0;
@ -59,16 +59,32 @@ public class TextureClockPBRImpl extends EaglerTextureAtlasSpritePBR {
if (i != this.frameCounter) {
this.frameCounter = i;
animationCachePBR[0].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY, this.width,
this.height, copyColorFramebuffer);
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY,
this.width, this.height, copyMaterialFramebuffer);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameLevelsToTex2D(this.frameCounter, this.originX,
this.originY + materialTexOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX,
this.originY, this.width, this.height, mapWidth, mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
(this.originY >> mapLevel) + (mapHeight >> 1), this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}

View File

@ -29,18 +29,17 @@ public class TextureCompassPBRImpl extends EaglerTextureAtlasSpritePBR {
super(spriteName);
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialOffset) {
public void updateAnimationPBR() {
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft.theWorld != null && minecraft.thePlayer != null) {
this.updateCompassPBR(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ,
(double) minecraft.thePlayer.rotationYaw, false, copyColorFramebuffer, copyMaterialFramebuffer, materialOffset);
(double) minecraft.thePlayer.rotationYaw, false);
} else {
this.updateCompassPBR((World) null, 0.0, 0.0, 0.0, true, copyColorFramebuffer, copyMaterialFramebuffer, materialOffset);
this.updateCompassPBR((World) null, 0.0, 0.0, 0.0, true);
}
}
public void updateCompassPBR(World worldIn, double playerX, double playerY, double playerZ, boolean noWorld,
IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialOffset) {
public void updateCompassPBR(World worldIn, double playerX, double playerY, double playerZ, boolean noWorld) {
if (!this.frameTextureDataPBR[0].isEmpty()) {
double d0 = 0.0;
if (worldIn != null && !noWorld) {
@ -76,15 +75,33 @@ public class TextureCompassPBRImpl extends EaglerTextureAtlasSpritePBR {
if (i != this.frameCounter) {
this.frameCounter = i;
animationCachePBR[0].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY, this.width,
this.height, copyColorFramebuffer);
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY,
this.width, this.height, copyMaterialFramebuffer);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameLevelsToTex2D(this.frameCounter, this.originX,
this.originY + materialOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
(this.originY >> mapLevel) + (mapHeight >> 1), this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}

View File

@ -88,6 +88,7 @@ public class EaglerChunkLoader extends AnvilChunkLoader {
@Override
public void saveChunk(World var1, Chunk var2) throws IOException {
var1.alfheim$getLightingEngine().processLightUpdates();
NBTTagCompound chunkData = new NBTTagCompound();
this.writeChunkToNBT(var2, var1, chunkData);
NBTTagCompound fileData = new NBTTagCompound();