Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/main/java/serverutils/invsee/GuiInvseeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StatCollector;

import serverutils.invsee.inventories.IModdedInventory;
import serverutils.invsee.inventories.InvSeeInventories;
Expand All @@ -26,7 +27,6 @@

public class GuiInvseeContainer extends GuiBase {

private static final Icon BUTTON_BACKGROUND = Color4I.GRAY.withBorder(Color4I.DARK_GRAY, true);
private final Map<InvSeeInventories, IInventory> inventories;
private final InvseeContainer container;
private final String playerName;
Expand All @@ -42,7 +42,10 @@ public GuiInvseeContainer(Map<InvSeeInventories, IInventory> inventories, String
this.playerName = playerName;
this.playerIcon = new PlayerHeadIcon(StringUtils.fromString(playerId));
this.wrapper = new GuiWrapper(this, container).disableSlotDrawing();
this.inventoryName = playerName + "'s " + InvSeeInventories.MAIN.getInventory().getInventoryName();
this.inventoryName = StatCollector.translateToLocalFormatted(
"serverutilities.invsee.title",
playerName,
InvSeeInventories.MAIN.getInventory().getInventoryName());
}

@Override
Expand Down Expand Up @@ -95,7 +98,11 @@ public void drawBackground(Theme theme, int x, int y, int w, int h) {

for (int i = 0; i < container.inventorySlots.size(); i++) {
Slot slot = container.inventorySlots.get(i);
theme.drawContainerSlot(x + slot.xDisplayPosition, y + slot.yDisplayPosition, 16, 16);
if (i >= container.getNonPlayerSlots()) {
theme.drawInventorySlot(x + slot.xDisplayPosition, y + slot.yDisplayPosition, 16, 16);
} else {
theme.drawContainerSlot(x + slot.xDisplayPosition, y + slot.yDisplayPosition, 16, 16);
}
if (i >= container.getNonPlayerSlots() || slot.getHasStack()) continue;
Icon overlay = container.getActiveInventory().getInventory().getSlotOverlay(slot);
if (overlay != null) {
Expand Down Expand Up @@ -124,7 +131,7 @@ public int getY() {

@Override
public void drawBackground(Theme theme, int x, int y, int w, int h) {
BUTTON_BACKGROUND.draw(x, y, w, h);
theme.drawWidget(x, y, w, h, getWidgetType());
}

@Override
Expand All @@ -138,7 +145,10 @@ public int getY() {
public void switchInventory(InvSeeInventories inventory) {
if (container.getActiveInventory() == inventory) return;
container.setActiveInventory(inventory);
inventoryName = playerName + "'s " + inventory.getInventory().getInventoryName();
inventoryName = StatCollector.translateToLocalFormatted(
"serverutilities.invsee.title",
playerName,
inventory.getInventory().getInventoryName());
alignWidgets();
new MessageInvseeSwitch(inventory).sendToServer();
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/serverutils/invsee/InvseeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class InvseeContainer extends ContainerBase {
private final Set<InvSeeInventories> modifiedInventories = new HashSet<>();
private InvSeeInventories activeInventory;
private int playerSlotStart;
private int armorSlotStart = -1;

public InvseeContainer(Map<InvSeeInventories, IInventory> moddedInventories, EntityPlayer player,
@Nullable ForgePlayer otherPlayer) {
Expand Down Expand Up @@ -64,15 +65,23 @@ public InvseeContainer(Map<InvSeeInventories, IInventory> moddedInventories, Ent
public void setActiveInventory(InvSeeInventories inventory) {
activeInventory = inventory;
inventorySlots.clear();
armorSlotStart = -1;
for (Slot slot : moddedInventorySlots.get(inventory)) {
addSlotToContainer(slot);
if (slot.yDisplayPosition < 0 && armorSlotStart == -1) {
armorSlotStart = slot.slotNumber;
}
}

playerSlotStart = inventorySlots.size();
addPlayerSlots(8, 85);
detectAndSendChanges();
}

public boolean isArmorSlot(int containerIndex) {
return armorSlotStart >= 0 && containerIndex >= armorSlotStart && containerIndex < playerSlotStart;
}

public InvSeeInventories getActiveInventory() {
return activeInventory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class AdventureBackpackInv implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "Adventure Backpack";
return StatCollector.translateToLocal("serverutilities.invsee.adventure_backpack");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.Constants;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class BattlegearInventory implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "Battlegear";
return StatCollector.translateToLocal("serverutilities.invsee.battlegear");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.inventory.Slot;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -82,7 +83,7 @@ public void syncSlotToClients(int slot) {}

@Override
public @NotNull String getButtonText() {
return "Baubles";
return StatCollector.translateToLocal("serverutilities.invsee.baubles");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryEnderChest;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.Constants;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -43,7 +44,7 @@ public class EnderInventory implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "Ender Chest";
return StatCollector.translateToLocal("serverutilities.invsee.ender_chest");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.Constants;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -41,7 +42,7 @@ public class GalacticraftInventory implements IModdedInventory {
case 2, 3 -> new PartIcon(icon, 116, 53, 16, 16, 4);
case 4 -> new PartIcon(icon, 143, 17, 16, 16, 4);
case 5 -> new PartIcon(icon, 107, 17, 16, 16, 4);
case 6, 7, 8, 9 -> new PartIcon(icon, 79, 8 + ((i - 6) * 18), 16, 16, 4);
case 6, 7, 8, 9 -> new PartIcon(icon, 80, 8 + ((i - 6) * 18), 16, 16, 4);
default -> ItemIcon.EMPTY;
};
}
Expand Down Expand Up @@ -72,12 +73,12 @@ public class GalacticraftInventory implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "Galacticraft";
return StatCollector.translateToLocal("serverutilities.invsee.galacticraft");
}

@Override
public String getInventoryName() {
return "GC Items";
return StatCollector.translateToLocal("serverutilities.invsee.gc_items");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.Constants;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -51,7 +52,7 @@ public class MainInventory implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "Main Inventory";
return StatCollector.translateToLocal("serverutilities.invsee.main");
}

@Override
Expand Down Expand Up @@ -95,7 +96,7 @@ public int getArmorSlotIndex(int index, IInventory inventory) {
return inventory.getSizeInventory() - 4;
}

private static class SlotArmor extends Slot {
public static class SlotArmor extends Slot {

private final int armorSlot;
private final EntityPlayer player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StatCollector;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -44,7 +45,7 @@ public class MinecraftBackpackInv implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "Personal Backpack";
return StatCollector.translateToLocal("serverutilities.invsee.personal_backpack");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -80,7 +81,7 @@ public class TiCInventory implements IModdedInventory {

@Override
public @NotNull String getButtonText() {
return "TiC Bag & Accessories";
return StatCollector.translateToLocal("serverutilities.invsee.tic_bag");
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/serverutils/lib/gui/GuiContainerWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {

Theme theme = wrappedGui.getTheme();
GuiHelper.setupDrawing();
drawDefaultBackground();
GuiHelper.setupDrawing();
wrappedGui.draw(theme, guiLeft, guiTop, xSize, ySize);

if (drawSlots) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/serverutils/lib/gui/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public class Theme {
private static final Icon WIDGET_MOUSE_OVER = new PartIcon(TEXTURE_SERVERUTILS_WIDGETS, 36, 60, 18, 18, 3);
private static final Icon WIDGET_DISABLED = WIDGET.withTint(Color4I.BLACK.withAlpha(100));

private static final Icon SLOT = new PartIcon(TEXTURE_SERVERUTILS_WIDGETS, 18, 78, 18, 18, 3);
private static final Icon SLOT = new PartIcon(TEXTURE_SERVERUTILS_WIDGETS, 36, 78, 18, 18, 3);
private static final Icon SLOT_MOUSE_OVER = SLOT.combineWith(Color4I.WHITE.withAlpha(33));

private static final Icon INV_SLOT = new PartIcon(TEXTURE_SERVERUTILS_WIDGETS, 18, 78, 18, 18, 3);

private static final Icon SCROLL_BAR_BG = new PartIcon(TEXTURE_SERVERUTILS_WIDGETS, 0, 60, 18, 18, 3);
private static final Icon SCROLL_BAR_BG_DISABLED = SCROLL_BAR_BG.withTint(Color4I.BLACK.withAlpha(100));

Expand Down Expand Up @@ -87,6 +89,10 @@ public void drawContainerSlot(int x, int y, int w, int h) {
SLOT.draw(x - 1, y - 1, w + 2, h + 2);
}

public void drawInventorySlot(int x, int y, int w, int h) {
INV_SLOT.draw(x - 1, y - 1, w + 2, h + 2);
}

public void drawButton(int x, int y, int w, int h, WidgetType type) {
(type == WidgetType.MOUSE_OVER ? BUTTON_MOUSE_OVER : type == WidgetType.DISABLED ? BUTTON_DISABLED : BUTTON)
.draw(x, y, w, h);
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/assets/serverutilities/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -814,3 +814,15 @@ serverutilities.jm.own_team=Your Team
serverutilities.jm.claim=Double click an empty chunk to claim.
serverutilities.jm.load_hint=Double click a claimed chunk to load/unload
serverutilities.jm.unclaim_hint=Press %s to unclaim

# Invsee GUI
serverutilities.invsee.title=%s's %s
serverutilities.invsee.main=Main Inventory
serverutilities.invsee.ender_chest=Ender Chest
serverutilities.invsee.personal_backpack=Personal Backpack
serverutilities.invsee.baubles=Baubles
serverutilities.invsee.adventure_backpack=Adventure Backpack
serverutilities.invsee.battlegear=Battlegear
serverutilities.invsee.tic_bag=TiC Bag & Accessories
serverutilities.invsee.galacticraft=Galacticraft
serverutilities.invsee.gc_items=GC Items
Binary file modified src/main/resources/assets/serverutilities/textures/gui/widgets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading