Replace wildcard with metadata 0 for display purposes, fixes #370

N.B. The output is still not visible for non-zero inputs when using wildcard trades, but for now this is good enough
This commit is contained in:
Electroblob77
2020-03-18 15:32:59 +00:00
parent 587ab1338e
commit 0b56d47022
3 changed files with 48 additions and 2 deletions
@@ -24,6 +24,7 @@ import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.inventory.EntityEquipmentSlot.Type;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.*;
@@ -795,6 +796,20 @@ public final class WizardryUtilities {
return false;
}
/**
* Returns a new {@link ItemStack} that is identical to the supplied one, except with the metadata changed to the
* new value given.
* @param toCopy The stack to copy
* @param newMetadata The new metadata value
* @return The resulting {@link ItemStack}
*/
public static ItemStack copyWithMeta(ItemStack toCopy, int newMetadata){
ItemStack copy = new ItemStack(toCopy.getItem(), toCopy.getCount(), newMetadata);
NBTTagCompound compound = toCopy.getTagCompound();
if(compound != null) copy.setTagCompound(compound.copy());
return copy;
}
/**
* Checks if the given player is opped on the given server. If the server is a singleplayer or LAN server, this
* means they have cheats enabled.