Skip to content

Commit 2131de4

Browse files
committed
Make UnknownItemDesc always output something.
1 parent 7e8fdb0 commit 2131de4

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

loader/src/main/java/com/fox2code/foxloader/registry/missing/MissingItemDesc.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public void runDesc(World world, List<String> list, ItemStack itemStack) {
4848
int itemId = itemStack.getItemID();
4949
remoteRawId = GameRegistry.itemIdMappingLocalNames[itemId];
5050
isBlock = GameRegistry.isItemBlock(itemId);
51-
if (remoteRawId == null) return;
51+
if (remoteRawId == null) {
52+
remoteRawId = itemStack.hasRemoteID() ?
53+
("Unknown remote id: " + itemStack.getRemoteItemID()) :
54+
("Unknown local id: " + itemStack.getItemID());
55+
}
5256
}
5357
if ("foxloader:item_missing".equals(remoteRawId) ||
5458
"foxloader:block_missing".equals(remoteRawId)) {

patching/src/main/java/com/fox2code/foxloader/patching/game/RegistryPatch.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,20 @@ private static void patchItemStackNet(ClassNode classNode) {
538538
setRemoteItemID.instructions.add(new InsnNode(RETURN));
539539
TransformerUtils.setThisParameterName(classNode, setRemoteItemID);
540540
TransformerUtils.setParameterName(setRemoteItemID, 1, "netItemID");
541+
// Has remote id
542+
MethodNode hasRemoteID = new MethodNode(ACC_PUBLIC, "hasRemoteID", "()Z", null, null);
543+
classNode.methods.add(hasRemoteID);
544+
hasRemoteID.instructions.add(new VarInsnNode(ALOAD, 0));
545+
hasRemoteID.instructions.add(new FieldInsnNode(GETFIELD, ItemStack, "netItemID", "I"));
546+
hasRemoteID.instructions.add(TransformerUtils.getNumberInsn(-1));
547+
LabelNode ifNegOne = new LabelNode();
548+
hasRemoteID.instructions.add(new JumpInsnNode(IF_ICMPEQ, ifNegOne));
549+
hasRemoteID.instructions.add(TransformerUtils.getBooleanInsn(true));
550+
hasRemoteID.instructions.add(new InsnNode(IRETURN));
551+
hasRemoteID.instructions.add(ifNegOne);
552+
hasRemoteID.instructions.add(TransformerUtils.getBooleanInsn(false));
553+
hasRemoteID.instructions.add(new InsnNode(IRETURN));
554+
TransformerUtils.setThisParameterName(classNode, hasRemoteID);
541555
}
542556

543557
private static void patchPacket(ClassNode classNode) {

0 commit comments

Comments
 (0)