Skip to content

Commit

Permalink
Fix a few things as well as enable forwarding for now
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Feb 27, 2024
1 parent fe2f76d commit ed70ecc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Expand Up @@ -51,7 +51,7 @@ flatlaf-fonts-inter = { module = "com.formdev:flatlaf-fonts-inter", version.ref
flatlaf-fonts-jetbrains-mono = { module = "com.formdev:flatlaf-fonts-jetbrains-mono", version.ref = "flatlaf-jetbrains-mono-version" }
xchart = "org.knowm.xchart:xchart:3.8.7"
miglayout-swing = "com.miglayout:miglayout-swing:11.3"
mcprotocollib = "com.github.GeyserMC:MCProtocolLib:2a76b37"
mcprotocollib = "com.github.GeyserMC:MCProtocolLib:eacfb2d"
velocity-native = "com.velocitypowered:velocity-native:3.1.2-SNAPSHOT"
netty-raknet = "org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR1-SNAPSHOT"
via-version = { module = "com.viaversion:viaversion-common", version.ref = "via-version" }
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/soulfiremc/server/plugins/POVServer.java
Expand Up @@ -49,6 +49,7 @@
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundPingPacket;
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundUpdateTagsPacket;
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundPongPacket;
import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundFinishConfigurationPacket;
import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket;
Expand Down Expand Up @@ -108,6 +109,7 @@
import com.soulfiremc.server.settings.lib.property.BooleanProperty;
import com.soulfiremc.server.settings.lib.property.IntProperty;
import com.soulfiremc.server.settings.lib.property.Property;
import com.soulfiremc.server.util.TimeUtil;
import com.soulfiremc.util.PortHelper;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
Expand All @@ -132,6 +134,7 @@ public class POVServer implements InternalPlugin {
private static final List<Class<?>> NOT_SYNCED =
List.of(
ClientboundKeepAlivePacket.class,
ServerboundKeepAlivePacket.class,
ClientboundPingPacket.class,
ServerboundPongPacket.class,
ClientboundCustomPayloadPacket.class,
Expand Down Expand Up @@ -255,7 +258,7 @@ public POVServerInstance(int port, AttackManager attackManager) {
for (var i = 0; i < sectionCount; i++) {
var chunk = DataPalette.createForChunk();
chunk.set(0, 0, 0, 0);
var biome = DataPalette.createForBiome(6);
var biome = DataPalette.createForBiome();
biome.set(0, 0, 0, 0);
SessionDataManager.writeChunkSection(
buf,
Expand Down Expand Up @@ -381,6 +384,7 @@ public void packetReceived(Session session, Packet packet) {
});
}
} else if (!NOT_SYNCED.contains(packet.getClass()) && enableForwarding) {
System.out.println(packet);
// MC Client -> Server of the bot
botConnection.session().send(packet);
}
Expand Down Expand Up @@ -669,7 +673,7 @@ private void syncBotAndUser() {
session.send(
new ClientboundContainerSetContentPacket(
container.id(),
++stateIndex,
stateIndex++,
Arrays.stream(
sessionDataManager
.inventoryManager()
Expand Down Expand Up @@ -791,7 +795,10 @@ private void syncBotAndUser() {
.toList()));
}

// enableForwarding = true;
// Give the client a few moments to process the packets
TimeUtil.waitTime(2, TimeUnit.SECONDS);

enableForwarding = true;
}
});
}
Expand Down
Expand Up @@ -117,7 +117,6 @@
import com.soulfiremc.server.data.EntityType;
import com.soulfiremc.server.data.ModifierOperation;
import com.soulfiremc.server.protocol.BotConnection;
import com.soulfiremc.server.protocol.bot.block.GlobalBlockPalette;
import com.soulfiremc.server.protocol.bot.container.InventoryManager;
import com.soulfiremc.server.protocol.bot.container.SFItemStack;
import com.soulfiremc.server.protocol.bot.container.WindowContainer;
Expand Down Expand Up @@ -726,7 +725,7 @@ public void onChunkData(ClientboundChunksBiomesPacket packet) {
try {
for (var i = 0; chunkData.getSectionCount() > i; i++) {
var section = chunkData.getSection(i);
var biomePalette = codec.readDataPalette(buf, PaletteType.BIOME, biomesEntryBitsSize);
var biomePalette = codec.readDataPalette(buf, PaletteType.BIOME);
chunkData.setSection(
i, new ChunkSection(section.getBlockCount(), section.getChunkData(), biomePalette));
}
Expand Down Expand Up @@ -1125,8 +1124,8 @@ public ChunkSection readChunkSection(ByteBuf buf, MinecraftCodecHelper codec) th

var chunkPalette =
codec.readDataPalette(
buf, PaletteType.CHUNK, GlobalBlockPalette.INSTANCE.blockBitsPerEntry());
var biomePalette = codec.readDataPalette(buf, PaletteType.BIOME, biomesEntryBitsSize);
buf, PaletteType.CHUNK);
var biomePalette = codec.readDataPalette(buf, PaletteType.BIOME);
return new ChunkSection(blockCount, chunkPalette, biomePalette);
}

Expand Down

0 comments on commit ed70ecc

Please sign in to comment.