Skip to content

Commit

Permalink
Fix potentially getting the wrong value for ItemStack.itemDamage
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Cysteine committed Feb 22, 2023
1 parent e026e2f commit 367fd9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nesqlExporterVersion=0.4.5
nesqlExporterVersion=0.4.6

minecraftVersion=1.7.10
forgeVersion=10.13.4.1614
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.dcysteine.nesql.sql.base.item.Item;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;

import java.io.PrintWriter;
Expand Down Expand Up @@ -42,6 +43,10 @@ public Item get(ItemStack itemStack) {
String modId = uniqueId.modId;
String internalName = uniqueId.name;

// We can't just call itemStack.getItemDamage(), because that may have been overridden
// to return something other than the raw ItemStack.itemDamage field.
int itemDamage = Items.feather.getDamage(itemStack);

String nbt = "";
if (itemStack.hasTagCompound()) {
nbt = itemStack.getTagCompound().toString();
Expand All @@ -63,7 +68,7 @@ public Item get(ItemStack itemStack) {
itemStack.getUnlocalizedName(),
StringUtil.stripFormatting(itemStack.getDisplayName()),
ItemUtil.getItemId(itemStack),
itemStack.getItemDamage(),
itemDamage,
nbt,
tooltip,
itemStack.getMaxStackSize(),
Expand All @@ -84,7 +89,7 @@ public Item get(ItemStack itemStack) {
"ERROR",
"ERROR",
ItemUtil.getItemId(itemStack),
itemStack.getItemDamage(),
itemDamage,
nbt,
stackTrace,
itemStack.getMaxStackSize(),
Expand Down

0 comments on commit 367fd9b

Please sign in to comment.