Skip to content

Commit

Permalink
Merge pull request #37 from Basicprogrammer10/update-mc-1.20.2
Browse files Browse the repository at this point in the history
Update to Minecraft 1.20.2
  • Loading branch information
connorslade authored Sep 30, 2023
2 parents 2d05df2 + 0112873 commit c7be342
Show file tree
Hide file tree
Showing 59 changed files with 268 additions and 175 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SigmaUtils ![build](/~https://github.com/Basicprogrammer10/SigmaUtils/actions/workflows/build.yml/badge.svg) ![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/Basicprogrammer10/SigmaUtils?include_prereleases) ![GitHub all releases](https://img.shields.io/github/downloads/Basicprogrammer10/SigmaUtils/total)

Requires: <kbd>[Minecraft 1.20.1](https://minecraft.fandom.com/wiki/Java_Edition_1.20.1)</kbd> <kbd>[Fabric API](https://modrinth.com/mod/fabric-api/version/0.75.3+1.19.4)</kbd>
Requires: <kbd>[Minecraft 1.20.2](https://minecraft.fandom.com/wiki/Java_Edition_1.20.2)</kbd> <kbd>[Fabric API](https://modrinth.com/mod/fabric-api/version/0.89.2+1.20.2)</kbd>

SigmaUtils is a utility mod for Minecraft 1.20.1.
SigmaUtils is a utility mod for Minecraft 1.20.2.
It is made up of 'modules', which are discrete features that can be toggled and configured.
By default, SigmaUtils changes nothing about the game, except adding a button to the title screen to open the config
GUI.
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.8
loader_version=0.14.21
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.2
loader_version=0.14.22
# Mod Properties
mod_version=0.1.6-alpha
mod_version=0.1.7-alpha
maven_group=com.connorcode
archives_base_name=sigma-utils
# Dependencies
fabric_version=0.84.0+1.20.1
mod_menu_version=7.1.0
fabric_version=0.89.2+1.20.2
mod_menu_version=8.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static com.connorcode.sigmautils.SigmaUtils.client;


public class About implements Command {
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(ClientCommandManager.literal("util")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/connorcode/sigmautils/commands/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ int execute(CommandContext<FabricClientCommandSource> context) throws IOExceptio
.append(i.getSimpleName())
.append("\n");
Files.write(dumps.toPath().resolve("packets.txt"), out.toString().getBytes());
context.getSource().sendFeedback(Text.of("Dumped packets to " + dumps.toPath().resolve("packets.txt")));
return 0;
}

Expand All @@ -91,6 +92,7 @@ int execute(CommandContext<FabricClientCommandSource> context) throws IOExceptio

Files.write(file.toPath(), text.toString().getBytes());
}
context.getSource().sendFeedback(Text.of("Dumped docs to " + docs.toPath()));
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/connorcode/sigmautils/commands/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected void init() {

@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);
renderBackground(drawContext, mouseX, mouseY, delta);

var lines = textRenderer.wrapLines(StringVisitable.plain(note.text), noteWidth);
var startX = width / 2f - noteWidth / 2f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;


public class PlayerCommand implements Command {
@Override
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/connorcode/sigmautils/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import static com.connorcode.sigmautils.SigmaUtils.*;


public class Config {
public static final File configFile = new File(directory.toFile(), "config.nbt");
static final KeyBinding configKeybinding = KeyBindingHelper.registerKeyBinding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void init() {

public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
int padding = getPadding();
this.renderBackground(drawContext);
this.renderBackground(drawContext, mouseX, mouseY, delta);

for (int x = 0; x < Category.realValues().length; x++)
drawContext.drawCenteredTextWithShadow(textRenderer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
Setting.RenderData renderData = new Setting.RenderData(this, drawContext, mouseX, mouseY, delta);
int padding = getPadding();

this.renderBackground(drawContext);
this.renderBackground(drawContext, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);

int x = -75 + 20 + padding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ protected void init() {
}
}

@Override
public void tick() {
this.searchField.tick();
}

private boolean search(K resource, String search) {
var finalSearch = search.toLowerCase(Locale.ROOT);
return Arrays.stream(renderer.getSearch(resource)).anyMatch(s -> s.contains(finalSearch));
Expand All @@ -188,7 +183,7 @@ public void close() {

@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);
renderBackground(drawContext, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
this.searchField.render(drawContext, mouseX, mouseY, delta);
}
Expand Down Expand Up @@ -267,7 +262,7 @@ public void close() {

@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);
renderBackground(drawContext, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.connorcode.sigmautils.SigmaUtils.client;
import static com.connorcode.sigmautils.modules.meta.Padding.getPadding;


public class DynamicSelectorSetting<K> extends Setting<DynamicSelectorSetting<K>> {
ResourceManager<K> manager;
K value;
Expand Down Expand Up @@ -164,11 +165,6 @@ protected void init() {
}
}

@Override
public void tick() {
this.searchField.tick();
}

private boolean search(K resource, String search) {
var finalSearch = search.toLowerCase(Locale.ROOT);
return Arrays.stream(renderer.getSearch(resource)).anyMatch(s -> s.contains(finalSearch));
Expand All @@ -181,7 +177,7 @@ public void close() {

@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
renderBackground(drawContext);
renderBackground(drawContext, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
this.searchField.render(drawContext, mouseX, mouseY, delta);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.connorcode.sigmautils.config.settings.list;


import com.connorcode.sigmautils.config.settings.DynamicListSetting;
import com.connorcode.sigmautils.misc.util.NetworkUtils;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
Expand All @@ -11,6 +12,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class PacketList implements DynamicListSetting.ResourceManager<Class<? extends Packet<?>>> {
DynamicListSetting<Class<? extends Packet<?>>> setting;
Expand All @@ -34,7 +36,7 @@ public List<Class<? extends Packet<?>>> getAllResources() {

@Override
public String getDisplay(Class<? extends Packet<?>> resource) {
return NetworkUtils.getPacketName(resource);
return Optional.ofNullable(NetworkUtils.getPacketName(resource)).orElse(resource.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.connorcode.sigmautils.SigmaUtils.client;
import static com.connorcode.sigmautils.modules.meta.Padding.getPadding;


public abstract class SimpleSelector<T> implements DynamicSelectorSetting.ResourceManager<T> {
protected Registry<T> registry;
protected DynamicSelectorSetting<T> setting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

public class PacketSendEvent extends Cancellable {
public Packet<?> packet;
public boolean flush;

public PacketSendEvent(Packet<?> packet) {
public PacketSendEvent(Packet<?> packet, boolean flush) {
this.packet = packet;
this.flush = flush;
}

public Packet<?> get() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.connorcode.sigmautils.event.network;

import com.connorcode.sigmautils.event.Cancellable;
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;

public class UnknownPacketEvent extends Cancellable {
public CustomPayloadS2CPacket packet;
public Identifier identifier;
PacketByteBuf buf;

public UnknownPacketEvent(CustomPayloadS2CPacket packet) {
this.packet = packet;
this.identifier = packet.getChannel();
public UnknownPacketEvent(PacketByteBuf buf, Identifier identifier) {
this.buf = buf;
this.identifier = identifier;
}

public CustomPayloadS2CPacket get() {
return packet;
public PacketByteBuf get() {
return buf;
}

public Identifier getIdentifier() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.connorcode.sigmautils.misc;

import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;

public class CancelledUnknownPacket implements CustomPayload {
Identifier id;

public CancelledUnknownPacket(Identifier id) {
this.id = id;
}

@Override
public void write(PacketByteBuf buf) {

}

@Override
public Identifier id() {
return this.id;
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/connorcode/sigmautils/misc/Components.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
protected abstract double maxScroll();

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
scroll -= amount * (entryHeight + padding);
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
scroll -= verticalAmount * (entryHeight + padding);
refreshScrollConstrains();
this.clearAndInit();
return true;
Expand Down
19 changes: 7 additions & 12 deletions src/main/java/com/connorcode/sigmautils/misc/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ private void onTick(Tick.GameTickEvent event) {

@EventHandler
private void onPacketSend_PacketSendEvent(PacketSendEvent event) {
if (event.get() instanceof PlayerActionC2SPacket packet)
Objects.requireNonNull(client.player).sendMessage(Text.of(String.format("Action: %s [%d]", packet.getAction(), packet.getSequence())), false);
if (event.get() instanceof PlayerActionC2SPacket packet && debug)
Objects.requireNonNull(client.player)
.sendMessage(Text.of(String.format("Action: %s [%d]", packet.getAction(), packet.getSequence())),
false);
}

public void addAction(Action action) {
Expand Down Expand Up @@ -95,7 +97,6 @@ public void tick() {
}

public static class AttackAction extends InteractAction {
Direction lastDirection = Direction.UP;
BlockPos lastBlock;

public AttackAction(InteractTime time) {
Expand All @@ -115,20 +116,14 @@ void interact() {
}

if (client.crosshairTarget instanceof BlockHitResult hit) {
if (lastBlock == null) {
net.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, hit.getBlockPos(), hit.getSide()));
sequenced(sequence -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, hit.getBlockPos(), hit.getSide(), sequence));
} else if (!lastBlock.equals(hit.getBlockPos())) {
// sequenced(sequence -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, lastBlock, lastDirection, sequence));
sequenced(sequence -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, hit.getBlockPos(), hit.getSide(), sequence));
if (lastBlock == null || !lastBlock.equals(hit.getBlockPos())) {
sequenced(sequence -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, hit.getBlockPos(), hit.getSide()));
sequenced(sequence -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, hit.getBlockPos(), hit.getSide(), sequence));
}
lastBlock = hit.getBlockPos();
lastDirection = hit.getSide();
} else if (lastBlock != null) {
net.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, lastBlock, lastDirection));
net.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, lastBlock, Direction.UP));
lastBlock = null;
lastDirection = Direction.UP;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.connorcode.sigmautils.misc.util;

import static com.connorcode.sigmautils.SigmaUtils.client;

public class ClientUtils {
public static boolean isConnectedToRealms() {
return client.getCurrentServerEntry() != null && client.getCurrentServerEntry().isLocal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.network.NetworkSide;
import net.minecraft.network.NetworkState;
import net.minecraft.network.packet.Packet;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -28,7 +29,7 @@ public static Object2IntOpenHashMap<Class<? extends Packet<?>>> getPackets(Netwo
Arrays.stream(NetworkState.values())
.map(state -> state.packetHandlers.get(side))
.filter(Objects::nonNull)
.forEach(handler -> packets.putAll(handler.packetIds));
.forEach(handler -> packets.putAll(handler.backingHandler.packetIds));
return packets;
}

Expand All @@ -43,6 +44,7 @@ public static String getPacketName(Class<? extends Packet<?>> packet) {
return getPacketName(packet.getName());
}

@Nullable
public static String getPacketName(String bytecodeName) {
var intermediary = mappingResolver.unmapClassName("intermediary", bytecodeName);
if (packetNames.isEmpty())
Expand All @@ -61,18 +63,17 @@ public static synchronized AuthStatus getAuthStatus() {
authStatus = AuthStatus.Waiting;
lastAuthStatusCheck = System.currentTimeMillis();

// TODO: Verify that this works
new Thread(() -> {
var session = client.getSession();
var profile = session.getProfile();
var token = session.getAccessToken();
var id = UUID.randomUUID().toString();

// Thank you /~https://github.com/axieum/authme
var sessionService = (YggdrasilMinecraftSessionService) client.getSessionService();
try {
sessionService.joinServer(profile, token, id);
authStatus = sessionService.hasJoinedServer(profile, id, null)
.isComplete() ? AuthStatus.Online : AuthStatus.Offline;
sessionService.joinServer(client.getSession().getUuidOrNull(), token, id);
authStatus = sessionService.hasJoinedServer(session.getUsername(), id, null) != null ? AuthStatus.Online : AuthStatus.Offline;
} catch (AuthenticationException e) {
authStatus = AuthStatus.Invalid;
}
Expand Down
Loading

0 comments on commit c7be342

Please sign in to comment.