mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 21:09:40 +00:00
Show Attributes on Items in Auction House
This commit is contained in:
1 parent
185f06822a
commit
5c975a339d
3 files changed
+28
-31
No files matched your search
@@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.ClientProxy;
|
||||
import noppes.npcs.client.gui.player.GuiAuctionInterface;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
import noppes.npcs.controllers.data.Magic;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -230,12 +231,12 @@ public class AttributeItemUtil {
|
||||
* Returns the item tooltip.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static List<String> getToolTip(List<String> original, NBTTagCompound compound) {
|
||||
public static List<String> getToolTip(List<String> original, NBTTagCompound compound, boolean override) {
|
||||
List<String> tooltip = new ArrayList<>(original);
|
||||
// Get the RPGCore compound and then the Attributes compound.
|
||||
NBTTagCompound rpgCore = compound.hasKey(TAG_RPGCORE) ? compound.getCompoundTag(TAG_RPGCORE) : new NBTTagCompound();
|
||||
NBTTagCompound attrTag = rpgCore.hasKey(TAG_ATTRIBUTES) ? rpgCore.getCompoundTag(TAG_ATTRIBUTES) : new NBTTagCompound();
|
||||
if (Keyboard.isKeyDown(ClientProxy.NPCButton.getKeyCode())) {
|
||||
if (Keyboard.isKeyDown(ClientProxy.NPCButton.getKeyCode()) || override) {
|
||||
List<String> newTooltips = new ArrayList<>();
|
||||
if (!tooltip.isEmpty()) {
|
||||
newTooltips.add(tooltip.get(0));
|
||||
|
||||
@@ -88,10 +88,16 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
AuctionListing listing = tradesContainer.getListingAt(slot);
|
||||
AuctionClaim claim = tradesContainer.getClaimAt(slot);
|
||||
|
||||
if (listing != null && tradesContainer.isSellingAt(slot) && mouseButton == 1) {
|
||||
// Right-click on own listing = show cancel
|
||||
setPending(slot, PendingOp.CANCEL);
|
||||
NoppesUtil.clickSound();
|
||||
if (listing != null && tradesContainer.isSellingAt(slot)) {
|
||||
if (mouseButton == 0) {
|
||||
// Left-click on own listing = view details
|
||||
AuctionActionPacket.openBidding(listing.id);
|
||||
NoppesUtil.clickSound();
|
||||
} else if (mouseButton == 1) {
|
||||
// Right-click on own listing = show cancel
|
||||
setPending(slot, PendingOp.CANCEL);
|
||||
NoppesUtil.clickSound();
|
||||
}
|
||||
} else if (listing != null && tradesContainer.isBiddingAt(slot) && mouseButton == 0) {
|
||||
// Left-click on active bid = open bidding GUI to increase bid
|
||||
AuctionActionPacket.openBidding(listing.id);
|
||||
@@ -315,16 +321,13 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
AuctionListing listing = tradesContainer.getListingAt(slot);
|
||||
AuctionClaim claim = tradesContainer.getClaimAt(slot);
|
||||
|
||||
if (listing != null) {
|
||||
if (tradesContainer.isSellingAt(slot)) {
|
||||
tooltip.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("auction.trades.activeListing"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.rightClickToCancel"));
|
||||
} else if (tradesContainer.isBiddingAt(slot)) {
|
||||
tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("auction.trades.activeBid"));
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.trades.winningBid"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.leftClickToIncrease"));
|
||||
}
|
||||
} else if (claim != null) {
|
||||
// Slots with items have tooltips handled by AuctionTooltipHandler via ItemTooltipEvent
|
||||
if (listing != null) return;
|
||||
if (claim != null && (claim.type == EnumClaimType.ITEM ||
|
||||
(claim.type == EnumClaimType.REFUND && claim.item != null))) return;
|
||||
|
||||
// Non-item slots (currency claims, refund without item, unavailable)
|
||||
if (claim != null) {
|
||||
switch (claim.type) {
|
||||
case CURRENCY:
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.soldClaim"));
|
||||
@@ -342,20 +345,6 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.trades.outbidBy") + ": " + EnumChatFormatting.AQUA + claim.otherPlayerName);
|
||||
}
|
||||
tooltip.add(EnumChatFormatting.GOLD + String.format("%,d", claim.currency) + " " + AuctionClientConfig.getCurrencyName());
|
||||
// Show rebid option if item is present (active listing)
|
||||
if (claim.item != null) {
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.leftClickRebid"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.rightClickRefund"));
|
||||
return; // Skip the generic claim message
|
||||
}
|
||||
break;
|
||||
case ITEM:
|
||||
if (claim.isReturned) {
|
||||
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocal("auction.trades.expiredClaim"));
|
||||
} else {
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.wonClaim"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.leftClickToClaim"));
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package noppes.npcs.mixin;
|
||||
|
||||
import kamkeel.npcs.util.AttributeItemUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.gui.player.GuiAuctionInterface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -28,9 +30,14 @@ public abstract class MixinItemStack {
|
||||
|
||||
@Inject(method = "getTooltip", at = @At("TAIL"), cancellable = true)
|
||||
public void getAttributeTooltip(EntityPlayer player, boolean advanced, CallbackInfoReturnable<List<String>> cir) {
|
||||
boolean override = false;
|
||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiAuctionInterface) {
|
||||
override = true;
|
||||
}
|
||||
|
||||
List<String> tooltip = cir.getReturnValue();
|
||||
if (hasTagCompound() && getTagCompound().hasKey(TAG_RPGCORE)) {
|
||||
cir.setReturnValue(AttributeItemUtil.getToolTip(tooltip, getTagCompound()));
|
||||
cir.setReturnValue(AttributeItemUtil.getToolTip(tooltip, getTagCompound(), override));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user