Skip to content

Commit d8cb69c

Browse files
Fix CloudburstMC#1077 Unable to craft stuff using ink_sac as ingredient
1 parent 9f179ad commit d8cb69c

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

src/main/java/cn/nukkit/blockentity/BlockEntityItemFrame.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ public CompoundTag getSpawnCompound() {
110110
if (!item.isNull()) {
111111
CompoundTag itemTag = NBTIO.putItemHelper(item);
112112
int networkFullId = item.getNetworkFullId();
113-
int networkDamage = RuntimeItems.hasData(networkFullId)? RuntimeItems.getData(networkFullId)
114-
: item.hasMeta() && ! (item instanceof ItemDurable) ? item.getDamage()
115-
: 0 ;
113+
int networkDamage = (networkFullId & 0x1) == 0x1? 0 : item.getDamage();
116114
String namespacedId = RuntimeItems.getRuntimeMapping().getNamespacedIdByNetworkId(
117115
RuntimeItems.getNetworkId(networkFullId)
118116
);

src/main/java/cn/nukkit/item/RuntimeItems.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cn.nukkit.item;
22

33
import cn.nukkit.Server;
4+
import cn.nukkit.api.PowerNukkitOnly;
45
import cn.nukkit.api.Since;
56
import cn.nukkit.utils.BinaryStream;
67
import com.google.gson.Gson;
@@ -23,6 +24,8 @@
2324
import java.util.LinkedHashMap;
2425
import java.util.Map;
2526

27+
import static com.google.common.base.Verify.verify;
28+
2629
@Since("1.3.2.0-PN")
2730
@UtilityClass
2831
@Log4j2
@@ -59,8 +62,14 @@ public class RuntimeItems {
5962
if (entry.oldId != null) {
6063
boolean hasData = entry.oldData != null;
6164
int fullId = getFullId(entry.oldId, hasData ? entry.oldData : 0);
62-
legacyNetworkMap.put(fullId, (entry.id << 1) | (hasData ? 1 : 0));
63-
networkLegacyMap.put(entry.id, fullId | (hasData ? 1 : 0));
65+
if (entry.deprecated != Boolean.TRUE) {
66+
verify(legacyNetworkMap.put(fullId, (entry.id << 1) | (hasData ? 1 : 0)) == 0,
67+
"Conflict while registering an item runtime id!"
68+
);
69+
}
70+
verify(networkLegacyMap.put(entry.id, fullId | (hasData ? 1 : 0)) == 0,
71+
"Conflict while registering an item runtime id!"
72+
);
6473
}
6574
}
6675

@@ -106,5 +115,8 @@ static class Entry {
106115
int id;
107116
Integer oldId;
108117
Integer oldData;
118+
@PowerNukkitOnly
119+
@Since("1.4.0.0-PN")
120+
Boolean deprecated;
109121
}
110122
}

src/main/java/cn/nukkit/utils/BinaryStream.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package cn.nukkit.utils;
22

3-
import cn.nukkit.block.Block;
43
import cn.nukkit.api.Since;
4+
import cn.nukkit.block.Block;
55
import cn.nukkit.entity.Attribute;
66
import cn.nukkit.entity.data.Skin;
7-
import cn.nukkit.item.*;
7+
import cn.nukkit.item.Item;
8+
import cn.nukkit.item.ItemDurable;
9+
import cn.nukkit.item.ItemID;
10+
import cn.nukkit.item.RuntimeItems;
811
import cn.nukkit.level.GameRule;
912
import cn.nukkit.level.GameRules;
10-
import cn.nukkit.level.GlobalBlockPalette;
1113
import cn.nukkit.math.BlockFace;
1214
import cn.nukkit.math.BlockVector3;
1315
import cn.nukkit.math.Vector3f;
@@ -24,7 +26,6 @@
2426
import io.netty.util.internal.EmptyArrays;
2527

2628
import java.io.IOException;
27-
import java.io.UncheckedIOException;
2829
import java.lang.reflect.Array;
2930
import java.nio.ByteOrder;
3031
import java.nio.charset.StandardCharsets;

src/main/resources/runtime_item_ids.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4654,22 +4654,26 @@
46544654
{
46554655
"name": "minecraft:boat",
46564656
"id": 611,
4657-
"oldId": 333
4657+
"oldId": 333,
4658+
"deprecated": true
46584659
},
46594660
{
46604661
"name": "minecraft:dye",
46614662
"id": 612,
4662-
"oldId": 351
4663+
"oldId": 351,
4664+
"deprecated": true
46634665
},
46644666
{
46654667
"name": "minecraft:banner_pattern",
46664668
"id": 613,
4667-
"oldId": 434
4669+
"oldId": 434,
4670+
"deprecated": true
46684671
},
46694672
{
46704673
"name": "minecraft:spawn_egg",
46714674
"id": 614,
4672-
"oldId": 383
4675+
"oldId": 383,
4676+
"deprecated": true
46734677
},
46744678
{
46754679
"name": "minecraft:end_crystal",

0 commit comments

Comments
 (0)