Skip to content

Commit

Permalink
Merge pull request #10 from MeteorDevelopment/master
Browse files Browse the repository at this point in the history
update from upstream - Releasing precompiled soon.
  • Loading branch information
crazycrystals committed Aug 11, 2023
2 parents 68b7bd4 + 6799f8e commit 3de97fd
Show file tree
Hide file tree
Showing 32 changed files with 389 additions and 112 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ archives_base_name=meteor-client
# Dependency Versions

# Sodium (https://github.com/CaffeineMC/sodium-fabric)
sodium_version=mc1.20-0.4.10
sodium_version=mc1.20.1-0.5.0

# Lithium (https://github.com/CaffeineMC/lithium-fabric)
lithium_version=mc1.20-0.11.2

# Iris (https://github.com/IrisShaders/Iris)
iris_version=1.6.4+1.20
iris_version=1.6.5+1.20.1

# Orbit (https://github.com/MeteorDevelopment/orbit)
orbit_version=0.2.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MixinPlugin implements IMixinConfigPlugin {

private static boolean isOriginsPresent;
private static boolean isIndigoPresent;
private static boolean isSodiumPresent;
public static boolean isSodiumPresent;
private static boolean isCanvasPresent;
private static boolean isLithiumPresent;
public static boolean isIrisPresent;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.events.world;

import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;

public class ServerConnectBeginEvent {
private static final ServerConnectBeginEvent INSTANCE = new ServerConnectBeginEvent();
public ServerAddress address;
public ServerInfo info;

public static ServerConnectBeginEvent get(ServerAddress address, ServerInfo info) {
INSTANCE.address = address;
INSTANCE.info = info;
return INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import java.net.InetSocketAddress;

public class ConnectToServerEvent {
private static final ConnectToServerEvent INSTANCE = new ConnectToServerEvent();
public class ServerConnectEndEvent {
private static final ServerConnectEndEvent INSTANCE = new ServerConnectEndEvent();
public InetSocketAddress address;

public static ConnectToServerEvent get(InetSocketAddress address) {
public static ServerConnectEndEvent get(InetSocketAddress address) {
INSTANCE.address = address;
return INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public WDoubleEdit(double value, double min, double max, double sliderMin, doubl
this.value = value;
this.min = min;
this.max = max;
this.decimalPlaces = decimalPlaces;
this.sliderMin = sliderMin;
this.sliderMax = sliderMax;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public float getSlipperiness(float original) {
Slippy slippy = Modules.get().get(Slippy.class);
Block block = (Block) (Object) this;

if (slippy.isActive() && !slippy.ignoredBlocks.get().contains(block)) {
if (slippy.isActive() && (slippy.listMode.get() == Slippy.ListMode.Whitelist ? slippy.allowedBlocks.get().contains(block) : !slippy.ignoredBlocks.get().contains(block))) {
return slippy.friction.get().floatValue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

package meteordevelopment.meteorclient.mixin;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.proxy.Socks4ProxyHandler;
import io.netty.handler.proxy.Socks5ProxyHandler;
import io.netty.handler.timeout.TimeoutException;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.events.world.ConnectToServerEvent;
import meteordevelopment.meteorclient.events.world.ServerConnectEndEvent;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick;
import meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder;
Expand Down Expand Up @@ -52,8 +53,8 @@ private void disconnect(Text disconnectReason, CallbackInfo ci) {
}

@Inject(method = "connect", at = @At("HEAD"))
private static void onConnect(InetSocketAddress address, boolean useEpoll, CallbackInfoReturnable<ClientConnection> info) {
MeteorClient.EVENT_BUS.post(ConnectToServerEvent.get(address));
private static void onConnect(InetSocketAddress address, boolean useEpoll, CallbackInfoReturnable<?> cir) {
MeteorClient.EVENT_BUS.post(ServerConnectEndEvent.get(address));
}

@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ public void onClickArmorSlot(int syncId, int slotId, int button, SlotActionType
clickSlot(syncId, 17, armorSlot, SlotActionType.SWAP, player); //armor slot <-> inv slot
ci.cancel();
} else if (actionType == SlotActionType.SWAP) {
clickSlot(syncId, 36 + button, armorSlot, SlotActionType.SWAP, player); //invert swap
ci.cancel();
if (button >= 10) {
clickSlot(syncId, 45, armorSlot, SlotActionType.SWAP, player);
ci.cancel();
} else {
clickSlot(syncId, 36 + button, armorSlot, SlotActionType.SWAP, player); //invert swap
ci.cancel();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.world.ServerConnectBeginEvent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
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(ConnectScreen.class)
public class ConnectScreenMixin {
@Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;)V", at = @At("HEAD"))
private void tryConnectEvent(MinecraftClient client, ServerAddress address, ServerInfo info, CallbackInfo ci) {
MeteorClient.EVENT_BUS.post(ServerConnectBeginEvent.get(address, info));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ private String getText() {
}

private void tryConnecting() {
var conn = Modules.get().get(AutoReconnect.class).lastServerConnection;
var host = conn.getAddress().getHostName();
if (host.contains(":")) host = host.substring(0, host.indexOf(":"));
ConnectScreen.connect(new TitleScreen(), mc, new ServerAddress(host, conn.getPort()), new ServerInfo(I18n.translate("selectServer.defaultName"), host, false), false);
var lastServer = Modules.get().get(AutoReconnect.class).lastServerConnection;
ConnectScreen.connect(new TitleScreen(), mc, lastServer.left(), lastServer.right(), false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

package meteordevelopment.meteorclient.mixin.sodium;

import me.jellysquid.mods.sodium.client.render.vertex.VertexBufferWriter;
import me.jellysquid.mods.sodium.client.render.vertex.VertexFormatDescription;
import me.jellysquid.mods.sodium.client.render.vertex.transform.CommonVertexElement;
import meteordevelopment.meteorclient.utils.render.MeshVertexConsumerProvider;
import net.caffeinemc.mods.sodium.api.vertex.attributes.CommonVertexAttribute;
import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.minecraft.client.render.VertexConsumer;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
Expand All @@ -18,11 +18,12 @@
public abstract class MeshVertexConsumerMixin implements VertexConsumer, VertexBufferWriter {
@Override
public void push(MemoryStack stack, long ptr, int count, VertexFormatDescription format) {
int positionOffset = format.elementOffsets[CommonVertexElement.POSITION.ordinal()];
int positionOffset = format.getElementOffset(CommonVertexAttribute.POSITION);

if (positionOffset == -1) return;

for (int i = 0; i < count; i++) {
long positionPtr = ptr + (long) format.stride * i + positionOffset;
long positionPtr = ptr + (long) format.stride() * i + positionOffset;

float x = MemoryUtil.memGetFloat(positionPtr);
float y = MemoryUtil.memGetFloat(positionPtr + 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin.sodium;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.jellysquid.mods.sodium.client.world.biome.BiomeColorCache;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.world.Ambience;
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;

@Mixin(value = BiomeColorCache.class, remap = false)
public class SodiumBiomeColorCacheMixin {
@Unique
private Ambience ambience;

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
ambience = Modules.get().get(Ambience.class);
}

@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getGrassColorAt(DD)I", remap = true))
private int modify_getGrassColorAt(int color) {
return ambience.isActive() && ambience.customGrassColor.get() ? ambience.grassColor.get().getPacked() : color;
}

@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getFoliageColor()I", remap = true))
private int modify_getFoliageColor(int color) {
return ambience.isActive() && ambience.customFoliageColor.get() ? ambience.foliageColor.get().getPacked() : color;
}

@ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getWaterColor()I", remap = true))
private int modify_getWaterColor(int color) {
return ambience.isActive() && ambience.customWaterColor.get() ? ambience.waterColor.get().getPacked() : color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,31 @@
package meteordevelopment.meteorclient.mixin.sodium;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import me.jellysquid.mods.sodium.client.render.occlusion.BlockOcclusionCache;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockOcclusionCache;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
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;

@Mixin(value = BlockOcclusionCache.class, remap = false)
public class SodiumBlockOcclusionCacheMixin {
@Unique
private Xray xray;

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
xray = Modules.get().get(Xray.class);
}

@ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN"))
private boolean shouldDrawSide(boolean original, BlockState state, BlockView view, BlockPos pos, Direction facing) {
Xray xray = Modules.get().get(Xray.class);

if (xray.isActive()) {
return xray.modifyDrawSide(state, view, pos, facing, original);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,21 @@

package meteordevelopment.meteorclient.mixin.sodium;

import me.jellysquid.mods.sodium.client.model.IndexBufferBuilder;
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation;
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
import me.jellysquid.mods.sodium.client.render.vertex.type.ChunkVertexBufferBuilder;
import me.jellysquid.mods.sodium.client.render.vertex.type.ChunkVertexEncoder;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import net.minecraft.util.math.Vec3d;
import org.objectweb.asm.Opcodes;
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(value = BlockRenderer.class, remap = false)
public class SodiumBlockRendererMixin {
@Unique private final ThreadLocal<Integer> alphas = new ThreadLocal<>();

@Inject(method = "renderModel", at = @At("HEAD"), cancellable = true)
private void onRenderModel(BlockRenderContext ctx, ChunkModelBuilder buffers, CallbackInfoReturnable<Boolean> info) {
private void onRenderModel(BlockRenderContext ctx, ChunkBuildBuffers buffers, CallbackInfo info) {
int alpha = Xray.getAlpha(ctx.state(), ctx.pos());

if (alpha == 0) info.setReturnValue(false);
else alphas.set(alpha);
}


@Inject(method = "writeGeometry", at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/render/vertex/type/ChunkVertexEncoder$Vertex;color:I", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
private void setColor(BlockRenderContext ctx, ChunkVertexBufferBuilder vertexBuffer, IndexBufferBuilder indexBuffer, Vec3d offset, ModelQuadView quad, int[] colors, float[] brightness, int[] lightmap, CallbackInfo info, ModelQuadOrientation orientation, ChunkVertexEncoder.Vertex[] vertices, int dstIndex, int srcIndex, ChunkVertexEncoder.Vertex out) {
int alpha = alphas.get();

if (alpha == 0) info.cancel();
else if (alpha != -1) {
out.color &= 0xFFFFFF;
out.color |= alpha << 24;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,55 @@

package meteordevelopment.meteorclient.mixin.sodium;

import me.jellysquid.mods.sodium.client.model.color.ColorProvider;
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
import me.jellysquid.mods.sodium.client.model.quad.blender.ColorSampler;
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer;
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
import me.jellysquid.mods.sodium.client.util.color.ColorARGB;
import me.jellysquid.mods.sodium.client.world.WorldSlice;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import meteordevelopment.meteorclient.systems.modules.world.Ambience;
import net.caffeinemc.mods.sodium.api.util.ColorABGR;
import net.minecraft.fluid.FluidState;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import org.spongepowered.asm.mixin.Final;
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.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Arrays;

@Mixin(value = FluidRenderer.class, remap = false)
public class SodiumFluidRendererMixin {
@Final @Shadow private int[] quadColors;
@Final @Shadow
private int[] quadColors;

@Unique private final ThreadLocal<Integer> alphas = new ThreadLocal<>();
@Unique
private Ambience ambience;

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
ambience = Modules.get().get(Ambience.class);
}

@Inject(method = "render", at = @At("HEAD"), cancellable = true)
private void onRender(BlockRenderView world, FluidState fluidState, BlockPos pos, BlockPos offset, ChunkModelBuilder buffers, CallbackInfoReturnable<Boolean> info) {
int alpha = Xray.getAlpha(fluidState.getBlockState(), pos);
private void onRender(WorldSlice world, FluidState fluidState, BlockPos blockPos, BlockPos offset, ChunkBuildBuffers buffers, CallbackInfo info) {
int alpha = Xray.getAlpha(fluidState.getBlockState(), blockPos);

if (alpha == 0) info.setReturnValue(false);
else alphas.set(alpha);
if (alpha == 0) info.cancel();
}

@Inject(method = "updateQuad", at = @At("TAIL"))
private void onUpdateQuad(ModelQuadView quad, BlockRenderView world, BlockPos pos, LightPipeline lighter, Direction dir, float brightness, ColorSampler<FluidState> colorSampler, FluidState fluidState, CallbackInfo info) {
private void onUpdateQuad(ModelQuadView quad, WorldSlice world, BlockPos pos, LightPipeline lighter, Direction dir, float brightness, ColorProvider<FluidState> colorProvider, FluidState fluidState, CallbackInfo info) {
// Ambience
Ambience ambience = Modules.get().get(Ambience.class);

if (ambience.isActive() && ambience.customLavaColor.get() && fluidState.isIn(FluidTags.LAVA)) {
Arrays.fill(quadColors, ColorARGB.toABGR(ambience.lavaColor.get().getPacked()));
} else {
// XRay and Wallhack
int alpha = alphas.get();

for (int i = 0; i < quadColors.length; i++) {
quadColors[i] = ColorABGR.withAlpha(quadColors[i], alpha / 255f);
}
Arrays.fill(quadColors, ColorABGR.withAlpha(ambience.lavaColor.get().getPacked(), 255));
}
}
}
Loading

0 comments on commit 3de97fd

Please sign in to comment.