fixed graphical bugs, added WSS server redirects

This commit is contained in:
LAX1DUDE 2022-09-02 17:28:53 -07:00
parent abe87fce2a
commit 52eb579c7d
11 changed files with 116 additions and 14 deletions

View File

@ -134,4 +134,9 @@ public class BungeeServerInfo implements ServerInfo {
public Queue<DefinedPacket> getPacketQueue() {
return this.packetQueue;
}
@Override
public String getRedirect() {
return null;
}
}

View File

@ -7,6 +7,7 @@ package net.md_5.bungee;
import java.beans.ConstructorProperties;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@ -39,6 +40,7 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.score.Scoreboard;
import net.md_5.bungee.api.tab.TabListHandler;
import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.eaglercraft.RedirectServerInfo;
import net.md_5.bungee.netty.ChannelWrapper;
import net.md_5.bungee.netty.HandlerBoss;
import net.md_5.bungee.netty.PipelineUtils;
@ -125,6 +127,10 @@ public final class UserConnection implements ProxiedPlayer {
}
public void connect(final ServerInfo info, final boolean retry) {
if(info instanceof RedirectServerInfo) {
sendData("EAG|Reconnect", ((RedirectServerInfo)info).getRedirect().getBytes(StandardCharsets.UTF_8));
return;
}
final ServerConnectEvent event = new ServerConnectEvent(this, info);
if (this.bungee.getPluginManager().callEvent(event).isCancelled()) {
return;

View File

@ -16,6 +16,8 @@ public interface ServerInfo {
String getName();
InetSocketAddress getAddress();
String getRedirect();
Collection<ProxiedPlayer> getPlayers();

View File

@ -37,6 +37,7 @@ import net.md_5.bungee.api.config.MOTDCacheConfiguration;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.config.TexturePackInfo;
import net.md_5.bungee.api.tab.TabListHandler;
import net.md_5.bungee.eaglercraft.RedirectServerInfo;
import net.md_5.bungee.eaglercraft.WebSocketRateLimiter;
import net.md_5.bungee.tab.Global;
import net.md_5.bungee.tab.GlobalPing;
@ -138,11 +139,18 @@ public class YamlConfig implements ConfigurationAdapter {
for (final Map.Entry<String, HashMap> entry : base.entrySet()) {
final Map<String, Object> val = entry.getValue();
final String name = entry.getKey();
final String addr = this.get("address", "localhost:25501", val);
final boolean restricted = this.get("restricted", false, val);
final InetSocketAddress address = Util.getAddr(addr);
final ServerInfo info = ProxyServer.getInstance().constructServerInfo(name, address, restricted);
ret.put(name, info);
if(val.containsKey("redirect")) {
final String addr = this.get("redirect", "ws://someOtherServer/", val);
final boolean restricted = this.get("restricted", false, val);
final ServerInfo info = new RedirectServerInfo(name, addr, restricted);
ret.put(name, info);
}else {
final String addr = this.get("address", "localhost:25501", val);
final boolean restricted = this.get("restricted", false, val);
final InetSocketAddress address = Util.getAddr(addr);
final ServerInfo info = ProxyServer.getInstance().constructServerInfo(name, address, restricted);
ret.put(name, info);
}
}
return ret;
}

View File

@ -47,7 +47,7 @@ public class UpstreamBridge extends PacketHandler {
this.bungee.getPluginManager().callEvent(event);
this.con.getTabList().onDisconnect();
BungeeCord.getInstance().removeConnection(this.con);
if (this.con.getServer() != null && this.con.getServer().getInfo() == null) {
if (this.con.getServer() != null && this.con.getServer().getInfo() != null) {
this.con.getServer().disconnect("Quitting");
}
}

View File

@ -0,0 +1,63 @@
package net.md_5.bungee.eaglercraft;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
import com.google.common.base.Preconditions;
import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class RedirectServerInfo implements ServerInfo {
private final String serverName;
private final String serverRedirect;
private final boolean restricted;
@Override
public String getName() {
return serverName;
}
@Override
public InetSocketAddress getAddress() {
return null;
}
@Override
public String getRedirect() {
return serverRedirect;
}
@Override
public Collection<ProxiedPlayer> getPlayers() {
return Collections.emptyList();
}
@Override
public boolean canAccess(CommandSender p0) {
Preconditions.checkNotNull((Object) p0, (Object) "player");
return !this.restricted || p0.hasPermission("bungeecord.server." + serverName);
}
@Override
public void sendData(String p0, byte[] p1) {
}
@Override
public void ping(Callback<ServerPing> p0) {
p0.done(null, new UnsupportedOperationException("Cannot ping a redirect server!"));
}
public RedirectServerInfo(String serverName, String serverRedirect, boolean restricted) {
this.serverName = serverName;
this.serverRedirect = serverRedirect;
this.restricted = restricted;
}
}

View File

@ -6,7 +6,7 @@ public class ConfigConstants {
public static boolean profanity = false;
public static final String version = "22w35b";
public static final String version = "22w35c";
public static final String mainMenuString = "eaglercraft " + version;
public static final String forkMe = "https://github.com/lax1dude/eaglercraft";

View File

@ -146,6 +146,8 @@ public class EffectPipeline {
_wglDrawArrays(_wGL_TRIANGLES, 0, 6);
glColorMask(true, true, true, false);
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
_wglBindFramebuffer(_wGL_FRAMEBUFFER, null);
_wglViewport(0, 0, viewportW, viewportH);
}
@ -173,8 +175,6 @@ public class EffectPipeline {
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glColor4f(0.05f, 0.05f, 0.05f, 0.0f);
float aspect = (float) viewportW / viewportH;
@ -187,6 +187,8 @@ public class EffectPipeline {
intensityModifier = Math.min(1.0f - ((j / 65536) / 256.0f), 1.0f - ((j % 65536) / 256.0f)) * 3.0f;
bb += intensityModifier * bb;
}
glColor4f(0.0166f * bb, 0.0166f * bb, 0.0166f * bb, 0.0f);
glPushMatrix(); // 2
@ -200,7 +202,7 @@ public class EffectPipeline {
if(intensityModifier > 1.5f) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f(0.8f, 1.0f, 0.5f, (intensityModifier - 1.5f) * 0.03f);
glColor4f(0.8f, 1.0f, 0.5f, (intensityModifier - 1.5f) * 0.03f * intensity);
glPushMatrix();
glScalef(0.5f, 0.5f, 1.0f);
drawGradientTextureRect(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);

View File

@ -1517,6 +1517,17 @@ public class Minecraft implements Runnable {
}else {
this.sndManager.stopTheTitleMusic();
}
if(reconnectAddress != null) {
if(theWorld != null) {
System.out.println("Redirecting to: " + reconnectAddress);
theWorld.sendQuittingDisconnectingPacket();
loadWorld((WorldClient) null);
stopServerAndDisplayGuiScreen(new GuiConnecting(new GuiMultiplayer(new GuiMainMenu()), this,
new ServerData("reconnect", reconnectAddress, true)));
}
reconnectAddress = null;
}
this.mcProfiler.endSection();
this.systemTime = getSystemTime();
@ -1524,6 +1535,8 @@ public class Minecraft implements Runnable {
private int titleMusicObj = -1;
public String reconnectAddress = null;
/**
* Forces a reload of the sound manager and all the resources. Called in game by
* holding 'F3' and pressing 'S'.

View File

@ -922,7 +922,7 @@ public class EntityRenderer {
if(i > 0.15f) {
EffectPipeline.updateNoiseTexture(mc.displayWidth, mc.displayHeight, i);
EffectPipeline.drawNoise(var14, var15, i);
EffectPipeline.drawNoise(var14, var15, (i - 0.15f) / 0.85f);
}
this.renderEndNanoTime = System.nanoTime();
@ -1395,7 +1395,7 @@ public class EntityRenderer {
do {
l = Block.blocksList[random.nextInt(256)];
}while(l == null);
EntityFallingSand itm = new EntityFallingSand(var3, x + var4, yy + 1, z + var6, l.blockID, 0);
EntityFallingSand itm = new EntityFallingSand(var3, x + var4 + 0.5, yy + 1, z + var6 + 0.5, l.blockID, 0);
itm.entityId = --var3.ghostEntityId;
itm.ghost = true;
var3.spawnEntityInWorld(itm);
@ -1404,7 +1404,7 @@ public class EntityRenderer {
do {
l = Item.itemsList[random.nextInt(384)];
}while(l == null);
EntityItem itm = new EntityItem(var3, x + var4, yy + 1, z + var6, new ItemStack(l, 1));
EntityItem itm = new EntityItem(var3, x + var4 + 0.5, yy + 1, z + var6 + 0.5, new ItemStack(l, 1));
itm.entityId = --var3.ghostEntityId;
itm.ghost = true;
var3.spawnEntityInWorld(itm);
@ -1414,7 +1414,7 @@ public class EntityRenderer {
}
float probability = MathHelper.sin(startup / 300.0f);
while(random.nextFloat() < (probability * 0.3f + 0.7f) * 0.002f) {
this.mc.sndManager.playSoundFX("adl.l", MathHelper.clamp_float(startup / 300.0f, 0.03f, 0.5f), random.nextFloat() * 0.2f + 0.9f);
this.mc.sndManager.playSoundFX("adl.l", MathHelper.clamp_float(startup / 400.0f, 0.03f, 0.3f), random.nextFloat() * 0.2f + 0.9f);
}
while(random.nextFloat() < (probability * 0.3f + 0.7f) * 0.005f) {
this.mc.sndManager.playSound("adl.a", (float) var2.posX - 4.0f + 8.0f * random.nextFloat(), (float) var2.posY - 2.0f + 4.0f * random.nextFloat(),

View File

@ -3,6 +3,7 @@ package net.minecraft.src;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -1200,6 +1201,8 @@ public class NetClientHandler extends NetHandler {
}
}else if("EAG|Voice".equals(par1Packet250CustomPayload.channel)) {
EaglerAdapter.handleVoiceSignal(par1Packet250CustomPayload.data);
}else if("EAG|Reconnect".equals(par1Packet250CustomPayload.channel)) {
mc.reconnectAddress = new String(par1Packet250CustomPayload.data, StandardCharsets.UTF_8);
}
}