mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-08 09:27:34 +01:00
parent
13f5c14599
commit
bdaa843f2d
2
pom.xml
2
pom.xml
@ -17,7 +17,7 @@
|
||||
<project.fullVersion>${project.version}</project.fullVersion>
|
||||
|
||||
<powermock.version>2.0.7</powermock.version>
|
||||
<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
|
||||
<spigot.version>1.16.2-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
@ -117,51 +117,51 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
public static final PacketType BOSS = new PacketType(PROTOCOL, SENDER, 0x0C, "Boss", "SPacketUpdateBossInfo");
|
||||
public static final PacketType SERVER_DIFFICULTY = new PacketType(PROTOCOL, SENDER, 0x0D, "ServerDifficulty", "SPacketServerDifficulty");
|
||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x0E, "Chat", "SPacketChat");
|
||||
public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x0F, "MultiBlockChange", "SPacketMultiBlockChange");
|
||||
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x10, "TabComplete", "SPacketTabComplete");
|
||||
public static final PacketType COMMANDS = new PacketType(PROTOCOL, SENDER, 0x11, "Commands");
|
||||
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x12, "Transaction", "SPacketConfirmTransaction");
|
||||
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x13, "CloseWindow", "SPacketCloseWindow");
|
||||
public static final PacketType WINDOW_ITEMS = new PacketType(PROTOCOL, SENDER, 0x14, "WindowItems", "SPacketWindowItems");
|
||||
public static final PacketType WINDOW_DATA = new PacketType(PROTOCOL, SENDER, 0x15, "WindowData", "SPacketWindowProperty");
|
||||
public static final PacketType SET_SLOT = new PacketType(PROTOCOL, SENDER, 0x16, "SetSlot", "SPacketSetSlot");
|
||||
public static final PacketType SET_COOLDOWN = new PacketType(PROTOCOL, SENDER, 0x17, "SetCooldown", "SPacketCooldown");
|
||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x18, "CustomPayload", "SPacketCustomPayload");
|
||||
public static final PacketType CUSTOM_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x19, "CustomSoundEffect", "SPacketCustomSound");
|
||||
public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x1A, "KickDisconnect", "SPacketDisconnect");
|
||||
public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1B, "EntityStatus", "SPacketEntityStatus");
|
||||
public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x1C, "Explosion", "SPacketExplosion");
|
||||
public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x1D, "UnloadChunk", "SPacketUnloadChunk");
|
||||
public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x1E, "GameStateChange", "SPacketChangeGameState");
|
||||
public static final PacketType OPEN_WINDOW_HORSE = new PacketType(PROTOCOL, SENDER, 0x1F, "OpenWindowHorse");
|
||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x20, "KeepAlive", "SPacketKeepAlive");
|
||||
public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x21, "MapChunk", "SPacketChunkData");
|
||||
public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x22, "WorldEvent", "SPacketEffect");
|
||||
public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x23, "WorldParticles", "SPacketParticles");
|
||||
public static final PacketType LIGHT_UPDATE = new PacketType(PROTOCOL, SENDER, 0x24, "LightUpdate");
|
||||
public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x25, "Login", "SPacketJoinGame");
|
||||
public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x26, "Map", "SPacketMaps");
|
||||
public static final PacketType OPEN_WINDOW_MERCHANT = new PacketType(PROTOCOL, SENDER, 0x27, "OpenWindowMerchant");
|
||||
public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x28, "Entity$RelEntityMove", "SPacketEntity$S15PacketEntityRelMove");
|
||||
public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x29, "Entity$RelEntityMoveLook", "SPacketEntity$S17PacketEntityLookMove");
|
||||
public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x2A, "Entity$EntityLook", "SPacketEntity$S16PacketEntityLook");
|
||||
public static final PacketType ENTITY = new PacketType(PROTOCOL, SENDER, 0x2B, "Entity", "SPacketEntity");
|
||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x2C, "VehicleMove", "SPacketMoveVehicle");
|
||||
public static final PacketType OPEN_BOOK = new PacketType(PROTOCOL, SENDER, 0x2D, "OpenBook");
|
||||
public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x2E, "OpenWindow", "SPacketOpenWindow");
|
||||
public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x2F, "OpenSignEditor", "SPacketSignEditorOpen");
|
||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x30, "AutoRecipe", "SPacketPlaceGhostRecipe");
|
||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x31, "Abilities", "SPacketPlayerAbilities");
|
||||
public static final PacketType COMBAT_EVENT = new PacketType(PROTOCOL, SENDER, 0x32, "CombatEvent", "SPacketCombatEvent");
|
||||
public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x33, "PlayerInfo", "SPacketPlayerListItem");
|
||||
public static final PacketType LOOK_AT = new PacketType(PROTOCOL, SENDER, 0x34, "LookAt", "SPacketPlayerPosLook");
|
||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x35, "Position");
|
||||
public static final PacketType RECIPES = new PacketType(PROTOCOL, SENDER, 0x36, "Recipes", "SPacketRecipeBook");
|
||||
public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x37, "EntityDestroy", "SPacketDestroyEntities");
|
||||
public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x38, "RemoveEntityEffect", "SPacketRemoveEntityEffect");
|
||||
public static final PacketType RESOURCE_PACK_SEND = new PacketType(PROTOCOL, SENDER, 0x39, "ResourcePackSend", "SPacketResourcePackSend");
|
||||
public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x3A, "Respawn", "SPacketRespawn");
|
||||
public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x3B, "EntityHeadRotation", "SPacketEntityHeadLook");
|
||||
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0F, "TabComplete", "SPacketTabComplete");
|
||||
public static final PacketType COMMANDS = new PacketType(PROTOCOL, SENDER, 0x10, "Commands");
|
||||
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x11, "Transaction", "SPacketConfirmTransaction");
|
||||
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x12, "CloseWindow", "SPacketCloseWindow");
|
||||
public static final PacketType WINDOW_ITEMS = new PacketType(PROTOCOL, SENDER, 0x13, "WindowItems", "SPacketWindowItems");
|
||||
public static final PacketType WINDOW_DATA = new PacketType(PROTOCOL, SENDER, 0x14, "WindowData", "SPacketWindowProperty");
|
||||
public static final PacketType SET_SLOT = new PacketType(PROTOCOL, SENDER, 0x15, "SetSlot", "SPacketSetSlot");
|
||||
public static final PacketType SET_COOLDOWN = new PacketType(PROTOCOL, SENDER, 0x16, "SetCooldown", "SPacketCooldown");
|
||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x17, "CustomPayload", "SPacketCustomPayload");
|
||||
public static final PacketType CUSTOM_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x18, "CustomSoundEffect", "SPacketCustomSound");
|
||||
public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x19, "KickDisconnect", "SPacketDisconnect");
|
||||
public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1A, "EntityStatus", "SPacketEntityStatus");
|
||||
public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x1B, "Explosion", "SPacketExplosion");
|
||||
public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x1C, "UnloadChunk", "SPacketUnloadChunk");
|
||||
public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x1D, "GameStateChange", "SPacketChangeGameState");
|
||||
public static final PacketType OPEN_WINDOW_HORSE = new PacketType(PROTOCOL, SENDER, 0x1E, "OpenWindowHorse");
|
||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x1F, "KeepAlive", "SPacketKeepAlive");
|
||||
public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x20, "MapChunk", "SPacketChunkData");
|
||||
public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x21, "WorldEvent", "SPacketEffect");
|
||||
public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x22, "WorldParticles", "SPacketParticles");
|
||||
public static final PacketType LIGHT_UPDATE = new PacketType(PROTOCOL, SENDER, 0x23, "LightUpdate");
|
||||
public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x24, "Login", "SPacketJoinGame");
|
||||
public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x25, "Map", "SPacketMaps");
|
||||
public static final PacketType OPEN_WINDOW_MERCHANT = new PacketType(PROTOCOL, SENDER, 0x26, "OpenWindowMerchant");
|
||||
public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x27, "Entity$RelEntityMove", "SPacketEntity$S15PacketEntityRelMove");
|
||||
public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x28, "Entity$RelEntityMoveLook", "SPacketEntity$S17PacketEntityLookMove");
|
||||
public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x29, "Entity$EntityLook", "SPacketEntity$S16PacketEntityLook");
|
||||
public static final PacketType ENTITY = new PacketType(PROTOCOL, SENDER, 0x2A, "Entity", "SPacketEntity");
|
||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x2B, "VehicleMove", "SPacketMoveVehicle");
|
||||
public static final PacketType OPEN_BOOK = new PacketType(PROTOCOL, SENDER, 0x2C, "OpenBook");
|
||||
public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x2D, "OpenWindow", "SPacketOpenWindow");
|
||||
public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x2E, "OpenSignEditor", "SPacketSignEditorOpen");
|
||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x2F, "AutoRecipe", "SPacketPlaceGhostRecipe");
|
||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x30, "Abilities", "SPacketPlayerAbilities");
|
||||
public static final PacketType COMBAT_EVENT = new PacketType(PROTOCOL, SENDER, 0x31, "CombatEvent", "SPacketCombatEvent");
|
||||
public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x32, "PlayerInfo", "SPacketPlayerListItem");
|
||||
public static final PacketType LOOK_AT = new PacketType(PROTOCOL, SENDER, 0x33, "LookAt", "SPacketPlayerPosLook");
|
||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x34, "Position");
|
||||
public static final PacketType RECIPES = new PacketType(PROTOCOL, SENDER, 0x35, "Recipes", "SPacketRecipeBook");
|
||||
public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x36, "EntityDestroy", "SPacketDestroyEntities");
|
||||
public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x37, "RemoveEntityEffect", "SPacketRemoveEntityEffect");
|
||||
public static final PacketType RESOURCE_PACK_SEND = new PacketType(PROTOCOL, SENDER, 0x38, "ResourcePackSend", "SPacketResourcePackSend");
|
||||
public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x39, "Respawn", "SPacketRespawn");
|
||||
public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x3A, "EntityHeadRotation", "SPacketEntityHeadLook");
|
||||
public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x3B, "MultiBlockChange", "SPacketMultiBlockChange");
|
||||
public static final PacketType SELECT_ADVANCEMENT_TAB = new PacketType(PROTOCOL, SENDER, 0x3C, "SelectAdvancementTab", "SPacketSelectAdvancementsTab");
|
||||
public static final PacketType WORLD_BORDER = new PacketType(PROTOCOL, SENDER, 0x3D, "WorldBorder", "SPacketWorldBorder");
|
||||
public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x3E, "Camera", "SPacketCamera");
|
||||
@ -320,23 +320,24 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x1B, "BlockDig", "CPacketPlayerDigging");
|
||||
public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x1C, "EntityAction", "CPacketEntityAction");
|
||||
public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x1D, "SteerVehicle", "CPacketInput");
|
||||
public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x1E, "RecipeDisplayed", "CPacketRecipeInfo");
|
||||
public static final PacketType ITEM_NAME = new PacketType(PROTOCOL, SENDER, 0x1F, "ItemName");
|
||||
public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x20, "ResourcePackStatus", "CPacketResourcePackStatus");
|
||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x21, "Advancements", "CPacketSeenAdvancements");
|
||||
public static final PacketType TR_SEL = new PacketType(PROTOCOL, SENDER, 0x22, "TrSel");
|
||||
public static final PacketType BEACON = new PacketType(PROTOCOL, SENDER, 0x23, "Beacon");
|
||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x24, "HeldItemSlot", "CPacketHeldItemChange");
|
||||
public static final PacketType SET_COMMAND_BLOCK = new PacketType(PROTOCOL, SENDER, 0x25, "SetCommandBlock");
|
||||
public static final PacketType SET_COMMAND_MINECART = new PacketType(PROTOCOL, SENDER, 0x26, "SetCommandMinecart");
|
||||
public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x27, "SetCreativeSlot", "CPacketCreativeInventoryAction");
|
||||
public static final PacketType SET_JIGSAW = new PacketType(PROTOCOL, SENDER, 0x28, "SetJigsaw");
|
||||
public static final PacketType STRUCT = new PacketType(PROTOCOL, SENDER, 0x29, "Struct");
|
||||
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x2A, "UpdateSign", "CPacketUpdateSign");
|
||||
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x2B, "ArmAnimation", "CPacketAnimation");
|
||||
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x2C, "Spectate", "CPacketSpectate");
|
||||
public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x2D, "UseItem", "CPacketPlayerTryUseItemOnBlock");
|
||||
public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x2E, "BlockPlace", "CPacketPlayerTryUseItem");
|
||||
public static final PacketType RECIPE_SETTINGS = new PacketType(PROTOCOL, SENDER, 0x1E, "RecipeSettings");
|
||||
public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x1F, "RecipeDisplayed", "CPacketRecipeInfo");
|
||||
public static final PacketType ITEM_NAME = new PacketType(PROTOCOL, SENDER, 0x20, "ItemName");
|
||||
public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x21, "ResourcePackStatus", "CPacketResourcePackStatus");
|
||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x22, "Advancements", "CPacketSeenAdvancements");
|
||||
public static final PacketType TR_SEL = new PacketType(PROTOCOL, SENDER, 0x23, "TrSel");
|
||||
public static final PacketType BEACON = new PacketType(PROTOCOL, SENDER, 0x24, "Beacon");
|
||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x25, "HeldItemSlot", "CPacketHeldItemChange");
|
||||
public static final PacketType SET_COMMAND_BLOCK = new PacketType(PROTOCOL, SENDER, 0x26, "SetCommandBlock");
|
||||
public static final PacketType SET_COMMAND_MINECART = new PacketType(PROTOCOL, SENDER, 0x27, "SetCommandMinecart");
|
||||
public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x28, "SetCreativeSlot", "CPacketCreativeInventoryAction");
|
||||
public static final PacketType SET_JIGSAW = new PacketType(PROTOCOL, SENDER, 0x29, "SetJigsaw");
|
||||
public static final PacketType STRUCT = new PacketType(PROTOCOL, SENDER, 0x2A, "Struct");
|
||||
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x2B, "UpdateSign", "CPacketUpdateSign");
|
||||
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x2C, "ArmAnimation", "CPacketAnimation");
|
||||
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x2D, "Spectate", "CPacketSpectate");
|
||||
public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x2E, "UseItem", "CPacketPlayerTryUseItemOnBlock");
|
||||
public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x2F, "BlockPlace", "CPacketPlayerTryUseItem");
|
||||
|
||||
private final static Client INSTANCE = new Client();
|
||||
|
||||
|
@ -294,7 +294,15 @@ public class PacketContainer implements Serializable {
|
||||
public StructureModifier<int[]> getIntegerArrays() {
|
||||
return structureModifier.withType(int[].class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a read/write structure for every short array field.
|
||||
* @return A modifier for every short array field.
|
||||
*/
|
||||
public StructureModifier<short[]> getShortArrays() {
|
||||
return structureModifier.withType(short[].class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a read/write structure for ItemStack.
|
||||
* <p>
|
||||
@ -581,7 +589,21 @@ public class PacketContainer implements Serializable {
|
||||
public StructureModifier<WrappedBlockData> getBlockData() {
|
||||
// Convert to and from our wrapper
|
||||
return structureModifier.withType(
|
||||
MinecraftReflection.getIBlockDataClass(), BukkitConverters.getWrappedBlockDataConverter());
|
||||
MinecraftReflection.getIBlockDataClass(),
|
||||
BukkitConverters.getWrappedBlockDataConverter()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a read/write structure for IBlockData arrays in Minecraft 1.16.2+
|
||||
* @return A modifier for IBlockData array fields
|
||||
*/
|
||||
public StructureModifier<WrappedBlockData[]> getBlockDataArrays() {
|
||||
// TODO we might want to make this a lazy converter and only convert indexes as needed
|
||||
return structureModifier.withType(
|
||||
MinecraftReflection.getArrayClass(MinecraftReflection.getIBlockDataClass()),
|
||||
Converters.array(MinecraftReflection.getIBlockDataClass(), BukkitConverters.getWrappedBlockDataConverter())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -596,7 +618,9 @@ public class PacketContainer implements Serializable {
|
||||
|
||||
// Convert to and from our wrapper
|
||||
return structureModifier.withType(
|
||||
MinecraftReflection.getMultiBlockChangeInfoArrayClass(), MultiBlockChangeInfo.getArrayConverter(chunk));
|
||||
MinecraftReflection.getMultiBlockChangeInfoArrayClass(),
|
||||
Converters.array(MinecraftReflection.getMultiBlockChangeInfoClass(), MultiBlockChangeInfo.getConverter(chunk))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -918,14 +942,12 @@ public class PacketContainer implements Serializable {
|
||||
MinecraftKey.getConverter());
|
||||
}
|
||||
|
||||
private static final boolean NEW_DIMENSIONS = MinecraftVersion.NETHER_UPDATE.atOrAbove();
|
||||
|
||||
/**
|
||||
* Retrieve a read/write structure for dimension IDs in 1.13.1+
|
||||
* @return A modifier for dimension IDs
|
||||
*/
|
||||
public StructureModifier<Integer> getDimensions() {
|
||||
if (NEW_DIMENSIONS) {
|
||||
if (MinecraftVersion.NETHER_UPDATE.atOrAbove() && !MinecraftVersion.NETHER_UPDATE_2.atOrAbove()) {
|
||||
return structureModifier.withParamType(
|
||||
MinecraftReflection.getMinecraftClass("ResourceKey"),
|
||||
BukkitConverters.getDimensionIDConverter(),
|
||||
@ -984,6 +1006,17 @@ public class PacketContainer implements Serializable {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a read/write structure for SectionPositions in 1.16.2+
|
||||
* @return The Structure Modifier
|
||||
*/
|
||||
public StructureModifier<BlockPosition> getSectionPositions() {
|
||||
return structureModifier.withType(
|
||||
MinecraftReflection.getMinecraftClass("SectionPosition"),
|
||||
BukkitConverters.getSectionPositionConverter()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a read/write structure for the Map class.
|
||||
* @param keyConverter Converter for map keys
|
||||
|
@ -64,13 +64,13 @@ public class ImmutableDetector implements Cloner {
|
||||
add(MinecraftReflection::getItemClass);
|
||||
add("SoundEffect");
|
||||
|
||||
if (MinecraftVersion.atOrAbove(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
if (MinecraftVersion.AQUATIC_UPDATE.atOrAbove()) {
|
||||
add(MinecraftReflection::getFluidTypeClass);
|
||||
add(MinecraftReflection::getParticleTypeClass);
|
||||
add("Particle");
|
||||
}
|
||||
|
||||
if (MinecraftVersion.atOrAbove(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||
if (MinecraftVersion.VILLAGE_UPDATE.atOrAbove()) {
|
||||
add("EntityTypes");
|
||||
add("VillagerType");
|
||||
add("VillagerProfession");
|
||||
@ -79,9 +79,13 @@ public class ImmutableDetector implements Cloner {
|
||||
// TODO automatically detect the technically-not-an-enum enums that Mojang is so fond of
|
||||
// Would also probably go in tandem with having the FieldCloner use this
|
||||
|
||||
if (MinecraftVersion.atOrAbove(MinecraftVersion.NETHER_UPDATE)) {
|
||||
if (MinecraftVersion.NETHER_UPDATE.atOrAbove()) {
|
||||
add("IRegistry");
|
||||
}
|
||||
|
||||
if (MinecraftVersion.NETHER_UPDATE_2.atOrAbove()) {
|
||||
add("ResourceKey");
|
||||
}
|
||||
}
|
||||
|
||||
private static void add(Supplier<Class<?>> getClass) {
|
||||
|
@ -21,10 +21,10 @@ package com.comphenix.protocol.utility;
|
||||
*/
|
||||
|
||||
public final class Constants {
|
||||
public static final String PACKAGE_VERSION = "v1_16_R1";
|
||||
public static final String PACKAGE_VERSION = "v1_16_R2";
|
||||
public static final String NMS = "net.minecraft.server." + PACKAGE_VERSION;
|
||||
public static final String OBC = "org.bukkit.craftbukkit." + PACKAGE_VERSION;
|
||||
public static final MinecraftVersion CURRENT_VERSION = MinecraftVersion.NETHER_UPDATE;
|
||||
public static final MinecraftVersion CURRENT_VERSION = MinecraftVersion.NETHER_UPDATE_2;
|
||||
|
||||
public static void init() {
|
||||
MinecraftReflection.setMinecraftPackage(NMS, OBC);
|
||||
|
@ -69,6 +69,7 @@ public class MinecraftProtocolVersion {
|
||||
|
||||
map.put(new MinecraftVersion(1, 16, 0), 735);
|
||||
map.put(new MinecraftVersion(1, 16, 1), 736);
|
||||
map.put(new MinecraftVersion(1, 16, 2), 751);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,12 @@ public class MinecraftVersion implements Comparable<MinecraftVersion>, Serializa
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-.]+).*");
|
||||
|
||||
/**
|
||||
* Version 1.16 - the nether update
|
||||
* Version 1.16.2 - breaking change to the nether update
|
||||
*/
|
||||
public static final MinecraftVersion NETHER_UPDATE_2 = new MinecraftVersion("1.16.2");
|
||||
|
||||
/**
|
||||
* Version 1.16.0 - the nether update
|
||||
*/
|
||||
public static final MinecraftVersion NETHER_UPDATE = new MinecraftVersion("1.16");
|
||||
|
||||
@ -117,6 +122,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion>, Serializa
|
||||
private final int major;
|
||||
private final int minor;
|
||||
private final int build;
|
||||
private Boolean atLeast;
|
||||
|
||||
// The development stage
|
||||
private final String development;
|
||||
@ -270,7 +276,11 @@ public class MinecraftVersion implements Comparable<MinecraftVersion>, Serializa
|
||||
}
|
||||
|
||||
public boolean atOrAbove() {
|
||||
return MinecraftVersion.getCurrentVersion().isAtLeast(this);
|
||||
if (atLeast == null) {
|
||||
atLeast = MinecraftVersion.atOrAbove(this);
|
||||
}
|
||||
|
||||
return atLeast;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1164,9 +1164,9 @@ public class BukkitConverters {
|
||||
});
|
||||
}
|
||||
|
||||
private static final boolean NEW_DIMENSION = MinecraftVersion.NETHER_UPDATE.atOrAbove();
|
||||
private static Class<?> dimensionManager;
|
||||
private static FauxEnumConverter<Dimension> dimensionConverter;
|
||||
private static FauxEnumConverter<DimensionImpl> dimensionImplConverter;
|
||||
|
||||
private static MethodAccessor dimensionFromId = null;
|
||||
private static MethodAccessor idFromDimension = null;
|
||||
@ -1224,6 +1224,26 @@ public class BukkitConverters {
|
||||
});
|
||||
}
|
||||
|
||||
enum DimensionImpl {
|
||||
OVERWORLD_IMPL(0),
|
||||
THE_NETHER_IMPL(-1),
|
||||
THE_END_IMPL(1);
|
||||
|
||||
int id;
|
||||
DimensionImpl(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
static DimensionImpl fromId(int id) {
|
||||
switch (id) {
|
||||
case 0: return OVERWORLD_IMPL;
|
||||
case -1: return THE_NETHER_IMPL;
|
||||
case 1: return THE_END_IMPL;
|
||||
default: throw new IllegalArgumentException("Invalid dimension " + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static EquivalentConverter<Integer> getDimensionIDConverter() {
|
||||
return ignoreNull(new EquivalentConverter<Integer>() {
|
||||
@Override
|
||||
@ -1232,27 +1252,34 @@ public class BukkitConverters {
|
||||
dimensionManager = MinecraftReflection.getNullableNMS("DimensionManager");
|
||||
}
|
||||
|
||||
if (NEW_DIMENSION) {
|
||||
if (MinecraftVersion.NETHER_UPDATE_2.atOrAbove()) {
|
||||
if (dimensionImplConverter == null) {
|
||||
dimensionImplConverter = new FauxEnumConverter<>(DimensionImpl.class, dimensionManager);
|
||||
}
|
||||
|
||||
DimensionImpl dimension = DimensionImpl.fromId(specific);
|
||||
return dimensionImplConverter.getGeneric(dimension);
|
||||
} else if (MinecraftVersion.NETHER_UPDATE.atOrAbove()) {
|
||||
if (dimensionConverter == null) {
|
||||
dimensionConverter = new FauxEnumConverter<>(Dimension.class, dimensionManager);
|
||||
}
|
||||
|
||||
Dimension dimension = Dimension.fromId(specific);
|
||||
return dimensionConverter.getGeneric(dimension);
|
||||
}
|
||||
} else {
|
||||
if (dimensionFromId == null) {
|
||||
FuzzyReflection reflection = FuzzyReflection.fromClass(dimensionManager, false);
|
||||
FuzzyMethodContract contract = FuzzyMethodContract
|
||||
.newBuilder()
|
||||
.requireModifier(Modifier.STATIC)
|
||||
.parameterExactType(int.class)
|
||||
.returnTypeExact(dimensionManager)
|
||||
.build();
|
||||
dimensionFromId = Accessors.getMethodAccessor(reflection.getMethod(contract));
|
||||
}
|
||||
|
||||
if (dimensionFromId == null) {
|
||||
FuzzyReflection reflection = FuzzyReflection.fromClass(dimensionManager, false);
|
||||
FuzzyMethodContract contract = FuzzyMethodContract
|
||||
.newBuilder()
|
||||
.requireModifier(Modifier.STATIC)
|
||||
.parameterExactType(int.class)
|
||||
.returnTypeExact(dimensionManager)
|
||||
.build();
|
||||
dimensionFromId = Accessors.getMethodAccessor(reflection.getMethod(contract));
|
||||
return dimensionFromId.invoke(null, specific);
|
||||
}
|
||||
|
||||
return dimensionFromId.invoke(null, specific);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1261,27 +1288,34 @@ public class BukkitConverters {
|
||||
dimensionManager = MinecraftReflection.getNullableNMS("DimensionManager");
|
||||
}
|
||||
|
||||
if (NEW_DIMENSION) {
|
||||
if (MinecraftVersion.NETHER_UPDATE_2.atOrAbove()) {
|
||||
if (dimensionImplConverter == null) {
|
||||
dimensionImplConverter = new FauxEnumConverter<>(DimensionImpl.class, dimensionManager);
|
||||
}
|
||||
|
||||
DimensionImpl dimension = dimensionImplConverter.getSpecific(generic);
|
||||
return dimension.id;
|
||||
} else if (MinecraftVersion.NETHER_UPDATE.atOrAbove()) {
|
||||
if (dimensionConverter == null) {
|
||||
dimensionConverter = new FauxEnumConverter<>(Dimension.class, dimensionManager);
|
||||
}
|
||||
|
||||
Dimension dimension = dimensionConverter.getSpecific(generic);
|
||||
return dimension.getId();
|
||||
}
|
||||
} else {
|
||||
if (idFromDimension == null) {
|
||||
FuzzyReflection reflection = FuzzyReflection.fromClass(dimensionManager, false);
|
||||
FuzzyMethodContract contract = FuzzyMethodContract
|
||||
.newBuilder()
|
||||
.banModifier(Modifier.STATIC)
|
||||
.returnTypeExact(int.class)
|
||||
.parameterCount(0)
|
||||
.build();
|
||||
idFromDimension = Accessors.getMethodAccessor(reflection.getMethod(contract));
|
||||
}
|
||||
|
||||
if (idFromDimension == null) {
|
||||
FuzzyReflection reflection = FuzzyReflection.fromClass(dimensionManager, false);
|
||||
FuzzyMethodContract contract = FuzzyMethodContract
|
||||
.newBuilder()
|
||||
.banModifier(Modifier.STATIC)
|
||||
.returnTypeExact(int.class)
|
||||
.parameterCount(0)
|
||||
.build();
|
||||
idFromDimension = Accessors.getMethodAccessor(reflection.getMethod(contract));
|
||||
return (Integer) idFromDimension.invoke(generic);
|
||||
}
|
||||
|
||||
return (Integer) idFromDimension.invoke(generic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1339,5 +1373,42 @@ public class BukkitConverters {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static MethodAccessor sectionPositionCreate;
|
||||
private static Class<?> sectionPositionClass;
|
||||
|
||||
public static EquivalentConverter<BlockPosition> getSectionPositionConverter() {
|
||||
return ignoreNull(new EquivalentConverter<BlockPosition>() {
|
||||
@Override
|
||||
public Object getGeneric(BlockPosition specific) {
|
||||
if (sectionPositionClass == null) {
|
||||
sectionPositionClass = MinecraftReflection.getMinecraftClass("SectionPosition");
|
||||
}
|
||||
|
||||
if (sectionPositionCreate == null) {
|
||||
sectionPositionCreate = Accessors.getMethodAccessor(
|
||||
FuzzyReflection.fromClass(sectionPositionClass).getMethod(FuzzyMethodContract
|
||||
.newBuilder()
|
||||
.requireModifier(Modifier.STATIC)
|
||||
.returnTypeExact(sectionPositionClass)
|
||||
.parameterExactArray(int.class, int.class, int.class)
|
||||
.build())
|
||||
);
|
||||
}
|
||||
|
||||
return sectionPositionCreate.invoke(null, specific.x, specific.y, specific.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPosition getSpecific(Object generic) {
|
||||
StructureModifier<Integer> modifier = new StructureModifier<>(generic.getClass()).withTarget(generic).withType(int.class);
|
||||
return new BlockPosition(modifier.readSafely(0), modifier.readSafely(1), modifier.readSafely(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BlockPosition> getSpecificType() {
|
||||
return BlockPosition.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,17 @@
|
||||
*/
|
||||
package com.comphenix.protocol.wrappers;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
|
||||
/**
|
||||
* Utility class for converters
|
||||
* @author dmulloy2
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Converters {
|
||||
|
||||
/**
|
||||
@ -103,4 +106,47 @@ public class Converters {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a generic array converter. Converts a NMS object array to and from a wrapper array by converting
|
||||
* each element individually.
|
||||
*
|
||||
* @param nmsClass NMS class
|
||||
* @param converter Underlying converter
|
||||
* @param <T> Generic type
|
||||
* @return An array converter
|
||||
*/
|
||||
public static <T> EquivalentConverter<T[]> array(final Class<?> nmsClass, final EquivalentConverter<T> converter) {
|
||||
return new EquivalentConverter<T[]>() {
|
||||
@Override
|
||||
public T[] getSpecific(Object generic) {
|
||||
Object[] array = (Object[]) generic;
|
||||
T[] result = (T[]) new Object[array.length];
|
||||
|
||||
// Unwrap every item
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = converter.getSpecific(array[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGeneric(T[] specific) {
|
||||
Object[] result = (Object[]) Array.newInstance(nmsClass, specific.length);
|
||||
|
||||
// Wrap every item
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = converter.getGeneric(specific[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T[]> getSpecificType() {
|
||||
return (Class<T[]>) MinecraftReflection.getArrayClass(converter.getSpecificType());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -915,9 +915,9 @@ public abstract class EnumWrappers {
|
||||
return lookup.computeIfAbsent(generic, x -> {
|
||||
for (Field field : genericClass.getDeclaredFields()) {
|
||||
try {
|
||||
// if (!field.isAccessible()) {
|
||||
// field.setAccessible(true);
|
||||
//}
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
|
||||
if (field.get(null) == generic) {
|
||||
return Enum.valueOf(specificClass, field.getName().toUpperCase());
|
||||
|
@ -229,40 +229,4 @@ public class MultiBlockChangeInfo {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static EquivalentConverter<MultiBlockChangeInfo[]> getArrayConverter(final ChunkCoordIntPair chunk) {
|
||||
return new EquivalentConverter<MultiBlockChangeInfo[]>() {
|
||||
private final EquivalentConverter<MultiBlockChangeInfo> converter = MultiBlockChangeInfo.getConverter(chunk);
|
||||
|
||||
@Override
|
||||
public MultiBlockChangeInfo[] getSpecific(Object generic) {
|
||||
Object[] array = (Object[]) generic;
|
||||
MultiBlockChangeInfo[] result = new MultiBlockChangeInfo[array.length];
|
||||
|
||||
// Unwrap every item
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = converter.getSpecific(array[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGeneric(MultiBlockChangeInfo[] specific) {
|
||||
Object[] result = (Object[]) Array.newInstance(nmsClass, specific.length);
|
||||
|
||||
// Wrap every item
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = converter.getGeneric(specific[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<MultiBlockChangeInfo[]> getSpecificType() {
|
||||
return MultiBlockChangeInfo[].class;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,17 @@ import java.util.List;
|
||||
import com.comphenix.protocol.reflect.FieldUtils;
|
||||
import com.comphenix.protocol.utility.Constants;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.DispenserRegistry;
|
||||
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||
import net.minecraft.server.v1_16_R2.DispenserRegistry;
|
||||
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemFactory;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.util.Versioning;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemFactory;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.util.Versioning;
|
||||
import org.spigotmc.SpigotWorldConfig;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -27,11 +27,12 @@ import com.comphenix.protocol.utility.Constants;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.EnumProtocol;
|
||||
import net.minecraft.server.v1_16_R1.EnumProtocolDirection;
|
||||
import net.minecraft.server.v1_16_R1.PacketLoginInStart;
|
||||
import net.minecraft.server.v1_16_R2.EnumProtocol;
|
||||
import net.minecraft.server.v1_16_R2.EnumProtocolDirection;
|
||||
import net.minecraft.server.v1_16_R2.PacketLoginInStart;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -50,6 +51,11 @@ public class PacketTypeTest {
|
||||
};
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
PacketType.onDynamicCreate = __ -> {};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) throws Exception {
|
||||
Constants.init();
|
||||
|
@ -38,9 +38,9 @@ import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.md_5.bungee.api.chat.*;
|
||||
import net.minecraft.server.v1_16_R1.*;
|
||||
import net.minecraft.server.v1_16_R1.MinecraftKey;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot;
|
||||
import net.minecraft.server.v1_16_R2.*;
|
||||
import net.minecraft.server.v1_16_R2.MinecraftKey;
|
||||
import net.minecraft.server.v1_16_R2.PacketPlayOutUpdateAttributes.AttributeSnapshot;
|
||||
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
@ -64,7 +64,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
// Ensure that the CraftItemFactory is mockable
|
||||
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" })
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*", "javax.management.*", "javax.xml.parsers.*", "com.sun.org.apache.xerces.internal.jaxp.*" })
|
||||
//@PrepareForTest(CraftItemFactory.class)
|
||||
public class PacketContainerTest {
|
||||
// Helper converters
|
||||
@ -542,6 +542,25 @@ public class PacketContainerTest {
|
||||
assertTrue(back.isInsideBlock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiBlockChange() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE);
|
||||
|
||||
packet.getShortArrays().writeSafely(0, new short[] { 420, 69 });
|
||||
assertArrayEquals(new short[] { 420, 69}, packet.getShortArrays().readSafely(0));
|
||||
|
||||
packet.getBlockDataArrays().writeSafely(0, new WrappedBlockData[] {
|
||||
WrappedBlockData.createData(Material.IRON_BARS),
|
||||
WrappedBlockData.createData(Material.IRON_BLOCK)
|
||||
});
|
||||
assertArrayEquals(new WrappedBlockData[] {
|
||||
WrappedBlockData.createData(Material.IRON_BARS),
|
||||
WrappedBlockData.createData(Material.IRON_BLOCK)
|
||||
}, packet.getBlockDataArrays().readSafely(0));
|
||||
|
||||
packet.getSectionPositions().writeSafely(0, new BlockPosition(42, 43, 44));
|
||||
assertEquals(new BlockPosition(42, 43, 44), packet.getSectionPositions().readSafely(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions from the outbound Boss packet. Used for testing generic enums.
|
||||
@ -573,7 +592,8 @@ public class PacketContainerTest {
|
||||
public void testDeepClone() {
|
||||
// Try constructing all the packets
|
||||
for (PacketType type : PacketType.values()) {
|
||||
if (type.isDeprecated() || type.name().contains("CUSTOM_PAYLOAD") || type.name().contains("TAGS") || !type.isSupported()) {
|
||||
if (type.isDeprecated() || type.name().contains("CUSTOM_PAYLOAD") || type.name().contains("TAGS") || !type.isSupported()
|
||||
|| type == PacketType.Play.Server.RECIPES) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,16 @@ package com.comphenix.protocol.injector;
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_16_R1.Entity;
|
||||
import net.minecraft.server.v1_16_R1.PlayerChunkMap;
|
||||
import net.minecraft.server.v1_16_R1.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||
import net.minecraft.server.v1_16_R2.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_16_R2.Entity;
|
||||
import net.minecraft.server.v1_16_R2.PlayerChunkMap;
|
||||
import net.minecraft.server.v1_16_R2.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||
|
||||
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -6,8 +6,8 @@ import static org.junit.Assert.assertEquals;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.ItemStack;
|
||||
import net.minecraft.server.v1_16_R1.NonNullList;
|
||||
import net.minecraft.server.v1_16_R2.ItemStack;
|
||||
import net.minecraft.server.v1_16_R2.NonNullList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -6,22 +6,22 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.ChatComponentText;
|
||||
import net.minecraft.server.v1_16_R1.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_16_R1.DataWatcher;
|
||||
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||
import net.minecraft.server.v1_16_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_16_R1.NBTCompressedStreamTools;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot;
|
||||
import net.minecraft.server.v1_16_R1.PlayerConnection;
|
||||
import net.minecraft.server.v1_16_R1.ServerPing;
|
||||
import net.minecraft.server.v1_16_R1.ServerPing.ServerData;
|
||||
import net.minecraft.server.v1_16_R1.ServerPing.ServerPingPlayerSample;
|
||||
import net.minecraft.server.v1_16_R2.ChatComponentText;
|
||||
import net.minecraft.server.v1_16_R2.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_16_R2.DataWatcher;
|
||||
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||
import net.minecraft.server.v1_16_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R2.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_16_R2.NBTCompressedStreamTools;
|
||||
import net.minecraft.server.v1_16_R2.PacketPlayOutUpdateAttributes.AttributeSnapshot;
|
||||
import net.minecraft.server.v1_16_R2.PlayerConnection;
|
||||
import net.minecraft.server.v1_16_R2.ServerPing;
|
||||
import net.minecraft.server.v1_16_R2.ServerPing.ServerData;
|
||||
import net.minecraft.server.v1_16_R2.ServerPing.ServerPingPlayerSample;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -16,14 +16,14 @@ public class ChunkCoordIntPairTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
net.minecraft.server.v1_16_R1.ChunkCoordIntPair pair = new net.minecraft.server.v1_16_R1.ChunkCoordIntPair(1, 2);
|
||||
net.minecraft.server.v1_16_R2.ChunkCoordIntPair pair = new net.minecraft.server.v1_16_R2.ChunkCoordIntPair(1, 2);
|
||||
ChunkCoordIntPair specific = ChunkCoordIntPair.getConverter().getSpecific(pair);
|
||||
|
||||
assertEquals(1, specific.getChunkX());
|
||||
assertEquals(2, specific.getChunkZ());
|
||||
|
||||
net.minecraft.server.v1_16_R1.ChunkCoordIntPair roundtrip =
|
||||
(net.minecraft.server.v1_16_R1.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
|
||||
net.minecraft.server.v1_16_R2.ChunkCoordIntPair roundtrip =
|
||||
(net.minecraft.server.v1_16_R2.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
|
||||
getGeneric(specific);
|
||||
|
||||
assertEquals(1, roundtrip.x);
|
||||
|
@ -3,12 +3,12 @@ package com.comphenix.protocol.wrappers;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.server.v1_16_R1.EnumChatVisibility;
|
||||
import net.minecraft.server.v1_16_R1.EnumDifficulty;
|
||||
import net.minecraft.server.v1_16_R1.EnumGamemode;
|
||||
import net.minecraft.server.v1_16_R1.EnumProtocol;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayInClientCommand.EnumClientCommand;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayInUseEntity.EnumEntityUseAction;
|
||||
import net.minecraft.server.v1_16_R2.EnumChatVisibility;
|
||||
import net.minecraft.server.v1_16_R2.EnumDifficulty;
|
||||
import net.minecraft.server.v1_16_R2.EnumGamemode;
|
||||
import net.minecraft.server.v1_16_R2.EnumProtocol;
|
||||
import net.minecraft.server.v1_16_R2.PacketPlayInClientCommand.EnumClientCommand;
|
||||
import net.minecraft.server.v1_16_R2.PacketPlayInUseEntity.EnumEntityUseAction;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -36,12 +36,12 @@ import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" })
|
||||
public class MultiBlockChangeTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void initializeBukkit() throws IllegalAccessException {
|
||||
// @BeforeClass
|
||||
public static void initializeBukkit() {
|
||||
BukkitInitialization.initializeItemMeta();
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
public void test() {
|
||||
int x = 42;
|
||||
int y = 64;
|
||||
@ -57,7 +57,10 @@ public class MultiBlockChangeTest {
|
||||
|
||||
MultiBlockChangeInfo[] array = { info, info };
|
||||
|
||||
EquivalentConverter<MultiBlockChangeInfo[]> converter = MultiBlockChangeInfo.getArrayConverter(chunk);
|
||||
EquivalentConverter<MultiBlockChangeInfo[]> converter = Converters.array(
|
||||
MinecraftReflection.getMultiBlockChangeInfoClass(),
|
||||
MultiBlockChangeInfo.getConverter(chunk)
|
||||
);
|
||||
Object generic = converter.getGeneric(array);
|
||||
MultiBlockChangeInfo[] back = converter.getSpecific(generic);
|
||||
|
||||
|
@ -6,12 +6,12 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.AttributeBase;
|
||||
import net.minecraft.server.v1_16_R1.AttributeModifier;
|
||||
import net.minecraft.server.v1_16_R1.IRegistry;
|
||||
import net.minecraft.server.v1_16_R1.MinecraftKey;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutUpdateAttributes;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot;
|
||||
import net.minecraft.server.v1_16_R2.AttributeBase;
|
||||
import net.minecraft.server.v1_16_R2.AttributeModifier;
|
||||
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||
import net.minecraft.server.v1_16_R2.MinecraftKey;
|
||||
import net.minecraft.server.v1_16_R2.PacketPlayOutUpdateAttributes;
|
||||
import net.minecraft.server.v1_16_R2.PacketPlayOutUpdateAttributes.AttributeSnapshot;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -18,14 +18,14 @@ package com.comphenix.protocol.wrappers;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.GlassPane;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.block.impl.CraftStainedGlassPane;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.block.impl.CraftStainedGlassPane;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -23,10 +23,10 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.EntityEgg;
|
||||
import net.minecraft.server.v1_16_R2.EntityEgg;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEgg;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEgg;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -87,8 +87,8 @@ public class WrappedDataWatcherTest {
|
||||
|
||||
@Test
|
||||
public void testSerializers() {
|
||||
Serializer blockPos = Registry.get(net.minecraft.server.v1_16_R1.BlockPosition.class, false);
|
||||
Serializer optionalBlockPos = Registry.get(net.minecraft.server.v1_16_R1.BlockPosition.class, true);
|
||||
Serializer blockPos = Registry.get(net.minecraft.server.v1_16_R2.BlockPosition.class, false);
|
||||
Serializer optionalBlockPos = Registry.get(net.minecraft.server.v1_16_R2.BlockPosition.class, true);
|
||||
assertNotSame(blockPos, optionalBlockPos);
|
||||
|
||||
// assertNull(Registry.get(ItemStack.class, false));
|
||||
|
@ -4,8 +4,6 @@ import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutWorldParticles;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
@ -26,8 +24,7 @@ public class WrappedParticleTest {
|
||||
@Test
|
||||
public void testBlockData() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.WORLD_PARTICLES);
|
||||
System.out.println(packet.getType().getPacketClass());
|
||||
System.out.println(PacketType.fromClass(PacketPlayOutWorldParticles.class));
|
||||
|
||||
WrappedParticle before = WrappedParticle.create(Particle.BLOCK_CRACK,
|
||||
WrappedBlockData.createData(Material.LAPIS_BLOCK));
|
||||
packet.getNewParticles().write(0, before);
|
||||
|
@ -30,9 +30,9 @@ import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.server.v1_16_R1.ItemStack;
|
||||
import net.minecraft.server.v1_16_R1.Items;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagTypes;
|
||||
import net.minecraft.server.v1_16_R2.ItemStack;
|
||||
import net.minecraft.server.v1_16_R2.Items;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagTypes;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
Loading…
Reference in New Issue
Block a user