diff --git a/build.gradle b/build.gradle index b5b30caf3e..3c3640283a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ repositories { maven { url = "https://maven.minecraftforge.net/" } maven { url = "https://repo.spongepowered.org/repository/maven-public/" } maven { url = "https://jitpack.io/" } - maven { url = "https://repo.viaversion.com" } + maven { url = "https://repo.viaversion.com/" } } version = "5.4.0" @@ -52,6 +52,8 @@ def viaLibs = [ "com.viaversion:viaversion:${project.viaversion_version}", "com.viaversion:viabackwards:${project.viabackwards_version}", "com.viaversion:viarewind-universal:${project.viarewind_version}", + "net.raphimc:ViaLoader:${project.vialoader_version}", + "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}", "org.yaml:snakeyaml:${project.snake_yml_version}", "org.slf4j:slf4j-api:${project.slf4j_version}" ] @@ -72,6 +74,10 @@ dependencies { include(via) } + include ("net.raphimc:ViaLegacy:${project.vialegacy_version}") { + exclude group: "com.google.code.gson", module: "gson" + } + include('com.github.half-cambodian-hacker-man:Koffee:d8cee73') { exclude module: 'asm-commons' exclude module: 'asm-tree' @@ -169,3 +175,12 @@ reobf { } } tasks.reobfJar.dependsOn(shadowJar) + +configurations { + compileClasspath { + attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm") + } + include { + attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm") + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 9d0765522f..8c48d236bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,10 +5,12 @@ kotlin_version = 1.6.10 detekt_version = 1.19.0 forgeVersion=1.8.9-11.15.1.2318-1.8.9 -vialoader_version=2.2.11-SNAPSHOT -viaversion_version=4.9.0-23w45a-SNAPSHOT -viabackwards_version=4.9.0-23w45a-SNAPSHOT -viarewind_version=3.0.4-SNAPSHOT +vialoader_version=2.2.13-SNAPSHOT +viaversion_version=4.10.0-23w51b-SNAPSHOT +viabackwards_version=4.10.0-23w51b-SNAPSHOT +viarewind_version=3.0.6-SNAPSHOT +vialegacy_version=2.2.22-SNAPSHOT +viaaprilfools_version=2.0.11-SNAPSHOT forgegradle_version = f2c5bb338e mixingradle_version = ae2a80e diff --git a/libs/ViaBackwards-4.4.1.jar b/libs/ViaBackwards-4.4.1.jar deleted file mode 100644 index a41706cbaf..0000000000 Binary files a/libs/ViaBackwards-4.4.1.jar and /dev/null differ diff --git a/libs/ViaRewind-2.0.3-AnimationFixed.jar b/libs/ViaRewind-2.0.3-AnimationFixed.jar deleted file mode 100644 index 7fe98b5b41..0000000000 Binary files a/libs/ViaRewind-2.0.3-AnimationFixed.jar and /dev/null differ diff --git a/libs/ViaSnakeYaml-1.30.jar b/libs/ViaSnakeYaml-1.30.jar deleted file mode 100644 index 6c9b2bc65b..0000000000 Binary files a/libs/ViaSnakeYaml-1.30.jar and /dev/null differ diff --git a/libs/ViaVersion-4.4.1.jar b/libs/ViaVersion-4.4.1.jar deleted file mode 100644 index 4223bd1225..0000000000 Binary files a/libs/ViaVersion-4.4.1.jar and /dev/null differ diff --git a/src/main/java/cc/paimonmc/viamcp/ViaMCP.java b/src/main/java/cc/paimonmc/viamcp/ViaMCP.java deleted file mode 100644 index 8262769ee9..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/ViaMCP.java +++ /dev/null @@ -1,136 +0,0 @@ -package cc.paimonmc.viamcp; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.viaversion.viaversion.ViaManagerImpl; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.data.MappingDataLoader; -import io.netty.channel.EventLoop; -import io.netty.channel.local.LocalEventLoopGroup; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import org.apache.logging.log4j.LogManager; -import cc.paimonmc.viamcp.gui.AsyncVersionSlider; -import cc.paimonmc.viamcp.loader.MCPBackwardsLoader; -import cc.paimonmc.viamcp.loader.MCPRewindLoader; -import cc.paimonmc.viamcp.loader.MCPViaLoader; -import cc.paimonmc.viamcp.platform.MCPViaInjector; -import cc.paimonmc.viamcp.platform.MCPViaPlatform; -import cc.paimonmc.viamcp.utils.JLoggerToLog4j; -import java.io.File; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.logging.Logger; -import net.ccbluex.liquidbounce.utils.MinecraftInstance; - -import static net.ccbluex.liquidbounce.utils.MinecraftInstance.mc; - -public class ViaMCP { - public final static int PROTOCOL_VERSION = 47; - private static final ViaMCP instance = new ViaMCP(); - - public static ViaMCP getInstance() { - return instance; - } - - private final Logger jLogger = new JLoggerToLog4j(LogManager.getLogger("ViaMCP")); - private final CompletableFuture INIT_FUTURE = new CompletableFuture<>(); - - private ExecutorService ASYNC_EXEC; - private EventLoop EVENT_LOOP; - - private File file; - private int version; - private String lastServer; - - public static boolean hidden; - - public static void staticInit() { - getInstance().start(); - } - - /** - * Version Slider that works Asynchronously with the Version GUI - * Please initialize this before usage with initAsyncSlider() or initAsyncSlider(x, y, width (min. 110), height) - */ - public AsyncVersionSlider asyncSlider; - - public void start() { - try { - final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ViaMCP-%d").build(); - ASYNC_EXEC = Executors.newFixedThreadPool(8, factory); - - EVENT_LOOP = new LocalEventLoopGroup(1, factory).next(); - EVENT_LOOP.submit(INIT_FUTURE::join); - - setVersion(PROTOCOL_VERSION); - this.file = new File("ViaMCP"); - if (this.file.mkdir()) { - this.getjLogger().info("Creating ViaMCP Folder"); - } - - Via.init(ViaManagerImpl.builder().injector(new MCPViaInjector()).loader(new MCPViaLoader()).platform(new MCPViaPlatform(file)).build()); - - MappingDataLoader.enableMappingsCache(); - ((ViaManagerImpl) Via.getManager()).init(); - - new MCPBackwardsLoader(file); - new MCPRewindLoader(file); - - INIT_FUTURE.complete(null); - - //ViaMCP.getInstance().initAsyncSlider(); - } catch (final Exception exception) { - exception.printStackTrace(); - } - } - - public Logger getjLogger() { - return jLogger; - } - - public CompletableFuture getInitFuture() { - return INIT_FUTURE; - } - - public ExecutorService getAsyncExecutor() { - return ASYNC_EXEC; - } - - public EventLoop getEventLoop() { - return EVENT_LOOP; - } - - public File getFile() { - return file; - } - - public String getLastServer() { - return lastServer; - } - - public int getVersion() { - return version; - } - - public void setVersion(final int version) { - this.version = version; - } - - public void setFile(final File file) { - this.file = file; - } - - public void setLastServer(final String lastServer) { - this.lastServer = lastServer; - } - - public static boolean isHidden() { - return hidden; - } - - public static void setHidden(boolean hidden) { - ViaMCP.hidden = hidden; - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/gui/AsyncVersionSlider.java b/src/main/java/cc/paimonmc/viamcp/gui/AsyncVersionSlider.java deleted file mode 100644 index 659532cc19..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/gui/AsyncVersionSlider.java +++ /dev/null @@ -1,90 +0,0 @@ -package cc.paimonmc.viamcp.gui; - -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.protocols.ProtocolCollection; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; - -import java.util.Arrays; -import java.util.Collections; - -public class AsyncVersionSlider extends GuiButton { - private float dragValue = (float) (ProtocolCollection.values().length - Arrays.asList(ProtocolCollection.values()).indexOf(ProtocolCollection.getProtocolCollectionById(ViaMCP.PROTOCOL_VERSION))) / ProtocolCollection.values().length; - - private final ProtocolCollection[] values; - private float sliderValue; - public boolean dragging; - - public AsyncVersionSlider(final int buttonId, final int x, final int y, final int widthIn, final int heightIn) { - super(buttonId, x, y, Math.max(widthIn, 110), heightIn, ""); - this.values = ProtocolCollection.values(); - Collections.reverse(Arrays.asList(values)); - this.sliderValue = dragValue; - this.displayString = values[(int) (this.sliderValue * (values.length - 1))].getVersion().getName(); - } - - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { - super.drawButton(mc, mouseX, mouseY); - } - - /** - * Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over - * this button. - */ - public int getHoverState(final boolean mouseOver) { - return 0; - } - - /** - * Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e). - */ - public void mouseDragged(final Minecraft mc, final int mouseX, final int mouseY) { - if (this.visible) { - if (this.dragging) { - this.sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8); - this.sliderValue = MathHelper.clamp_float(this.sliderValue, 0.0F, 1.0F); - this.dragValue = sliderValue; - this.displayString = values[(int) (this.sliderValue * (values.length - 1))].getVersion().getName(); - ViaMCP.getInstance().setVersion(values[(int) (this.sliderValue * (values.length - 1))].getVersion().getVersion()); - } - - mc.getTextureManager().bindTexture(buttonTextures); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.drawTexturedModalRect(this.xPosition + (int) (this.sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20); - this.drawTexturedModalRect(this.xPosition + (int) (this.sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); - } - } - - /** - * Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent - * e). - */ - public boolean mousePressed(final Minecraft mc, final int mouseX, final int mouseY) { - if (super.mousePressed(mc, mouseX, mouseY)) { - this.sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8); - this.sliderValue = MathHelper.clamp_float(this.sliderValue, 0.0F, 1.0F); - this.dragValue = sliderValue; - this.displayString = values[(int) (this.sliderValue * (values.length - 1))].getVersion().getName(); - ViaMCP.getInstance().setVersion(values[(int) (this.sliderValue * (values.length - 1))].getVersion().getVersion()); - this.dragging = true; - return true; - } else { - return false; - } - } - - /** - * Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e). - */ - public void mouseReleased(final int mouseX, final int mouseY) { - this.dragging = false; - } - - public void setVersion(final int protocol) { - this.dragValue = (float) (ProtocolCollection.values().length - Arrays.asList(ProtocolCollection.values()).indexOf(ProtocolCollection.getProtocolCollectionById(protocol))) / ProtocolCollection.values().length; - this.sliderValue = this.dragValue; - this.displayString = values[(int) (this.sliderValue * (values.length - 1))].getVersion().getName(); - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/gui/GuiProtocolSelector.java b/src/main/java/cc/paimonmc/viamcp/gui/GuiProtocolSelector.java deleted file mode 100644 index 4c6303d81c..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/gui/GuiProtocolSelector.java +++ /dev/null @@ -1,105 +0,0 @@ -package cc.paimonmc.viamcp.gui; - -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.protocols.ProtocolCollection; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiSlot; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.EnumChatFormatting; - -import java.io.IOException; - -public class GuiProtocolSelector extends GuiScreen { - private final GuiScreen parent; - public SlotList list; - - public GuiProtocolSelector(final GuiScreen parent) { - this.parent = parent; - } - - @Override - public void initGui() { - super.initGui(); - buttonList.add(new GuiButton(1, width / 2 - 100, height - 25, 200, 20, "Back")); - buttonList.add(new GuiButton(2, width / 2 - 180, height - 25, 75, 20, "Credits")); - list = new SlotList(mc, width, height, 32, height - 32, 10); - } - - @Override - public void actionPerformed(final GuiButton guiButton){ - list.actionPerformed(guiButton); - - if (guiButton.id == 1) { - mc.displayGuiScreen(parent); - } - } - - @Override - public void handleMouseInput() throws IOException { - list.handleMouseInput(); - super.handleMouseInput(); - } - - @Override - public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) { - list.drawScreen(mouseX, mouseY, partialTicks); - GlStateManager.pushMatrix(); - GlStateManager.scale(2.0, 2.0, 2.0); - final String title = EnumChatFormatting.BOLD + "ViaMCP Reborn"; - drawString(this.fontRendererObj, title, (this.width - (this.fontRendererObj.getStringWidth(title) * 2)) / 4, 5, -1); - GlStateManager.popMatrix(); - - final String versionName = ProtocolCollection.getProtocolById(ViaMCP.getInstance().getVersion()).getName(); - final String versionCodeName = ProtocolCollection.getProtocolInfoById(ViaMCP.getInstance().getVersion()).getName(); - final String versionReleaseDate = ProtocolCollection.getProtocolInfoById(ViaMCP.getInstance().getVersion()).getReleaseDate(); - final String versionTitle = "Version: " + versionName + " - " + versionCodeName; - final String versionReleased = "Released: " + versionReleaseDate; - - final int fixedHeight = ((5 + this.fontRendererObj.FONT_HEIGHT) * 2) + 2; - - drawString(this.fontRendererObj, EnumChatFormatting.GRAY + (EnumChatFormatting.BOLD + "Version Information"), (width - this.fontRendererObj.getStringWidth("Version Information")) / 2, fixedHeight, -1); - drawString(this.fontRendererObj, versionTitle, (width - this.fontRendererObj.getStringWidth(versionTitle)) / 2, fixedHeight + this.fontRendererObj.FONT_HEIGHT, -1); - drawString(this.fontRendererObj, versionReleased, (width - this.fontRendererObj.getStringWidth(versionReleased)) / 2, fixedHeight + this.fontRendererObj.FONT_HEIGHT * 2, -1); - - super.drawScreen(mouseX, mouseY, partialTicks); - } - - class SlotList extends GuiSlot { - public SlotList(final Minecraft mc, final int width, final int height, final int top, final int bottom, final int slotHeight) { - super(mc, width, height, top + 30, bottom, 18); - } - - @Override - public int getSize() { - return ProtocolCollection.values().length; - } - - @Override - public void elementClicked(final int i, final boolean b, final int i1, final int i2) { - final int protocolVersion = ProtocolCollection.values()[i].getVersion().getVersion(); - ViaMCP.getInstance().setVersion(protocolVersion); - ViaMCP.getInstance().asyncSlider.setVersion(protocolVersion); - } - - @Override - public boolean isSelected(final int i) { - return false; - } - - @Override - public void drawBackground() { - drawDefaultBackground(); - } - - @Override - public void drawSlot(final int i, final int i1, final int i2, final int i3, final int i4, final int i5) { - drawCenteredString(mc.fontRendererObj, (ViaMCP.getInstance().getVersion() == ProtocolCollection.values()[i].getVersion().getVersion() ? EnumChatFormatting.GREEN.toString() + EnumChatFormatting.BOLD : EnumChatFormatting.GRAY.toString()) + ProtocolCollection.getProtocolById(ProtocolCollection.values()[i].getVersion().getVersion()).getName(), width / 2, i2 + 2, -1); - GlStateManager.pushMatrix(); - GlStateManager.scale(0.5, 0.5, 0.5); - drawCenteredString(mc.fontRendererObj, "PVN: " + ProtocolCollection.getProtocolById(ProtocolCollection.values()[i].getVersion().getVersion()).getVersion(), width, (i2 + 2) * 2 + 20, -1); - GlStateManager.popMatrix(); - } - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/handler/CommonTransformer.java b/src/main/java/cc/paimonmc/viamcp/handler/CommonTransformer.java deleted file mode 100644 index cc40d811ff..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/handler/CommonTransformer.java +++ /dev/null @@ -1,38 +0,0 @@ -package cc.paimonmc.viamcp.handler; - -import com.viaversion.viaversion.util.PipelineUtil; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; -import io.netty.handler.codec.MessageToByteEncoder; -import io.netty.handler.codec.MessageToMessageDecoder; - -import java.lang.reflect.InvocationTargetException; - -public class CommonTransformer { - public static final String HANDLER_DECODER_NAME = "via-decoder"; - public static final String HANDLER_ENCODER_NAME = "via-encoder"; - - public static void decompress(final ChannelHandlerContext ctx, final ByteBuf buf) throws InvocationTargetException { - final ChannelHandler handler = ctx.pipeline().get("decompress"); - final ByteBuf decompressed = handler instanceof MessageToMessageDecoder ? (ByteBuf) PipelineUtil.callDecode((MessageToMessageDecoder) handler, ctx, buf).get(0) : (ByteBuf) PipelineUtil.callDecode((ByteToMessageDecoder) handler, ctx, buf).get(0); - - try { - buf.clear().writeBytes(decompressed); - } finally { - decompressed.release(); - } - } - - public static void compress(final ChannelHandlerContext ctx, final ByteBuf buf) throws Exception { - final ByteBuf compressed = ctx.alloc().buffer(); - - try { - PipelineUtil.callEncode((MessageToByteEncoder) ctx.pipeline().get("compress"), ctx, buf, compressed); - buf.clear().writeBytes(compressed); - } finally { - compressed.release(); - } - } -} \ No newline at end of file diff --git a/src/main/java/cc/paimonmc/viamcp/handler/MCPDecodeHandler.java b/src/main/java/cc/paimonmc/viamcp/handler/MCPDecodeHandler.java deleted file mode 100644 index 4184fa28f0..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/handler/MCPDecodeHandler.java +++ /dev/null @@ -1,100 +0,0 @@ -package cc.paimonmc.viamcp.handler; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.exception.CancelCodecException; -import com.viaversion.viaversion.exception.CancelDecoderException; -import com.viaversion.viaversion.util.PipelineUtil; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToMessageDecoder; - -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -@ChannelHandler.Sharable -public class MCPDecodeHandler extends MessageToMessageDecoder { - private final UserConnection info; - private boolean handledCompression; - private boolean skipDoubleTransform; - - public MCPDecodeHandler(final UserConnection info) { - this.info = info; - } - - public UserConnection getInfo() { - return info; - } - - // https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java - @Override - protected void decode(final ChannelHandlerContext ctx, final ByteBuf bytebuf, final List out) throws Exception { - if (skipDoubleTransform) { - skipDoubleTransform = false; - out.add(bytebuf.retain()); - return; - } - - if (!info.checkIncomingPacket()) { - throw CancelDecoderException.generate(null); - } - - if (!info.shouldTransformPacket()) { - out.add(bytebuf.retain()); - return; - } - - final ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - - try { - final boolean needsCompress = handleCompressionOrder(ctx, transformedBuf); - - info.transformIncoming(transformedBuf, CancelDecoderException::generate); - - if (needsCompress) { - CommonTransformer.compress(ctx, transformedBuf); - skipDoubleTransform = true; - } - - out.add(transformedBuf.retain()); - } finally { - transformedBuf.release(); - } - } - - private boolean handleCompressionOrder(final ChannelHandlerContext ctx, final ByteBuf buf) throws InvocationTargetException { - if (handledCompression) { - return false; - } - - final int decoderIndex = ctx.pipeline().names().indexOf("decompress"); - - if (decoderIndex == -1) { - return false; - } - - handledCompression = true; - - if (decoderIndex > ctx.pipeline().names().indexOf("via-decoder")) { - // Need to decompress this packet due to bad order - CommonTransformer.decompress(ctx, buf); - final ChannelHandler encoder = ctx.pipeline().get("via-encoder"); - final ChannelHandler decoder = ctx.pipeline().get("via-decoder"); - ctx.pipeline().remove(encoder); - ctx.pipeline().remove(decoder); - ctx.pipeline().addAfter("compress", "via-encoder", encoder); - ctx.pipeline().addAfter("decompress", "via-decoder", decoder); - return true; - } - - return false; - } - - @Override - public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { - if (PipelineUtil.containsCause(cause, CancelCodecException.class)) { - return; - } - super.exceptionCaught(ctx, cause); - } -} \ No newline at end of file diff --git a/src/main/java/cc/paimonmc/viamcp/handler/MCPEncodeHandler.java b/src/main/java/cc/paimonmc/viamcp/handler/MCPEncodeHandler.java deleted file mode 100644 index 732328fc0d..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/handler/MCPEncodeHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -package cc.paimonmc.viamcp.handler; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.exception.CancelCodecException; -import com.viaversion.viaversion.exception.CancelEncoderException; -import com.viaversion.viaversion.util.PipelineUtil; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToMessageEncoder; - -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -@ChannelHandler.Sharable -public class MCPEncodeHandler extends MessageToMessageEncoder { - private final UserConnection info; - private boolean handledCompression; - - public MCPEncodeHandler(final UserConnection info) { - this.info = info; - } - - @Override - protected void encode(final ChannelHandlerContext ctx, final ByteBuf bytebuf, final List out) throws Exception { - if (!info.checkOutgoingPacket()) { - throw CancelEncoderException.generate(null); - } - - if (!info.shouldTransformPacket()) { - out.add(bytebuf.retain()); - return; - } - - final ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - - try { - final boolean needsCompress = handleCompressionOrder(ctx, transformedBuf); - - info.transformOutgoing(transformedBuf, CancelEncoderException::generate); - - if (needsCompress) { - CommonTransformer.compress(ctx, transformedBuf); - } - - out.add(transformedBuf.retain()); - } finally { - transformedBuf.release(); - } - } - - private boolean handleCompressionOrder(final ChannelHandlerContext ctx, final ByteBuf buf) throws InvocationTargetException { - if (handledCompression) { - return false; - } - - final int encoderIndex = ctx.pipeline().names().indexOf("compress"); - - if (encoderIndex == -1) { - return false; - } - handledCompression = true; - - if (encoderIndex > ctx.pipeline().names().indexOf("via-encoder")) { - // Need to decompress this packet due to bad order - CommonTransformer.decompress(ctx, buf); - final ChannelHandler encoder = ctx.pipeline().get("via-encoder"); - final ChannelHandler decoder = ctx.pipeline().get("via-decoder"); - ctx.pipeline().remove(encoder); - ctx.pipeline().remove(decoder); - ctx.pipeline().addAfter("compress", "via-encoder", encoder); - ctx.pipeline().addAfter("decompress", "via-decoder", decoder); - return true; - } - - return false; - } - - @Override - public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { - if (PipelineUtil.containsCause(cause, CancelCodecException.class)) { - return; - } - - super.exceptionCaught(ctx, cause); - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/loader/MCPBackwardsLoader.java b/src/main/java/cc/paimonmc/viamcp/loader/MCPBackwardsLoader.java deleted file mode 100644 index bdad94301d..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/loader/MCPBackwardsLoader.java +++ /dev/null @@ -1,34 +0,0 @@ -package cc.paimonmc.viamcp.loader; - -import cc.paimonmc.viamcp.ViaMCP; -import com.viaversion.viabackwards.api.ViaBackwardsPlatform; - -import java.io.File; -import java.util.logging.Logger; - -public class MCPBackwardsLoader implements ViaBackwardsPlatform { - private final File file; - - public MCPBackwardsLoader(final File file) { - this.init(this.file = new File(file, "ViaBackwards")); - } - - @Override - public Logger getLogger() { - return ViaMCP.getInstance().getjLogger(); - } - - @Override - public void disable() { - } - - @Override - public boolean isOutdated() { - return false; - } - - @Override - public File getDataFolder() { - return new File(this.file, "config.yml"); - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/loader/MCPRewindLoader.java b/src/main/java/cc/paimonmc/viamcp/loader/MCPRewindLoader.java deleted file mode 100644 index 2a13a90689..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/loader/MCPRewindLoader.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.paimonmc.viamcp.loader; - -import com.viaversion.viaversion.api.Via; -import de.gerrygames.viarewind.api.ViaRewindConfigImpl; -import de.gerrygames.viarewind.api.ViaRewindPlatform; - -import java.io.File; -import java.util.logging.Logger; - -public class MCPRewindLoader implements ViaRewindPlatform { - public MCPRewindLoader(final File file) { - final ViaRewindConfigImpl conf = new ViaRewindConfigImpl(file.toPath().resolve("ViaRewind").resolve("config.yml").toFile()); - conf.reloadConfig(); - this.init(conf); - } - - @Override - public Logger getLogger() { - return Via.getPlatform().getLogger(); - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/loader/MCPViaLoader.java b/src/main/java/cc/paimonmc/viamcp/loader/MCPViaLoader.java deleted file mode 100644 index cd933f0526..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/loader/MCPViaLoader.java +++ /dev/null @@ -1,31 +0,0 @@ -package cc.paimonmc.viamcp.loader; - -import cc.paimonmc.viamcp.ViaMCP; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.platform.ViaPlatformLoader; -import com.viaversion.viaversion.api.protocol.version.VersionProvider; -import com.viaversion.viaversion.bungee.providers.BungeeMovementTransmitter; -import com.viaversion.viaversion.protocols.base.BaseVersionProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; - -public class MCPViaLoader implements ViaPlatformLoader { - @Override - public void load() { - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); - Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() { - @Override - public int getClosestServerProtocol(final UserConnection connection) throws Exception { - if (connection.isClientSide()) { - return ViaMCP.getInstance().getVersion(); - } - - return super.getClosestServerProtocol(connection); - } - }); - } - - @Override - public void unload() { - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaAPI.java b/src/main/java/cc/paimonmc/viamcp/platform/MCPViaAPI.java deleted file mode 100644 index c1fedad6e2..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaAPI.java +++ /dev/null @@ -1,8 +0,0 @@ -package cc.paimonmc.viamcp.platform; - -import com.viaversion.viaversion.ViaAPIBase; - -import java.util.UUID; - -public class MCPViaAPI extends ViaAPIBase { -} diff --git a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaConfig.java b/src/main/java/cc/paimonmc/viamcp/platform/MCPViaConfig.java deleted file mode 100644 index 738e80de9d..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -package cc.paimonmc.viamcp.platform; - -import com.viaversion.viaversion.configuration.AbstractViaConfig; - -import java.io.File; -import java.net.URL; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class MCPViaConfig extends AbstractViaConfig { - private static final List UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "quick-move-action-fix", "nms-player-ticking", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); - - public MCPViaConfig(final File configFile) { - super(configFile); - reloadConfig(); - } - - @Override - public URL getDefaultConfigURL() { - return getClass().getClassLoader().getResource("assets/viaversion/config.yml"); - } - - @Override - protected void handleConfig(final Map config) { - // Is not needed! - } - - @Override - public List getUnsupportedOptions() { - return UNSUPPORTED; - } - - @Override - public boolean isAntiXRay() { - return false; - } - - @Override - public boolean isNMSPlayerTicking() { - return false; - } - - @Override - public boolean is1_12QuickMoveActionFix() { - return false; - } - - @Override - public String getBlockConnectionMethod() { - return "packet"; - } - - @Override - public boolean is1_9HitboxFix() { - return false; - } - - @Override - public boolean is1_14HitboxFix() { - return false; - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaInjector.java b/src/main/java/cc/paimonmc/viamcp/platform/MCPViaInjector.java deleted file mode 100644 index edbf7049ba..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaInjector.java +++ /dev/null @@ -1,39 +0,0 @@ -package cc.paimonmc.viamcp.platform; - -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.handler.CommonTransformer; -import com.viaversion.viaversion.api.platform.ViaInjector; -import com.viaversion.viaversion.libs.gson.JsonObject; - -public class MCPViaInjector implements ViaInjector { - @Override - public void inject() { - // In a nutshell, this is not forge - } - - @Override - public void uninject() { - // Update! Still not forge! - } - - @Override - public int getServerProtocolVersion() { - return ViaMCP.PROTOCOL_VERSION; - } - - @Override - public String getEncoderName() { - return CommonTransformer.HANDLER_ENCODER_NAME; - } - - @Override - public String getDecoderName() { - return CommonTransformer.HANDLER_DECODER_NAME; - } - - @Override - public JsonObject getDump() { - final JsonObject obj = new JsonObject(); - return obj; - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaPlatform.java b/src/main/java/cc/paimonmc/viamcp/platform/MCPViaPlatform.java deleted file mode 100644 index 3011991597..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/platform/MCPViaPlatform.java +++ /dev/null @@ -1,165 +0,0 @@ -package cc.paimonmc.viamcp.platform; - -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.utils.FutureTaskId; -import cc.paimonmc.viamcp.utils.JLoggerToLog4j; -import com.viaversion.viaversion.api.ViaAPI; -import com.viaversion.viaversion.api.command.ViaCommandSender; -import com.viaversion.viaversion.api.configuration.ConfigurationProvider; -import com.viaversion.viaversion.api.configuration.ViaVersionConfig; -import com.viaversion.viaversion.api.platform.PlatformTask; -import com.viaversion.viaversion.api.platform.ViaPlatform; -import com.viaversion.viaversion.libs.gson.JsonObject; -import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; -import org.apache.logging.log4j.LogManager; - -import java.io.File; -import java.nio.file.Path; -import java.util.UUID; -import java.util.concurrent.CancellationException; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; - -public class MCPViaPlatform implements ViaPlatform { - private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion")); - - private final MCPViaConfig config; - private final File dataFolder; - private final ViaAPI api; - - public MCPViaPlatform(final File dataFolder) { - final Path configDir = dataFolder.toPath().resolve("ViaVersion"); - config = new MCPViaConfig(configDir.resolve("viaversion.yml").toFile()); - this.dataFolder = configDir.toFile(); - api = new MCPViaAPI(); - } - - public static String legacyToJson(final String legacy) { - return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(legacy)); - } - - @Override - public Logger getLogger() { - return logger; - } - - @Override - public String getPlatformName() { - return "ViaMCP"; - } - - @Override - public String getPlatformVersion() { - return String.valueOf(ViaMCP.PROTOCOL_VERSION); - } - - @Override - public String getPluginVersion() { - return "4.1.1"; - } - - @Override - public FutureTaskId runAsync(final Runnable runnable) { - return new FutureTaskId(CompletableFuture.runAsync(runnable, ViaMCP.getInstance().getAsyncExecutor()).exceptionally(throwable -> - { - if (!(throwable instanceof CancellationException)) { - throwable.printStackTrace(); - } - - return null; - }) - ); - } - - @Override - public FutureTaskId runSync(final Runnable runnable) { - return new FutureTaskId(ViaMCP.getInstance().getEventLoop().submit(runnable).addListener(errorLogger())); - } - - @Override - public PlatformTask runSync(final Runnable runnable, final long ticks) { - return new FutureTaskId(ViaMCP.getInstance().getEventLoop().schedule(() -> runSync(runnable), ticks * 50, TimeUnit.MILLISECONDS).addListener(errorLogger())); - } - - @Override - public PlatformTask runRepeatingSync(final Runnable runnable, final long ticks) { - return new FutureTaskId(ViaMCP.getInstance().getEventLoop().scheduleAtFixedRate(() -> runSync(runnable), 0, ticks * 50, TimeUnit.MILLISECONDS).addListener(errorLogger())); - } - - private > GenericFutureListener errorLogger() { - return future -> - { - if (!future.isCancelled() && future.cause() != null) { - future.cause().printStackTrace(); - } - }; - } - - @Override - public ViaCommandSender[] getOnlinePlayers() { - return new ViaCommandSender[1337]; // What the fuck - } - - private ViaCommandSender[] getServerPlayers() { - return new ViaCommandSender[1337]; // What the fuck 2: Electric Boogaloo - } - - @Override - public void sendMessage(final UUID uuid, final String s) { - // Don't even know why this needs to be overridden - } - - @Override - public boolean kickPlayer(final UUID uuid, final String s) { - return false; - } - - @Override - public boolean isPluginEnabled() { - return true; - } - - @Override - public ViaAPI getApi() { - return api; - } - - @Override - public ViaVersionConfig getConf() { - return config; - } - - @Override - public ConfigurationProvider getConfigurationProvider() { - return config; - } - - @Override - public File getDataFolder() { - return dataFolder; - } - - @Override - public void onReload() { - logger.info("ViaVersion was reloaded? (How did that happen)"); - } - - @Override - public JsonObject getDump() { - return new JsonObject(); - } - - @Override - public boolean isOldClientsAllowed() { - return true; - } - - @Override - public boolean hasPlugin(final String s) { - return false; - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolCollection.java b/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolCollection.java deleted file mode 100644 index e276cd9d36..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolCollection.java +++ /dev/null @@ -1,113 +0,0 @@ -package cc.paimonmc.viamcp.protocols; - - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; - -public enum ProtocolCollection { - /* 1.19.x */ - R_1_19_1(ProtocolVersion.v1_19_1, ProtocolInfoCollection.R1_19_1), - R_1_19(ProtocolVersion.v1_19, ProtocolInfoCollection.R1_19), - - /* 1.18.x */ - R1_18_2(ProtocolVersion.v1_18_2, ProtocolInfoCollection.R1_18_2), - R1_18(ProtocolVersion.v1_18, ProtocolInfoCollection.R1_18), - - /* 1.17.x */ - R1_17_1(ProtocolVersion.v1_17_1, ProtocolInfoCollection.R1_17_1), - R1_17(ProtocolVersion.v1_17, ProtocolInfoCollection.R1_17), - - /* 1.16.x */ - R1_16_4(ProtocolVersion.v1_16_4, ProtocolInfoCollection.R1_16_4), - R1_16_3(ProtocolVersion.v1_16_3, ProtocolInfoCollection.R1_16_3), - R1_16_2(ProtocolVersion.v1_16_2, ProtocolInfoCollection.R1_16_2), - R1_16_1(ProtocolVersion.v1_16_1, ProtocolInfoCollection.R1_16_1), - R1_16(ProtocolVersion.v1_16, ProtocolInfoCollection.R1_16), - - /* 1.15.x */ - R1_15_2(ProtocolVersion.v1_15_2, ProtocolInfoCollection.R1_15_2), - R1_15_1(ProtocolVersion.v1_15_1, ProtocolInfoCollection.R1_15_1), - R1_15(ProtocolVersion.v1_15, ProtocolInfoCollection.R1_15), - - /* 1.14.x */ - R1_14_4(ProtocolVersion.v1_14_4, ProtocolInfoCollection.R1_14_4), - R1_14_3(ProtocolVersion.v1_14_3, ProtocolInfoCollection.R1_14_3), - R1_14_2(ProtocolVersion.v1_14_2, ProtocolInfoCollection.R1_14_2), - R1_14_1(ProtocolVersion.v1_14_1, ProtocolInfoCollection.R1_14_1), - R1_14(ProtocolVersion.v1_14, ProtocolInfoCollection.R1_14), - - /* 1.13.x */ - R1_13_2(ProtocolVersion.v1_13_2, ProtocolInfoCollection.R1_13_2), - R1_13_1(ProtocolVersion.v1_13_1, ProtocolInfoCollection.R1_13_1), - R1_13(ProtocolVersion.v1_13, ProtocolInfoCollection.R1_13), - - /* 1.12.x */ - R1_12_2(ProtocolVersion.v1_12_2, ProtocolInfoCollection.R1_12_2), - R1_12_1(ProtocolVersion.v1_12_1, ProtocolInfoCollection.R1_12_1), - R1_12(ProtocolVersion.v1_12, ProtocolInfoCollection.R1_12), - - /* 1.11.x */ - R1_11_1(ProtocolVersion.v1_11_1, ProtocolInfoCollection.R1_11_1), - R1_11(ProtocolVersion.v1_11, ProtocolInfoCollection.R1_11), - - /* 1.10.x */ - R1_10(ProtocolVersion.v1_10, ProtocolInfoCollection.R1_10), - - /* 1.9.x */ - R1_9_3(ProtocolVersion.v1_9_3, ProtocolInfoCollection.R1_9_3), - R1_9_2(ProtocolVersion.v1_9_2, ProtocolInfoCollection.R1_9_2), - R1_9_1(ProtocolVersion.v1_9_1, ProtocolInfoCollection.R1_9_1), - R1_9(ProtocolVersion.v1_9, ProtocolInfoCollection.R1_9), - - /* 1.8.x */ - R1_8(ProtocolVersion.v1_8, ProtocolInfoCollection.R1_8), - - /* 1.7.x */ - R1_7_6(ProtocolVersion.v1_7_6, ProtocolInfoCollection.R1_7_6), - R1_7(ProtocolVersion.v1_7_1, ProtocolInfoCollection.R1_7); - - private final ProtocolVersion version; - private final ProtocolInfo info; - - ProtocolCollection(final ProtocolVersion version, final ProtocolInfo info) { - this.version = version; - this.info = info; - } - - public ProtocolVersion getVersion() { - return version; - } - - public ProtocolInfo getInfo() { - return info; - } - - public static ProtocolCollection getProtocolCollectionById(final int id) { - for (final ProtocolCollection coll : values()) { - if (coll.getVersion().getVersion() == id) { - return coll; - } - } - - return null; - } - - public static ProtocolVersion getProtocolById(final int id) { - for (final ProtocolCollection coll : values()) { - if (coll.getVersion().getVersion() == id) { - return coll.getVersion(); - } - } - - return null; - } - - public static ProtocolInfo getProtocolInfoById(final int id) { - for (final ProtocolCollection coll : values()) { - if (coll.getVersion().getVersion() == id) { - return coll.getInfo(); - } - } - - return null; - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolInfo.java b/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolInfo.java deleted file mode 100644 index c12a5a31e0..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package cc.paimonmc.viamcp.protocols; - -public class ProtocolInfo { - private final String name; - private final String description; - private final String releaseDate; - - public ProtocolInfo(final String name, final String description, final String releaseDate) { - this.name = name; - this.description = description; - this.releaseDate = releaseDate; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public String getReleaseDate() { - return releaseDate; - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolInfoCollection.java b/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolInfoCollection.java deleted file mode 100644 index 480409c8db..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/protocols/ProtocolInfoCollection.java +++ /dev/null @@ -1,145 +0,0 @@ -package cc.paimonmc.viamcp.protocols; - -public class ProtocolInfoCollection { - private static final String NO_DESC = "No Description Available"; - - public static ProtocolInfo R1_19_1 = new ProtocolInfo( - "The Wild Update", NO_DESC, "July 27, 2022" - ); - - public static ProtocolInfo R1_19 = new ProtocolInfo( - "The Wild Update", NO_DESC, "June 7, 2022" - ); - - public static ProtocolInfo R1_18_2 = new ProtocolInfo( - "Caves & Cliffs: Part II", NO_DESC, "February 28, 2022" - ); - - public static ProtocolInfo R1_18 = new ProtocolInfo( - "Caves & Cliffs: Part II", NO_DESC, "November 30, 2021 - December 10, 2021" - ); - - public static ProtocolInfo R1_17_1 = new ProtocolInfo( - "Caves & Cliffs: Part I", NO_DESC, "July 6, 2021" - ); - - public static ProtocolInfo R1_17 = new ProtocolInfo( - "Caves & Cliffs: Part I", NO_DESC, "June 8, 2021" - ); - - public static ProtocolInfo R1_16_4 = new ProtocolInfo( - "Nether Update", NO_DESC, "November 2, 2020 - January 13, 2021" - ); - - public static ProtocolInfo R1_16_3 = new ProtocolInfo( - "Nether Update", NO_DESC, "September 7, 2020" - ); - - public static ProtocolInfo R1_16_2 = new ProtocolInfo( - "Nether Update", NO_DESC, "August 11, 2020" - ); - - public static ProtocolInfo R1_16_1 = new ProtocolInfo( - "Nether Update", NO_DESC, "June 24, 2020" - ); - - public static ProtocolInfo R1_16 = new ProtocolInfo( - "Nether Update", NO_DESC, "June 23, 2020" - ); - - public static ProtocolInfo R1_15_2 = new ProtocolInfo( - "Buzzy Bees", NO_DESC, "January 21, 2020" - ); - - public static ProtocolInfo R1_15_1 = new ProtocolInfo( - "Buzzy Bees", NO_DESC, "December 17, 2019" - ); - - public static ProtocolInfo R1_15 = new ProtocolInfo( - "Buzzy Bees", NO_DESC, "December 10, 2019" - ); - - public static ProtocolInfo R1_14_4 = new ProtocolInfo( - "Village & Pillage", NO_DESC, "July 19, 2019" - ); - - public static ProtocolInfo R1_14_3 = new ProtocolInfo( - "Village & Pillage", NO_DESC, "June 24, 2019" - ); - - public static ProtocolInfo R1_14_2 = new ProtocolInfo( - "Village & Pillage", NO_DESC, "May 27, 2019" - ); - - public static ProtocolInfo R1_14_1 = new ProtocolInfo( - "Village & Pillage", NO_DESC, "May 13, 2019" - ); - - public static ProtocolInfo R1_14 = new ProtocolInfo( - "Village & Pillage", NO_DESC, "April 23, 2019" - ); - - public static ProtocolInfo R1_13_2 = new ProtocolInfo( - "Update Aquatic", NO_DESC, "October 22, 2018" - ); - - public static ProtocolInfo R1_13_1 = new ProtocolInfo( - "Update Aquatic", NO_DESC, "August 22, 2018" - ); - - public static ProtocolInfo R1_13 = new ProtocolInfo( - "Update Aquatic", NO_DESC, "July 18, 2018" - ); - - public static ProtocolInfo R1_12_2 = new ProtocolInfo( - "World of Color Update", NO_DESC, "September 18, 2017" - ); - - public static ProtocolInfo R1_12_1 = new ProtocolInfo( - "World of Color Update", NO_DESC, "August 3, 2017" - ); - - public static ProtocolInfo R1_12 = new ProtocolInfo( - "World of Color Update", NO_DESC, "June 7, 2017" - ); - - public static ProtocolInfo R1_11_1 = new ProtocolInfo( - "Exploration Update", NO_DESC, "December 20, 2016 - December 21, 2016" - ); - - public static ProtocolInfo R1_11 = new ProtocolInfo( - "Exploration Update", NO_DESC, "November 14, 2016" - ); - - public static ProtocolInfo R1_10 = new ProtocolInfo( - "Frostburn Update", NO_DESC, "June 8, 2016 - June 23, 2016" - ); - - public static ProtocolInfo R1_9_3 = new ProtocolInfo( - "Combat Update", NO_DESC, "May 10, 2016" - ); - - public static ProtocolInfo R1_9_2 = new ProtocolInfo( - "Combat Update", NO_DESC, "March 30, 2016" - ); - - public static ProtocolInfo R1_9_1 = new ProtocolInfo( - "Combat Update", NO_DESC, "March 30, 2016" - ); - - public static ProtocolInfo R1_9 = new ProtocolInfo( - "Combat Update", NO_DESC, "February 29, 2016" - ); - - public static ProtocolInfo R1_8 = new ProtocolInfo( - "Bountiful Update", NO_DESC, "September 2, 2014 - December 9, 2015" - ); - - public static ProtocolInfo R1_7_6 = new ProtocolInfo( - "The Update that Changed the World", NO_DESC, "April 9, 2014 - June 26, 2014" - ); - - public static ProtocolInfo R1_7 = new ProtocolInfo( - "The Update that Changed the World", NO_DESC, "October 22, 2013 - February 26, 2014" - ); -} \ No newline at end of file diff --git a/src/main/java/cc/paimonmc/viamcp/utils/FixedSoundEngine.java b/src/main/java/cc/paimonmc/viamcp/utils/FixedSoundEngine.java deleted file mode 100644 index 0aba1785a3..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/utils/FixedSoundEngine.java +++ /dev/null @@ -1,83 +0,0 @@ -package cc.paimonmc.viamcp.utils; - -import cc.paimonmc.viamcp.ViaMCP; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -public class FixedSoundEngine { - private static final Minecraft mc = Minecraft.getMinecraft(); - - /** - * Fix for block breaking sounds on protocols above 1.8.x - */ - public static boolean destroyBlock(final World world, final BlockPos pos, final boolean dropBlock) { - final IBlockState iblockstate = world.getBlockState(pos); - final Block block = iblockstate.getBlock(); - - // Moving playAusSFX out of else-statement to play sound correctly (For some reason block.getMaterial() always returns Material.air on 1.9+ protocols) - // This should also function correctly on 1.8.x protocol, so no need for base version checks - world.playAuxSFX(2001, pos, Block.getStateId(iblockstate)); - - if (block.getMaterial() == Material.air) { - return false; - } else { - if (dropBlock) { - block.dropBlockAsItem(world, pos, iblockstate, 0); - } - - return world.setBlockState(pos, Blocks.air.getDefaultState(), 3); - } - } - - /** - * Fix for block placing sounds on protocols above 1.8.x - */ - public static boolean onItemUse(final ItemBlock iblock, final ItemStack stack, final EntityPlayer playerIn, final World worldIn, BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ) { - final IBlockState iblockstate = worldIn.getBlockState(pos); - final Block block = iblockstate.getBlock(); - - if (!block.isReplaceable(worldIn, pos)) { - pos = pos.offset(side); - } - - if (stack.stackSize == 0) { - return false; - } else if (!playerIn.canPlayerEdit(pos, side, stack)) { - return false; - } else if (worldIn.canBlockBePlaced(iblock.getBlock(), pos, false, side, null, stack)) { - final int i = iblock.getMetadata(stack.getMetadata()); - IBlockState iblockstate1 = iblock.getBlock().onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); - - if (worldIn.setBlockState(pos, iblockstate1, 3)) { - iblockstate1 = worldIn.getBlockState(pos); - - if (iblockstate1.getBlock() == iblock.getBlock()) { - ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack); - iblock.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); - } - - if (ViaMCP.getInstance().getVersion() != ViaMCP.PROTOCOL_VERSION) { - // Using playSoundAtPos instead of playSoundEffect (I have no understanding as to why playSoundEffect is not functioning properly on 1.9+ protocols) - mc.theWorld.playSoundAtPos(pos.add(0.5, 0.5, 0.5), iblock.getBlock().stepSound.getPlaceSound(), (iblock.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, iblock.getBlock().stepSound.getFrequency() * 0.8F, false); - } else { - worldIn.playSoundEffect((float) pos.getX() + 0.5F, (float) pos.getY() + 0.5F, (float) pos.getZ() + 0.5F, iblock.getBlock().stepSound.getPlaceSound(), (iblock.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, iblock.getBlock().stepSound.getFrequency() * 0.8F); - } - - --stack.stackSize; - } - - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/utils/FutureTaskId.java b/src/main/java/cc/paimonmc/viamcp/utils/FutureTaskId.java deleted file mode 100644 index b9f7ea41ca..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/utils/FutureTaskId.java +++ /dev/null @@ -1,24 +0,0 @@ -package cc.paimonmc.viamcp.utils; - - -import com.viaversion.viaversion.api.platform.PlatformTask; - -import java.util.concurrent.Future; - -public class FutureTaskId implements PlatformTask> { - private final Future object; - - public FutureTaskId(final Future object) { - this.object = object; - } - - @Override - public Future getObject() { - return object; - } - - @Override - public void cancel() { - object.cancel(false); - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/utils/JLoggerToLog4j.java b/src/main/java/cc/paimonmc/viamcp/utils/JLoggerToLog4j.java deleted file mode 100644 index 83f6c24db3..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/utils/JLoggerToLog4j.java +++ /dev/null @@ -1,65 +0,0 @@ -package cc.paimonmc.viamcp.utils; - -import java.text.MessageFormat; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -public class JLoggerToLog4j extends Logger { - private final org.apache.logging.log4j.Logger base; - - public JLoggerToLog4j(final org.apache.logging.log4j.Logger logger) { - super("logger", null); - this.base = logger; - } - - public void log(final LogRecord record) { - this.log(record.getLevel(), record.getMessage()); - } - - public void log(final Level level, final String msg) { - if (level == Level.FINE) { - this.base.debug(msg); - } else if (level == Level.WARNING) { - this.base.warn(msg); - } else if (level == Level.SEVERE) { - this.base.error(msg); - } else if (level == Level.INFO) { - this.base.info(msg); - } else { - this.base.trace(msg); - } - } - - public void log(final Level level, final String msg, final Object param1) { - if (level == Level.FINE) { - this.base.debug(msg, param1); - } else if (level == Level.WARNING) { - this.base.warn(msg, param1); - } else if (level == Level.SEVERE) { - this.base.error(msg, param1); - } else if (level == Level.INFO) { - this.base.info(msg, param1); - } else { - this.base.trace(msg, param1); - } - } - - public void log(final Level level, final String msg, final Object[] params) { - log(level, MessageFormat.format(msg, params)); - } - - public void log(final Level level, final String msg, final Throwable params) { - if (level == Level.FINE) { - this.base.debug(msg, params); - } else if (level == Level.WARNING) { - this.base.warn(msg, params); - } else if (level == Level.SEVERE) { - this.base.error(msg, params); - } else if (level == Level.INFO) { - this.base.info(msg, params); - } else { - this.base.trace(msg, params); - } - } -} diff --git a/src/main/java/cc/paimonmc/viamcp/utils/NettyUtil.java b/src/main/java/cc/paimonmc/viamcp/utils/NettyUtil.java deleted file mode 100644 index bce472ecec..0000000000 --- a/src/main/java/cc/paimonmc/viamcp/utils/NettyUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -package cc.paimonmc.viamcp.utils; - -import cc.paimonmc.viamcp.handler.CommonTransformer; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelPipeline; - -public class NettyUtil { - public static ChannelPipeline decodeEncodePlacement(final ChannelPipeline instance, String base, final String newHandler, final ChannelHandler handler) { - switch (base) { - case "decoder": { - if (instance.get(CommonTransformer.HANDLER_DECODER_NAME) != null) { - base = CommonTransformer.HANDLER_DECODER_NAME; - } - - break; - } - case "encoder": { - if (instance.get(CommonTransformer.HANDLER_ENCODER_NAME) != null) { - base = CommonTransformer.HANDLER_ENCODER_NAME; - } - - break; - } - } - - return instance.addBefore(base, newHandler, handler); - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt b/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt index 21818c9f10..9e78dfbf9c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt +++ b/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt @@ -17,6 +17,7 @@ import net.ccbluex.liquidbounce.handler.combat.CombatManager import net.ccbluex.liquidbounce.handler.discord.DiscordRPC import net.ccbluex.liquidbounce.handler.network.BungeeCordSpoof import net.ccbluex.liquidbounce.handler.network.ClientFixes +import net.ccbluex.liquidbounce.handler.network.ClientSpoof import net.ccbluex.liquidbounce.ui.client.gui.EnumLaunchFilter import net.ccbluex.liquidbounce.ui.client.gui.LaunchFilterInfo import net.ccbluex.liquidbounce.ui.client.gui.LaunchOption @@ -42,7 +43,7 @@ object FDPClient { const val CLIENT_NAME = "FDPClient" const val COLORED_NAME = "§7[§b§lFDPClient§7] " const val CLIENT_CREATOR = "CCBlueX, Zywl & SkidderMC TEAM" - const val CLIENT_WEBSITE = "fdpinfo.github.io" + const val CLIENT_WEBSITE = "https://fdpinfo.github.io" const val CLIENT_VERSION = "v5.5.0" // Flags @@ -75,6 +76,7 @@ object FDPClient { lateinit var combatManager: CombatManager lateinit var macroManager: MacroManager lateinit var configManager: ConfigManager + lateinit var clientSpoof: ClientSpoof // Some UI things lateinit var hud: HUD @@ -124,6 +126,7 @@ object FDPClient { keyBindManager = KeyBindManager() combatManager = CombatManager() tipSoundManager = TipSoundManager() + clientSpoof = ClientSpoof() // Load language LanguageManager.switchLanguage(Minecraft.getMinecraft().gameSettings.language) @@ -137,6 +140,7 @@ object FDPClient { eventManager.registerListener(LocationCache()) eventManager.registerListener(macroManager) eventManager.registerListener(combatManager) + eventManager.registerListener(ClientSpoof()) // Load client fonts Fonts.loadFonts() diff --git a/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt b/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt index b036381e57..18bfd9a267 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.config.core import com.google.gson.JsonObject diff --git a/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigSection.kt b/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigSection.kt index 1e3063943e..78e1b3eb44 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigSection.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigSection.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.config.core import com.google.gson.JsonObject diff --git a/src/main/java/net/ccbluex/liquidbounce/config/core/sections/MacrosSection.kt b/src/main/java/net/ccbluex/liquidbounce/config/core/sections/MacrosSection.kt index 542f932303..0a0c29f528 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/core/sections/MacrosSection.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/core/sections/MacrosSection.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.config.core.sections import com.google.gson.JsonArray diff --git a/src/main/java/net/ccbluex/liquidbounce/config/core/sections/ModulesSection.kt b/src/main/java/net/ccbluex/liquidbounce/config/core/sections/ModulesSection.kt index ca5f26c407..4ed5f219c1 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/core/sections/ModulesSection.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/core/sections/ModulesSection.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.config.core.sections import com.google.gson.JsonObject diff --git a/src/main/java/net/ccbluex/liquidbounce/config/impl/SpecialConfig.kt b/src/main/java/net/ccbluex/liquidbounce/config/impl/SpecialConfig.kt index 01e6dfbea2..abe8504461 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/impl/SpecialConfig.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/impl/SpecialConfig.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.config.impl import com.google.gson.JsonObject diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/IllegalItems.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/IllegalItems.kt deleted file mode 100644 index 18ee94e84b..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/IllegalItems.kt +++ /dev/null @@ -1,321 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.features.module.modules.exploit - -import net.ccbluex.liquidbounce.features.module.Module -import net.ccbluex.liquidbounce.features.module.ModuleCategory -import net.ccbluex.liquidbounce.features.module.ModuleInfo -import net.ccbluex.liquidbounce.features.value.BoolValue -import net.ccbluex.liquidbounce.features.value.IntegerValue -import net.ccbluex.liquidbounce.features.value.ListValue -import net.ccbluex.liquidbounce.utils.item.ilegalItems -import net.minecraft.client.gui.inventory.GuiInventory -import net.minecraft.init.Blocks -import net.minecraft.init.Items -import net.minecraft.item.ItemStack -import net.minecraft.nbt.NBTTagCompound -import net.minecraft.nbt.NBTTagList -import net.minecraft.network.play.client.C0DPacketCloseWindow -import net.minecraft.network.play.client.C16PacketClientStatus - -@ModuleInfo(name = "IllegalItems", category = ModuleCategory.EXPLOIT) -object IllegalItems : Module() { - - private val mode = ListValue("Mode", arrayOf("InInventory", "Throw"), "InInventory") - private val inventorySpoof = BoolValue("InventorySpoof", false) - private val stackSize = IntegerValue("StackSize", 1, 1, 64) - private val addUnbreakableNBT = BoolValue("AddUnbreakableNBT", true) - private val addLootingNBT = BoolValue("AddLootingNBT", false) - private val addThornsNBT = BoolValue("AddThornsNBT", false) - private val toolEnchantment = ListValue("ToolEnchantment", arrayOf("Off", "SilkTouch", "Fortune"), "Off") - private val item = ListValue("Item", arrayOf( - "32KSword", - "32KBow", - "32KShovel", - "32KPickaxe", - "32KAxe", - "32KHelmet", - "32KChestplate", - "32KLeggings", - "32KBoots", - "TrollPotion", - "KillPotion", - "CrashAnvil", - "CrashHead", - "CrashSpawner", - "CrashStand", - "LagSign", - "lagTag", - "SpawnEgg1", - "SpawnEgg2", - "SpawnEgg3", - "InfinityFirework", - "EnderDragon-Loop", - "CommandBlock", - "CommandBlockMinecart", - "Barrier", - "DragonEgg", - "BrownMushroomBlock", - "RedMushroomBlock", - "Farmland", - "MobSpawner", - "LitFurnace" - ), "32KSword") - private fun getEmptySlot(): Int? { - for (i in 36 .. 44) { - if (mc.thePlayer?.inventoryContainer?.getSlot(i)?.stack == null) - return i - } - for (i in 9..35) { - if (mc.thePlayer?.inventoryContainer?.getSlot(i)?.stack == null) - return i - } - return null - } - private fun add32K(id: Int, nbtTagList: NBTTagList) { - val enchantment = NBTTagCompound() - enchantment.setShort("id", id.toShort()) - enchantment.setShort("lvl", Short.MAX_VALUE) - nbtTagList.appendTag(enchantment) - } - private fun addUnbreakable(itemStack: ItemStack) { - if (!addUnbreakableNBT.get()) - return - if (itemStack.tagCompound == null) - itemStack.tagCompound = NBTTagCompound() - itemStack.tagCompound.setBoolean("Unbreakable", true) - } - override fun onEnable() { - if (mc.theWorld == null || mc.thePlayer == null) { - this.state = false - return - } - if (mc.playerController.isNotCreative) { - - this.state = false - return - } - val itemStack = when(item.get()) { - //Exploits - "32KSword" -> { - val sword = ItemStack(Items.diamond_sword) - val swordNBTs = NBTTagList() - for (id in if (!addLootingNBT.get()) arrayOf(16, 19, 20, 34) else arrayOf(16, 19, 20, 21, 34)) - add32K(id, swordNBTs) - sword.setTagInfo("ench", swordNBTs) - addUnbreakable(sword) - sword - } - "32KBow" -> { - val bow = ItemStack(Items.bow) - val bowNBTs = NBTTagList() - for (id in arrayOf(48, 49, 50, 34)) - add32K(id, bowNBTs) - val enchantment = NBTTagCompound() - enchantment.setShort("id", 51) - enchantment.setShort("lvl", 1) - bowNBTs.appendTag(enchantment) - bow.setTagInfo("ench", bowNBTs) - addUnbreakable(bow) - bow - } - "32KShovel" -> { - val shovel = ItemStack(Items.diamond_shovel) - val shovelNBTs = NBTTagList() - val list = when (toolEnchantment.get()) { - "SilkTouch" -> arrayOf(34, 32, 33) - "Fortune" -> arrayOf(34, 32, 35) - else -> arrayOf(34, 32) - } - for (id in list) - add32K(id, shovelNBTs) - shovel.setTagInfo("ench", shovelNBTs) - addUnbreakable(shovel) - shovel - } - "32KPickaxe" -> { - val pickaxe = ItemStack(Items.diamond_pickaxe) - val pickaxeNBTs = NBTTagList() - val list = when (toolEnchantment.get()) { - "SilkTouch" -> arrayOf(34, 32, 33) - "Fortune" -> arrayOf(34, 32, 35) - else -> arrayOf(34, 32) - } - for (id in list) - add32K(id, pickaxeNBTs) - pickaxe.setTagInfo("ench", pickaxeNBTs) - addUnbreakable(pickaxe) - pickaxe - } - "32KAxe" -> { - val axe = ItemStack(Items.diamond_axe) - val axeNBTs = NBTTagList() - val list = when (toolEnchantment.get()) { - "SilkTouch" -> arrayOf(34, 32, 33) - "Fortune" -> arrayOf(34, 32, 35) - else -> arrayOf(34, 32) - } - for (id in list) - add32K(id, axeNBTs) - axe.setTagInfo("ench", axeNBTs) - addUnbreakable(axe) - axe - } - "32KHelmet" -> { - val helmet = ItemStack(Items.diamond_helmet) - val helmetNBTs = NBTTagList() - val list = - if (addThornsNBT.get()) - arrayOf(34, 0, 5, 6, 7) - else - arrayOf(34, 0, 5, 6) - for (id in list) - add32K(id, helmetNBTs) - helmet.setTagInfo("ench", helmetNBTs) - addUnbreakable(helmet) - helmet - } - "32KChestplate" -> { - val chestPlate = ItemStack(Items.diamond_chestplate) - val chestPlateNBTs = NBTTagList() - val list = - if (addThornsNBT.get()) - arrayOf(34, 0, 7) - else - arrayOf(34, 0) - for (id in list) - add32K(id, chestPlateNBTs) - chestPlate.setTagInfo("ench", chestPlateNBTs) - addUnbreakable(chestPlate) - chestPlate - } - "32KLeggings" -> { - val leggings = ItemStack(Items.diamond_leggings) - val leggingsNBTs = NBTTagList() - val list = - if (addThornsNBT.get()) - arrayOf(34, 0, 7) - else - arrayOf(34, 0) - for (id in list) - add32K(id, leggingsNBTs) - leggings.setTagInfo("ench", leggingsNBTs) - addUnbreakable(leggings) - leggings - } - "32KBoots" -> { - val boots = ItemStack(Items.diamond_boots) - val bootsNBTs = NBTTagList() - val list = - if (addThornsNBT.get()) - arrayOf(34, 0, 2, 7) - else - arrayOf(34, 0, 2) - for (id in list) - add32K(id, bootsNBTs) - boots.setTagInfo("ench", bootsNBTs) - addUnbreakable(boots) - boots - } - "TrollPotion" -> { - val trollPotion = ItemStack(Items.potionitem) - - trollPotion.itemDamage = 16395 - - val trollPotionEffects = NBTTagList() - for (i in 1..27) { - val effect = NBTTagCompound() - effect.setInteger("Amplifier", Integer.MAX_VALUE) - effect.setInteger("Duration", Integer.MAX_VALUE) - effect.setInteger("Id", i) - trollPotionEffects.appendTag(effect) - } - trollPotion.setTagInfo("CustomPotionEffects", trollPotionEffects) - trollPotion.setStackDisplayName("§c§lTroll§6§lPotion") - trollPotion - } - "KillPotion" -> { - val killPotion = ItemStack(Items.potionitem) - killPotion.itemDamage = 16395 - val effect = NBTTagCompound() - effect.setInteger("Amplifier", 125) - effect.setInteger("Duration", 1) - effect.setInteger("Id", 6) - val effects = NBTTagList() - effects.appendTag(effect) - killPotion.setTagInfo("CustomPotionEffects", effects) - killPotion.setStackDisplayName("§c§lKill§6§lPotion") - killPotion - } - "CrashAnvil" -> { - val crashAnvil = ItemStack(Blocks.anvil) - crashAnvil.setStackDisplayName("§8Crash§c§lAnvil §7| §cmc1.8-mc1.8") - crashAnvil.itemDamage = 16384 - crashAnvil - } - "CrashHead" -> { - val crashHead = ItemStack(Items.skull) - val compound = NBTTagCompound() - compound.setString("SkullOwner", " ") - crashHead.tagCompound = compound - crashHead.setStackDisplayName("§8Crash§6§lHead §7| §cmc1.8-mc1.10") - crashHead - } - "CrashSpawner" -> ilegalItems.createItem("mob_spawner 1 0 {BlockEntityTag:{EntityId:\"Painting\"}}").setStackDisplayName("§8Crash§c§lSpawner §7| §cmc1.8-mc1.8") - "CrashStand" -> ilegalItems.createItem("armor_stand 1 0 {EntityTag:{Equipment:[{},{},{},{},{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\"Test\"}}]}}").setStackDisplayName("§8Crash§2§lStand §7| §cmc1.10") - "LagSign" -> { - val lagStringBuilder = StringBuilder() - for (i in 0..499) - lagStringBuilder.append("/(!§()%/§)=/(!§()%/§)=/(!§()%/§)=") - ilegalItems.createItem("sign 1 0 {BlockEntityTag:{Text1:\"{\\\"text\\\":\\\"$lagStringBuilder\\\"}\",Text2:\"{\\\"text\\\":\\\"$lagStringBuilder\\\"}\",Text3:\"{\\\"text\\\":\\\"$lagStringBuilder\\\"}\",Text4:\"{\\\"text\\\":\\\"$lagStringBuilder\\\"}\"}}").setStackDisplayName("§8Lag§2§lSign §7| §cmc1.8") - } - "lagTag" -> { - val lagStringBuilder = StringBuilder() - for (i in 0..499) - lagStringBuilder.append("/(!§()%/§)=/(!§()%/§)=/(!§()%/§)=") - ilegalItems.createItem("name_tag 1 0 {display:{Name: \"$lagStringBuilder\"}}") - } - "SpawnEgg1" -> ilegalItems.createItem("spawn_egg 1 64") - "SpawnEgg2" -> ilegalItems.createItem("spawn_egg 1 63") - "SpawnEgg3" -> ilegalItems.createItem("spawn_egg 1 53") - "InfinityFirework" -> ilegalItems.createItem("fireworks 1 0 {HideFlags:63,Fireworks:{Flight:127b,Explosions:[0:{Type:0b,Trail:1b,Colors:[16777215,],Flicker:1b,FadeColors:[0,]}]}}").setStackDisplayName("§cInfinity §a§lFirework") - "EnderDragon-Loop" -> ilegalItems.createItem("chest 1 0 {BlockEntityTag:{Items:[0:{Slot:0b, id:\"minecraft:mob_spawner\",Count:64b,tag:{BlockEntityTag:{EntityId:\"FallingSand\",MaxNearbyEntities:1000,RequiredPlayerRange:100,SpawnCount:100,SpawnData:{Motion:[0:0.0d,1:0.0d,2:0.0d],Block:\"mob_spawner\",Time:1,Data:0,TileEntityData:{EntityId:\"FallingSand\",MaxNearbyEntities:1000,RequiredPlayerRange:100,SpawnCount:100,SpawnData:{Motion:[0:0.0d,1:0.0d,2:0.0d],Block:\"mob_spawner\",Time:1,Data:0,TileEntityData:{EntityId:\"EnderDragon\",MaxNearbyEntities:1000,RequiredPlayerRange:100,SpawnCount:100,MaxSpawnDelay:20,SpawnRange:100,MinSpawnDelay:20},DropItem:0},MaxSpawnDelay:20,SpawnRange:500,MinSpawnDelay:20},DropItem:0},MaxSpawnDelay:5,SpawnRange:500,Delay:20,MinSpawnDelay:5}},Damage:0s}],value:\"Chest\",Lock:\"\"}}")!!.setStackDisplayName("§c§lEnder§c§a§lDragon §bSpawner Chest") - //Blocks - "CommandBlock" -> ItemStack(Blocks.command_block) - "CommandBlockMinecart" -> ItemStack(Items.command_block_minecart) - "Barrier" -> ItemStack(Blocks.barrier) - "DragonEgg" -> ItemStack(Blocks.dragon_egg) - "BrownMushroomBlock" -> ItemStack(Blocks.brown_mushroom_block) - "RedMushroomBlock" -> ItemStack(Blocks.red_mushroom_block) - "Farmland" -> ItemStack(Blocks.farmland) - "MobSpawner" -> ItemStack(Blocks.mob_spawner) - "LitFurnace" -> ItemStack(Blocks.lit_furnace) - else -> ItemStack(Blocks.stone) - } - itemStack.stackSize = stackSize.get() - if (inventorySpoof.get() && mc.currentScreen !is GuiInventory) { - mc.netHandler.addToSendQueue(C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT)) - } - when(mode.get()) { - "InInventory" -> { - // find empty slot - val emptySlot = getEmptySlot() - if (emptySlot != null) { - mc.playerController.sendSlotPacket(itemStack, emptySlot) - alert("§aPacket sent.") - } else alert("§cError: No empty stack.") - } - "Throw" -> { - mc.playerController.sendPacketDropItem(itemStack) - alert("§aPacket sent.") - } - } - if (inventorySpoof.get() && mc.currentScreen !is GuiInventory) { - mc.netHandler.addToSendQueue(C0DPacketCloseWindow()) - } - this.state = false - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLadder.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLadder.java index c21000445a..ecb7d99839 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLadder.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLadder.java @@ -5,20 +5,19 @@ */ package net.ccbluex.liquidbounce.injection.forge.mixins.block; -import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.features.module.modules.exploit.ViaVersionFix; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; import net.minecraft.block.BlockLadder; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -import java.util.Objects; - @Mixin(BlockLadder.class) public class MixinBlockLadder { @ModifyConstant(method = "setBlockBoundsBasedOnState", constant = @Constant(floatValue = 0.125F)) private float ViaVersion_LadderBB(float constant) { - if (Objects.requireNonNull(FDPClient.moduleManager.getModule(ViaVersionFix.class)).getState()) + if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol() && !MinecraftInstance.mc.isIntegratedServerRunning()) return 0.1875F; return 0.125F; } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLilyPad.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLilyPad.java index c718a31029..991e9e1e13 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLilyPad.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinBlockLilyPad.java @@ -5,14 +5,15 @@ */ package net.ccbluex.liquidbounce.injection.forge.mixins.block; -import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.features.module.modules.exploit.ViaVersionFix; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLilyPad; import net.minecraft.block.state.IBlockState; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -22,8 +23,8 @@ public abstract class MixinBlockLilyPad extends BlockBush { @Overwrite public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { - if (Objects.requireNonNull(FDPClient.moduleManager.getModule(ViaVersionFix.class)).getState()) - return new AxisAlignedBB((double)pos.getX() + 0.0625D, (double)pos.getY() + 0.0D, (double)pos.getZ() + 0.0625D, (double)pos.getX() + 0.9375D, (double)pos.getY() + 0.09375D, (double)pos.getZ() + 0.9375D); - return new AxisAlignedBB((double)pos.getX() + 0.0D, (double)pos.getY() + 0.0D, (double)pos.getZ() + 0.0D, (double)pos.getX() + 1.0D, (double)pos.getY() + 0.015625D, (double)pos.getZ() + 1.0D); + if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol() && !MinecraftInstance.mc.isIntegratedServerRunning()) + return new AxisAlignedBB((double) pos.getX() + 0.0625D, (double) pos.getY() + 0.0D, (double) pos.getZ() + 0.0625D, (double) pos.getX() + 0.9375D, (double) pos.getY() + 0.09375D, (double) pos.getZ() + 0.9375D); + return new AxisAlignedBB((double) pos.getX() + 0.0D, (double) pos.getY() + 0.0D, (double) pos.getZ() + 0.0D, (double) pos.getX() + 1.0D, (double) pos.getY() + 0.015625D, (double) pos.getZ() + 1.0D); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinItemBlock.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinItemBlock.java new file mode 100644 index 0000000000..2569618832 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/block/MixinItemBlock.java @@ -0,0 +1,67 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.block; + +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(ItemBlock.class) +public class MixinItemBlock extends Item { + + @Shadow + @Final + public Block block; + + + @Overwrite + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { + IBlockState iblockstate = worldIn.getBlockState(pos); + Block block = iblockstate.getBlock(); + + if (!block.isReplaceable(worldIn, pos)) { + pos = pos.offset(side); + } + + if (stack.stackSize == 0) { + return false; + } else if (!playerIn.canPlayerEdit(pos, side, stack)) { + return false; + } else if (worldIn.canBlockBePlaced(this.block, pos, false, side, null, stack)) { + int i = this.getMetadata(stack.getMetadata()); + IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); + + if (worldIn.setBlockState(pos, iblockstate1, 3)) { + iblockstate1 = worldIn.getBlockState(pos); + + if (iblockstate1.getBlock() == this.block) { + ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack); + this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); + } + + if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol() && !MinecraftInstance.mc.isIntegratedServerRunning()) { + MinecraftInstance.mc.theWorld.playSoundAtPos(pos.add(0.5, 0.5, 0.5), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F, false); + } else { + worldIn.playSoundEffect((float) pos.getX() + 0.5F, (float) pos.getY() + 0.5F, (float) pos.getZ() + 0.5F, this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); + } + + --stack.stackSize; + } + + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java index f45a50f3c0..2a104ec8d0 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java @@ -4,8 +4,8 @@ * https://github.com/SkidderMC/FDPClient/ */ package net.ccbluex.liquidbounce.injection.forge.mixins.client; -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.utils.AttackOrder; + + import net.ccbluex.liquidbounce.FDPClient; import net.ccbluex.liquidbounce.event.*; import net.ccbluex.liquidbounce.features.module.modules.client.SoundModule; @@ -15,6 +15,9 @@ import net.ccbluex.liquidbounce.features.module.modules.visual.PerspectiveMod; import net.ccbluex.liquidbounce.injection.access.StaticStorage; import net.ccbluex.liquidbounce.injection.forge.mixins.accessors.MinecraftForgeClientAccessor; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.protocol.ProtocolMod; +import net.ccbluex.liquidbounce.protocol.api.AttackFixer; import net.ccbluex.liquidbounce.utils.CPSCounter; import net.ccbluex.liquidbounce.utils.ClientUtils; import net.ccbluex.liquidbounce.utils.RotationUtils; @@ -31,6 +34,9 @@ import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -54,6 +60,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.nio.ByteBuffer; +import java.util.Objects; import static org.objectweb.asm.Opcodes.PUTFIELD; @@ -62,52 +69,41 @@ public abstract class MixinMinecraft { @Shadow public GuiScreen currentScreen; - @Shadow public boolean skipRenderWorld; - - @Shadow - private int leftClickCounter; - @Shadow public MovingObjectPosition objectMouseOver; - @Shadow public WorldClient theWorld; - @Shadow public EntityPlayerSP thePlayer; - @Shadow public EffectRenderer effectRenderer; - + @Shadow + public EntityRenderer entityRenderer; @Shadow public PlayerControllerMP playerController; - @Shadow - public int rightClickDelayTimer; - + public int displayWidth; @Shadow - public GameSettings gameSettings; - + public int displayHeight; @Shadow - @Final - public File mcDataDir; - + public int rightClickDelayTimer; @Shadow - public int displayWidth; - + public GameSettings gameSettings; @Shadow - public int displayHeight; + private Entity renderViewEntity; @Shadow private boolean fullscreen; + @Shadow + public int leftClickCounter; + private long lastFrame = getTime(); - private float prevYaw = 0.0f; + @Shadow + public abstract IResourceManager getResourceManager(); - @Inject(method = "", at = @At("RETURN")) - public void injectConstructor(GameConfiguration p_i45547_1_, CallbackInfo ci) { - ViaMCP.staticInit(); - } + @Shadow + public abstract RenderManager getRenderManager(); @Inject(method = "run", at = @At("HEAD")) private void init(CallbackInfo callbackInfo) { @@ -118,12 +114,16 @@ private void init(CallbackInfo callbackInfo) { displayHeight = 622; } - @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V", ordinal = 2, shift = At.Shift.AFTER)) private void startGame(CallbackInfo callbackInfo) { FDPClient.INSTANCE.initClient(); } + @Inject(method = "", at = @At("RETURN")) + public void startVia(GameConfiguration p_i45547_1_, CallbackInfo ci) { + ProtocolBase.init(ProtocolMod.PLATFORM); + } + @Inject(method = "createDisplay", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V", shift = At.Shift.AFTER)) private void createDisplay(CallbackInfo callbackInfo) { ClientUtils.INSTANCE.setTitle(); @@ -143,8 +143,6 @@ private void displayGuiScreen(CallbackInfo callbackInfo) { FDPClient.eventManager.callEvent(new ScreenEvent(currentScreen)); } - private long lastFrame = getTime(); - @Inject(method = "runGameLoop", at = @At("HEAD")) private void runGameLoop(final CallbackInfo callbackInfo) { final long currentTime = getTime(); @@ -199,19 +197,45 @@ private void shutdown(CallbackInfo callbackInfo) { FDPClient.INSTANCE.stopClient(); } - @Inject(method = "clickMouse", at = @At("HEAD")) - private void clickMouse(CallbackInfo callbackInfo) { + @Overwrite + public void clickMouse() { CPSCounter.registerClick(CPSCounter.MouseButton.LEFT); - if (FDPClient.moduleManager.getModule(AutoClicker.class).getState()) - leftClickCounter = 0; + if (this.leftClickCounter <= 0) { + if (this.objectMouseOver != null && Objects.requireNonNull(this.objectMouseOver.typeOfHit) != MovingObjectPosition.MovingObjectType.ENTITY) { + this.thePlayer.swingItem(); + } + + if (this.objectMouseOver != null) { + switch (this.objectMouseOver.typeOfHit) { + case ENTITY: + AttackFixer.sendFixedAttack(this.thePlayer, this.objectMouseOver.entityHit); + break; + + case BLOCK: + BlockPos blockpos = this.objectMouseOver.getBlockPos(); + + if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air) { + this.playerController.clickBlock(blockpos, this.objectMouseOver.sideHit); + break; + } + + case MISS: + default: + if (this.playerController.isNotCreative()) { + this.leftClickCounter = 10; + } + } + } + } } @Redirect( method = "clickMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;attackEntity(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/entity/Entity;)V") ) - public void fixAttackOrder_VanillaAttack(PlayerControllerMP controller, EntityPlayer player, Entity e) { - AttackOrder.sendFixedAttack(this.thePlayer, this.objectMouseOver.entityHit); + + private void fixAttackOrder_VanillaSwing(PlayerControllerMP instance, EntityPlayer p_attackEntity_1_, Entity p_attackEntity_2_) { + AttackFixer.sendConditionalSwing(this.objectMouseOver); } @Inject(method = "middleClickMouse", at = @At("HEAD")) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntity.java index 929531a599..0b5143aa8b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntity.java @@ -13,7 +13,9 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.StrafeFix; import net.ccbluex.liquidbounce.features.module.modules.exploit.ViaVersionFix; import net.ccbluex.liquidbounce.injection.access.IWorld; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; import net.ccbluex.liquidbounce.utils.EntityUtils; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.crash.CrashReportCategory; @@ -23,6 +25,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -30,6 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.Objects; import java.util.Random; import java.util.UUID; @@ -214,16 +218,15 @@ private void isInLava(final CallbackInfoReturnable cir) { @Inject(method = "getCollisionBorderSize", at = @At("HEAD"), cancellable = true) private void getCollisionBorderSize(final CallbackInfoReturnable callbackInfoReturnable) { - final HitBox hitBox = FDPClient.moduleManager.getModule(HitBox.class); - final ViaVersionFix viaVersionFix = FDPClient.moduleManager.getModule(ViaVersionFix.class); + final HitBox hitBoxes = Objects.requireNonNull(FDPClient.moduleManager.getModule(HitBox.class)); - if (hitBox.getState() && EntityUtils.INSTANCE.isSelected(((Entity)((Object)this)),true)) { - if (viaVersionFix.getState()) { - callbackInfoReturnable.setReturnValue(hitBox.getSizeValue().get()); + if (hitBoxes.getState() && EntityUtils.INSTANCE.isSelected(((Entity) ((Object) this)), true)) { + if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol() && !MinecraftInstance.mc.isIntegratedServerRunning()) { + callbackInfoReturnable.setReturnValue(hitBoxes.getSizeValue().get()); } else { - callbackInfoReturnable.setReturnValue(0.1F + hitBox.getSizeValue().get()); + callbackInfoReturnable.setReturnValue(0.1F + hitBoxes.getSizeValue().get()); } - } else if (viaVersionFix.getState()) { + } else if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol() && !MinecraftInstance.mc.isIntegratedServerRunning()) { callbackInfoReturnable.setReturnValue(0.0F); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java index 16410f0e8b..3e2d19b3b8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java @@ -14,6 +14,8 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.StrafeFix; import net.ccbluex.liquidbounce.features.module.modules.visual.AntiBlind; import net.ccbluex.liquidbounce.features.module.modules.exploit.ViaVersionFix; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; import net.ccbluex.liquidbounce.utils.MovementUtils; import net.ccbluex.liquidbounce.utils.RotationUtils; import net.minecraft.block.Block; @@ -26,6 +28,7 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; +import net.raphimc.vialoader.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -132,10 +135,8 @@ private void onJumpSection(CallbackInfo callbackInfo) { @ModifyConstant(method = "onLivingUpdate", constant = @Constant(doubleValue = 0.005D)) private double ViaVersion_MovementThreshold(double constant) { - final ViaVersionFix viaversionfix = (ViaVersionFix) FDPClient.moduleManager.getModule(ViaVersionFix.class); - if (Objects.requireNonNull(viaversionfix.getState())){ + if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol() && !MinecraftInstance.mc.isIntegratedServerRunning()) return 0.003D; - } return 0.005D; } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java index 64902f98e7..682a28aa7e 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java @@ -16,6 +16,8 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.Sprint; import net.ccbluex.liquidbounce.features.module.modules.movement.StrafeFix; import net.ccbluex.liquidbounce.features.module.modules.world.Scaffold; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; import net.ccbluex.liquidbounce.utils.RotationUtils; import net.ccbluex.liquidbounce.utils.MovementUtils; import net.minecraft.block.Block; @@ -32,101 +34,178 @@ import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.ItemSword; +import net.minecraft.network.Packet; import net.minecraft.network.play.client.C03PacketPlayer; import net.minecraft.network.play.client.C0BPacketEntityAction; import net.minecraft.potion.Potion; import net.minecraft.util.*; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; +import net.raphimc.vialoader.util.VersionEnum; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.List; +import java.util.Objects; @Mixin(EntityPlayerSP.class) public abstract class MixinEntityPlayerSP extends MixinAbstractClientPlayer { - @Shadow - private boolean serverSneakState; + @Unique + private boolean viaForge$prevOnGround; + /** + * The Server sprint state. + */ @Shadow public boolean serverSprintState; - - @Shadow - public abstract void playSound(String name, float volume, float pitch); - + /** + * The Sprinting ticks left. + */ @Shadow public int sprintingTicksLeft; - - @Shadow - protected int sprintToggleTimer; - + /** + * The Time in portal. + */ @Shadow public float timeInPortal; - + /** + * The Prev time in portal. + */ @Shadow public float prevTimeInPortal; - - @Shadow - protected Minecraft mc; - + /** + * The Movement input. + */ @Shadow public MovementInput movementInput; - + /** + * The Horse jump power. + */ @Shadow - public abstract void setSprinting(boolean sprinting); - + public float horseJumpPower; + /** + * The Horse jump power counter. + */ @Shadow - protected abstract boolean pushOutOfBlocks(double x, double y, double z); - + public int horseJumpPowerCounter; + /** + * The Send queue. + */ @Shadow - public abstract void sendPlayerAbilities(); - + @Final + public NetHandlerPlayClient sendQueue; + /** + * The Sprint toggle timer. + */ @Shadow - public float horseJumpPower; - + protected int sprintToggleTimer; + /** + * The Mc. + */ @Shadow - public int horseJumpPowerCounter; - + protected Minecraft mc; @Shadow - protected abstract void sendHorseJump(); - + private boolean serverSneakState; @Shadow - public abstract boolean isRidingHorse(); - + private double lastReportedPosX; @Shadow - @Final - public NetHandlerPlayClient sendQueue; - + public int positionUpdateTicks; @Shadow - public abstract boolean isSneaking(); + private double lastReportedPosY; + @Shadow + private double lastReportedPosZ; + @Shadow + private float lastReportedYaw; + @Shadow + private float lastReportedPitch; + @Unique + private boolean lastOnGround; + /** + * Play sound. + * + * @param name the name + * @param volume the volume + * @param pitch the pitch + */ @Shadow - private double lastReportedPosX; + public abstract void playSound(String name, float volume, float pitch); + /** + * Sets sprinting. + * + * @param sprinting the sprinting + */ @Shadow - private int positionUpdateTicks; + public abstract void setSprinting(boolean sprinting); + /** + * Push out of blocks boolean. + * + * @param x the x + * @param y the y + * @param z the z + * @return the boolean + */ @Shadow - private double lastReportedPosY; + protected abstract boolean pushOutOfBlocks(double x, double y, double z); + /** + * Send player abilities. + */ @Shadow - private double lastReportedPosZ; + public abstract void sendPlayerAbilities(); + /** + * Send horse jump. + */ @Shadow - private float lastReportedYaw; + protected abstract void sendHorseJump(); + /** + * Is riding horse boolean. + * + * @return the boolean + */ @Shadow - private float lastReportedPitch; + public abstract boolean isRidingHorse(); @Shadow - protected abstract boolean isCurrentViewEntity(); + public abstract boolean isSneaking(); + + /** + * Is current view entity boolean. + * + * @return the boolean + * @author As_pw + * @reason Fix Video + */ + @Overwrite + protected boolean isCurrentViewEntity() { + final Flight flight = Objects.requireNonNull(FDPClient.moduleManager.getModule(Flight.class)); + + return (mc.getRenderViewEntity() != null && mc.getRenderViewEntity().equals(this)) || (FDPClient.moduleManager != null && flight.getState()); + } private boolean debug_AttemptSprint = false; + @Redirect(method = "onUpdateWalkingPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/NetHandlerPlayClient;addToSendQueue(Lnet/minecraft/network/Packet;)V", ordinal = 7)) + public void emulateIdlePacket(NetHandlerPlayClient instance, Packet p_addToSendQueue_1_) { + if (ProtocolBase.getManager().getTargetVersion().isNewerThan(VersionEnum.r1_8) && !MinecraftInstance.mc.isIntegratedServerRunning()) { + if (this.viaForge$prevOnGround == this.onGround) { + return; + } + } + instance.addToSendQueue(p_addToSendQueue_1_); + } + + @Inject(method = "onUpdateWalkingPlayer", at = @At("RETURN")) + public void saveGroundState(CallbackInfo ci) { + this.viaForge$prevOnGround = this.onGround; + } + /** * @author CCBlueX, liulihaocai * diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiMultiplayer.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiMultiplayer.java index 49cc469b9d..62b2c81ed8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiMultiplayer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiMultiplayer.java @@ -5,7 +5,6 @@ */ package net.ccbluex.liquidbounce.injection.forge.mixins.gui; -import cc.paimonmc.viamcp.gui.AsyncVersionSlider; import net.ccbluex.liquidbounce.ui.client.GuiProxySelect; import net.ccbluex.liquidbounce.ui.elements.ToolDropdown; import net.minecraft.client.Minecraft; @@ -25,14 +24,10 @@ public abstract class MixinGuiMultiplayer extends MixinGuiScreen { @Inject(method = "initGui", at = @At("RETURN")) private void initGui(CallbackInfo callbackInfo) { buttonList.add(toolButton = new GuiButton(997, 5, 8, 138, 20, "Tools")); - // buttonList.add(new GuiButton(998, width - 104, 8, 98, 20, "%ui.serverSpoof%")); buttonList.add(new GuiButton(999, width - 208, 8, 98, 20, "Proxy")); + buttonList.add(new GuiButton(1151, 4, height - 24, 68, 20, "Protocol")); } - @Inject(method = "createButtons",at = @At("HEAD")) - public void createButtons(CallbackInfo ci){ - buttonList.add(new AsyncVersionSlider(-1, this.width - 104, 8, 98, 20)); - } @Inject(method = "actionPerformed", at = @At("HEAD")) private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinGuiConnecting_1.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinGuiConnecting_1.java new file mode 100644 index 0000000000..5d5b03f076 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinGuiConnecting_1.java @@ -0,0 +1,27 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.network; + + +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.protocol.api.ExtendedServerData; +import net.minecraft.client.Minecraft; +import net.minecraft.network.NetworkManager; +import net.raphimc.vialoader.util.VersionEnum; +import org.spongepowered.asm.mixin.Mixin; + +import java.net.InetAddress; + +@Mixin(targets = "net.minecraft.client.multiplayer.GuiConnecting$1") +public class MixinGuiConnecting_1 { + + public NetworkManager trackVersion(InetAddress address, int i, boolean b) { + if (Minecraft.getMinecraft().getCurrentServerData() instanceof ExtendedServerData) { + final VersionEnum version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaForge$getVersion(); + if (version != null) { + ProtocolBase.getManager().setTargetVersionSilent(version); + } + } + + return NetworkManager.createNetworkManagerAndConnect(address, i, b); + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager.java index 54df567ba8..44fc74373e 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager.java @@ -15,29 +15,77 @@ import net.ccbluex.liquidbounce.features.module.modules.client.Animations; import net.ccbluex.liquidbounce.features.module.modules.other.SilentDisconnect; import net.ccbluex.liquidbounce.handler.network.ProxyManager; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.protocol.api.VFNetworkManager; import net.ccbluex.liquidbounce.utils.BlinkUtils; import net.ccbluex.liquidbounce.utils.ClientUtils; import net.ccbluex.liquidbounce.utils.PacketUtils; -import net.minecraft.network.EnumPacketDirection; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -import net.minecraft.util.MessageDeserializer; -import net.minecraft.util.MessageDeserializer2; -import net.minecraft.util.MessageSerializer; -import net.minecraft.util.MessageSerializer2; +import net.minecraft.network.*; +import net.minecraft.util.*; +import net.raphimc.vialoader.netty.VLLegacyPipeline; +import net.raphimc.vialoader.util.VersionEnum; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; import java.net.InetAddress; import java.net.Proxy; @Mixin(NetworkManager.class) -public abstract class MixinNetworkManager { +public class MixinNetworkManager implements VFNetworkManager { + + @Shadow + private Channel channel; + + @Shadow + private INetHandler packetListener; + + @Unique + private Cipher viaForge$decryptionCipher; + + @Unique + private VersionEnum viaForge$targetVersion; + + private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) { + ((VFNetworkManager) networkmanager).viaForge$setTrackedVersion(ProtocolBase.getManager().getTargetVersion()); + } + + @Inject(method = "enableEncryption", at = @At("HEAD"), cancellable = true) + private void storeEncryptionCiphers(SecretKey key, CallbackInfo ci) { + if (ProtocolBase.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) { + ci.cancel(); + this.viaForge$decryptionCipher = CryptManager.createNetCipherInstance(2, key); + this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key))); + } + } + + @Inject(method = "setCompressionTreshold", at = @At("RETURN")) + public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) { + ProtocolBase.getManager().reorderCompression(channel); + } + + @Override + public void viaForge$setupPreNettyDecryption() { + this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaForge$decryptionCipher)); + } + + @Override + public VersionEnum viaForge$getTrackedVersion() { + return viaForge$targetVersion; + } + + @Override + public void viaForge$setTrackedVersion(VersionEnum version) { + viaForge$targetVersion = version; + } /** * show player head in tab bar diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManagerChInit.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManagerChInit.java deleted file mode 100644 index 5ee4a3ba15..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManagerChInit.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.injection.forge.mixins.network; - -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.handler.CommonTransformer; -import cc.paimonmc.viamcp.handler.MCPDecodeHandler; -import cc.paimonmc.viamcp.handler.MCPEncodeHandler; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.connection.UserConnectionImpl; -import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; -import io.netty.channel.Channel; -import io.netty.channel.socket.SocketChannel; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(targets = "net.minecraft.network.NetworkManager$5") -public abstract class MixinNetworkManagerChInit { - - @Inject(method={"initChannel"}, at={@At(value="TAIL")}, remap=false) - private void onInitChannel(Channel p_initChannel_1_, CallbackInfo callbackInfo) { - if (p_initChannel_1_ instanceof SocketChannel && ViaMCP.getInstance().getVersion() != ViaMCP.PROTOCOL_VERSION) { - UserConnection user = new UserConnectionImpl(p_initChannel_1_, true); - new ProtocolPipelineImpl(user); - p_initChannel_1_.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new MCPEncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new MCPDecodeHandler(user)); - } - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager_5.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager_5.java new file mode 100644 index 0000000000..e3274374e6 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager_5.java @@ -0,0 +1,26 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.network; + +import io.netty.channel.Channel; + +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.protocol.api.VFNetworkManager; +import net.minecraft.network.NetworkManager; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(targets = "net.minecraft.network.NetworkManager$5") +public class MixinNetworkManager_5 { + + @Final + @Mutable + NetworkManager val$networkmanager; + + @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) + private void onInitChannel(Channel channel, CallbackInfo ci) { + ProtocolBase.getManager().inject(channel, (VFNetworkManager) val$networkmanager); + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkPlayerInfo.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkPlayerInfo.java new file mode 100644 index 0000000000..765f6348c0 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkPlayerInfo.java @@ -0,0 +1,25 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.network; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.util.ResourceLocation; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +/** + * The type Mixin network player info. + */ +@Mixin(NetworkPlayerInfo.class) +public class MixinNetworkPlayerInfo { + @Shadow + @Final + private GameProfile gameProfile; + + @Inject(method = "getLocationSkin", at = @At("HEAD")) + private void injectSkinProtect(CallbackInfoReturnable cir) { + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinServerData.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinServerData.java new file mode 100644 index 0000000000..60eb90162e --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinServerData.java @@ -0,0 +1,53 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.network; + + +import net.ccbluex.liquidbounce.protocol.api.ExtendedServerData; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.nbt.NBTTagCompound; +import net.raphimc.vialoader.util.VersionEnum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(ServerData.class) +public class MixinServerData implements ExtendedServerData { + + @Unique + private VersionEnum viaForge$version; + + @Inject(method = "getNBTCompound", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) + public void saveVersion(CallbackInfoReturnable cir, NBTTagCompound nbttagcompound) { + if (viaForge$version != null) { + nbttagcompound.setInteger("viaForge$version", viaForge$version.getVersion()); + } + } + + @Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL")) + private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable cir) { + if (nbtCompound.hasKey("viaForge$version")) { + ((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(VersionEnum.fromProtocolId(nbtCompound.getInteger("viaForge$version"))); + } + } + + @Inject(method = "copyFrom", at = @At("HEAD")) + public void track(ServerData serverDataIn, CallbackInfo ci) { + if (serverDataIn instanceof ExtendedServerData) { + viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion(); + } + } + + @Override + public VersionEnum viaForge$getVersion() { + return viaForge$version; + } + + @Override + public void viaForge$setVersion(VersionEnum version) { + viaForge$version = version; + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinServerPinger.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinServerPinger.java new file mode 100644 index 0000000000..720963bae0 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinServerPinger.java @@ -0,0 +1,43 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.network; + +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.protocol.api.ExtendedServerData; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.network.OldServerPinger; +import net.minecraft.network.NetworkManager; +import net.raphimc.vialoader.util.VersionEnum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.net.InetAddress; + +@Mixin(OldServerPinger.class) +public class MixinServerPinger { + + @Unique + private ServerData viaForge$serverData; + + @Inject(method = "ping", at = @At("HEAD")) + public void trackServerData(ServerData server, CallbackInfo ci) { + viaForge$serverData = server; + } + + @Redirect(method = "ping", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;func_181124_a(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"), remap = false) + public NetworkManager trackVersion(InetAddress address, int i, boolean b) { + if (viaForge$serverData instanceof ExtendedServerData) { + final VersionEnum version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion(); + if (version != null) { + ProtocolBase.getManager().setTargetVersionSilent(version); + } + + viaForge$serverData = null; + } + + return NetworkManager.createNetworkManagerAndConnect(address, i, b); + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/ProtocolBase.java b/src/main/java/net/ccbluex/liquidbounce/protocol/ProtocolBase.java new file mode 100644 index 0000000000..e410f1b720 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/ProtocolBase.java @@ -0,0 +1,77 @@ +package net.ccbluex.liquidbounce.protocol; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.connection.UserConnectionImpl; +import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; +import io.netty.channel.Channel; +import io.netty.channel.socket.SocketChannel; +import io.netty.util.AttributeKey; +import net.ccbluex.liquidbounce.protocol.api.*; +import net.raphimc.vialoader.ViaLoader; +import net.raphimc.vialoader.impl.platform.*; +import net.raphimc.vialoader.netty.CompressionReorderEvent; +import net.raphimc.vialoader.util.VersionEnum; + +public class ProtocolBase { + + private VersionEnum targetVersion = VersionEnum.r1_8; + public static final AttributeKey LOCAL_VIA_USER = AttributeKey.valueOf("local_via_user"); + public static final AttributeKey VF_NETWORK_MANAGER = AttributeKey.valueOf("encryption_setup"); + private final VFPlatform platform; + private static ProtocolBase manager; + + public ProtocolBase(VFPlatform platform) { + this.platform = platform; + } + + public static void init(final VFPlatform platform) { + if (manager != null) { + return; + } + + final VersionEnum version = VersionEnum.fromProtocolId(platform.getGameVersion()); + if (version == VersionEnum.UNKNOWN) { + throw new IllegalArgumentException("Unknown version " + platform.getGameVersion()); + } + + manager = new ProtocolBase(platform); + + ViaLoader.init(new ViaVersionPlatformImpl(null), new ProtocolVLLoader(platform), new ProtocolVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new); + } + + public void inject(final Channel channel, final VFNetworkManager networkManager) { + if (channel instanceof SocketChannel) { + final UserConnection user = new UserConnectionImpl(channel, true); + new ProtocolPipelineImpl(user); + + channel.attr(LOCAL_VIA_USER).set(user); + channel.attr(VF_NETWORK_MANAGER).set(networkManager); + + channel.pipeline().addLast(new ProtocolVLLegacyPipeline(user, targetVersion)); + } + } + + public VersionEnum getTargetVersion() { + return targetVersion; + } + + public void setTargetVersionSilent(final VersionEnum targetVersion) { + this.targetVersion = targetVersion; + } + + public void setTargetVersion(final VersionEnum targetVersion) { + this.targetVersion = targetVersion; + } + + public void reorderCompression(final Channel channel) { + channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE); + } + + public VFPlatform getPlatform() { + return platform; + } + + public static ProtocolBase getManager() { + return manager; + } +} diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/ProtocolMod.java b/src/main/java/net/ccbluex/liquidbounce/protocol/ProtocolMod.java new file mode 100644 index 0000000000..f9c2532f88 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/ProtocolMod.java @@ -0,0 +1,38 @@ +package net.ccbluex.liquidbounce.protocol; + +import net.ccbluex.liquidbounce.protocol.api.ProtocolGameProfileFetcher; +import net.ccbluex.liquidbounce.protocol.api.VFPlatform; +import net.minecraft.client.Minecraft; +import net.minecraft.realms.RealmsSharedConstants; +import net.minecraft.util.Session; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; + +import java.util.function.Supplier; + +public class ProtocolMod implements VFPlatform { + + public static ProtocolMod PLATFORM = new ProtocolMod(); + + @Override + public int getGameVersion() { + return RealmsSharedConstants.NETWORK_PROTOCOL_VERSION; + } + + @Override + public Supplier isSingleplayer() { + return () -> Minecraft.getMinecraft().isSingleplayer(); + } + + @Override + public void joinServer(String serverId) throws Throwable { + final Session session = Minecraft.getMinecraft().getSession(); + + Minecraft.getMinecraft().getSessionService().joinServer(session.getProfile(), session.getToken(), serverId); + } + + @Override + public GameProfileFetcher getGameProfileFetcher() { + return new ProtocolGameProfileFetcher(); + } + +} \ No newline at end of file diff --git a/src/main/java/cc/paimonmc/viamcp/utils/AttackOrder.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/AttackFixer.java similarity index 64% rename from src/main/java/cc/paimonmc/viamcp/utils/AttackOrder.java rename to src/main/java/net/ccbluex/liquidbounce/protocol/api/AttackFixer.java index 37fed7c0a4..6cedccc07f 100644 --- a/src/main/java/cc/paimonmc/viamcp/utils/AttackOrder.java +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/AttackFixer.java @@ -1,17 +1,15 @@ -package cc.paimonmc.viamcp.utils; +package net.ccbluex.liquidbounce.protocol.api; -import cc.paimonmc.viamcp.ViaMCP; -import cc.paimonmc.viamcp.protocols.ProtocolCollection; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MovingObjectPosition; +import net.raphimc.vialoader.util.VersionEnum; -public class AttackOrder { +public class AttackFixer { private static final Minecraft mc = Minecraft.getMinecraft(); - public static final int VER_1_8_ID = 47; - public static void sendConditionalSwing(final MovingObjectPosition mop) { if (mop != null && mop.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY) { mc.thePlayer.swingItem(); @@ -19,24 +17,20 @@ public static void sendConditionalSwing(final MovingObjectPosition mop) { } public static void sendFixedAttack(final EntityPlayer entityIn, final Entity target) { - // Using this instead of ViaMCP.PROTOCOL_VERSION so does not need to be changed between 1.8.x and 1.12.2 base - // getVersion() can be null, but not in this case, as ID 47 exists, if not removed - if (ViaMCP.getInstance().getVersion() <= ProtocolCollection.getProtocolById(VER_1_8_ID).getVersion()) { - send1_8Attack(entityIn, target); - } else { + if (ProtocolBase.getManager().getTargetVersion().getProtocol() != VersionEnum.r1_8.getProtocol()) { send1_9Attack(entityIn, target); + } else { + send1_8Attack(entityIn, target); } } - private static void send1_8Attack(EntityPlayer entityIn, Entity target) - { + private static void send1_8Attack(EntityPlayer entityIn, Entity target) { mc.thePlayer.swingItem(); mc.playerController.attackEntity(entityIn, target); } - private static void send1_9Attack(EntityPlayer entityIn, Entity target) - { + private static void send1_9Attack(EntityPlayer entityIn, Entity target) { mc.playerController.attackEntity(entityIn, target); mc.thePlayer.swingItem(); } -} +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ExtendedServerData.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ExtendedServerData.java new file mode 100644 index 0000000000..4ac858a99a --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ExtendedServerData.java @@ -0,0 +1,14 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import net.raphimc.vialoader.util.VersionEnum; + +/** + * This interface is used to store the target version for a specific server in the server list. + */ +public interface ExtendedServerData { + + VersionEnum viaForge$getVersion(); + + void viaForge$setVersion(final VersionEnum version); + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolClassicMPPassProvider.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolClassicMPPassProvider.java new file mode 100644 index 0000000000..d323afd40e --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolClassicMPPassProvider.java @@ -0,0 +1,62 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.connection.UserConnection; +import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider; +import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider; +import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage; + +import java.io.InputStream; +import java.net.InetAddress; +import java.net.URL; +import java.security.MessageDigest; +import java.util.Formatter; +import java.util.Scanner; +import java.util.logging.Level; + +public class ProtocolClassicMPPassProvider extends ClassicMPPassProvider { + + @Override + public String getMpPass(UserConnection user) { + final HandshakeStorage handshakeStorage = user.get(HandshakeStorage.class); + + return getBetacraftMpPass(user, user.getProtocolInfo().getUsername(), handshakeStorage.getHostname(), handshakeStorage.getPort()); + } + + private static String getBetacraftMpPass(final UserConnection user, final String username, final String ip, final int port) { + try { + final String server = InetAddress.getByName(ip).getHostAddress() + ":" + port; + + Via.getManager().getProviders().get(OldAuthProvider.class).sendAuthRequest(user, sha1(server.getBytes())); + + final InputStream connection = new URL("https://api.betacraft.uk/getmppass.jsp?user=" + username + "&server=" + server).openStream(); + Scanner scanner = new Scanner(connection); + StringBuilder response = new StringBuilder(); + while (scanner.hasNext()) { + response.append(scanner.next()); + } + connection.close(); + + if (response.toString().contains("FAILED") || response.toString().contains("SERVER NOT FOUND")) return "0"; + + return response.toString(); + } catch (Throwable t) { + Via.getPlatform().getLogger().log(Level.WARNING, "An unknown error occurred while authenticating with BetaCraft", t); + return "0"; + } + } + + private static String sha1(final byte[] input) { + try { + Formatter formatter = new Formatter(); + final byte[] hash = MessageDigest.getInstance("SHA-1").digest(input); + for (byte b : hash) { + formatter.format("%02x", b); + } + return formatter.toString(); + } catch (Exception e) { + return null; + } + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolEncryptionProvider.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolEncryptionProvider.java new file mode 100644 index 0000000000..814e1487e2 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolEncryptionProvider.java @@ -0,0 +1,14 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.connection.UserConnection; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider; + +public class ProtocolEncryptionProvider extends EncryptionProvider { + + @Override + public void enableDecryption(UserConnection user) { + user.getChannel().attr(ProtocolBase.VF_NETWORK_MANAGER).getAndRemove().viaForge$setupPreNettyDecryption(); + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolGameProfileFetcher.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolGameProfileFetcher.java new file mode 100644 index 0000000000..0e9b2e1bb0 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolGameProfileFetcher.java @@ -0,0 +1,59 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.mojang.authlib.Agent; +import com.mojang.authlib.GameProfileRepository; +import com.mojang.authlib.HttpAuthenticationService; +import com.mojang.authlib.ProfileLookupCallback; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.yggdrasil.ProfileNotFoundException; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.GameProfile; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; + +import java.net.Proxy; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class ProtocolGameProfileFetcher extends GameProfileFetcher { + + public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, ""); + public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService(); + public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository(); + + @Override + public UUID loadMojangUUID(String playerName) throws Exception { + final CompletableFuture future = new CompletableFuture<>(); + GAME_PROFILE_REPOSITORY.findProfilesByNames(new String[]{playerName}, Agent.MINECRAFT, new ProfileLookupCallback() { + @Override + public void onProfileLookupSucceeded(com.mojang.authlib.GameProfile profile) { + future.complete(profile); + } + + @Override + public void onProfileLookupFailed(com.mojang.authlib.GameProfile profile, Exception exception) { + future.completeExceptionally(exception); + } + }); + if (!future.isDone()) { + future.completeExceptionally(new ProfileNotFoundException()); + } + return future.get().getId(); + } + + @Override + public GameProfile loadGameProfile(UUID uuid) throws Exception { + final com.mojang.authlib.GameProfile inProfile = new com.mojang.authlib.GameProfile(uuid, null); + final com.mojang.authlib.GameProfile mojangProfile = SESSION_SERVICE.fillProfileProperties(inProfile, true); + if (mojangProfile.equals(inProfile)) throw new ProfileNotFoundException(); + + final GameProfile gameProfile = new GameProfile(mojangProfile.getName(), mojangProfile.getId()); + for (final java.util.Map.Entry entry : mojangProfile.getProperties().entries()) { + final Property prop = entry.getValue(); + gameProfile.addProperty(new GameProfile.Property(prop.getName(), prop.getValue(), prop.getSignature())); + } + + return gameProfile; + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolMovementTransmitterProvider.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolMovementTransmitterProvider.java new file mode 100644 index 0000000000..73d61c85c5 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolMovementTransmitterProvider.java @@ -0,0 +1,13 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; + +public class ProtocolMovementTransmitterProvider extends MovementTransmitterProvider { + + @Override + public void sendPlayer(UserConnection userConnection) { + // We are on the client side, so we can handle the idle packet properly + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolOldAuthProvider.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolOldAuthProvider.java new file mode 100644 index 0000000000..d91ea87f51 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolOldAuthProvider.java @@ -0,0 +1,15 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.connection.UserConnection; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider; + +public class ProtocolOldAuthProvider extends OldAuthProvider { + + @Override + public void sendAuthRequest(UserConnection user, String serverId) throws Throwable { + final ProtocolBase common = ProtocolBase.getManager(); + common.getPlatform().joinServer(serverId); + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolSelector.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolSelector.java new file mode 100644 index 0000000000..ff3371f6e5 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolSelector.java @@ -0,0 +1,117 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.mojang.realmsclient.gui.ChatFormatting; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSlot; +import net.raphimc.vialoader.util.VersionEnum; +import org.lwjgl.input.Keyboard; + +import java.io.IOException; + +public class ProtocolSelector extends GuiScreen { + + private final GuiScreen parent; + private final boolean simple; + private final FinishedCallback finishedCallback; + + private SlotList list; + + public ProtocolSelector(final GuiScreen parent) { + this(parent, false, (version, unused) -> ProtocolBase.getManager().setTargetVersion(version)); + } + + public ProtocolSelector(final GuiScreen parent, final boolean simple, final FinishedCallback finishedCallback) { + this.parent = parent; + this.simple = simple; + this.finishedCallback = finishedCallback; + } + + @Override + public void initGui() { + super.initGui(); + buttonList.add(new GuiButton(1, 5, height - 25, 20, 20, "<-")); + + list = new SlotList(mc, width, height, -26 + (fontRendererObj.FONT_HEIGHT) * 3 /* title is 2 */, height, fontRendererObj.FONT_HEIGHT); + } + + @Override + protected void actionPerformed(GuiButton button) { + list.actionPerformed(button); + + if (button.id == 1) { + mc.displayGuiScreen(parent); + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + if (keyCode == Keyboard.KEY_ESCAPE) { + mc.displayGuiScreen(parent); + } + } + + @Override + public void handleMouseInput() throws IOException { + list.handleMouseInput(); + super.handleMouseInput(); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + list.drawScreen(mouseX, mouseY, partialTicks); + + super.drawScreen(mouseX, mouseY, partialTicks); + } + + class SlotList extends GuiSlot { + + public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) { + super(client, width, height, top, bottom, slotHeight); + } + + @Override + protected int getSize() { + return VersionEnum.SORTED_VERSIONS.size(); + } + + @Override + protected void elementClicked(int index, boolean b, int i1, int i2) { + finishedCallback.finished(VersionEnum.SORTED_VERSIONS.get(index), parent); + } + + @Override + protected boolean isSelected(int index) { + return false; + } + + @Override + protected void drawBackground() { + drawDefaultBackground(); + } + + @Override + protected void drawSlot(int index, int x, int y, int slotHeight, int mouseX, int mouseY) { + final VersionEnum targetVersion = ProtocolBase.getManager().getTargetVersion(); + final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(index); + + String color; + if (targetVersion == version) { + color = ProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString(); + } else { + color = ProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString(); + } + + drawCenteredString(mc.fontRendererObj, (color) + version.getName(), width / 2, y - 3, -1); + } + } + + public interface FinishedCallback { + + void finished(final VersionEnum version, final GuiScreen parent); + + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLInjector.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLInjector.java new file mode 100644 index 0000000000..bfdd5272ae --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLInjector.java @@ -0,0 +1,18 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import net.raphimc.vialoader.impl.viaversion.VLInjector; +import net.raphimc.vialoader.netty.VLLegacyPipeline; + +public class ProtocolVLInjector extends VLInjector { + + @Override + public String getDecoderName() { + return VLLegacyPipeline.VIA_DECODER_NAME; + } + + @Override + public String getEncoderName() { + return VLLegacyPipeline.VIA_ENCODER_NAME; + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLLegacyPipeline.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLLegacyPipeline.java new file mode 100644 index 0000000000..c056f7e48f --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLLegacyPipeline.java @@ -0,0 +1,43 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.connection.UserConnection; +import net.raphimc.vialoader.netty.VLLegacyPipeline; +import net.raphimc.vialoader.util.VersionEnum; + +public class ProtocolVLLegacyPipeline extends VLLegacyPipeline { + + public ProtocolVLLegacyPipeline(UserConnection user, VersionEnum version) { + super(user, version); + } + + @Override + protected String decompressName() { + return "decompress"; + } + + @Override + protected String compressName() { + return "compress"; + } + + @Override + protected String packetDecoderName() { + return "decoder"; + } + + @Override + protected String packetEncoderName() { + return "encoder"; + } + + @Override + protected String lengthSplitterName() { + return "splitter"; + } + + @Override + protected String lengthPrependerName() { + return "prepender"; + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLLoader.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLLoader.java new file mode 100644 index 0000000000..b660890574 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVLLoader.java @@ -0,0 +1,35 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.platform.providers.ViaProviders; +import com.viaversion.viaversion.api.protocol.version.VersionProvider; +import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; +import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider; +import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider; +import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; +import net.raphimc.vialoader.impl.viaversion.VLLoader; + +public class ProtocolVLLoader extends VLLoader { + + private final VFPlatform platform; + + public ProtocolVLLoader(VFPlatform platform) { + this.platform = platform; + } + + @Override + public void load() { + super.load(); + + final ViaProviders providers = Via.getManager().getProviders(); + + providers.use(VersionProvider.class, new ProtocolVersionProvider()); + providers.use(MovementTransmitterProvider.class, new ProtocolMovementTransmitterProvider()); + providers.use(OldAuthProvider.class, new ProtocolOldAuthProvider()); + providers.use(GameProfileFetcher.class, platform.getGameProfileFetcher()); + providers.use(EncryptionProvider.class, new ProtocolEncryptionProvider()); + providers.use(ClassicMPPassProvider.class, new ProtocolClassicMPPassProvider()); + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVersionProvider.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVersionProvider.java new file mode 100644 index 0000000000..2fd075290c --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/ProtocolVersionProvider.java @@ -0,0 +1,19 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.protocols.base.BaseVersionProvider; +import net.ccbluex.liquidbounce.protocol.ProtocolBase; + +import java.util.Objects; + +public class ProtocolVersionProvider extends BaseVersionProvider { + + @Override + public int getClosestServerProtocol(UserConnection connection) throws Exception { + if (connection.isClientSide() && !ProtocolBase.getManager().getPlatform().isSingleplayer().get()) { + return Objects.requireNonNull(connection.getChannel()).attr(ProtocolBase.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion().getVersion(); + } + return super.getClosestServerProtocol(connection); + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/VFNetworkManager.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/VFNetworkManager.java new file mode 100644 index 0000000000..44a6d15ba7 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/VFNetworkManager.java @@ -0,0 +1,21 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import net.raphimc.vialoader.util.VersionEnum; + +public interface VFNetworkManager { + + void viaForge$setupPreNettyDecryption(); + + /** + * @return the target version of the connection + */ + VersionEnum viaForge$getTrackedVersion(); + + /** + * Sets the target version of the connection. + * + * @param version the target version + */ + void viaForge$setTrackedVersion(final VersionEnum version); + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/protocol/api/VFPlatform.java b/src/main/java/net/ccbluex/liquidbounce/protocol/api/VFPlatform.java new file mode 100644 index 0000000000..150278e256 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/protocol/api/VFPlatform.java @@ -0,0 +1,34 @@ +package net.ccbluex.liquidbounce.protocol.api; + +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; + +import java.util.function.Supplier; + +/** + * This interface is used to access platform specific fields. + */ +public interface VFPlatform { + + /** + * @return the native version of the platform + */ + int getGameVersion(); + + /** + * @return if the client is in singleplayer + */ + Supplier isSingleplayer(); + + /** + * Sends the joinServer API request to authentication servers. + * + * @param serverId the server id of the server + */ + void joinServer(final String serverId) throws Throwable; + + /** + * @return the game profile fetcher of the platform for ViaLegacy + */ + GameProfileFetcher getGameProfileFetcher(); + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGUIModule.kt b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGUIModule.kt index 72fd13c83f..7075ecdb77 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGUIModule.kt +++ b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGUIModule.kt @@ -15,7 +15,6 @@ import net.ccbluex.liquidbounce.features.value.FloatValue import net.ccbluex.liquidbounce.features.value.IntegerValue import net.ccbluex.liquidbounce.features.value.ListValue import net.ccbluex.liquidbounce.ui.clickgui.style.styles.* -import net.ccbluex.liquidbounce.ui.clickgui.style.styles.Slight.SlightUI import net.ccbluex.liquidbounce.ui.clickgui.style.styles.classic.DropdownGUI import net.ccbluex.liquidbounce.ui.clickgui.style.styles.light.LightClickGUI import net.ccbluex.liquidbounce.ui.clickgui.style.styles.newVer.NewUi @@ -38,13 +37,10 @@ object ClickGUIModule : Module() { "OneTap", "Light", "Novoline", - "Astolfo", "LB+", - "LiquidBounce", - "Tenacity5", - "Slight", + "Astolfo", + "Mixed", "Null", - "Slowly", "Black", "White" ), @@ -70,7 +66,6 @@ object ClickGUIModule : Module() { private var lightClickGUI = LightClickGUI() private var otcGui = OtcClickGUi() private var novoline = ClickyUI() - private var slight = SlightUI() private var dropdown = DropdownGUI() override fun onEnable() { @@ -80,7 +75,6 @@ object ClickGUIModule : Module() { styleValue.get().contains("Light") -> mc.displayGuiScreen(lightClickGUI) styleValue.get().equals("Classic", ignoreCase = true) -> mc.displayGuiScreen(dropdown) styleValue.get().equals("LB+", ignoreCase = true) -> mc.displayGuiScreen(NewUi.getInstance()) - styleValue.get().contains("Slight") -> mc.displayGuiScreen(slight) else -> { updateStyle() mc.displayGuiScreen(modernuiLaunchOption.clickGui) @@ -90,11 +84,9 @@ object ClickGUIModule : Module() { } private fun updateStyle() { when (styleValue.get().lowercase(Locale.getDefault())) { - "liquidbounce" -> modernuiLaunchOption.clickGui.style = LiquidBounceStyle() "null" -> modernuiLaunchOption.clickGui.style = NullStyle() - "slowly" -> modernuiLaunchOption.clickGui.style = SlowlyStyle() "black", "white" -> modernuiLaunchOption.clickGui.style = if (styleValue.get() == "White") WhiteStyle() else BlackStyle() - "tenacity5" -> modernuiLaunchOption.clickGui.style = TenacityStyle() + "mixed" -> modernuiLaunchOption.clickGui.style = MixedStyle() "astolfo" -> modernuiLaunchOption.clickGui.style = AstolfoStyle() } } diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGui.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGui.java index ea46771f82..c3708ada5c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGui.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/ClickGui.java @@ -12,7 +12,7 @@ import net.ccbluex.liquidbounce.ui.clickgui.elements.Element; import net.ccbluex.liquidbounce.ui.clickgui.elements.ModuleElement; import net.ccbluex.liquidbounce.ui.clickgui.style.Style; -import net.ccbluex.liquidbounce.ui.clickgui.style.styles.SlowlyStyle; +import net.ccbluex.liquidbounce.ui.clickgui.style.styles.BlackStyle; import net.ccbluex.liquidbounce.ui.client.gui.options.modernuiLaunchOption; import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner; import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer; @@ -32,7 +32,7 @@ public class ClickGui extends GuiScreen { public final List panels = new ArrayList<>(); - public Style style = new SlowlyStyle(); + public Style style = new BlackStyle(); private Panel clickedPanel; private int mouseX; private int mouseY; diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/TenacityStyle.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/MixedStyle.java similarity index 98% rename from src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/TenacityStyle.java rename to src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/MixedStyle.java index 7fd45847da..1d7385ce04 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/TenacityStyle.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/MixedStyle.java @@ -26,9 +26,10 @@ import java.awt.*; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; -public class TenacityStyle extends Style { +public class MixedStyle extends Style { private boolean mouseDown; private boolean rightMouseDown; @@ -46,7 +47,7 @@ public static float drawSlider(final float value, final float min, final float m double i = MathHelper.clamp_double(((double) mouseX - (double) x) / ((double) width - 3), 0, 1); BigDecimal bigDecimal = new BigDecimal(Double.toString((min + (max - min) * i))); - bigDecimal = bigDecimal.setScale(2, 4); + bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP); return bigDecimal.floatValue(); } @@ -87,7 +88,7 @@ public void drawButtonElement(int mouseX, int mouseY, ButtonElement buttonElemen @Override public void drawModuleElement(int mouseX, int mouseY, ModuleElement moduleElement) { - if(moduleElement.getModule().getState() == true){ + if(moduleElement.getModule().getState()){ Gui.drawRect(moduleElement.getX() + 2, moduleElement.getY() - 1, moduleElement.getX() + moduleElement.getWidth() -2, moduleElement.getY() + moduleElement.getHeight(), hoverColor(new Color(0,0,0,30), moduleElement.hoverTime).getRGB()); } else { Gui.drawRect(moduleElement.getX() +2, moduleElement.getY() - 2, moduleElement.getX() + moduleElement.getWidth() - 2, moduleElement.getY() + moduleElement.getHeight() + 1, hoverColor(new Color(33, 33, 33), moduleElement.hoverTime).getRGB()); @@ -282,7 +283,7 @@ public void drawModuleElement(int mouseX, int mouseY, ModuleElement moduleElemen private BigDecimal round(final float v) { BigDecimal bigDecimal = new BigDecimal(Float.toString(v)); - bigDecimal = bigDecimal.setScale(2, 4); + bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP); return bigDecimal; } diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/Opacity.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/Opacity.java deleted file mode 100644 index 5d3f98a5d6..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/Opacity.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.ccbluex.liquidbounce.ui.clickgui.style.styles.Slight; - -import net.ccbluex.liquidbounce.ui.client.gui.AnimationUtil; - -public class Opacity { - - private float opacity; - private long lastMS; - - public Opacity(int opacity) { - this.opacity = (float) opacity; - this.lastMS = System.currentTimeMillis(); - } - - public void interpolate(float targetOpacity) { - long currentMS = System.currentTimeMillis(); - long delta = currentMS - this.lastMS; - - this.lastMS = currentMS; - this.opacity = AnimationUtil.calculateCompensation(targetOpacity, this.opacity, delta, 20); - } - - public void interp(float targetOpacity, int speed) { - long currentMS = System.currentTimeMillis(); - long delta = currentMS - this.lastMS; - - this.lastMS = currentMS; - this.opacity = AnimationUtil.calculateCompensation(targetOpacity, this.opacity, delta, speed); - } - - public float getOpacity() { - return (float) ((int) this.opacity); - } - - public void setOpacity(float opacity) { - this.opacity = opacity; - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/RenderUtil.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/RenderUtil.java deleted file mode 100644 index f8837dd7fe..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/RenderUtil.java +++ /dev/null @@ -1,318 +0,0 @@ -package net.ccbluex.liquidbounce.ui.clickgui.style.styles.Slight; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public enum RenderUtil { - - ; - - public static int reAlpha(int color, float alpha) { - Color c = new Color(color); - float r = 0.003921569F * (float) c.getRed(); - float g = 0.003921569F * (float) c.getGreen(); - float b = 0.003921569F * (float) c.getBlue(); - - return (new Color(r, g, b, alpha)).getRGB(); - } - - public static void drawGradientRect2(double left, double top, double right, double bottom, int startColor, int endColor) { - float sa = (float) (startColor >> 24 & 255) / 255.0F; - float sr = (float) (startColor >> 16 & 255) / 255.0F; - float sg = (float) (startColor >> 8 & 255) / 255.0F; - float sb = (float) (startColor & 255) / 255.0F; - float ea = (float) (endColor >> 24 & 255) / 255.0F; - float er = (float) (endColor >> 16 & 255) / 255.0F; - float eg = (float) (endColor >> 8 & 255) / 255.0F; - float eb = (float) (endColor & 255) / 255.0F; - - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.shadeModel(7425); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos(left, bottom, 0.0D).color(sr, sg, sb, sa).endVertex(); - worldrenderer.pos(right, bottom, 0.0D).color(er, eg, eb, ea).endVertex(); - worldrenderer.pos(right, top, 0.0D).color(er, eg, eb, ea).endVertex(); - worldrenderer.pos(left, top, 0.0D).color(sr, sg, sb, sa).endVertex(); - tessellator.draw(); - GlStateManager.shadeModel(7424); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - } - - public static void drawDimRect(double x, double y, double x2, double y2, int col1) { - drawRect(x, y, x2, y2, col1); - float f2 = (float) (col1 >> 16 & 255) / 255.0F; - float f3 = (float) (col1 >> 8 & 255) / 255.0F; - float f4 = (float) (col1 & 255) / 255.0F; - - GL11.glEnable(3042); - GL11.glDisable(3553); - GL11.glBlendFunc(770, 771); - GL11.glEnable(2848); - GL11.glPushMatrix(); - GL11.glColor4f(f2, f3, f4, 0.2F); - GL11.glLineWidth(2.0F); - GL11.glBegin(1); - GL11.glVertex2d(x, y); - GL11.glVertex2d(x, y2); - GL11.glVertex2d(x2, y2); - GL11.glVertex2d(x2, y); - GL11.glVertex2d(x, y); - GL11.glVertex2d(x2, y); - GL11.glVertex2d(x, y2); - GL11.glVertex2d(x2, y2); - GL11.glEnd(); - GL11.glPopMatrix(); - GL11.glEnable(3553); - GL11.glDisable(3042); - GL11.glDisable(2848); - } - - public static int height() { - return (new ScaledResolution(Minecraft.getMinecraft())).getScaledHeight(); - } - - - public static double getAnimationState(double animation, double finalState, double speed) { - float add = (float) (0.01D * speed); - - animation = animation < finalState ? (animation + (double) add < finalState ? animation + (double) add : finalState) : (animation - (double) add > finalState ? animation - (double) add : finalState); - return animation; - } - - public static void drawImage(ResourceLocation image, int x, int y, int width, int height2) { - drawImage(image, x, y, width, height2, 1.0F); - } - - public static void drawImage(ResourceLocation image, int x, int y, int width, int height2, float alpha) { - new ScaledResolution(Minecraft.getMinecraft()); - GL11.glDisable(2929); - GL11.glEnable(3042); - GL11.glDepthMask(false); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); - Minecraft.getMinecraft().getTextureManager().bindTexture(image); - Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, width, height2, (float) width, (float) height2); - GL11.glDepthMask(true); - GL11.glDisable(3042); - GL11.glEnable(2929); - } - - public static void doGlScissor(int x, int y, int width, int height2) { - Minecraft mc = Minecraft.getMinecraft(); - int scaleFactor = 1; - int k = mc.gameSettings.guiScale; - - if (k == 0) { - k = 1000; - } - - while (scaleFactor < k && mc.displayWidth / (scaleFactor + 1) >= 320 && mc.displayHeight / (scaleFactor + 1) >= 240) { - ++scaleFactor; - } - - GL11.glScissor(x * scaleFactor, mc.displayHeight - (y + height2) * scaleFactor, width * scaleFactor, height2 * scaleFactor); - } - - public static void drawRect(float left, float top, float right, float bottom, int color) { - float f3; - - if (left < right) { - f3 = left; - left = right; - right = f3; - } - - if (top < bottom) { - f3 = top; - top = bottom; - bottom = f3; - } - - f3 = (float) (color >> 24 & 255) / 255.0F; - float f = (float) (color >> 16 & 255) / 255.0F; - float f1 = (float) (color >> 8 & 255) / 255.0F; - float f2 = (float) (color & 255) / 255.0F; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer WorldRenderer2 = tessellator.getWorldRenderer(); - - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(f, f1, f2, f3); - WorldRenderer2.begin(7, DefaultVertexFormats.POSITION); - WorldRenderer2.pos((double) left, (double) bottom, 0.0D).endVertex(); - WorldRenderer2.pos((double) right, (double) bottom, 0.0D).endVertex(); - WorldRenderer2.pos((double) right, (double) top, 0.0D).endVertex(); - WorldRenderer2.pos((double) left, (double) top, 0.0D).endVertex(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - public static void circle(float x, float y, float radius, int fill) { - arc(x, y, 0.0F, 360.0F, radius, fill); - } - - public static void circle(float x, float y, float radius, Color fill) { - arc(x, y, 0.0F, 360.0F, radius, fill); - } - - public static void arc(float x, float y, float start, float end, float radius, int color) { - arcEllipse(x, y, start, end, radius, radius, color); - } - - public static void arc(float x, float y, float start, float end, float radius, Color color) { - arcEllipse(x, y, start, end, radius, radius, color); - } - - public static void arcEllipse(float x, float y, float start, float end, float w, float h, int color) { - GlStateManager.color(0.0F, 0.0F, 0.0F); - GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.0F); - float temp = 0.0F; - - if (start > end) { - temp = end; - end = start; - start = temp; - } - - float f = (float) (color >> 24 & 255) / 255.0F; - float f1 = (float) (color >> 16 & 255) / 255.0F; - float f2 = (float) (color >> 8 & 255) / 255.0F; - float f3 = (float) (color & 255) / 255.0F; - - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(f1, f2, f3, f); - float ldy; - float ldx; - float i; - - if (f > 0.5F) { - GL11.glEnable(2848); - GL11.glLineWidth(2.0F); - GL11.glBegin(3); - - for (i = end; i >= start; i -= 4.0F) { - ldx = (float) Math.cos((double) i * 3.141592653589793D / 180.0D) * w * 1.001F; - ldy = (float) Math.sin((double) i * 3.141592653589793D / 180.0D) * h * 1.001F; - GL11.glVertex2f(x + ldx, y + ldy); - } - - GL11.glEnd(); - GL11.glDisable(2848); - } - - GL11.glBegin(6); - - for (i = end; i >= start; i -= 4.0F) { - ldx = (float) Math.cos((double) i * 3.141592653589793D / 180.0D) * w; - ldy = (float) Math.sin((double) i * 3.141592653589793D / 180.0D) * h; - GL11.glVertex2f(x + ldx, y + ldy); - } - - GL11.glEnd(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - public static void arcEllipse(float x, float y, float start, float end, float w, float h, Color color) { - GlStateManager.color(0.0F, 0.0F, 0.0F); - GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.0F); - float temp = 0.0F; - - if (start > end) { - temp = end; - end = start; - start = temp; - } - - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color((float) color.getRed() / 255.0F, (float) color.getGreen() / 255.0F, (float) color.getBlue() / 255.0F, (float) color.getAlpha() / 255.0F); - float ldy; - float ldx; - float i; - - if ((float) color.getAlpha() > 0.5F) { - GL11.glEnable(2848); - GL11.glLineWidth(2.0F); - GL11.glBegin(3); - - for (i = end; i >= start; i -= 4.0F) { - ldx = (float) Math.cos((double) i * 3.141592653589793D / 180.0D) * w * 1.001F; - ldy = (float) Math.sin((double) i * 3.141592653589793D / 180.0D) * h * 1.001F; - GL11.glVertex2f(x + ldx, y + ldy); - } - - GL11.glEnd(); - GL11.glDisable(2848); - } - - GL11.glBegin(6); - - for (i = end; i >= start; i -= 4.0F) { - ldx = (float) Math.cos((double) i * 3.141592653589793D / 180.0D) * w; - ldy = (float) Math.sin((double) i * 3.141592653589793D / 180.0D) * h; - GL11.glVertex2f(x + ldx, y + ldy); - } - - GL11.glEnd(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - public static void drawRect(double d, double e, double g, double h, int color) { - int f3; - - if (d < g) { - f3 = (int) d; - d = g; - g = (double) f3; - } - - if (e < h) { - f3 = (int) e; - e = h; - h = (double) f3; - } - - float f31 = (float) (color >> 24 & 255) / 255.0F; - float f = (float) (color >> 16 & 255) / 255.0F; - float f1 = (float) (color >> 8 & 255) / 255.0F; - float f2 = (float) (color & 255) / 255.0F; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(f, f1, f2, f31); - worldrenderer.begin(7, DefaultVertexFormats.POSITION); - worldrenderer.pos(d, h, 0.0D).endVertex(); - worldrenderer.pos(g, h, 0.0D).endVertex(); - worldrenderer.pos(g, e, 0.0D).endVertex(); - worldrenderer.pos(d, e, 0.0D).endVertex(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - -} diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/SlightUI.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/SlightUI.java deleted file mode 100644 index 7d4ddff303..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/SlightUI.java +++ /dev/null @@ -1,445 +0,0 @@ -package net.ccbluex.liquidbounce.ui.clickgui.style.styles.Slight; - -import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.features.module.Module; -import net.ccbluex.liquidbounce.features.module.ModuleCategory; -import net.ccbluex.liquidbounce.features.value.*; -import net.ccbluex.liquidbounce.ui.font.Fonts; -import net.ccbluex.liquidbounce.ui.font.GameFontRenderer; -import net.ccbluex.liquidbounce.utils.render.Colors; -import net.ccbluex.liquidbounce.utils.timer.TimerUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiYesNoCallback; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class SlightUI extends GuiScreen implements GuiYesNoCallback { - - public static ModuleCategory currentModuleType = ModuleCategory.COMBAT; - public static Module currentModule = (Module) FDPClient.moduleManager.getModuleInCategory(currentModuleType).get(0); - public static float startX = 100.0F; - public static float startY = 85.0F; - public float moduleStart = 0.0F; - public int valueStart = 0; - boolean previousmouse = true; - boolean mouse; - boolean MIND = false; - public Opacity opacity = new Opacity(0); - public int opacityx = 255; - public float animationopacity = 0.0F; - public float animationMN = 0.0F; - public float animationX = 0.0F; - public float animationY = 0.0F; - public float moveX = 0.0F; - public float moveY = 0.0F; - private Color buttonColor = new Color(0, 0, 0); - public GameFontRenderer LogoFont; - boolean bind; - TimerUtils AnimationTimer; - private boolean isDraging; - private boolean clickNotDraging; - float animationDWheel; - int finheight; - float animheight; - public ArrayList modBooleanValue; - public ArrayList modModeValue; - public ArrayList modDoubleValue; - public ArrayList modIntValue; - public static Map doubleValueMap = new HashMap(); - public static Map IntValueMap = new HashMap(); - - public SlightUI() { - this.LogoFont = Fonts.fontSFUI35; - this.bind = false; - this.AnimationTimer = new TimerUtils(); - this.animheight = 0.0F; - this.modBooleanValue = new ArrayList(); - this.modModeValue = new ArrayList(); - this.modDoubleValue = new ArrayList(); - this.modIntValue = new ArrayList(); - } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - if (this.isHovered(startX - 10.0F, startY - 40.0F, startX + 280.0F, startY + 25.0F, mouseX, mouseY) && Mouse.isButtonDown(0)) { - if (this.moveX == 0.0F && this.moveY == 0.0F) { - this.moveX = (float) mouseX - startX; - this.moveY = (float) mouseY - startY; - } else { - startX = (float) mouseX - this.moveX; - startY = (float) mouseY - this.moveY; - } - - this.previousmouse = true; - } else if (this.moveX != 0.0F || this.moveY != 0.0F) { - this.moveX = 0.0F; - this.moveY = 0.0F; - } - - float scale = 1.0F; - ScaledResolution sr = new ScaledResolution(this.mc); - - if (sr.getScaledHeight() > 420 && sr.getScaledWidth() > 570) { - scale = 1.0F; - } else { - scale = 0.8F; - } - - RenderUtil.drawImage(new ResourceLocation("fdpclient/ui/clickgui/slight/background.png"), 0, 0, (int) ((float) sr.getScaledWidth() * (1.0F / scale)), (int) ((float) sr.getScaledHeight() * (1.0F / scale))); - this.opacity.interpolate((float) this.opacityx); - boolean countMod = false; - int[] counter = new int[1]; - int rainbowCol = UISlider.rainbow(System.nanoTime() * 3L, (float) counter[0], 1.0F).getRGB(); - Color col = new Color(rainbowCol); - int Ranbow = (new Color(0, col.getGreen() / 3 + 40, col.getGreen() / 2 + 100)).getRGB(); - int Ranbow1 = (new Color(0, col.getGreen() / 4 + 20, col.getGreen() / 2 + 100)).getRGB(); - - RenderUtil.drawDimRect((double) (startX - 40.0F), (double) (startY - 10.0F), (double) (startX + 300.0F), (double) (startY + 260.0F), Colors.getColor(32, 32, 32)); - RenderUtil.drawGradientRect2((double) (startX - 40.0F), (double) (startY - 12.0F), (double) (startX + 300.0F), (double) (startY - 10.0F), Ranbow, (new Color(4555775)).getRGB()); - RenderUtil.drawRect(startX + 65.0F, startY + 25.0F, startX + 165.0F, startY + 30.0F, (new Color(25, 145, 220)).getRGB()); - - int m; - - for (m = 0; m < ModuleCategory.values().length; ++m) { - ModuleCategory[] mY = ModuleCategory.values(); - - if (mY[m] == currentModuleType) { - this.finheight = m * 30; - RenderUtil.drawGradientRect2((double) (startX - 30.0F), (double) (startY + 30.0F + this.animheight), (double) (startX - 29.0F), (double) (startY + 40.0F + this.animheight), Ranbow, (new Color(4555775)).getRGB()); - this.animheight = (float) RenderUtil.getAnimationState((double) this.animheight, (double) this.finheight, (double) Math.max(100.0F, Math.abs((float) this.finheight - this.animheight) * 10.0F)); - if (this.animheight == (float) this.finheight) { - Fonts.fontSFUI35.drawString(mY[m].name(), startX - 25.0F, startY + 30.0F + (float) (m * 30), (new Color(255, 255, 255)).getRGB()); - } else { - Fonts.fontSFUI35.drawString(mY[m].name(), startX - 25.0F, startY + 30.0F + (float) (m * 30), (new Color(196, 196, 196)).getRGB()); - } - } else { - RenderUtil.drawRect(startX - 25.0F, startY + 50.0F + (float) (m * 30), startX + 60.0F, startY + 75.0F + (float) (m * 30), (new Color(255, 255, 255, 0)).getRGB()); - Fonts.fontSFUI35.drawString(mY[m].name(), startX - 25.0F, startY + 30.0F + (float) (m * 30), (new Color(196, 196, 196)).getRGB()); - } - - try { - if (this.isCategoryHovered(startX - 40.0F, startY + 20.0F + (float) (m * 30), startX + 60.0F, startY + 45.0F + (float) (m * 40), mouseX, mouseY) && Mouse.isButtonDown(0) && !this.MIND) { - currentModuleType = mY[m]; - currentModule = FDPClient.moduleManager.getModuleInCategory(currentModuleType).size() != 0 ? (Module) FDPClient.moduleManager.getModuleInCategory(currentModuleType).get(0) : null; - this.moduleStart = 0.0F; - } - } catch (Exception exception) { - System.err.println(exception); - } - } - - m = Mouse.getDWheel(); - if (this.isCategoryHovered(startX + 60.0F, startY, startX + 200.0F, startY + 235.0F, mouseX, mouseY) && !this.MIND) { - if (m < 0 && this.moduleStart < (float) (FDPClient.moduleManager.getModuleInCategory(currentModuleType).size() - 1)) { - ++this.moduleStart; - this.animationDWheel = (float) RenderUtil.getAnimationState((double) this.animationDWheel, 1.0D, 50.0D); - Minecraft.getMinecraft().thePlayer.playSound("random.click", 0.2F, 2.0F); - } - - if (m > 0 && this.moduleStart > 0.0F) { - --this.moduleStart; - this.moduleStart = (float) RenderUtil.getAnimationState((double) this.moduleStart, -1.0D, 50.0D); - Minecraft.getMinecraft().thePlayer.playSound("random.click", 0.2F, 2.0F); - } - } else { - this.animationDWheel = 0.0F; - } - - if (this.isCategoryHovered(startX - 40.0F, startY - 10.0F, startX + 300.0F, startY + 240.0F, mouseX, mouseY) && this.MIND) { - if (m < 0 && this.valueStart < currentModule.getValues().size() - 1) { - ++this.valueStart; - } - - if (m > 0 && this.valueStart > 0) { - --this.valueStart; - } - } - - if (currentModule != null) { - this.modBooleanValue.clear(); - this.modModeValue.clear(); - this.modDoubleValue.clear(); - this.modIntValue.clear(); - float f = startY + 30.0F; - - int font; - - for (font = 0; font < FDPClient.moduleManager.getModuleInCategory(currentModuleType).size(); ++font) { - Module value = (Module) FDPClient.moduleManager.getModuleInCategory(currentModuleType).get(font); - - if (f > startY + 220.0F) { - break; - } - - if ((float) font >= this.moduleStart) { - RenderUtil.drawRect(startX + 75.0F, f, startX + 185.0F, f + 2.0F, (new Color(246, 246, 246, 100)).getRGB()); - if (!value.getState()) { - RenderUtil.drawDimRect((double) (startX + 50.0F), (double) (f - 5.0F), (double) (startX + 285.0F), (double) (f + 20.0F), (new Color(38, 38, 37)).getRGB()); - if (SlightUI.currentModule.getValues().size() > 0) { - RenderUtil.drawDimRect((double) (startX + 270.0F), (double) (f - 5.0F), (double) (startX + 285.0F), (double) (f + 20.0F), (new Color(44, 44, 45)).getRGB()); - RenderUtil.circle(startX + 277.0F, f + 2.0F, 0.7F, new Color(95, 95, 95)); - RenderUtil.circle(startX + 277.0F, f + 7.0F, 0.7F, new Color(95, 95, 95)); - RenderUtil.circle(startX + 277.0F, f + 12.0F, 0.7F, new Color(95, 95, 95)); - } - } else { - RenderUtil.drawDimRect((double) (startX + 50.0F), (double) (f - 5.0F), (double) (startX + 285.0F), (double) (f + 20.0F), (new Color(55, 55, 55)).getRGB()); - } - - if (this.isSettingsButtonHovered(startX + 65.0F, f, startX + 285.0F, f + 8.0F + (float) Fonts.fontSFUI35.getStringWidth(""), mouseX, mouseY) && !this.MIND) { - this.animationopacity = (float) RenderUtil.getAnimationState((double) this.animationopacity, 0.30000001192092896D, 20.0D); - this.animationMN = (float) RenderUtil.getAnimationState((double) this.animationMN, 10.0D, 100.0D); - if (!value.getState()) { - Fonts.fontSFUI35.drawString(value.getName(), startX + 70.0F + this.animationMN, f + 4.0F, (new Color(240, 240, 240)).getRGB(), false); - } else { - Fonts.fontSFUI35.drawString(value.getName(), startX + 70.0F + this.animationMN, f + 4.0F, (new Color(255, 255, 255)).getRGB(), false); - } - } else { - this.animationopacity = (float) RenderUtil.getAnimationState((double) this.animationopacity, 0.0D, 20.0D); - this.animationMN = (float) RenderUtil.getAnimationState((double) this.animationMN, 0.0D, 100.0D); - if (value.getState()) { - Fonts.fontSFUI35.drawString(value.getName(), startX + 70.0F + this.animationMN, f + 4.0F, (new Color(200, 200, 200)).getRGB(), false); - } else { - Fonts.fontSFUI35.drawString(value.getName(), startX + 70.0F + this.animationMN, f + 4.0F, (new Color(190, 190, 190)).getRGB(), false); - } - } - - RenderUtil.drawRect(startX + 50.0F, f - 5.0F, startX + 285.0F, f + 20.0F, RenderUtil.reAlpha(Colors.WHITE.c, this.animationopacity)); - if (value.getState()) { - RenderUtil.drawGradientRect2((double) (startX + 50.0F), (double) (f - 5.0F), (double) (startX + 51.0F), (double) (f + 20.0F), Ranbow, (new Color(4555775)).getRGB()); - } - - if (this.isSettingsButtonHovered(startX + 65.0F, f, startX + 285.0F, f + 8.0F + (float) Fonts.fontSFUI35.getStringWidth(""), mouseX, mouseY) && !this.MIND) { - if (!this.previousmouse && Mouse.isButtonDown(0)) { - if (value.getState()) { - value.setState(false); - } else { - value.setState(true); - } - - this.previousmouse = true; - } - - if (!this.previousmouse && Mouse.isButtonDown(1)) { - this.previousmouse = true; - } - } - - if (!Mouse.isButtonDown(0) && !this.MIND) { - this.previousmouse = false; - } - - if (this.isSettingsButtonHovered(startX + 65.0F, f, startX + 285.0F + (float) Fonts.fontSFUI35.getStringWidth(value.getName()), f + 8.0F + (float) Fonts.fontSFUI35.getStringWidth(""), mouseX, mouseY) && Mouse.isButtonDown(1) && !this.MIND) { - currentModule = value; - Minecraft.getMinecraft().thePlayer.playSound("random.click", 0.5F, 4.0F); - this.valueStart = 0; - this.MIND = true; - } - - f += 30.0F; - } - } - - for (font = 0; font < currentModule.getValues().size(); ++font) { - Value value = (Value) currentModule.getValues().get(font); - - if (value instanceof BoolValue) { - this.modBooleanValue.add((BoolValue) value); - } - - if (value instanceof ListValue) { - this.modModeValue.add((ListValue) value); - } - - if (value instanceof FloatValue) { - this.modDoubleValue.add((FloatValue) value); - } - - if (value instanceof IntegerValue) { - this.modIntValue.add((IntegerValue) value); - } - } - - f = startY + 12.0F; - if (this.MIND) { - if (this.isCategoryHovered(startX - 40.0F, startY - 10.0F, startX + 300.0F, startY + 240.0F, mouseX, mouseY)) { - if (m < 0 && this.valueStart < (currentModule.getValues().size() - 1) * 12) { - this.valueStart += 12; - } - - if (m > 0 && this.valueStart - 12 >= 0) { - this.valueStart -= 12; - } else if (m > 0) { - this.valueStart = 0; - } - } - - if (this.animationX == 0.0F) { - ; - } - - this.animationX = (float) RenderUtil.getAnimationState((double) this.animationX, 390.0D, 600.0D); - this.animationY = (float) RenderUtil.getAnimationState((double) this.animationY, 120.0D, 800.0D); - GL11.glPushMatrix(); - GL11.glEnable(3089); - RenderUtil.doGlScissor((int) (startX - 40.0F), 0, (int) this.animationX, RenderUtil.height()); - RenderUtil.drawDimRect((double) (startX - 40.0F), (double) (startY - 10.0F), (double) (startX + 300.0F), (double) (startY + 8.0F), Colors.getColor(44, 44, 45)); - RenderUtil.drawDimRect((double) (startX - 40.0F), (double) (startY + 8.0F), (double) (startX + 300.0F), (double) (startY + 260.0F), Colors.getColor(37, 37, 38)); - RenderUtil.circle(startX + 292.0F, startY - 4.0F, 4.0F, (new Color(-14848033)).brighter()); - if (this.isSettingsButtonHovered(startX + 288.0F, startY - 6.0F, startX + 344.0F, startY + 2.0F, mouseX, mouseY) && Mouse.isButtonDown(0)) { - this.MIND = false; - } - - GameFontRenderer gamefontrenderer = Fonts.fontSFUI35; - - Fonts.fontSFUI35.drawString(currentModule.getName(), startX - 35.0F, startY - 8.0F, -1); - GL11.glPushMatrix(); - if (this.animationX == 390.0F) { - RenderUtil.doGlScissor((int) startX - 40, (int) startY + 8, (int) startX + 300, RenderUtil.height()); - } - - float x; - Iterator iterator; - - for (iterator = this.modBooleanValue.iterator(); iterator.hasNext(); f += 20.0F) { - BoolValue value1 = (BoolValue) iterator.next(); - - if (f - (float) this.valueStart > startY + 220.0F) { - break; - } - - Gui.drawRect(1, 1, 1, 1, -1); - x = startX + 250.0F; - gamefontrenderer.drawString(value1.getName(), startX - 30.0F, f - (float) this.valueStart, (new Color(255, 255, 255)).getRGB()); - if (((Boolean) value1.getValue()).booleanValue()) { - this.buttonColor = (new Color(-14848033)).brighter(); - } else { - this.buttonColor = new Color(80, 80, 80); - } - - RenderUtil.circle(x + 35.0F, f - (float) this.valueStart + 2.0F, 4.0F, this.buttonColor.getRGB()); - if (this.isCheckBoxHovered(x + 30.0F, f - (float) this.valueStart, x + 38.0F, f - (float) this.valueStart + 9.0F, mouseX, mouseY)) { - if (!this.previousmouse && Mouse.isButtonDown(0)) { - this.previousmouse = true; - this.mouse = true; - } - - if (this.mouse) { - value1.setValue(Boolean.valueOf(!((Boolean) value1.getValue()).booleanValue())); - this.mouse = false; - } - } - - if (!Mouse.isButtonDown(0)) { - this.previousmouse = false; - } - } - - UISlider uislider; - - for (iterator = this.modDoubleValue.iterator(); iterator.hasNext(); f += 22.0F) { - FloatValue floatvalue = (FloatValue) iterator.next(); - - if (f - (float) this.valueStart > startY + 220.0F) { - break; - } - - if (doubleValueMap.containsKey(floatvalue)) { - uislider = (UISlider) doubleValueMap.get(floatvalue); - } else { - uislider = new UISlider(floatvalue); - doubleValueMap.put(floatvalue, uislider); - } - - uislider.drawAll(startX + 45.0F, f - (float) this.valueStart, mouseX, mouseY); - } - - for (iterator = this.modIntValue.iterator(); iterator.hasNext(); f += 22.0F) { - IntegerValue integervalue = (IntegerValue) iterator.next(); - - if (f - (float) this.valueStart > startY + 220.0F) { - break; - } - - if (IntValueMap.containsKey(integervalue)) { - uislider = (UISlider) IntValueMap.get(integervalue); - } else { - uislider = new UISlider(integervalue); - IntValueMap.put(integervalue, uislider); - } - - uislider.drawAlll(startX + 45.0F, f - (float) this.valueStart, mouseX, mouseY); - } - - for (iterator = this.modModeValue.iterator(); iterator.hasNext(); f += 20.0F) { - ListValue listvalue = (ListValue) iterator.next(); - - if (f - (float) this.valueStart > startY + 220.0F) { - break; - } - - x = startX + 250.0F; - RenderUtil.drawRect(x - 40.0F, f - (float) this.valueStart - 1.0F, x + 40.0F, f - (float) this.valueStart + 12.0F, (new Color(60, 60, 60)).getRGB()); - Fonts.fontSFUI35.drawString(listvalue.getName(), startX - 30.0F, f - (float) this.valueStart, (new Color(255, 255, 255)).getRGB()); - Fonts.fontSFUI35.drawCenteredString((String) listvalue.getValue(), x - 2.0F, f - (float) this.valueStart + 2.0F, -1); - if (this.isStringHovered(x - 40.0F, f - (float) this.valueStart - 1.0F, x + 40.0F, f - (float) this.valueStart + 12.0F, mouseX, mouseY)) { - if (Mouse.isButtonDown(0) && !this.previousmouse) { - String current = (String) listvalue.getValue(); - - listvalue.set(listvalue.getValues()[listvalue.getModeListNumber(current) + 1 >= listvalue.getValues().length ? 0 : listvalue.getModeListNumber(current) + 1]); - this.previousmouse = true; - } - - if (!Mouse.isButtonDown(0)) { - this.previousmouse = false; - } - } - } - - GL11.glPopMatrix(); - GL11.glDisable(3089); - GL11.glPopMatrix(); - } else { - this.animationX = (float) RenderUtil.getAnimationState((double) this.animationX, 0.0D, 800.0D); - this.animationY = (float) RenderUtil.getAnimationState((double) this.animationY, 0.0D, 800.0D); - } - } - - } - - public boolean isStringHovered(float f, float y, float g, float y2, int mouseX, int mouseY) { - return (float) mouseX >= f && (float) mouseX <= g && (float) mouseY >= y && (float) mouseY <= y2; - } - - public boolean isSettingsButtonHovered(float x, float y, float x2, float y2, int mouseX, int mouseY) { - return (float) mouseX >= x && (float) mouseX <= x2 && (float) mouseY >= y && (float) mouseY <= y2; - } - - public boolean isButtonHovered(float f, float y, float g, float y2, int mouseX, int mouseY) { - return (float) mouseX >= f && (float) mouseX <= g && (float) mouseY >= y && (float) mouseY <= y2; - } - - public boolean isCheckBoxHovered(float f, float y, float g, float y2, int mouseX, int mouseY) { - return (float) mouseX >= f && (float) mouseX <= g && (float) mouseY >= y && (float) mouseY <= y2; - } - - public boolean isCategoryHovered(float x, float y, float x2, float y2, int mouseX, int mouseY) { - return (float) mouseX >= x && (float) mouseX <= x2 && (float) mouseY >= y && (float) mouseY <= y2; - } - - public boolean isHovered(float x, float y, float x2, float y2, int mouseX, int mouseY) { - return (float) mouseX >= x && (float) mouseX <= x2 && (float) mouseY >= y && (float) mouseY <= y2; - } - - public void onGuiClosed() { - this.opacity.setOpacity(0.0F); - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/UISlider.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/UISlider.java deleted file mode 100644 index e3001cd114..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/Slight/UISlider.java +++ /dev/null @@ -1,189 +0,0 @@ -package net.ccbluex.liquidbounce.ui.clickgui.style.styles.Slight; - -import net.ccbluex.liquidbounce.features.value.FloatValue; -import net.ccbluex.liquidbounce.features.value.IntegerValue; -import net.ccbluex.liquidbounce.ui.font.Fonts; -import net.ccbluex.liquidbounce.ui.font.GameFontRenderer; -import net.ccbluex.liquidbounce.utils.render.Colors; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import org.lwjgl.input.Mouse; - -import java.awt.*; - -public class UISlider { - - FloatValue value; - IntegerValue valuee; - public float x; - public float y; - public int x2; - public int y2; - private boolean isDraging; - private boolean clickNotDraging; - public boolean showValue; - public int tX; - public int tY; - public int dragX; - public int dragY; - float ani = 0.0F; - float aniH; - - public UISlider(FloatValue value) { - this.value = value; - } - - public UISlider(IntegerValue valuee) { - this.valuee = valuee; - } - - public static Color rainbow(long time, float count, float fade) { - float hue = ((float) time + (1.0E-9F + count) * 4.0E8F) / 1.75000003E10F * 3.0F; - long color = Long.parseLong(Integer.toHexString(Integer.valueOf(Color.HSBtoRGB(hue, 0.5F, 1.0F)).intValue()), 16); - Color c = new Color((int) color); - - return new Color((float) c.getRed() / 255.0F * fade, (float) c.getGreen() / 255.0F * fade, (float) c.getBlue() / 255.0F * fade, (float) c.getAlpha() / 255.0F); - } - - public void draw(float x, float y) { - boolean countMod = false; - int[] counter = new int[1]; - int rainbowCol = rainbow(System.nanoTime() * 3L, (float) counter[0], 1.0F).getRGB(); - Color col = new Color(rainbowCol); - int Ranbow = (new Color(0, col.getGreen() / 3 + 40, col.getGreen() / 2 + 100)).getRGB(); - int Ranbow1 = (new Color(0, col.getGreen() / 3 + 20, col.getGreen() / 2 + 100)).getRGB(); - GameFontRenderer tahoma20 = Fonts.font35; - float n = (((Float) this.value.getValue()).floatValue() - this.value.getMinimum()) / (this.value.getMaximum() - this.value.getMinimum()); - - tahoma20.drawString(this.value.getName(), x - 75.0F, y - 3.0F, Colors.WHITE.c); - Fonts.font35.drawString(this.value.getValue() + "", x + 250.0F - (float) Fonts.font35.getStringWidth(this.value.getValue() + ""), y - 1.0F, (new Color(Colors.GREY.c)).brighter().brighter().getRGB()); - if (this.ani == 0.0F) { - this.ani = (float) ((double) (x + 250.0F) - (370.0D - 370.0D * (double) n)); - } - - this.ani = (float) RenderUtil.getAnimationState((double) this.ani, (double) ((float) ((double) (x + 250.0F) - (370.0D - 370.0D * (double) n))), (double) ((float) Math.max(10.0D, Math.abs((double) this.ani - ((double) (x + 120.0F) - (370.0D - 370.0D * (double) n))) * 30.0D * 0.3D))); - if (this.showValue) { - ; - } - - RenderUtil.drawRect(x - 75.0F, y + 3.0F + 11.0F, x + 250.0F, y + 4.0F + 11.0F, (new Color(60, 60, 60)).getRGB()); - RenderUtil.drawGradientRect2((double) (x - 75.0F), (double) (y + 3.0F + 11.0F), (double) this.ani, (double) (y + 4.0F + 11.0F), Ranbow, (new Color(4555775)).getRGB()); - } - - public void draww(float x, float y) { - boolean countMod = false; - int[] counter = new int[1]; - int rainbowCol = rainbow(System.nanoTime() * 3L, (float) counter[0], 1.0F).getRGB(); - Color col = new Color(rainbowCol); - int Ranbow = (new Color(0, col.getGreen() / 3 + 40, col.getGreen() / 2 + 100)).getRGB(); - int Ranbow1 = (new Color(0, col.getGreen() / 3 + 20, col.getGreen() / 2 + 100)).getRGB(); - GameFontRenderer tahoma20 = Fonts.font35; - int n = (((Integer) this.valuee.getValue()).intValue() - this.valuee.getMinimum()) / (this.valuee.getMaximum() - this.valuee.getMinimum()); - - tahoma20.drawString(this.valuee.getName(), x - 75.0F, y - 3.0F, Colors.WHITE.c); - Fonts.font35.drawString(this.valuee.getValue() + "", x + 250.0F - (float) Fonts.font35.getStringWidth(this.valuee.getValue() + ""), y - 1.0F, (new Color(Colors.GREY.c)).brighter().brighter().getRGB()); - if (this.ani == 0.0F) { - this.ani = (float) ((double) (x + 250.0F) - (370.0D - 370.0D * (double) n)); - } - - this.ani = (float) RenderUtil.getAnimationState((double) this.ani, (double) ((float) ((double) (x + 250.0F) - (370.0D - 370.0D * (double) n))), (double) ((float) Math.max(10.0D, Math.abs((double) this.ani - ((double) (x + 120.0F) - (370.0D - 370.0D * (double) n))) * 30.0D * 0.3D))); - if (this.showValue) { - ; - } - - RenderUtil.drawRect(x - 75.0F, y + 3.0F + 11.0F, x + 250.0F, y + 4.0F + 11.0F, (new Color(60, 60, 60)).getRGB()); - RenderUtil.drawGradientRect2((double) (x - 75.0F), (double) (y + 3.0F + 11.0F), (double) this.ani, (double) (y + 4.0F + 11.0F), Ranbow, (new Color(4555775)).getRGB()); - } - - public void drawAll(float x, float y, int tx, int ty) { - this.x = x; - this.y = y; - - new ScaledResolution(Minecraft.getMinecraft()); - - if (this.isHovered(tx, ty, this.x - 100.0F, this.y - 3.0F + 11.0F, this.x - 10.0F, this.y + 10.0F + 11.0F)) { - this.showValue = true; - } else { - this.showValue = false; - } - - if (Mouse.isButtonDown(0)) { - if (!this.isHovered(tx, ty, this.x - 75.0F, this.y - 3.0F + 11.0F, this.x + 250.0F, this.y + 10.0F + 11.0F) && !this.isDraging) { - this.clickNotDraging = true; - } else { - this.isDraging = true; - } - - if (this.isDraging && !this.clickNotDraging) { - float n = ((float) tx - this.x + 120.0F) / 370.0F; - - if ((double) n < 0.0D) { - n = 0.0F; - } - - if ((double) n > 1.0D) { - n = 1.0F; - } - - float n2 = (float) Math.round(this.value.getMaximum() - this.value.getMinimum()) * n + this.value.getMinimum() * 100.0F / 100.0F; - - this.value.set((Number) Float.valueOf(n2)); - } - } else { - this.isDraging = false; - this.clickNotDraging = false; - } - - this.tX = tx; - this.tY = ty; - this.draw(x, y); - } - - public void drawAlll(float x, float y, int tx, int ty) { - this.x = x; - this.y = y; - - new ScaledResolution(Minecraft.getMinecraft()); - - if (this.isHovered(tx, ty, this.x - 100.0F, this.y - 3.0F + 11.0F, this.x - 10.0F, this.y + 10.0F + 11.0F)) { - this.showValue = true; - } else { - this.showValue = false; - } - - if (Mouse.isButtonDown(0)) { - if (!this.isHovered(tx, ty, this.x - 75.0F, this.y - 3.0F + 11.0F, this.x + 250.0F, this.y + 10.0F + 11.0F) && !this.isDraging) { - this.clickNotDraging = true; - } else { - this.isDraging = true; - } - - if (this.isDraging && !this.clickNotDraging) { - int n = (tx - this.x2 + 120) / 370; - - if (n < 0) { - n = 0; - } - - if (n > 1) { - n = 1; - } - - int n2 = (int) ((double) (Math.round((float) (this.valuee.getMaximum() - this.valuee.getMinimum())) * n) + (double) this.valuee.getMinimum() * 1.0D / 1.0D); - - this.valuee.set((Number) Integer.valueOf(n2)); - } - } else { - this.isDraging = false; - this.clickNotDraging = false; - } - - this.tX = tx; - this.tY = ty; - this.draww(x, y); - } - - public boolean isHovered(int mouseX, int mouseY, float x, float y, float x2, float y2) { - return (float) mouseX >= x && (float) mouseX <= x2 && (float) mouseY >= y && (float) mouseY <= y2; - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/SlowlyStyle.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/SlowlyStyle.java deleted file mode 100644 index 4f59b5dfe7..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/SlowlyStyle.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.ui.clickgui.style.styles; - -import net.ccbluex.liquidbounce.ui.clickgui.Panel; -import net.ccbluex.liquidbounce.ui.clickgui.elements.ButtonElement; -import net.ccbluex.liquidbounce.ui.clickgui.elements.ModuleElement; -import net.ccbluex.liquidbounce.ui.clickgui.style.Style; -import net.ccbluex.liquidbounce.ui.font.Fonts; -import net.ccbluex.liquidbounce.ui.font.GameFontRenderer; -import net.ccbluex.liquidbounce.ui.i18n.LanguageManager; -import net.ccbluex.liquidbounce.utils.block.BlockUtils; -import net.ccbluex.liquidbounce.utils.render.RenderUtils; -import net.ccbluex.liquidbounce.features.value.*; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StringUtils; -import org.lwjgl.input.Mouse; - -import java.awt.*; -import java.math.BigDecimal; -import java.util.List; - -public class SlowlyStyle extends Style { - - private boolean mouseDown; - private boolean rightMouseDown; - - public static float drawSlider(final float value, final float min, final float max, final int x, final int y, final int width, final int mouseX, final int mouseY, final Color color) { - final float displayValue = Math.max(min, Math.min(value, max)); - - final float sliderValue = (float) x + (float) width * (displayValue - min) / (max - min); - - RenderUtils.drawRect(x, y, x + width, y + 2, Integer.MAX_VALUE); - RenderUtils.drawRect(x, y, sliderValue, y + 2, color); - RenderUtils.drawFilledCircle((int) sliderValue, y + 1, 3, color); - - if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 3 && Mouse.isButtonDown(0)) { - double i = MathHelper.clamp_double(((double) mouseX - (double) x) / ((double) width - 3), 0, 1); - - BigDecimal bigDecimal = new BigDecimal(Double.toString((min + (max - min) * i))); - bigDecimal = bigDecimal.setScale(2, 4); - return bigDecimal.floatValue(); - } - - return value; - } - - @Override - public void drawPanel(int mouseX, int mouseY, Panel panel) { - RenderUtils.drawBorderedRect((float) panel.getX(), (float) panel.getY() - 3, (float) panel.getX() + panel.getWidth(), (float) panel.getY() + 17, 3, new Color(42, 57, 79).getRGB(), new Color(42, 57, 79).getRGB()); - if (panel.getFade() > 0) { - RenderUtils.drawBorderedRect((float) panel.getX(), (float) panel.getY() + 17, (float) panel.getX() + panel.getWidth(), panel.getY() + 19 + panel.getFade(), 3, new Color(54, 71, 96).getRGB(), new Color(54, 71, 96).getRGB()); - RenderUtils.drawBorderedRect((float) panel.getX(), panel.getY() + 17 + panel.getFade(), (float) panel.getX() + panel.getWidth(), panel.getY() + 19 + panel.getFade() + 5, 3, new Color(42, 57, 79).getRGB(), new Color(42, 57, 79).getRGB()); - } - GlStateManager.resetColor(); - float textWidth = Fonts.font35.getStringWidth("§f" + StringUtils.stripControlCodes(LanguageManager.INSTANCE.get(panel.getName().replaceAll("%","")))); - Fonts.font35.drawString(LanguageManager.INSTANCE.get(panel.getName().replaceAll("%","")), (int) (panel.getX() - (textWidth - 100.0F) / 2F), panel.getY() + 7 - 3, Color.WHITE.getRGB()); - } - - @Override - public void drawDescription(int mouseX, int mouseY, String text) { - int textWidth = Fonts.font35.getStringWidth(LanguageManager.INSTANCE.get(text.replaceAll("%",""))); - - RenderUtils.drawBorderedRect(mouseX + 9, mouseY, mouseX + textWidth + 14, mouseY + Fonts.font35.FONT_HEIGHT + 3, 3F, new Color(42, 57, 79).getRGB(), new Color(42, 57, 79).getRGB()); - GlStateManager.resetColor(); - Fonts.font35.drawString(LanguageManager.INSTANCE.get(text.replaceAll("%","")), mouseX + 12, mouseY + (Fonts.font35.FONT_HEIGHT / 2), Color.WHITE.getRGB()); - } - - @Override - public void drawButtonElement(int mouseX, int mouseY, ButtonElement buttonElement) { - Gui.drawRect(buttonElement.getX() - 1, buttonElement.getY() - 1, buttonElement.getX() + buttonElement.getWidth() + 1, buttonElement.getY() + buttonElement.getHeight() + 1, hoverColor(buttonElement.getColor() != Integer.MAX_VALUE ? new Color(7, 152, 252) : new Color(54, 71, 96), buttonElement.hoverTime).getRGB()); - - GlStateManager.resetColor(); - - Fonts.font35.drawString(LanguageManager.INSTANCE.get(buttonElement.getDisplayName().replaceAll("%","")), buttonElement.getX() + 5, buttonElement.getY() + 5, Color.WHITE.getRGB()); - } - - /*public static boolean drawCheckbox(final boolean value, final int x, final int y, final int mouseX, final int mouseY, final Color color) { - RenderUtils.drawRect(x, y, x + 20, y + 10, value ? Color.GREEN : Color.RED); - RenderUtils.drawFilledCircle(x + (value ? 15 : 5),y + 5, 5, Color.WHITE); - - if(mouseX >= x && mouseX <= x + 20 && mouseY >= y && mouseY <= y + 10 && Mouse.isButtonDown(0)) - return !value; - - return value; - }*/ - - @Override - public void drawModuleElement(int mouseX, int mouseY, ModuleElement moduleElement) { - Gui.drawRect(moduleElement.getX() - 1, moduleElement.getY() - 1, moduleElement.getX() + moduleElement.getWidth() + 1, moduleElement.getY() + moduleElement.getHeight() + 1, hoverColor(new Color(54, 71, 96), moduleElement.hoverTime).getRGB()); - Gui.drawRect(moduleElement.getX() - 1, moduleElement.getY() - 1, moduleElement.getX() + moduleElement.getWidth() + 1, moduleElement.getY() + moduleElement.getHeight() + 1, hoverColor(new Color(7, 152, 252, moduleElement.slowlyFade), moduleElement.hoverTime).getRGB()); - GlStateManager.resetColor(); - Fonts.font35.drawString(LanguageManager.INSTANCE.get(moduleElement.getDisplayName().replaceAll("%","")), moduleElement.getX() + 5, moduleElement.getY() + 5, Color.WHITE.getRGB()); - - // Draw settings - final List> moduleValues = moduleElement.getModule().getValues(); - - if (!moduleValues.isEmpty()) { - Fonts.font35.drawString(">", moduleElement.getX() + moduleElement.getWidth() - 8, moduleElement.getY() + 5, Color.WHITE.getRGB()); - - if (moduleElement.isShowSettings()) { - if (moduleElement.getSettingsWidth() > 0F && moduleElement.slowlySettingsYPos > moduleElement.getY() + 6) - RenderUtils.drawBorderedRect(moduleElement.getX() + moduleElement.getWidth() + 4, moduleElement.getY() + 6, moduleElement.getX() + moduleElement.getWidth() + moduleElement.getSettingsWidth(), moduleElement.slowlySettingsYPos + 2, 3F, new Color(54, 71, 96).getRGB(), new Color(54, 71, 96).getRGB()); - - moduleElement.slowlySettingsYPos = moduleElement.getY() + 6; - for (final Value value : moduleValues) { - if(!value.getDisplayable()) - continue; - - if (value instanceof BoolValue) { - final String text = value.getName(); - final float textWidth = Fonts.font35.getStringWidth(text); - - if (moduleElement.getSettingsWidth() < textWidth + 8) - moduleElement.setSettingsWidth(textWidth + 8); - - if (mouseX >= moduleElement.getX() + moduleElement.getWidth() + 4 && mouseX <= moduleElement.getX() + moduleElement.getWidth() + moduleElement.getSettingsWidth() && mouseY >= moduleElement.slowlySettingsYPos && mouseY <= moduleElement.slowlySettingsYPos + 12 && Mouse.isButtonDown(0) && moduleElement.isntPressed()) { - final BoolValue boolValue = (BoolValue) value; - - boolValue.set(!boolValue.get()); - mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - } - - Fonts.font35.drawString(text, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 2, ((BoolValue) value).get() ? Color.WHITE.getRGB() : Integer.MAX_VALUE); - moduleElement.slowlySettingsYPos += 11; - } else if (value instanceof ListValue) { - final ListValue listValue = (ListValue) value; - - final String text = value.getName(); - final float textWidth = Fonts.font35.getStringWidth(text); - - if (moduleElement.getSettingsWidth() < textWidth + 16) - moduleElement.setSettingsWidth(textWidth + 16); - - Fonts.font35.drawString(text, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 2, 0xffffff); - Fonts.font35.drawString(listValue.openList ? "-" : "+", (int) (moduleElement.getX() + moduleElement.getWidth() + moduleElement.getSettingsWidth() - (listValue.openList ? 5 : 6)), moduleElement.slowlySettingsYPos + 2, 0xffffff); - - if (mouseX >= moduleElement.getX() + moduleElement.getWidth() + 4 && mouseX <= moduleElement.getX() + moduleElement.getWidth() + moduleElement.getSettingsWidth() && mouseY >= moduleElement.slowlySettingsYPos && mouseY <= moduleElement.slowlySettingsYPos + Fonts.font35.FONT_HEIGHT && Mouse.isButtonDown(0) && moduleElement.isntPressed()) { - listValue.openList = !listValue.openList; - mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - } - - moduleElement.slowlySettingsYPos += Fonts.font35.FONT_HEIGHT + 1; - - for (final String valueOfList : listValue.getValues()) { - final float textWidth2 = Fonts.font35.getStringWidth("> " + valueOfList); - - if (moduleElement.getSettingsWidth() < textWidth2 + 12) - moduleElement.setSettingsWidth(textWidth2 + 12); - - if (listValue.openList) { - if (mouseX >= moduleElement.getX() + moduleElement.getWidth() + 4 && mouseX <= moduleElement.getX() + moduleElement.getWidth() + moduleElement.getSettingsWidth() && mouseY >= moduleElement.slowlySettingsYPos + 2 && mouseY <= moduleElement.slowlySettingsYPos + 14 && Mouse.isButtonDown(0) && moduleElement.isntPressed()) { - listValue.set(valueOfList); - mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - } - - GlStateManager.resetColor(); - Fonts.font35.drawString("> " + valueOfList, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 2, listValue.get() != null && listValue.get().equalsIgnoreCase(valueOfList) ? Color.WHITE.getRGB() : Integer.MAX_VALUE); - moduleElement.slowlySettingsYPos += Fonts.font35.FONT_HEIGHT + 1; - } - } - - if (!listValue.openList) { - moduleElement.slowlySettingsYPos += 1; - } - } else if (value instanceof FloatValue) { - final FloatValue floatValue = (FloatValue) value; - final String text = value.getName() + "§f: " + round(floatValue.get()); - final float textWidth = Fonts.font35.getStringWidth(text); - - if (moduleElement.getSettingsWidth() < textWidth + 8) - moduleElement.setSettingsWidth(textWidth + 8); - - final float valueOfSlide = drawSlider(floatValue.get(), floatValue.getMinimum(), floatValue.getMaximum(), moduleElement.getX() + moduleElement.getWidth() + 8, moduleElement.slowlySettingsYPos + 14, (int) moduleElement.getSettingsWidth() - 12, mouseX, mouseY, new Color(7, 152, 252)); - - if (valueOfSlide != floatValue.get()) - floatValue.set(valueOfSlide); - - Fonts.font35.drawString(text, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 3, 0xffffff); - moduleElement.slowlySettingsYPos += 19; - } else if (value instanceof IntegerValue) { - final IntegerValue integerValue = (IntegerValue) value; - final String text = value.getName() + "§f: " + (value instanceof BlockValue ? BlockUtils.getBlockName(integerValue.get()) + " (" + integerValue.get() + ")" : integerValue.get()); - final float textWidth = Fonts.font35.getStringWidth(text); - - if (moduleElement.getSettingsWidth() < textWidth + 8) - moduleElement.setSettingsWidth(textWidth + 8); - - final float valueOfSlide = drawSlider(integerValue.get(), integerValue.getMinimum(), integerValue.getMaximum(), moduleElement.getX() + moduleElement.getWidth() + 8, moduleElement.slowlySettingsYPos + 14, (int) moduleElement.getSettingsWidth() - 12, mouseX, mouseY, new Color(7, 152, 252)); - - if (valueOfSlide != integerValue.get()) - integerValue.set((int) valueOfSlide); - - Fonts.font35.drawString(text, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 3, 0xffffff); - moduleElement.slowlySettingsYPos += 19; - } else if (value instanceof FontValue) { - final FontValue fontValue = (FontValue) value; - final FontRenderer fontRenderer = fontValue.get(); - - String displayString = "Font: Unknown"; - - if (fontRenderer instanceof GameFontRenderer) { - final GameFontRenderer liquidFontRenderer = (GameFontRenderer) fontRenderer; - - displayString = "Font: " + liquidFontRenderer.getDefaultFont().getFont().getName() + " - " + liquidFontRenderer.getDefaultFont().getFont().getSize(); - } else if (fontRenderer == Fonts.minecraftFont) - displayString = "Font: Minecraft"; - else { - final Object[] objects = Fonts.getFontDetails(fontRenderer); - - if (objects != null) { - displayString = objects[0] + ((int) objects[1] != -1 ? " - " + objects[1] : ""); - } - } - - Fonts.font35.drawString(displayString, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 2, Color.WHITE.getRGB()); - int stringWidth = Fonts.font35.getStringWidth(displayString); - - if (moduleElement.getSettingsWidth() < stringWidth + 8) - moduleElement.setSettingsWidth(stringWidth + 8); - - if ((Mouse.isButtonDown(0) && !mouseDown || Mouse.isButtonDown(1) && !rightMouseDown) && mouseX >= moduleElement.getX() + moduleElement.getWidth() + 4 && mouseX <= moduleElement.getX() + moduleElement.getWidth() + moduleElement.getSettingsWidth() && mouseY >= moduleElement.slowlySettingsYPos && mouseY <= moduleElement.slowlySettingsYPos + 12) { - final List fonts = Fonts.getFonts(); - - if (Mouse.isButtonDown(0)) { - for (int i = 0; i < fonts.size(); i++) { - final FontRenderer font = fonts.get(i); - - if (font == fontRenderer) { - i++; - - if (i >= fonts.size()) - i = 0; - - fontValue.set(fonts.get(i)); - break; - } - } - } else { - for (int i = fonts.size() - 1; i >= 0; i--) { - final FontRenderer font = fonts.get(i); - - if (font == fontRenderer) { - i--; - - if (i >= fonts.size()) - i = 0; - - if (i < 0) - i = fonts.size() - 1; - - fontValue.set(fonts.get(i)); - break; - } - } - } - } - - moduleElement.slowlySettingsYPos += 11; - } else { - final String text = value.getName() + "§f: " + value.get(); - final float textWidth = Fonts.font35.getStringWidth(text); - - if (moduleElement.getSettingsWidth() < textWidth + 8) - moduleElement.setSettingsWidth(textWidth + 8); - - GlStateManager.resetColor(); - Fonts.font35.drawString(text, moduleElement.getX() + moduleElement.getWidth() + 6, moduleElement.slowlySettingsYPos + 4, 0xffffff); - moduleElement.slowlySettingsYPos += 12; - } - } - - moduleElement.updatePressed(); - mouseDown = Mouse.isButtonDown(0); - rightMouseDown = Mouse.isButtonDown(1); - } - } - } - - private BigDecimal round(final float v) { - BigDecimal bigDecimal = new BigDecimal(Float.toString(v)); - bigDecimal = bigDecimal.setScale(2, 4); - return bigDecimal; - } - - private Color hoverColor(final Color color, final int hover) { - final int r = color.getRed() - (hover * 2); - final int g = color.getGreen() - (hover * 2); - final int b = color.getBlue() - (hover * 2); - - return new Color(Math.max(r, 0), Math.max(g, 0), Math.max(b, 0), color.getAlpha()); - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt new file mode 100644 index 0000000000..9afd63e4ed --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt @@ -0,0 +1,66 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ +package net.ccbluex.liquidbounce.ui.client.gui + +import net.ccbluex.liquidbounce.FDPClient +import net.ccbluex.liquidbounce.features.command.CommandManager +import net.ccbluex.liquidbounce.handler.combat.CombatManager +import net.ccbluex.liquidbounce.ui.sound.TipSoundManager +import net.ccbluex.liquidbounce.utils.misc.MiscUtils +import net.ccbluex.liquidbounce.utils.render.RenderUtils +import net.minecraft.client.gui.GuiButton +import net.minecraft.client.gui.GuiScreen +import net.minecraft.util.ResourceLocation + +import org.lwjgl.input.Keyboard + +class GuiInfo(private val prevGui: GuiScreen) : GuiScreen() { + + private val BUTTON_VERSIONS = 2 + + override fun initGui() { + buttonList.add(GuiButton(1, width / 2 - 100, height / 4 + 20 + 4, "Tools")) + buttonList.add(GuiButton(2, width / 2 - 100, height / 4 + 55 + 2, "Version")) + buttonList.add(GuiButton(3, width / 2 - 100, height / 4 + 90 - 2, "Website")) + buttonList.add(GuiButton(4, width / 2 - 100, height / 4 + 125 - 4, "Staff")) + buttonList.add(GuiButton(5, width / 2 - 100, height / 4 + 160 - 6, "Reload")) + buttonList.add(GuiButton(6, width / 2 - 100, height / 4 + 195 - 8, "Done")) + super.initGui() + } + + override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { + drawDefaultBackground() + RenderUtils.drawImage(ResourceLocation("fdpclient/ui/mainmenu/portal.png"), 0, 0, width, height) + super.drawScreen(mouseX, mouseY, partialTicks) + } + + override fun keyTyped(typedChar: Char, keyCode: Int) { + if (keyCode == Keyboard.KEY_ESCAPE) { + mc.displayGuiScreen(prevGui) + } + super.keyTyped(typedChar, keyCode) + } + + override fun actionPerformed(button: GuiButton) { + when (button.id) { + 2 -> BUTTON_VERSIONS + 3 -> MiscUtils.showURL(FDPClient.CLIENT_WEBSITE) + 5 -> { + FDPClient.commandManager = CommandManager() + FDPClient.commandManager.registerCommands() + for (module in FDPClient.moduleManager.modules) + FDPClient.moduleManager.generateCommand(module) + FDPClient.tipSoundManager = TipSoundManager() + FDPClient.combatManager = CombatManager() + FDPClient.fileManager.loadConfig(FDPClient.fileManager.hudConfig) + FDPClient.fileManager.loadConfig(FDPClient.fileManager.accountsConfig) + FDPClient.fileManager.loadConfig(FDPClient.fileManager.friendsConfig) + } + 6 -> mc.displayGuiScreen(prevGui) + // BUTTON_VERSIONS -> mc.displayGuiScreen(GuiProtocolSelector(this)) + } + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiMainMenu.java b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiMainMenu.java index 657af45e23..784957c6b3 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiMainMenu.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiMainMenu.java @@ -14,7 +14,6 @@ import net.minecraft.client.gui.*; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.GuiModList; import java.awt.*; import java.io.IOException; @@ -31,7 +30,7 @@ public void initGui() { this.butt.add(new MainMenuButton("G", "SinglePlayer", () -> this.mc.displayGuiScreen(new GuiSelectWorld(this)))); this.butt.add(new MainMenuButton("H", "MultiPlayer", () -> this.mc.displayGuiScreen(new GuiMultiplayer(this)))); this.butt.add(new MainMenuButton("I", "AltManager", () -> this.mc.displayGuiScreen(new GuiAltManager(this)))); - this.butt.add(new MainMenuButton("J", "Mods", () -> this.mc.displayGuiScreen(new GuiModList(this)), 0.5F)); + this.butt.add(new MainMenuButton("J", "Misc", () -> this.mc.displayGuiScreen(new GuiInfo(this)), 0.5F)); this.butt.add(new MainMenuButton("K", "Options", () -> this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)))); this.butt.add(new MainMenuButton("L", "Languages", () -> this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager())))); this.butt.add(new MainMenuButton("M", "Quit", () -> this.mc.shutdown())); diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt b/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt index 7e4a5290af..b399f72204 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt @@ -5,8 +5,6 @@ */ package net.ccbluex.liquidbounce.ui.client.hud.element.elements -import cc.paimonmc.viamcp.ViaMCP -import cc.paimonmc.viamcp.protocols.ProtocolCollection import net.ccbluex.liquidbounce.FDPClient import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner import net.ccbluex.liquidbounce.ui.client.hud.element.Border @@ -130,7 +128,6 @@ class Text( "cps", "lcps" -> return CPSCounter.getCPS(CPSCounter.MouseButton.LEFT).toString() "mcps" -> return CPSCounter.getCPS(CPSCounter.MouseButton.MIDDLE).toString() "rcps" -> return CPSCounter.getCPS(CPSCounter.MouseButton.RIGHT).toString() - "portalVersion" -> ProtocolCollection.getProtocolById(ViaMCP.getInstance().version).getName() else -> null // Null = don't replace } } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/item/ilegalItems.java b/src/main/java/net/ccbluex/liquidbounce/utils/item/ilegalItems.java deleted file mode 100644 index c4ba42e2f3..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/utils/item/ilegalItems.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.utils.item; - -import net.ccbluex.liquidbounce.utils.MinecraftInstance; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -import java.util.Objects; -import java.util.regex.Pattern; - -public final class ilegalItems extends MinecraftInstance { - - public static ItemStack createItem(String itemArguments) { - try { - itemArguments = itemArguments.replace('&', '§'); - Item item = new Item(); - String[] args = null; - int i = 1; - int j = 0; - - for (int mode = 0; mode <= Math.min(12, itemArguments.length() - 2); ++mode) { - args = itemArguments.substring(mode).split(Pattern.quote(" ")); - ResourceLocation resourcelocation = new ResourceLocation(args[0]); - item = Item.itemRegistry.getObject(resourcelocation); - - if (item != null) - break; - } - - if (item == null) - return null; - - if (Objects.requireNonNull(args).length >= 2 && args[1].matches("\\d+")) - i = Integer.parseInt(args[1]); - if (args.length >= 3 && args[2].matches("\\d+")) - j = Integer.parseInt(args[2]); - - ItemStack itemstack = new ItemStack(item, i, j); - - if (args.length >= 4) { - StringBuilder NBT = new StringBuilder(); - for (int nbtcount = 3; nbtcount < args.length; ++nbtcount) - NBT.append(" ").append(args[nbtcount]); - itemstack.setTagCompound(JsonToNBT.getTagFromJson(NBT.toString())); - } - - return itemstack; - } catch (Exception exception) { - exception.printStackTrace(); - return null; - } - } - -} diff --git a/src/main/resources/mixins.fdpclient.json b/src/main/resources/mixins.fdpclient.json index cde30c9985..485b33781f 100644 --- a/src/main/resources/mixins.fdpclient.json +++ b/src/main/resources/mixins.fdpclient.json @@ -14,6 +14,7 @@ "render.MixinLayerArmorBase", "render.MixinRender", "block.MixinBlock", + "block.MixinItemBlock", "block.MixinBlockAnvil", "block.MixinBlockModelRenderer", "block.MixinBlockSoulSand", @@ -64,7 +65,11 @@ "network.MixinC17PacketCustomPayload", "network.MixinS3FPacketCustomPayload", "network.MixinBlockedServers", - "network.MixinNetworkManagerChInit", + "network.MixinGuiConnecting_1", + "network.MixinNetworkManager_5", + "network.MixinServerData", + "network.MixinNetworkPlayerInfo", + "network.MixinServerPinger", "performance.MixinBlock", "performance.MixinChunk", "performance.MixinWorld",