Updated Via API usage

This commit is contained in:
RaphiMC 2024-08-23 15:08:26 +02:00
parent 11875755b4
commit 7f1cb82cf6
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
12 changed files with 40 additions and 91 deletions

View File

@ -106,8 +106,6 @@ ViaLegacy needs to have custom netty handlers in the pipeline which handle <= 1.
To implement the changes you should add something similar to the following lines to your netty pipeline (After the ViaVersion handlers are added): To implement the changes you should add something similar to the following lines to your netty pipeline (After the ViaVersion handlers are added):
```java ```java
if (serverTargetVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) { // Only add those handlers if the server version is <= 1.6.4 if (serverTargetVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) { // Only add those handlers if the server version is <= 1.6.4
user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE); // Allow to intercept the handshake packet
// You can either add a codec (if your pipeline is built for that) // You can either add a codec (if your pipeline is built for that)
channel.pipeline().addBefore("length-codec", "vialegacy-pre-netty-length-codec", new PreNettyLengthCodec(user)); channel.pipeline().addBefore("length-codec", "vialegacy-pre-netty-length-codec", new PreNettyLengthCodec(user));
// or two seperate netty handlers // or two seperate netty handlers

View File

@ -1,54 +0,0 @@
/*
* This file is part of ViaLegacy - https://github.com/RaphiMC/ViaLegacy
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.api.protocol;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.base.ServerboundHandshakePackets;
import com.viaversion.viaversion.protocols.base.v1_7.ServerboundBaseProtocol1_7;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.HandshakeStorage;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
public class PreNettyBaseProtocol extends ServerboundBaseProtocol1_7 {
public static final PreNettyBaseProtocol INSTANCE = new PreNettyBaseProtocol();
private PreNettyBaseProtocol() {
this.initialize();
}
@Override
protected void registerPackets() {
super.registerPackets();
this.registerServerbound(State.HANDSHAKE, ServerboundHandshakePackets.CLIENT_INTENTION.getId(), ServerboundHandshakePackets.CLIENT_INTENTION.getId(), wrapper -> {
wrapper.cancel();
wrapper.read(Types.VAR_INT); // protocolVersion
final String hostname = wrapper.read(Types.STRING); // hostName
final int port = wrapper.read(Types.UNSIGNED_SHORT); // port
wrapper.user().put(new HandshakeStorage(hostname, port));
});
}
@Override
public void init(final UserConnection user) {
super.init(user);
user.put(new ProtocolMetadataStorage());
}
}

View File

@ -71,19 +71,19 @@ public class AlphaInventoryTracker extends StoredObject {
for (int i = 1; i <= 9; i++) { for (int i = 1; i <= 9; i++) {
final Item item = this.openContainerItems[i]; final Item item = this.openContainerItems[i];
if (item == null) continue; if (item == null) continue;
dropItem(this.getUser(), item, false); dropItem(this.user(), item, false);
this.openContainerItems[i] = null; this.openContainerItems[i] = null;
} }
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
final Item item = this.craftingInventory[i]; final Item item = this.craftingInventory[i];
if (item == null) continue; if (item == null) continue;
dropItem(this.getUser(), item, false); dropItem(this.user(), item, false);
this.craftingInventory[i] = null; this.craftingInventory[i] = null;
} }
if (this.cursorItem != null) { if (this.cursorItem != null) {
dropItem(this.getUser(), this.cursorItem, false); dropItem(this.user(), this.cursorItem, false);
this.cursorItem = null; this.cursorItem = null;
} }
this.openWindowType = -1; this.openWindowType = -1;
@ -98,10 +98,10 @@ public class AlphaInventoryTracker extends StoredObject {
if (slot == -999) { if (slot == -999) {
if (this.cursorItem != null) { if (this.cursorItem != null) {
if (leftClick) { if (leftClick) {
dropItem(this.getUser(), this.cursorItem, false); dropItem(this.user(), this.cursorItem, false);
this.cursorItem = null; this.cursorItem = null;
} else { } else {
dropItem(this.getUser(), this.splitStack(this.cursorItem, 1), false); dropItem(this.user(), this.splitStack(this.cursorItem, 1), false);
} }
} }
} else { } else {
@ -255,8 +255,8 @@ public class AlphaInventoryTracker extends StoredObject {
if (direction == 255) { // interact if (direction == 255) { // interact
AlphaItems.doInteract(handItem); AlphaItems.doInteract(handItem);
} else { // place } else { // place
final IdAndData placedAgainst = this.getUser().get(ChunkTracker.class).getBlockNotNull(position); final IdAndData placedAgainst = this.user().get(ChunkTracker.class).getBlockNotNull(position);
final IdAndData targetBlock = this.getUser().get(ChunkTracker.class).getBlockNotNull(position.getRelative(BlockFaceUtil.getFace(direction))); final IdAndData targetBlock = this.user().get(ChunkTracker.class).getBlockNotNull(position.getRelative(BlockFaceUtil.getFace(direction)));
AlphaItems.doPlace(handItem, direction, placedAgainst); AlphaItems.doPlace(handItem, direction, placedAgainst);
if (handItem.identifier() < 256 || handItem.identifier() == ItemList1_6.reed.itemId()) { // block item if (handItem.identifier() < 256 || handItem.identifier() == ItemList1_6.reed.itemId()) { // block item
@ -339,7 +339,7 @@ public class AlphaInventoryTracker extends StoredObject {
// Add support for cheating items and classic block placement // Add support for cheating items and classic block placement
public void handleCreativeSetSlot(short slot, Item item) { public void handleCreativeSetSlot(short slot, Item item) {
if (!this.getUser().getProtocolInfo().serverProtocolVersion().equals(LegacyProtocolVersion.c0_30cpe)) item = fixItem(item); if (!this.user().getProtocolInfo().serverProtocolVersion().equals(LegacyProtocolVersion.c0_30cpe)) item = fixItem(item);
if (slot <= 0) return; if (slot <= 0) return;
if (slot <= 4) { if (slot <= 4) {
@ -404,7 +404,7 @@ public class AlphaInventoryTracker extends StoredObject {
} }
private void updateInventorySlot(final byte windowId, final short slot, final Item item) { private void updateInventorySlot(final byte windowId, final short slot, final Item item) {
final PacketWrapper setSlot = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_SLOT, this.getUser()); final PacketWrapper setSlot = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_SLOT, this.user());
setSlot.write(Types.BYTE, windowId); // window id setSlot.write(Types.BYTE, windowId); // window id
setSlot.write(Types.SHORT, slot); // slot setSlot.write(Types.SHORT, slot); // slot
setSlot.write(Typesb1_1.NBTLESS_ITEM, copyItem(item)); // item setSlot.write(Typesb1_1.NBTLESS_ITEM, copyItem(item)); // item
@ -422,7 +422,7 @@ public class AlphaInventoryTracker extends StoredObject {
} }
private void updateInventory(final byte windowId, final Item[] items) { private void updateInventory(final byte windowId, final Item[] items) {
final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, this.getUser()); final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, this.user());
windowItems.write(Types.BYTE, windowId); // window id windowItems.write(Types.BYTE, windowId); // window id
windowItems.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(items)); // items windowItems.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(items)); // items
windowItems.send(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class); windowItems.send(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);

View File

@ -36,12 +36,12 @@ public class BlockDigStorage extends StoredObject {
public void tick() { public void tick() {
if (this.tick >= 5) { if (this.tick >= 5) {
Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.getUser(), (byte) 0, this.position, this.facing); Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.user(), (byte) 0, this.position, this.facing);
this.tick = 0; this.tick = 0;
} else { } else {
this.tick++; this.tick++;
} }
Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.getUser(), (byte) 1, this.position, this.facing); Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.user(), (byte) 1, this.position, this.facing);
} }
} }

View File

@ -82,7 +82,7 @@ public class ClassicLevelStorage extends StoredObject {
throw new IllegalStateException("Failed to load level", e); throw new IllegalStateException("Failed to load level", e);
} }
final short maxChunkSectionCount = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(this.getUser()); final short maxChunkSectionCount = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(this.user());
this.chunkXCount = sizeX >> 4; this.chunkXCount = sizeX >> 4;
if (sizeX % 16 != 0) this.chunkXCount++; if (sizeX % 16 != 0) this.chunkXCount++;
@ -103,7 +103,7 @@ public class ClassicLevelStorage extends StoredObject {
if (chunkX < 0 || chunkX >= this.chunkXCount || chunkZ < 0 || chunkZ >= this.chunkZCount) { if (chunkX < 0 || chunkX >= this.chunkXCount || chunkZ < 0 || chunkZ >= this.chunkZCount) {
final Chunk chunk = ChunkUtil.createEmptyChunk(chunkX, chunkZ, Math.max(8, this.sectionYCount), this.sectionBitmask); final Chunk chunk = ChunkUtil.createEmptyChunk(chunkX, chunkZ, Math.max(8, this.sectionYCount), this.sectionBitmask);
ChunkUtil.setDummySkylight(chunk, true); ChunkUtil.setDummySkylight(chunk, true);
final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.getUser()); final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.user());
chunkData.write(Types1_1.CHUNK, chunk); chunkData.write(Types1_1.CHUNK, chunk);
chunkData.send(Protocolc0_28_30Toa1_0_15.class); chunkData.send(Protocolc0_28_30Toa1_0_15.class);
} }
@ -113,11 +113,11 @@ public class ClassicLevelStorage extends StoredObject {
} }
public void tick() { public void tick() {
final ClassicPositionTracker positionTracker = this.getUser().get(ClassicPositionTracker.class); final ClassicPositionTracker positionTracker = this.user().get(ClassicPositionTracker.class);
if (!positionTracker.spawned) return; if (!positionTracker.spawned) return;
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
this.getUser().getChannel().eventLoop().submit(() -> { this.user().getChannel().eventLoop().submit(() -> {
ClassicLevelStorage.this.eventLoopPing = System.currentTimeMillis() - start; ClassicLevelStorage.this.eventLoopPing = System.currentTimeMillis() - start;
}); });
@ -151,7 +151,7 @@ public class ClassicLevelStorage extends StoredObject {
public void sendChunk(final ChunkCoord coord) { public void sendChunk(final ChunkCoord coord) {
if (!this.shouldSend(coord)) return; if (!this.shouldSend(coord)) return;
final ClassicBlockRemapper remapper = this.getUser().get(ClassicBlockRemapper.class); final ClassicBlockRemapper remapper = this.user().get(ClassicBlockRemapper.class);
this.classicLevel.calculateLight(coord.chunkX * 16, coord.chunkZ * 16, this.subChunkXLength, this.subChunkZLength); this.classicLevel.calculateLight(coord.chunkX * 16, coord.chunkZ * 16, this.subChunkXLength, this.subChunkZLength);
@ -179,7 +179,7 @@ public class ClassicLevelStorage extends StoredObject {
this.loadedChunks.add(coord); this.loadedChunks.add(coord);
final Chunk viaChunk = new BaseChunk(coord.chunkX, coord.chunkZ, true, false, this.sectionBitmask, modernSections, new int[256], new ArrayList<>()); final Chunk viaChunk = new BaseChunk(coord.chunkX, coord.chunkZ, true, false, this.sectionBitmask, modernSections, new int[256], new ArrayList<>());
final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.getUser()); final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.user());
chunkData.write(Types1_1.CHUNK, viaChunk); chunkData.write(Types1_1.CHUNK, viaChunk);
chunkData.send(Protocolc0_28_30Toa1_0_15.class); chunkData.send(Protocolc0_28_30Toa1_0_15.class);
} }

View File

@ -76,7 +76,7 @@ public class ClassicOpLevelStorage extends StoredObject {
statusMessage += " "; statusMessage += " ";
statusMessage += this.respawn ? "§aRespawn" : "§cRespawn"; statusMessage += this.respawn ? "§aRespawn" : "§cRespawn";
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, this.getUser()); final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, this.user());
chatMessage.write(Typesb1_7_0_3.STRING, statusMessage); // message chatMessage.write(Typesb1_7_0_3.STRING, statusMessage); // message
chatMessage.send(Protocolc0_28_30Toa1_0_15.class); chatMessage.send(Protocolc0_28_30Toa1_0_15.class);
} }
@ -86,7 +86,7 @@ public class ClassicOpLevelStorage extends StoredObject {
this.opLevel = opLevel; this.opLevel = opLevel;
if (this.haxEnabled) { if (this.haxEnabled) {
final ClassicServerTitleStorage serverTitleStorage = this.getUser().get(ClassicServerTitleStorage.class); final ClassicServerTitleStorage serverTitleStorage = this.user().get(ClassicServerTitleStorage.class);
if (serverTitleStorage != null) { // Some servers update the op level before sending the login packet. Just ignore that because the op level is resent in the login packet. if (serverTitleStorage != null) { // Some servers update the op level before sending the login packet. Just ignore that because the op level is resent in the login packet.
this.updateHax(serverTitleStorage.isFlyEffectivelyEnabled(), serverTitleStorage.isNoclipEffectivelyEnabled(), serverTitleStorage.isSpeedEffectivelyEnabled(), serverTitleStorage.isRespawnEffectivelyEnabled()); this.updateHax(serverTitleStorage.isFlyEffectivelyEnabled(), serverTitleStorage.isNoclipEffectivelyEnabled(), serverTitleStorage.isSpeedEffectivelyEnabled(), serverTitleStorage.isRespawnEffectivelyEnabled());
} }
@ -98,8 +98,8 @@ public class ClassicOpLevelStorage extends StoredObject {
} }
public void updateAbilities() { public void updateAbilities() {
if (this.getUser().getProtocolInfo().getPipeline().contains(Protocolr1_2_1_3Tor1_2_4_5.class)) { if (this.user().getProtocolInfo().getPipeline().contains(Protocolr1_2_1_3Tor1_2_4_5.class)) {
final PacketWrapper playerAbilities = PacketWrapper.create(ClientboundPackets1_2_4.PLAYER_ABILITIES, this.getUser()); final PacketWrapper playerAbilities = PacketWrapper.create(ClientboundPackets1_2_4.PLAYER_ABILITIES, this.user());
playerAbilities.write(Types.BOOLEAN, true); // invulnerable playerAbilities.write(Types.BOOLEAN, true); // invulnerable
playerAbilities.write(Types.BOOLEAN, false); // flying playerAbilities.write(Types.BOOLEAN, false); // flying
playerAbilities.write(Types.BOOLEAN, this.flying); // allow flying playerAbilities.write(Types.BOOLEAN, this.flying); // allow flying

View File

@ -56,7 +56,7 @@ public class ClassicServerTitleStorage extends StoredObject {
} }
public boolean isFlyEffectivelyEnabled() { public boolean isFlyEffectivelyEnabled() {
final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100; final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isFlyEnabled() : !this.isFlyDisabled()) || (isOp && this.isOphaxEnabled()); return (this.isHaxDisabled() ? this.isFlyEnabled() : !this.isFlyDisabled()) || (isOp && this.isOphaxEnabled());
} }
@ -69,7 +69,7 @@ public class ClassicServerTitleStorage extends StoredObject {
} }
public boolean isNoclipEffectivelyEnabled() { public boolean isNoclipEffectivelyEnabled() {
final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100; final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isNoclipEnabled() : !this.isNoclipDisabled()) || (isOp && this.isOphaxEnabled()); return (this.isHaxDisabled() ? this.isNoclipEnabled() : !this.isNoclipDisabled()) || (isOp && this.isOphaxEnabled());
} }
@ -82,7 +82,7 @@ public class ClassicServerTitleStorage extends StoredObject {
} }
public boolean isRespawnEffectivelyEnabled() { public boolean isRespawnEffectivelyEnabled() {
final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100; final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isRespawnEnabled() : !this.isRespawnDisabled()) || (isOp && this.isOphaxEnabled()); return (this.isHaxDisabled() ? this.isRespawnEnabled() : !this.isRespawnDisabled()) || (isOp && this.isOphaxEnabled());
} }
@ -95,7 +95,7 @@ public class ClassicServerTitleStorage extends StoredObject {
} }
public boolean isSpeedEffectivelyEnabled() { public boolean isSpeedEffectivelyEnabled() {
final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100; final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isSpeedEnabled() : !this.isSpeedDisabled()) || (isOp && this.isOphaxEnabled()); return (this.isHaxDisabled() ? this.isSpeedEnabled() : !this.isSpeedDisabled()) || (isOp && this.isOphaxEnabled());
} }

View File

@ -68,7 +68,7 @@ public class PendingBlocksTracker extends StoredObject {
final PendingBlockEntry pendingBlockEntry = it.next(); final PendingBlockEntry pendingBlockEntry = it.next();
if (pendingBlockEntry.decrementAndCheckIsExpired()) { if (pendingBlockEntry.decrementAndCheckIsExpired()) {
it.remove(); it.remove();
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_UPDATE, this.getUser()); final PacketWrapper blockChange = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_UPDATE, this.user());
blockChange.write(Types1_7_6.BLOCK_POSITION_UBYTE, pendingBlockEntry.getPosition()); // position blockChange.write(Types1_7_6.BLOCK_POSITION_UBYTE, pendingBlockEntry.getPosition()); // position
blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getId()); // block id blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getId()); // block id
blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getData()); // block data blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getData()); // block data

View File

@ -157,7 +157,7 @@ public class EntityTracker extends StoredObject {
return; return;
} }
final PacketWrapper entitySound = PacketWrapper.create(ClientboundPackets1_3_1.CUSTOM_SOUND, this.getUser()); final PacketWrapper entitySound = PacketWrapper.create(ClientboundPackets1_3_1.CUSTOM_SOUND, this.user());
entitySound.write(Types1_6_4.STRING, sound.getSound().getSoundName()); // sound entitySound.write(Types1_6_4.STRING, sound.getSound().getSoundName()); // sound
entitySound.write(Types.INT, ((int) sourceLocation.getX()) * 8); // x entitySound.write(Types.INT, ((int) sourceLocation.getX()) * 8); // x
entitySound.write(Types.INT, ((int) sourceLocation.getY()) * 8); // y entitySound.write(Types.INT, ((int) sourceLocation.getY()) * 8); // y

View File

@ -38,10 +38,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap; import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap; import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; import com.viaversion.viaversion.protocols.base.*;
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ServerboundStatusPackets;
import com.viaversion.viaversion.protocols.base.v1_7.ClientboundBaseProtocol1_7; import com.viaversion.viaversion.protocols.base.v1_7.ClientboundBaseProtocol1_7;
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8;
import com.viaversion.viaversion.util.IdAndData; import com.viaversion.viaversion.util.IdAndData;
@ -849,6 +846,13 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol<Client
); );
this.cancelClientbound(ClientboundPackets1_6_4.SET_CREATIVE_MODE_SLOT); this.cancelClientbound(ClientboundPackets1_6_4.SET_CREATIVE_MODE_SLOT);
this.registerServerboundTransition(ServerboundHandshakePackets.CLIENT_INTENTION, null, wrapper -> {
wrapper.cancel();
wrapper.read(Types.VAR_INT); // protocol version
final String hostname = wrapper.read(Types.STRING); // hostname
final int port = wrapper.read(Types.UNSIGNED_SHORT); // port
wrapper.user().put(new HandshakeStorage(hostname, port));
});
this.registerServerboundTransition(ServerboundStatusPackets.STATUS_REQUEST, ServerboundPackets1_6_4.SERVER_PING, wrapper -> { this.registerServerboundTransition(ServerboundStatusPackets.STATUS_REQUEST, ServerboundPackets1_6_4.SERVER_PING, wrapper -> {
final HandshakeStorage handshakeStorage = wrapper.user().get(HandshakeStorage.class); final HandshakeStorage handshakeStorage = wrapper.user().get(HandshakeStorage.class);
final String ip = handshakeStorage.getHostname(); final String ip = handshakeStorage.getHostname();
@ -1104,6 +1108,7 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol<Client
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolr1_6_4Tor1_7_2_5.class, ClientboundPackets1_6_4::getPacket)); userConnection.put(new PreNettySplitter(Protocolr1_6_4Tor1_7_2_5.class, ClientboundPackets1_6_4::getPacket));
userConnection.put(new ProtocolMetadataStorage());
userConnection.put(new PlayerInfoStorage()); userConnection.put(new PlayerInfoStorage());
userConnection.put(new StatisticsStorage()); userConnection.put(new StatisticsStorage());
userConnection.put(new DimensionTracker()); userConnection.put(new DimensionTracker());

View File

@ -79,7 +79,7 @@ public class EntityTracker extends StoredObject {
this.entityMap.put(entityId, entityType); this.entityMap.put(entityId, entityType);
if (entityType == EntityTypes1_8.EntityType.HORSE || entityType == EntityTypes1_8.EntityType.WITHER_SKULL) { if (entityType == EntityTypes1_8.EntityType.HORSE || entityType == EntityTypes1_8.EntityType.WITHER_SKULL) {
this.hologramParts.put(entityId, new HologramPartEntity(this.getUser(), entityId, entityType)); this.hologramParts.put(entityId, new HologramPartEntity(this.user(), entityId, entityType));
} }
} }

View File

@ -48,7 +48,7 @@ public class TablistStorage extends StoredObject {
public void sendAddEntry(final TabListEntry entry) { public void sendAddEntry(final TabListEntry entry) {
final List<GameProfile.Property> gameProfileProperties = entry.gameProfile.getAllProperties(); final List<GameProfile.Property> gameProfileProperties = entry.gameProfile.getAllProperties();
final PacketWrapper addPlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.getUser()); final PacketWrapper addPlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.user());
addPlayerListItemPacket.write(Types.VAR_INT, 0); // action addPlayerListItemPacket.write(Types.VAR_INT, 0); // action
addPlayerListItemPacket.write(Types.VAR_INT, 1); // count addPlayerListItemPacket.write(Types.VAR_INT, 1); // count
addPlayerListItemPacket.write(Types.UUID, entry.gameProfile.uuid); // uuid addPlayerListItemPacket.write(Types.UUID, entry.gameProfile.uuid); // uuid
@ -68,7 +68,7 @@ public class TablistStorage extends StoredObject {
} }
public void sendRemoveEntry(final TabListEntry entry) { public void sendRemoveEntry(final TabListEntry entry) {
final PacketWrapper removePlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.getUser()); final PacketWrapper removePlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.user());
removePlayerListItemPacket.write(Types.VAR_INT, 4); // action removePlayerListItemPacket.write(Types.VAR_INT, 4); // action
removePlayerListItemPacket.write(Types.VAR_INT, 1); // count removePlayerListItemPacket.write(Types.VAR_INT, 1); // count
removePlayerListItemPacket.write(Types.UUID, entry.gameProfile.uuid); // uuid removePlayerListItemPacket.write(Types.UUID, entry.gameProfile.uuid); // uuid