Closed HowardZHY closed 1 year ago
If you open the giver without an item, it will crash the game, it happens with <1.10 versions, which are discontinued
:( could u try to fix it?
At 2022-05-20 01:32:01, "Antoine Willerval" @.***> wrote:
If you open the giver without an item, it will crash the game, it happens with <1.10 versions, which are discontinued
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
public static String getGiveCode(ItemStack itemStack) {
boolean a = itemStack.getTagCompound() != null && !itemStack.getTagCompound().hasNoTags();
boolean b = itemStack.getMetadata() == 0 && !a;
if (itemStack.stackSize > 1)
return itemStack == null ? ""
: Item.itemRegistry.getNameForObject(itemStack.getItem()).toString()
+ ((itemStack.stackSize == 1 || itemStack.stackSize == 0) && b ? ""
: " " + itemStack.stackSize
+ (b ? ""
: " " + itemStack.getMetadata()
+ (a ? " " + itemStack.getTagCompound().toString() : "")));
if (itemStack.stackSize == 0)
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("[ACT] Tried to edit null item"));
return null;
}
damn nope
In 1.10 version and before air = null, in 1.11 version and after air = ItemStack(Items.AIR), the ACT2 code is based on the second model, so to fix it, someone would need to check for null for every usage of an itemstack.
If someone wants to do a PR I can merge it and upload the result, but I won't work on this (the 1.8 was released when I was in high school and I have a M.Sc., maybe it's time to update...)
at least I've fixed a crash with TMI by replace equals to ==
public void getSubItems(CreativeTabs tab, NonNullList
Feel free to do a PR if you want...
Also it's better to not use ==
with non primitive values in Java, if you want to do equals on a and b, you can:
b.equals(a)
Objects.equals(a, b)
There's no existing 1.8.9 branch anymore... and here's the crash when try to edit hand(null item) crash-2023-01-16_23.38.32-client.txt
A temp solution is disable giver key. (it's useless with TMI)
if (!(mc.thePlayer.inventory.getCurrentItem() == null))
idk can this fix the sec crash
yea the sec crash fixed by int slot = mc.thePlayer.inventory.currentItem; if (mc.thePlayer.inventory.getCurrentItem() == null) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("[ACT] Tried to edit null item!")); if (mc.thePlayer.inventory.getCurrentItem() != null) mc.displayGuiScreen(new GuiItemStackModifier(this, mc.thePlayer.getHeldItem().copy(), is -> ItemUtils.give(mc, is, 36 + slot))); }, () -> {
public static String getGiveCode(ItemStack itemStack) {
if (mc.thePlayer.inventory.getCurrentItem() == null)
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("[ACT] Tried to give null item !"));
boolean a;
boolean b;
if (mc.thePlayer.inventory.getCurrentItem() != null) {
a = itemStack.getTagCompound() != null && !itemStack.getTagCompound().hasNoTags();
b = itemStack.getMetadata() == 0 && !a;
return itemStack == null ? ""
: Item.itemRegistry.getNameForObject(itemStack.getItem()).toString()
+ ((itemStack.stackSize == 1 || itemStack.stackSize == 0) && b ? ""
: " " + itemStack.stackSize
+ (b ? ""
: " " + itemStack.getMetadata()
+ (a ? " " + itemStack.getTagCompound().toString() : "")));
}
return null;
}
damn this crashes when loading, what thing should I return at last
oh damn I'm dumb I should add if && mc.thePlayer.inventory.getCurrentItem() != null in GuiGiver's init. All these 2 crashes should be fixed.
You should create a 1.8.9 branch to let me PR in...
Please make create a new 1.8.9 branch, then I can fork and PR in, and then I can make Chinese translation jsons.
crash-2022-05-18_22.31.44-client.txt crash-2022-05-18_22.35.12-client.txt