Skip to content

Commit

Permalink
Merge branch '1.21.0' into 1.21.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/zenith/network/registry/ZenithHandlerCodec.java
#	src/main/java/com/zenith/network/server/ServerSession.java
  • Loading branch information
rfresh2 committed Nov 23, 2024
2 parents 43c21c4 + a268d14 commit f518263
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/zenith/command/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class CommandManager {
new ReleaseChannelCommand(),
new ReplayCommand(),
new RespawnCommand(),
new RotateCommand(),
new SeenCommand(),
new SendMessageCommand(),
new ServerCommand(),
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/zenith/command/impl/DebugCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public CommandUsage commandUsage() {
"teleportResync on/off",
"ncpStrictInventory on/off",
"debugLogs on/off",
"chunkCacheFullbright on/off"
"chunkCacheFullbright on/off",
"enforceSpawnSeq on/off"
)
);
}
Expand Down Expand Up @@ -173,6 +174,12 @@ public LiteralArgumentBuilder<CommandContext> register() {
c.getSource().getEmbed()
.title("Chunk Cache Fullbright " + toggleStrCaps(CONFIG.debug.server.cache.fullbrightChunkSkylight));
return OK;
})))
.then(literal("enforceSpawnSeq").then(argument("toggle", toggle()).executes(c -> {
CONFIG.debug.enforcePlayerSpawnSequence = getToggle(c, "toggle");
c.getSource().getEmbed()
.title("Enforce Spawn Seq " + toggleStrCaps(CONFIG.debug.enforcePlayerSpawnSequence));
return OK;
})));
}

Expand All @@ -189,6 +196,7 @@ public void postPopulate(final Embed builder) {
.addField("NCP Strict Inventory", toggleStr(CONFIG.debug.ncpStrictInventory), false)
.addField("Debug Logs", toggleStr(CONFIG.debug.debugLogs), false)
.addField("Chunk Cache Fullbright", toggleStr(CONFIG.debug.server.cache.fullbrightChunkSkylight), false)
.addField("Enforce Spawn Seq", toggleStr(CONFIG.debug.enforcePlayerSpawnSequence), false)
.primaryColor();
}
}
108 changes: 108 additions & 0 deletions src/main/java/com/zenith/command/impl/RotateCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.zenith.command.impl;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.zenith.Proxy;
import com.zenith.command.Command;
import com.zenith.command.CommandUsage;
import com.zenith.command.brigadier.CommandCategory;
import com.zenith.command.brigadier.CommandContext;

import static com.mojang.brigadier.arguments.FloatArgumentType.floatArg;
import static com.mojang.brigadier.arguments.FloatArgumentType.getFloat;
import static com.zenith.Shared.CACHE;
import static com.zenith.Shared.PATHING;
import static java.util.Arrays.asList;

