Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 1.18+ ClientboundLevelChunkWithLightPacket #1592

Merged
merged 34 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7441607
Added BlockEntityInfo and it's StructureModifier
Etrayed May 6, 2022
92915f4
Added BlockEntityInfoTest and fixed a bug in WrappedRegistry
Etrayed May 6, 2022
becdd7f
Added equals & hashCode method to MinecraftKey for better comparison
Etrayed May 7, 2022
f96910c
Added WrappedLevelChunkData for processing the full ClientboundLevelC…
Etrayed May 7, 2022
535320f
Removed StreamSerializer usages and replaced them with WirePacket sta…
Etrayed May 7, 2022
7e9472e
Corrected a spelling mistake
Etrayed May 7, 2022
b7c5f27
Finished java docs of WrappedLevelChunkData
Etrayed May 7, 2022
1fcc0d6
Fixed an unnecessary bug with the new structures
Etrayed May 7, 2022
e385f03
Removed obsolete debug code
Etrayed May 7, 2022
54e234d
Removed obsolete debug code
Etrayed May 7, 2022
8336ced
Merge branch 'master' into feat/chunk-block-entity-info
Etrayed Jun 12, 2022
5e13609
Merge branch 'master' into feat/chunk-block-entity-info
Etrayed Jun 25, 2022
d4fe0bd
Replaced guava references with java.util equivalents
Etrayed Jun 26, 2022
2d272ec
Replaced Stream-API calls with for loops
Etrayed Jun 26, 2022
eb39697
Fixed broken WrappedLevelChunkData.ChunkData hashCode
Etrayed Jun 26, 2022
9d8d60f
Replaced inline field definitions with explicit ones
Etrayed Jun 26, 2022
6443fab
Corrected bad if-expression habit
Etrayed Jul 23, 2022
91b406d
Corrected bad if-expression habit
Etrayed Jul 23, 2022
c41235a
Merge branch 'dmulloy2:master' into feat/chunk-block-entity-info
Etrayed Jul 23, 2022
a538922
Modified tests to use live examples
Etrayed Jul 23, 2022
db816f9
Do not use field name directly
Etrayed Jul 23, 2022
a86adf1
Merge remote-tracking branch 'upstream/master' into feat/chunk-block-…
Etrayed Jul 28, 2022
8aa8340
Improved generic conversion to avoid using direct serialization
Etrayed Jul 28, 2022
f6d2824
Modified all WrappedLevelChunkData wrappers to extend AbstractWrapper…
Etrayed Jul 28, 2022
6a2d86e
Reformatted if-parentheses again
Etrayed Jul 29, 2022
b7baa2b
Multiple improvements on code quality
Etrayed Jul 30, 2022
6ddb50c
Some more improvements on code quality, readability and overall perfo…
Etrayed Jul 30, 2022
f0aee42
If-Expression spacings
Etrayed Jul 30, 2022
e19ba03
Update src/main/java/com/comphenix/protocol/wrappers/ComponentParser.…
Etrayed Jul 30, 2022
31cf431
Update src/main/java/com/comphenix/protocol/injector/PrioritizedListe…
Etrayed Jul 30, 2022
51bd840
Replaced star imports with single imports
Etrayed Jul 30, 2022
26cb7c1
Merge remote-tracking branch 'upstream/master' into feat/chunk-block-…
Etrayed Jul 31, 2022
c8919bc
Return a new instance rather than a ConstructorAccessor
Etrayed Jul 31, 2022
a06f057
Merge branch 'master' into feat/chunk-block-entity-info
dmulloy2 Aug 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/com/comphenix/protocol/events/AbstractStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,24 @@ public StructureModifier<WrappedProfileKeyData> getProfilePublicKeyData() {
BukkitConverters.getWrappedPublicKeyDataConverter());
}

/**
* Retrieve a read/write structure for LevelChunkPacketData in 1.18+
*
* @return The Structure Modifier
*/
public StructureModifier<WrappedLevelChunkData.ChunkData> getLevelChunkData() {
return structureModifier.withType(MinecraftReflection.getLevelChunkPacketDataClass(), WrappedLevelChunkData.ChunkData.getConverter());
}

/**
* Retrieve a read/write structure for LightUpdatePacketData in 1.18+
*
* @return The Structure Modifier
*/
public StructureModifier<WrappedLevelChunkData.LightData> getLightUpdateData() {
return structureModifier.withType(MinecraftReflection.getLightUpdatePacketDataClass(), WrappedLevelChunkData.LightData.getConverter());
}

/**
* Retrieve a read/write structure for the Map class.
* @param keyConverter Converter for map keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2299,4 +2299,21 @@ public static Class<?> getLibraryClass(String classname) {
return clazz;
}
}

public static Class<?> getLevelChunkPacketDataClass() {
return getNullableNMS("network.protocol.game.ClientboundLevelChunkPacketData");
}

public static Class<?> getLightUpdatePacketDataClass() {
return getNullableNMS("network.protocol.game.ClientboundLightUpdatePacketData");
}

public static Class<?> getBlockEntityTypeClass() {
return getMinecraftClass("world.level.block.entity.BlockEntityType", "world.level.block.entity.TileEntityTypes", "TileEntityTypes");
}

public static Class<?> getBlockEntityInfoClass() {
return getNullableNMS("network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo",
Etrayed marked this conversation as resolved.
Show resolved Hide resolved
"network.protocol.game.ClientboundLevelChunkPacketData$a");
}
}
18 changes: 18 additions & 0 deletions src/main/java/com/comphenix/protocol/wrappers/MinecraftKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.lang.reflect.Constructor;
import java.util.Locale;
import java.util.Objects;

import com.comphenix.protocol.reflect.EquivalentConverter;
import com.comphenix.protocol.reflect.StructureModifier;
Expand Down Expand Up @@ -112,6 +113,23 @@ public String getEnumFormat() {
return key.toUpperCase(Locale.ENGLISH).replace(".", "_");
}

@Override
public boolean equals(Object o) {
if(this == o) {
Etrayed marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
if(o == null || getClass() != o.getClass()) {
Etrayed marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
MinecraftKey that = (MinecraftKey) o;
return Objects.equals(prefix, that.prefix) && Objects.equals(key, that.key);
}

@Override
public int hashCode() {
return Objects.hash(prefix, key);
}

private static Constructor<?> constructor = null;

public static EquivalentConverter<MinecraftKey> getConverter() {
Expand Down
Loading