Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 7754375e15833c35fbbcba48b2ccdc9b519106f9 Mon Sep 17 00:00:00 2001
From 766d63ec9879dcf7ec959d0905f3eb03b51f5dcd Mon Sep 17 00:00:00 2001
From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com>
Date: Sun, 18 Oct 2026 16:55:37 +0200
Subject: [PATCH] feat(inventory): translate server-authoritative Bedrock
Expand Down Expand Up @@ -11621,7 +11621,7 @@ index f737c0b2..31341a0e 100644

final BlockEntity javaBlockEntity = BlockEntityRewriter.toJava(wrapper.user(), chunkTracker.getBlockState(bedrockBlockEntity.position()), bedrockBlockEntity);
diff --git a/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java
index bcf7ac89..988369db 100644
index 36b2cf55..a5193c10 100644
--- a/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java
+++ b/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java
@@ -35,10 +35,13 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
Expand All @@ -11638,7 +11638,7 @@ index bcf7ac89..988369db 100644
import net.raphimc.viabedrock.api.model.NativeItemStacking;
import net.raphimc.viabedrock.api.model.NativeItemStackData;
import net.raphimc.viabedrock.api.model.NativeItemStorageData;
@@ -50,12 +53,19 @@ import net.raphimc.viabedrock.protocol.data.BedrockMappingData;
@@ -54,12 +57,19 @@ import net.raphimc.viabedrock.protocol.data.BedrockMappingData;
import net.raphimc.viabedrock.protocol.data.ProtocolConstants;
import net.raphimc.viabedrock.protocol.data.generated.bedrock.CustomItemTags;
import net.raphimc.viabedrock.protocol.model.BedrockItem;
Expand All @@ -11660,7 +11660,7 @@ index bcf7ac89..988369db 100644
import net.raphimc.viabedrock.protocol.model.ItemCooldown;
import net.raphimc.viabedrock.protocol.model.ItemAnimationData;
import net.raphimc.viabedrock.protocol.model.ItemArmorData;
@@ -69,16 +79,19 @@ import net.raphimc.viabedrock.protocol.storage.MapTracker;
@@ -73,16 +83,19 @@ import net.raphimc.viabedrock.protocol.storage.MapTracker;
import net.raphimc.viabedrock.protocol.storage.ResourcePackStorage;
import net.raphimc.viabedrock.protocol.types.BedrockTypes;
import net.raphimc.viabedrock.protocol.types.array.ArrayType;
Expand All @@ -11680,8 +11680,8 @@ index bcf7ac89..988369db 100644
+public class ItemRewriter extends StoredObject implements NetworkItemStackContext {

private final ItemRegistry registry;

@@ -102,6 +115,8 @@ public class ItemRewriter extends StoredObject {
private int javaItemDepth;
@@ -107,6 +120,8 @@ public class ItemRewriter extends StoredObject {
private final Type<BedrockItem> newItemType;
private final Type<BedrockItem> optionalNewItemType;
private final Type<BedrockItem[]> newItemArrayType;
Expand All @@ -11690,7 +11690,7 @@ index bcf7ac89..988369db 100644

static {
// TODO: Add missing item nbt rewriters
@@ -134,10 +149,11 @@ public class ItemRewriter extends StoredObject {
@@ -139,10 +154,11 @@ public class ItemRewriter extends StoredObject {
super(user);

final BlockStateRewriter blockStateRewriter = this.user().get(BlockStateRewriter.class);
Expand All @@ -11704,7 +11704,7 @@ index bcf7ac89..988369db 100644
if (itemEntry.componentData() != null
&& itemEntry.componentData().get("components") instanceof CompoundTag components) {
this.animationData.put(itemEntry.identifier(), ItemAnimationData.fromNetworkComponents(components));
@@ -148,8 +164,10 @@ public class ItemRewriter extends StoredObject {
@@ -153,8 +169,10 @@ public class ItemRewriter extends StoredObject {
this.cooldowns.put(itemEntry.identifier(), cooldown);
}
}
Expand All @@ -11716,7 +11716,7 @@ index bcf7ac89..988369db 100644
blockItems.removeIf(identifier -> !this.items.containsKey(identifier));

this.blockItemValidBlockStates = new Int2ObjectOpenHashMap<>(blockItems.size());
@@ -158,22 +176,37 @@ public class ItemRewriter extends StoredObject {
@@ -163,22 +181,37 @@ public class ItemRewriter extends StoredObject {
if (validBlockStates == null) {
final String[] components = identifier.split(":", 2);
if (components[1].startsWith("item.")) {
Expand Down Expand Up @@ -11759,7 +11759,7 @@ index bcf7ac89..988369db 100644
}

public Item javaItem(final BedrockItem bedrockItem) {
@@ -183,13 +216,18 @@ public class ItemRewriter extends StoredObject {
@@ -197,13 +230,18 @@ public class ItemRewriter extends StoredObject {

final String identifier = this.registry.identifier(bedrockItem);
if (identifier == null) {
Expand All @@ -11780,7 +11780,7 @@ index bcf7ac89..988369db 100644
if (blockItemMappings != null) {
final BlockState displayState;
if (bedrockItem.hasBlockState()) {
@@ -202,9 +240,13 @@ public class ItemRewriter extends StoredObject {
@@ -216,9 +254,13 @@ public class ItemRewriter extends StoredObject {
javaItemMapping = displayState != null ? blockItemMappings.get(displayState) : null;
} else {
final int meta = bedrockItem.data() & 0xFFFF;
Expand All @@ -11796,7 +11796,7 @@ index bcf7ac89..988369db 100644
if (newBlockItemMappings != null) {
final IntSortedSet validBlockStates = this.blockItemValidBlockStates.get(bedrockItem.identifier());
javaItemMapping = validBlockStates != null && !validBlockStates.isEmpty()
@@ -213,7 +255,8 @@ public class ItemRewriter extends StoredObject {
@@ -227,7 +269,8 @@ public class ItemRewriter extends StoredObject {
javaItemMapping = null;
}
} else {
Expand All @@ -11806,7 +11806,7 @@ index bcf7ac89..988369db 100644
if (metaItemMappings != null) {
if (!metaItemMappings.containsKey(meta)) {
if ((metaItemMappings.size() != 1 || meta != 0)
@@ -245,8 +288,10 @@ public class ItemRewriter extends StoredObject {
@@ -259,8 +302,10 @@ public class ItemRewriter extends StoredObject {
}
javaItem = new StructuredItem(javaItemMapping.id(), bedrockItem.amount(), data);
} else {
Expand All @@ -11819,7 +11819,7 @@ index bcf7ac89..988369db 100644
final StructuredDataContainer data = ProtocolConstants.createStructuredDataContainer();

if (itemDefinition != null) {
@@ -264,13 +309,21 @@ public class ItemRewriter extends StoredObject {
@@ -278,13 +323,21 @@ public class ItemRewriter extends StoredObject {
data.set(StructuredDataKey.ITEM_MODEL, CustomItemTextureResourceRewriter.getItemModel(resourcePackStorage, itemDefinition.iconComponent()));
data.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, CustomItemTextureResourceRewriter.getCustomModelData("0"));
} else {
Expand All @@ -11843,7 +11843,7 @@ index bcf7ac89..988369db 100644
}

if (ordinaryNameKey != null) {
@@ -294,8 +347,12 @@ public class ItemRewriter extends StoredObject {
@@ -308,8 +361,12 @@ public class ItemRewriter extends StoredObject {

final CompoundTag bedrockTag = bedrockItem.tag();
if (bedrockTag != null) {
Expand All @@ -11858,7 +11858,7 @@ index bcf7ac89..988369db 100644
}
final String customName = this.registry.customName(identifier, bedrockTag);
if (customName != null) {
@@ -310,12 +367,16 @@ public class ItemRewriter extends StoredObject {
@@ -324,12 +381,16 @@ public class ItemRewriter extends StoredObject {
ITEM_NBT_REWRITERS.get(tag).toJava(this.user(), bedrockItem, javaItem);
}

Expand All @@ -11876,7 +11876,7 @@ index bcf7ac89..988369db 100644
if (this.registry.storageProperties(bedrockItem).storage()) {
final var storageSource = new NativeItemStorageData.Source() {
@Override
@@ -355,7 +416,8 @@ public class ItemRewriter extends StoredObject {
@@ -389,7 +450,8 @@ public class ItemRewriter extends StoredObject {
return null;
}
final CompoundTag javaTag = new CompoundTag();
Expand All @@ -11886,7 +11886,7 @@ index bcf7ac89..988369db 100644
javaTag.put("id", new StringTag(javaId));
javaTag.put("count", new IntTag(javaItem.amount()));
if (javaItem.tag() != null) {
@@ -369,28 +431,49 @@ public class ItemRewriter extends StoredObject {
@@ -403,28 +465,49 @@ public class ItemRewriter extends StoredObject {
return null;
}

Expand Down Expand Up @@ -11955,7 +11955,7 @@ index bcf7ac89..988369db 100644
}

/** Resolve primary text through the selected definition and current language sources. */
@@ -414,7 +497,33 @@ public class ItemRewriter extends StoredObject {
@@ -448,7 +531,33 @@ public class ItemRewriter extends StoredObject {
}

public BedrockItem bedrockItem(final Item javaItem) {
Expand Down Expand Up @@ -11990,7 +11990,7 @@ index bcf7ac89..988369db 100644
}

public BedrockItem[] bedrockItems(final Item[] javaItems) {
@@ -437,8 +546,72 @@ public class ItemRewriter extends StoredObject {
@@ -471,8 +580,72 @@ public class ItemRewriter extends StoredObject {
return this.registry.identifier(item);
}

Expand Down Expand Up @@ -12065,7 +12065,7 @@ index bcf7ac89..988369db 100644
}

/** Match network-loaded stack queries while their connection registry remains current. */
@@ -484,6 +657,17 @@ public class ItemRewriter extends StoredObject {
@@ -518,6 +691,17 @@ public class ItemRewriter extends StoredObject {
return properties == null ? 0 : properties.maximum();
}

Expand All @@ -12083,7 +12083,7 @@ index bcf7ac89..988369db 100644
public Type<BedrockItem> itemType() {
return this.itemType;
}
@@ -508,10 +692,13 @@ public class ItemRewriter extends StoredObject {
@@ -542,10 +726,13 @@ public class ItemRewriter extends StoredObject {
return this.newItemArrayType;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 01b333512158392bff14393a6a288b466701f413 Mon Sep 17 00:00:00 2001
From 01a39b69a548a1f5b2272188c53d76760b1c46aa Mon Sep 17 00:00:00 2001
From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com>
Date: Sun, 18 Oct 2026 16:55:37 +0200
Subject: [PATCH] feat(crafting): expose Bedrock recipes and place ingredients
Expand Down Expand Up @@ -4366,10 +4366,10 @@ index c04231bd..ac448e28 100644
if (channels.contains(LocatorBarSnapshot.CHANNEL) && wrapper.user().has(PlayerWaypointTracker.class)) {
wrapper.user().get(PlayerWaypointTracker.class).sendSnapshot();
diff --git a/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java b/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java
index 988369db..a044b07f 100644
index a5193c10..a6a4073d 100644
--- a/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java
+++ b/src/main/java/net/raphimc/viabedrock/protocol/rewriter/ItemRewriter.java
@@ -40,12 +40,16 @@ import net.raphimc.viabedrock.ViaBedrock;
@@ -40,8 +40,6 @@ import net.raphimc.viabedrock.ViaBedrock;
import net.raphimc.viabedrock.api.model.BlockState;
import net.raphimc.viabedrock.api.model.BedrockBlockState;
import net.raphimc.viabedrock.api.model.NativeItemNames;
Expand All @@ -4378,7 +4378,10 @@ index 988369db..a044b07f 100644
import net.raphimc.viabedrock.api.model.NativeItemStacking;
import net.raphimc.viabedrock.api.model.NativeItemStackData;
import net.raphimc.viabedrock.api.model.NativeItemStorageData;
import net.raphimc.viabedrock.api.model.NativeBundleTooltipData;
@@ -50,6 +48,12 @@ import net.raphimc.viabedrock.api.model.NativeBundleTooltipItems;
import net.raphimc.viabedrock.api.model.NativeContainerMessage;
import net.raphimc.viabedrock.protocol.storage.ChannelStorage;
import com.viaversion.nbt.tag.ByteArrayTag;
+import net.raphimc.viabedrock.api.model.container.NativeItemStackMatcher;
+import net.raphimc.viabedrock.api.model.container.NativeRecipeCounter;
+import net.raphimc.viabedrock.api.model.container.NativeRecipeDescriptor;
Expand All @@ -4388,7 +4391,7 @@ index 988369db..a044b07f 100644
import net.raphimc.viabedrock.api.resourcepack.definition.ItemDefinitions;
import net.raphimc.viabedrock.api.util.TextUtil;
import net.raphimc.viabedrock.protocol.BedrockProtocol;
@@ -62,9 +66,13 @@ import net.raphimc.viabedrock.protocol.model.SavedItemStack;
@@ -66,9 +70,13 @@ import net.raphimc.viabedrock.protocol.model.SavedItemStack;
import net.raphimc.viabedrock.protocol.model.NativeItemDefinitions;
import net.raphimc.viabedrock.protocol.model.NativeRecipeRegistry;
import net.raphimc.viabedrock.protocol.model.ItemNameContext;
Expand All @@ -4402,7 +4405,7 @@ index 988369db..a044b07f 100644
import net.raphimc.viabedrock.protocol.model.ItemCookingProperties;
import net.raphimc.viabedrock.protocol.model.ItemCooldown;
import net.raphimc.viabedrock.protocol.model.ItemAnimationData;
@@ -81,14 +89,19 @@ import net.raphimc.viabedrock.protocol.types.BedrockTypes;
@@ -85,14 +93,19 @@ import net.raphimc.viabedrock.protocol.types.BedrockTypes;
import net.raphimc.viabedrock.protocol.types.array.ArrayType;
import net.raphimc.viabedrock.protocol.types.inventory.ItemStackRequestResultType;
import net.raphimc.viabedrock.protocol.types.item.BedrockItemType;
Expand All @@ -4422,7 +4425,7 @@ index 988369db..a044b07f 100644
import java.util.logging.Level;

public class ItemRewriter extends StoredObject implements NetworkItemStackContext {
@@ -110,6 +123,8 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -115,6 +128,8 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
private final Set<String> componentItems;
private final Int2ObjectMap<IntSortedSet> blockItemValidBlockStates;
private final Type<BedrockItem> itemType;
Expand All @@ -4431,7 +4434,7 @@ index 988369db..a044b07f 100644
private final Type<BedrockItem> optionalItemType;
private final Type<BedrockItem[]> itemArrayType;
private final Type<BedrockItem> newItemType;
@@ -196,6 +211,8 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -201,6 +216,8 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
this.items.getOrDefault("minecraft:shield", 0),
false,
this);
Expand All @@ -4440,7 +4443,7 @@ index 988369db..a044b07f 100644
this.optionalItemType = new OptionalType<>(this.itemType);
this.itemArrayType = new ArrayType<>(this.itemType, BedrockTypes.UNSIGNED_VAR_INT);
this.newItemType =
@@ -482,6 +499,27 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -516,6 +533,27 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
(key, arguments) -> this.user().get(ResourcePackStorage.class).getTexts().translate(key, arguments.toArray()));
}

Expand Down Expand Up @@ -4468,7 +4471,7 @@ index 988369db..a044b07f 100644
private ItemNameContext itemNameContext() {
return new ItemNameContext((block, metadata) -> this.user().get(BlockStateRewriter.class).blockItemNameKey(block, metadata),
key -> this.user().get(ResourcePackStorage.class).getTexts().translate(key),
@@ -560,6 +598,14 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -594,6 +632,14 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
(definition, auxiliary) -> this.associatedBlock(blocks, definition, auxiliary));
}

Expand All @@ -4483,7 +4486,7 @@ index 988369db..a044b07f 100644
public BedrockItem createDefinitionItem(final NativeItemDefinitions.Definition<?> definition, final int metadata, final int amount) {
final var blocks = this.user().get(BlockStateRewriter.class);
return this.registry.createDefinitionItem(definition, metadata, amount,
@@ -602,6 +648,89 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -636,6 +682,89 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
? this.user().get(BlockStateRewriter.class).blockItemRecipeDescriptor(item.blockRuntimeId()) : null);
}

Expand Down Expand Up @@ -4573,7 +4576,7 @@ index 988369db..a044b07f 100644
public boolean matchesRecipeItem(final String identifier, final int metadata, final BedrockItem item) {
if (item == null) {
return false;
@@ -610,6 +739,37 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -644,6 +773,37 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
return NativeRecipeDescriptor.resolveName(identifier, metadata, context).matchesStack(item, context, this::recipeDescriptor);
}

Expand Down Expand Up @@ -4611,7 +4614,7 @@ index 988369db..a044b07f 100644
public ItemRegistry getItemRegistry() {
return this.registry;
}
@@ -632,6 +792,22 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -666,6 +826,22 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
return NativeItemStackMatcher.matchesIdentity(query, candidate, blocks::blockState, blocks::restrictionBlocks);
}

Expand All @@ -4634,7 +4637,7 @@ index 988369db..a044b07f 100644
public boolean canMerge(final BedrockItem source, final BedrockItem destination) {
if (destination == null || destination.isEmpty() || !this.registry.sameDefinition(source, destination)) {
return false;
@@ -672,6 +848,14 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
@@ -706,6 +882,14 @@ public class ItemRewriter extends StoredObject implements NetworkItemStackContex
return this.itemType;
}

Expand Down
Loading
Loading