Adds dropped item info to EntityListComponent

This commit is contained in:
noil 2020-12-18 23:48:21 -05:00
parent a2ca3d8c4b
commit 0b71bc000e
3 changed files with 43 additions and 6 deletions

View File

@ -45,7 +45,7 @@ public class ColorComponent extends TextComponent {
int newColor = (int) Long.parseLong(this.displayValue.replaceAll("#", ""), 16);
this.currentColor = new Color(newColor);
} catch (NumberFormatException e) {
Seppuku.INSTANCE.logChat(this.getName() + ": Invalid color format. Correct format example: \"FF0000\" for red.");
Seppuku.INSTANCE.logChat(this.getName() + ": Invalid color format. Correct format example: \"ff0000\" for red.");
} catch (Exception e) {
Seppuku.INSTANCE.logChat(this.getName() + ": Something went terribly wrong while setting the color. Please try again.");
}

View File

@ -15,10 +15,10 @@ import org.lwjgl.input.Keyboard;
*/
public final class MacroCommand extends Command {
private String[] addAlias = new String[]{"Add", "A"};
private String[] removeAlias = new String[]{"Remove", "R", "Rem", "Delete", "Del"};
private String[] listAlias = new String[]{"List", "L"};
private String[] clearAlias = new String[]{"Clear", "C"};
private final String[] addAlias = new String[]{"Add", "A"};
private final String[] removeAlias = new String[]{"Remove", "R", "Rem", "Delete", "Del"};
private final String[] listAlias = new String[]{"List", "L"};
private final String[] clearAlias = new String[]{"Clear", "C"};
public MacroCommand() {
super("Macro", new String[]{"Mac"}, "Allows you to create chat macros", "Macro Add <Name> <Key> <Macro>\n" +
@ -57,7 +57,7 @@ public final class MacroCommand extends Command {
for (int i = 4; i < size; i++) {
final String arg = split[i];
sb.append(arg + ((i == size - 1) ? "" : " "));
sb.append(arg).append((i == size - 1) ? "" : " ");
}
Seppuku.INSTANCE.logChat("Added macro \247c" + name + "\247f bound to " + key.toUpperCase());

View File

@ -11,6 +11,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockShulkerBox;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiShulkerBox;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
@ -21,7 +22,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemShulkerBox;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntityShulkerBox;
import java.util.List;
@ -294,6 +297,40 @@ public final class EntityListComponent extends DraggableHudComponent {
} else {
Seppuku.INSTANCE.errorChat("This shulker box is empty");
}
} else if (itemStack.isItemEnchanted()) {
final StringBuilder enchantStringBuilder = new StringBuilder("");
final NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound != null && !tagCompound.isEmpty()) {
final NBTTagList nbtEnchantTagList = tagCompound.getTagList("ench", 10);
for (NBTBase enchantBaseCompound : nbtEnchantTagList) {
if (enchantBaseCompound instanceof NBTTagCompound) {
final NBTTagCompound enchantCompound = (NBTTagCompound) enchantBaseCompound;
final short enchantID = enchantCompound.getShort("id");
final short enchantLvl = enchantCompound.getShort("lvl");
final Enchantment enchantment = Enchantment.getEnchantmentByID(enchantID);
if (enchantment != null) {
final String enchantName = ChatFormatting.RESET + "[" + ChatFormatting.AQUA + enchantment.getTranslatedName(enchantLvl) + ChatFormatting.RESET + "] ";
enchantStringBuilder.append(enchantName);
}
}
}
}
final String info = String.format("\n%s\n- Key: %s\n- Enchantments: %s\n- Durability: %s", ChatFormatting.AQUA + itemStack.getDisplayName() + ChatFormatting.RESET, itemStack.getTranslationKey(), enchantStringBuilder.toString(), itemStack.getMaxDamage() - itemStack.getItemDamage());
Seppuku.INSTANCE.logChat(info);
} else {
final String info = String.format("\n%s\n- Key: %s\n- Count: %s\n- Metadata: %s\n- Damage: %s\n- Max Damage: %s\n- Durability: %s", itemStack.getDisplayName(), itemStack.getTranslationKey(), itemStack.getCount(), itemStack.getMetadata(), itemStack.getItemDamage(), itemStack.getMaxDamage(), itemStack.getMaxDamage() - itemStack.getItemDamage());
Seppuku.INSTANCE.logChat(info);
NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound != null && !tagCompound.isEmpty()) {
StringBuilder compoundData = new StringBuilder("\n- Compound:");
for (String s : tagCompound.getKeySet()) {
compoundData.append("\n-- ").append(s).append(": ");
compoundData.append(tagCompound.getTag(s));
}
Seppuku.INSTANCE.logChat(compoundData.toString());
}
}
}
}