Skip to content

Commit

Permalink
fix: adapt new protocol update
Browse files Browse the repository at this point in the history
  • Loading branch information
IWareQ committed Feb 14, 2025
1 parent 1cce846 commit e66a2ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.allaymc.api.pdc.PersistentDataHolder;
import org.allaymc.api.world.Dimension;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.protocol.bedrock.data.inventory.CreativeItemData;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Vector3ic;
Expand Down Expand Up @@ -181,6 +182,19 @@ default void increaseCount(int count) {
*/
ItemData toNetworkItemData();

/**
* Get the creative item data.
*
* @return The creative item data.
*/
default CreativeItemData toCreativeItemData() {
var netItem = toNetworkItemData();
return CreativeItemData.builder()
.item(netItem)
.netId(netItem.getNetId())
.build();
}

/**
* Check if the item has a stack network id.
*
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nbt = { group = "org.allaymc", name = "NBT", version = "3.0.10" }
# Network protocol
network = { group = "org.cloudburstmc.protocol", name = "bedrock-connection", version = "3.0.0.Beta6-SNAPSHOT" }
# State Updater
stateupdater = { group = "org.allaymc", name = "stateupdater", version = "1.21.50" }
stateupdater = { group = "org.allaymc", name = "stateupdater", version = "1.21.60" }
# Collections
guava = { group = "com.google.guava", name = "guava", version = "33.4.0-jre" }
# Fastutil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.cloudburstmc.protocol.bedrock.data.*;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.cloudburstmc.protocol.bedrock.packet.*;
import org.cloudburstmc.protocol.common.PacketSignal;
import org.cloudburstmc.protocol.common.SimpleDefinitionRegistry;
Expand Down Expand Up @@ -465,7 +464,7 @@ public static CreativeContentPacket getCreativeContentPacket() {
CREATIVE_CONTENT_PACKET = new CreativeContentPacket();
// We should sort it first!
var map = new TreeMap<>(Registries.CREATIVE_ITEMS.getContent());
CREATIVE_CONTENT_PACKET.setContents(map.values().stream().map(ItemStack::toNetworkItemData).toArray(ItemData[]::new));
CREATIVE_CONTENT_PACKET.getContents().addAll(map.values().stream().map(ItemStack::toCreativeItemData).toList());
}
return CREATIVE_CONTENT_PACKET;
}
Expand Down

0 comments on commit e66a2ff

Please sign in to comment.