Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
first Hacks for 1.14 support
Browse files Browse the repository at this point in the history
  • Loading branch information
fionera committed May 5, 2019
1 parent 1a9e0ab commit db662d4
Show file tree
Hide file tree
Showing 11 changed files with 1,811 additions and 11 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Expand Up @@ -9,6 +9,7 @@ plugins {
}

repositories {
maven("https://jitpack.io")
jcenter()
}

Expand Down Expand Up @@ -47,6 +48,8 @@ dependencies {
implementation("com.github.ben-manes.caffeine:caffeine:2.6.2")
implementation("commons-io:commons-io:2.6")

implementation("com.github.querz:nbt:4.0")

// todo: switch back to lombok plugin as soon as intellij picks up the dependency again
implementation("org.projectlombok:lombok:1.18.4")
annotationProcessor("org.projectlombok:lombok:1.18.4")
Expand Down
@@ -1,13 +1,16 @@
package rocks.cleanstone.game.world.chunk;

import com.google.common.base.Objects;
import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.lang3.SerializationUtils;
import rocks.cleanstone.game.block.Block;
import rocks.cleanstone.game.block.ImmutableBlock;
import rocks.cleanstone.game.material.block.vanilla.VanillaBlockType;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

public class ArrayBlockDataTable implements BlockDataTable {

private static final Block AIR = ImmutableBlock.of(VanillaBlockType.AIR);
Expand Down Expand Up @@ -87,7 +90,15 @@ public boolean hasSkylight() {

@Override
public Collection<Block> getBlocks() {
return Arrays.asList((Block[]) Arrays.stream(blocks).toArray());
ArrayList<Block> blockArrayList = new ArrayList<>();

for (Block[][] blockArrayArray : blocks) {
for (Block[] blockArray : blockArrayArray) {
Collections.addAll(blockArrayList, blockArray);
}
}

return blockArrayList;
}

@Override
Expand Down
Expand Up @@ -10,7 +10,8 @@ public enum MinecraftClientProtocolLayer implements ClientProtocolLayer {
MINECRAFT_V1_12_2("1.12.2", 340),
MINECRAFT_V1_13("1.13", 393),
MINECRAFT_V1_13_1("1.13.1", 401),
MINECRAFT_V1_13_2("1.13.2", 404);
MINECRAFT_V1_13_2("1.13.2", 404),
MINECRAFT_V1_14("1.14", 477);

private final String name;
private final int versionNumber;
Expand Down
@@ -0,0 +1,88 @@
package rocks.cleanstone.net.minecraft.protocol.v1_14;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import rocks.cleanstone.net.minecraft.protocol.MinecraftClientProtocolLayer;
import rocks.cleanstone.net.minecraft.protocol.v1_12_2.inbound.*;
import rocks.cleanstone.net.minecraft.protocol.v1_12_2.outbound.*;
import rocks.cleanstone.net.minecraft.protocol.v1_13_2.MinecraftProtocolLayer_v1_13_2;
import rocks.cleanstone.net.minecraft.protocol.v1_14.inbound.CreativeInventoryActionCodec;
import rocks.cleanstone.net.minecraft.protocol.v1_14.outbound.BlockChangeCodec;
import rocks.cleanstone.net.minecraft.protocol.v1_14.outbound.ChunkDataCodec;
import rocks.cleanstone.net.minecraft.protocol.v1_14.outbound.JoinGameCodec;
import rocks.cleanstone.net.protocol.PacketCodec;

import java.util.List;

import static rocks.cleanstone.net.minecraft.protocol.VanillaProtocolState.*;

@Component("minecraftProtocolLayer_v1_14")
public class MinecraftProtocolLayer_v1_14 extends MinecraftProtocolLayer_v1_13_2 {

@Autowired
public MinecraftProtocolLayer_v1_14(List<? extends PacketCodec> packetCodecs) {
super(packetCodecs);
// inbound
registerPacketCodec(HandshakeCodec.class, HANDSHAKE, 0x00);
registerPacketCodec(LoginStartCodec.class, LOGIN, 0x00);
registerPacketCodec(EncryptionRequestCodec.class, LOGIN, 0x01);
registerPacketCodec(RequestCodec.class, STATUS, 0x00);
registerPacketCodec(PingCodec.class, STATUS, 0x01);
registerPacketCodec(ClientSettingsCodec.class, PLAY, 0x05);
registerPacketCodec(InKeepAliveCodec.class, PLAY, 0x0F);
registerPacketCodec(InChatMessageCodec.class, PLAY, 0x03);
registerPacketCodec(InTabCompleteCodec.class, PLAY, 0x06);
registerPacketCodec(PlayerPositionCodec.class, PLAY, 0x11);
registerPacketCodec(PlayerLookCodec.class, PLAY, 0x13);
registerPacketCodec(PlayerPositionAndLookCodec.class, PLAY, 0x12);
registerPacketCodec(UseItemCodec.class, PLAY, 0x2D);
registerPacketCodec(PlayerBlockPlacementCodec.class, PLAY, 0x2C);
registerPacketCodec(PlayerDiggingCodec.class, PLAY, 0x1A);
registerPacketCodec(CreativeInventoryActionCodec.class, PLAY, 0x26);
registerPacketCodec(HeldItemChangeCodec.class, PLAY, 0x23);
registerPacketCodec(InPlayerAbilitiesCodec.class, PLAY, 0x19);
registerPacketCodec(InAnimationCodec.class, PLAY, 0x27);
registerPacketCodec(InTabCompleteCodec.class, PLAY, 0x06);
registerPacketCodec(InPluginMessageCodec.class, PLAY, 0x0B);
registerPacketCodec(PlayerCodec.class, PLAY, 0x14);

// outbound
registerPacketCodec(DisconnectCodec.class, PLAY, 0x1A);
registerPacketCodec(DisconnectLoginCodec.class, LOGIN, 0x00);
registerPacketCodec(SpawnMobCodec.class, PLAY, 0x03);
registerPacketCodec(EncryptionResponseCodec.class, LOGIN, 0x01);
registerPacketCodec(SetCompressionCodec.class, LOGIN, 0x03);
registerPacketCodec(LoginSuccessCodec.class, LOGIN, 0x02);
registerPacketCodec(ResponseCodec.class, STATUS, 0x00);
registerPacketCodec(PongCodec.class, STATUS, 0x01);
registerPacketCodec(JoinGameCodec.class, PLAY, 0x25);
registerPacketCodec(SpawnPositionCodec.class, PLAY, 0x4D);
registerPacketCodec(OutPlayerAbilitiesCodec.class, PLAY, 0x31);
registerPacketCodec(OutPlayerPositionAndLookCodec.class, PLAY, 0x35);
registerPacketCodec(ChunkDataCodec.class, PLAY, 0x21);
registerPacketCodec(OutKeepAliveCodec.class, PLAY, 0x20);
registerPacketCodec(OutTabCompleteCodec.class, PLAY, 0x10);
registerPacketCodec(OutChatMessageCodec.class, PLAY, 0x0E);
registerPacketCodec(WindowItemsCodec.class, PLAY, 0x14);
registerPacketCodec(PlayerListItemCodec.class, PLAY, 0x33);
registerPacketCodec(EntityLookCodec.class, PLAY, 0x2A);
registerPacketCodec(EntityRelativeMoveCodec.class, PLAY, 0x28);
registerPacketCodec(EntityLookAndRelativeMoveCodec.class, PLAY, 0x29);
registerPacketCodec(SpawnPlayerCodec.class, PLAY, 0x05);
registerPacketCodec(TimeUpdateCodec.class, PLAY, 0x4E);
registerPacketCodec(UnloadChunkCodec.class, PLAY, 0x1D);
registerPacketCodec(BlockChangeCodec.class, PLAY, 0x0B);
registerPacketCodec(EntityTeleportCodec.class, PLAY, 0x50);
registerPacketCodec(DestroyEntitiesCodec.class, PLAY, 0x37);
registerPacketCodec(ChangeGameStateCodec.class, PLAY, 0x1E);
registerPacketCodec(EntityHeadLookCodec.class, PLAY, 0x3B);
registerPacketCodec(OutAnimationCodec.class, PLAY, 0x06);
registerPacketCodec(SpawnObjectCodec.class, PLAY, 0x00);
registerPacketCodec(OutPluginMessageCodec.class, PLAY, 0x18);
}

@Override
public MinecraftClientProtocolLayer getCorrespondingClientLayer() {
return MinecraftClientProtocolLayer.MINECRAFT_V1_14;
}
}

0 comments on commit db662d4

Please sign in to comment.