public class RotateCommand extends Command {
private static final int MOVE_PRIORITY = 1000000;

@Override
public CommandUsage commandUsage() {
return CommandUsage.args(
"rotate",
CommandCategory.MODULE,
"""
Rotates the bot in-game.
Note that many other modules can change the player's rotation after this command is executed.
""",
asList(
"<yaw> <pitch>",
"yaw <yaw>",
"pitch <pitch>"
)
);
}

@Override
public LiteralArgumentBuilder<CommandContext> register() {
return command("rotate")
.then(argument("yaw", floatArg(-180, 180)).then(argument("pitch", floatArg(-90, 90)).executes(c -> {
float yaw = getFloat(c, "yaw");
float pitch = getFloat(c, "pitch");
if (!Proxy.getInstance().isConnected()) {
c.getSource().getEmbed()
.title("Error")
.errorColor()
.description("Not connected to a server");
return OK;
}
if (Proxy.getInstance().hasActivePlayer()) {
c.getSource().getEmbed()
.title("Error")
.errorColor()
.description("Cannot rotate while player is controlling");
return OK;
}
PATHING.rotate(yaw, pitch, MOVE_PRIORITY);
c.getSource().getEmbed()
.title("Rotated")
.successColor();
return OK;
})))
.then(literal("yaw").then(argument("yaw", floatArg(-180, 180)).executes(c -> {
float yaw = getFloat(c, "yaw");
if (!Proxy.getInstance().isConnected()) {
c.getSource().getEmbed()
.title("Error")
.errorColor()
.description("Not connected to a server");
return OK;
}
if (Proxy.getInstance().hasActivePlayer()) {
c.getSource().getEmbed()
.title("Error")
.errorColor()
.description("Cannot rotate while player is controlling");
return OK;
}
PATHING.rotate(yaw, CACHE.getPlayerCache().getPitch(), MOVE_PRIORITY);
c.getSource().getEmbed()
.title("Rotated")
.successColor();
return OK;
})))
.then(literal("pitch").then(argument("pitch", floatArg(-90, 90)).executes(c -> {
float pitch = getFloat(c, "pitch");
if (!Proxy.getInstance().isConnected()) {
c.getSource().getEmbed()
.title("Error")
.errorColor()
.description("Not connected to a server");
return OK;
}
if (Proxy.getInstance().hasActivePlayer()) {
c.getSource().getEmbed()
.title("Error")
.errorColor()
.description("Cannot rotate while player is controlling");
return OK;
}
PATHING.rotate(CACHE.getPlayerCache().getYaw(), pitch, MOVE_PRIORITY);
c.getSource().getEmbed()
.title("Rotated")
.successColor();
return OK;
})));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ private ZenithHandlerCodec() {}
.registerOutbound(ClientboundContainerSetContentPacket.class, new ContainerSetContentSpectatorOutgoingHandler())
.registerOutbound(ClientboundPlaceGhostRecipePacket.class, new PlaceGhostRecipeSpectatorOutgoingHandler())
.registerOutbound(ClientboundOpenScreenPacket.class, new OpenScreenSpectatorOutgoingHandler())
.registerOutbound(ClientboundOpenSignEditorPacket.class, new OpenSignEditorSpectatorOutgoingHandler())
.registerOutbound(ClientboundSetHeldSlotPacket.class, new SetCarriedItemSpectatorOutgoingHandler())
.registerOutbound(ClientboundSetHealthPacket.class, new SetHealthSpectatorOutgoingHandler())
.registerOutbound(ClientboundPlayerPositionPacket.class, new PlayerPositionSpectatorOutgoingHandler())
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/zenith/network/server/ServerSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class ServerSession extends TcpServerSession {
// note: on 1.21.3, the position packet is sent before the teleport accept packet
// player has accepted the spawn teleport and position packets
// if false, we cancel any outbound teleport and position packets
protected boolean spawned = false;
protected boolean spawned = !CONFIG.debug.enforcePlayerSpawnSequence;
// default spawn teleport id
protected final int spawnTeleportId = 1234567890;
// cancel outbound packets until we have received the protocol switch ack
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.zenith.network.server.handler.spectator.outgoing;

import com.zenith.network.registry.PacketHandler;
import com.zenith.network.server.ServerSession;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundOpenSignEditorPacket;

public class OpenSignEditorSpectatorOutgoingHandler implements PacketHandler<ClientboundOpenSignEditorPacket, ServerSession> {
@Override
public ClientboundOpenSignEditorPacket apply(final ClientboundOpenSignEditorPacket packet, final ServerSession session) {
return null;
}
}
1 change: 1 addition & 0 deletions src/main/java/com/zenith/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public static final class Debug {
public boolean resyncTeleports = true;
public boolean ncpStrictInventory = false;
public boolean debugLogs = false;
public boolean enforcePlayerSpawnSequence = true;

public static final class PacketLog {
public boolean enabled = false;
Expand Down

0 comments on commit f518263

Please sign in to comment.