Skip to content

Commit

Permalink
fix shaders
Browse files Browse the repository at this point in the history
SpoilerRules committed Jan 21, 2024
1 parent a555071 commit 92ba096
Showing 5 changed files with 48 additions and 86 deletions.
15 changes: 6 additions & 9 deletions src/main/java/net/minecraft/client/gui/GuiChat.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package net.minecraft.client.gui;

import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import net.minecraft.network.play.client.C14PacketTabComplete;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

import java.io.IOException;
import java.util.List;

public class GuiChat extends GuiScreen
{
private static final Logger logger = LogManager.getLogger();
@@ -103,7 +100,7 @@ else if (keyCode == 209)
{
String s = this.inputField.getText().trim();

if (s.length() > 0)
if (!s.isEmpty())
{
this.sendChatMessage(s);
}
@@ -200,7 +197,7 @@ public void autocompletePlayerNames()

for (String s2 : this.foundPlayerNames)
{
if (stringbuilder.length() > 0)
if (!stringbuilder.isEmpty())
{
stringbuilder.append(", ");
}
13 changes: 3 additions & 10 deletions src/main/java/net/minecraft/client/gui/GuiTextField.java
Original file line number Diff line number Diff line change
@@ -53,16 +53,9 @@ public String getText() {
return this.text;
}

public void setText(String p_146180_1_) {
if (this.validator.test(p_146180_1_)) {
if (p_146180_1_.length() > this.maxStringLength) {
this.text = p_146180_1_.substring(0, this.maxStringLength);
} else {
this.text = p_146180_1_;
}

this.setCursorPositionEnd();
}
public void setText(String input) {
this.text = validator.test(input) ? input.substring(0, Math.min(input.length(), maxStringLength)) : text;
setCursorPositionEnd();
}

public String getSelectedText() {
30 changes: 12 additions & 18 deletions src/main/java/net/minecraft/world/chunk/storage/RegionFile.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package net.minecraft.world.chunk.storage;

import com.google.common.collect.Lists;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import net.minecraft.server.MinecraftServer;

import java.io.*;
import java.util.List;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import net.minecraft.server.MinecraftServer;

public class RegionFile
{
@@ -64,7 +58,7 @@ public RegionFile(File fileNameIn)
}

int k1 = (int)this.dataFile.length() / 4096;
this.sectorFree = Lists.<Boolean>newArrayListWithCapacity(k1);
this.sectorFree = Lists.newArrayListWithCapacity(k1);

for (int j = 0; j < k1; ++j)
{
@@ -128,7 +122,7 @@ public synchronized DataInputStream getChunkDataInputStream(int x, int z)
}
else
{
this.dataFile.seek((long)(j * 4096));
this.dataFile.seek(j * 4096L);
int l = this.dataFile.readInt();

if (l > 4096 * k)
@@ -209,7 +203,7 @@ protected synchronized void write(int x, int z, byte[] data, int length)
{
if (j1 != 0)
{
if (((Boolean)this.sectorFree.get(k1)).booleanValue())
if (this.sectorFree.get(k1).booleanValue())
{
++j1;
}
@@ -218,7 +212,7 @@ protected synchronized void write(int x, int z, byte[] data, int length)
j1 = 0;
}
}
else if (((Boolean)this.sectorFree.get(k1)).booleanValue())
else if (this.sectorFree.get(k1).booleanValue())
{
l1 = k1;
j1 = 1;
@@ -270,7 +264,7 @@ else if (((Boolean)this.sectorFree.get(k1)).booleanValue())

private void write(int sectorNumber, byte[] data, int length) throws IOException
{
this.dataFile.seek((long)(sectorNumber * 4096));
this.dataFile.seek(sectorNumber * 4096L);
this.dataFile.writeInt(length + 1);
this.dataFile.writeByte(2);
this.dataFile.write(data, 0, length);
@@ -294,14 +288,14 @@ public boolean isChunkSaved(int x, int z)
private void setOffset(int x, int z, int offset) throws IOException
{
this.offsets[x + z * 32] = offset;
this.dataFile.seek((long)((x + z * 32) * 4));
this.dataFile.seek((x + z * 32L) * 4);
this.dataFile.writeInt(offset);
}

private void setChunkTimestamp(int x, int z, int timestamp) throws IOException
{
this.chunkTimestamps[x + z * 32] = timestamp;
this.dataFile.seek((long)(4096 + (x + z * 32) * 4));
this.dataFile.seek(4096 + (x + z * 32L) * 4);
this.dataFile.writeInt(timestamp);
}

@@ -315,8 +309,8 @@ public void close() throws IOException

class ChunkBuffer extends ByteArrayOutputStream
{
private int chunkX;
private int chunkZ;
private final int chunkX;
private final int chunkZ;

public ChunkBuffer(int x, int z)
{
58 changes: 18 additions & 40 deletions src/main/java/net/optifine/shaders/config/ShaderPackParser.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
package net.optifine.shaders.config;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.CharArrayReader;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.src.Config;
import net.optifine.expr.ExpressionFloatArrayCached;
import net.optifine.expr.ExpressionFloatCached;
import net.optifine.expr.ExpressionParser;
import net.optifine.expr.ExpressionType;
import net.optifine.expr.IExpression;
import net.optifine.expr.IExpressionBool;
import net.optifine.expr.IExpressionFloat;
import net.optifine.expr.IExpressionFloatArray;
import net.optifine.expr.ParseException;
import net.optifine.expr.*;
import net.optifine.render.GlAlphaState;
import net.optifine.render.GlBlendState;
import net.optifine.shaders.IShaderPack;
import net.optifine.shaders.Program;
import net.optifine.shaders.SMCLog;
import net.optifine.shaders.ShaderUtils;
import net.optifine.shaders.Shaders;
import net.optifine.shaders.*;
import net.optifine.shaders.uniform.CustomUniform;
import net.optifine.shaders.uniform.CustomUniforms;
import net.optifine.shaders.uniform.ShaderExpressionResolver;
import net.optifine.shaders.uniform.UniformType;
import net.optifine.util.StrUtils;

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ShaderPackParser
{
private static final Pattern PATTERN_VERSION = Pattern.compile("^\\s*#version\\s+.*$");
@@ -879,7 +862,7 @@ else if (astring.length == 2)
{
String s2 = astring[0];
String s1 = astring[1];
Integer integer = (Integer)mapAlphaFuncs.get(s2);
Integer integer = mapAlphaFuncs.get(s2);
float f = Config.parseFloat(s1, -1.0F);

if (integer != null && f >= 0.0F)
@@ -1083,22 +1066,17 @@ public static void parseBuffersFlip(Properties props)
}
}

private static final Map<String, Integer> ALPHA_FUNCS_MAP = Map.of(
"NEVER", 512,
"LESS", 513,
"EQUAL", 514,
"LEQUAL", 515,
"GREATER", 516,
"NOTEQUAL", 517,
"GEQUAL", 518,
"ALWAYS", 519
);

private static Map<String, Integer> makeMapAlphaFuncs() {
if (ALPHA_FUNCS_MAP != null) {
return ALPHA_FUNCS_MAP;
}
return null;
return Map.of(
"NEVER", 512,
"LESS", 513,
"EQUAL", 514,
"LEQUAL", 515,
"GREATER", 516,
"NOTEQUAL", 517,
"GEQUAL", 518,
"ALWAYS", 519
);
}

private static final Map<String, Integer> BLEND_FACTORS_MAP = Map.ofEntries(
Original file line number Diff line number Diff line change
@@ -22,21 +22,21 @@ class KeyboardInputHandler : InputService() {

if (activeScreen == null || activeScreen.allowUserInput) {
when (keyEvent) {
mc.gameSettings.keyBindChat.keyCode -> if (activeScreen !is GuiInventory) mc.theWorld?.let {
mapOf(
EntityPlayer.EnumChatVisibility.FULL to { mc.displayGuiScreen(GuiChat()) },
EntityPlayer.EnumChatVisibility.SYSTEM to { mc.displayGuiScreen(GuiChat("/")) }
)[mc.gameSettings.chatVisibility]?.invoke()
}

mc.gameSettings.keyBindDrop.keyCode -> player?.takeUnless { it.isSpectator }?.dropOneItem(GuiScreen.isCtrlKeyDown())

mc.gameSettings.keyBindChat.keyCode -> mc.theWorld?.let { mc.displayGuiScreen(GuiChat()) }
mc.gameSettings.keyBindDrop.keyCode -> player?.takeUnless { it.isSpectator }
?.dropOneItem(GuiScreen.isCtrlKeyDown())
mc.gameSettings.keyBindInventory.keyCode -> if (mc.playerController.isRidingHorse) {
player?.sendHorseInventory()
} else {
mc.netHandler.addToSendQueue(C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT))
mc.displayGuiScreen(GuiInventory(player))
}
mc.gameSettings.keyBindChat.keyCode -> if (activeScreen !is GuiInventory) mc.theWorld?.let {
mapOf(
EntityPlayer.EnumChatVisibility.FULL to { mc.displayGuiScreen(GuiChat()) },
EntityPlayer.EnumChatVisibility.SYSTEM to { mc.displayGuiScreen(GuiChat("/")) }
)[mc.gameSettings.chatVisibility]?.invoke()
}
}

if (activeScreen !is GuiControls) {

0 comments on commit 92ba096

Please sign in to comment.