mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 04:05:12 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -10,57 +10,57 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public abstract class AbstractTab extends GuiButton {
|
||||
ResourceLocation texture = new ResourceLocation(
|
||||
"textures/gui/container/creative_inventory/tabs.png");
|
||||
ItemStack renderStack;
|
||||
RenderItem itemRenderer = new RenderItem();
|
||||
ResourceLocation texture = new ResourceLocation(
|
||||
"textures/gui/container/creative_inventory/tabs.png");
|
||||
ItemStack renderStack;
|
||||
RenderItem itemRenderer = new RenderItem();
|
||||
|
||||
public AbstractTab(int id, int posX, int posY, ItemStack renderStack) {
|
||||
super(id, posX, posY, 28, 32, "");
|
||||
this.renderStack = renderStack;
|
||||
}
|
||||
public AbstractTab(int id, int posX, int posY, ItemStack renderStack) {
|
||||
super(id, posX, posY, 28, 32, "");
|
||||
this.renderStack = renderStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int yTexPos = this.enabled ? 3 : 32;
|
||||
int ySize = this.enabled ? 25 : 32;
|
||||
int xOffset = this.id == 2 ? 0 : 1;
|
||||
int yPos = this.yPosition + (this.enabled ? 3 : 0);
|
||||
mc.renderEngine.bindTexture(this.texture);
|
||||
this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28,
|
||||
yTexPos, 28, ySize);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer,
|
||||
mc.renderEngine, renderStack, xPosition + 6, yPosition + 8);
|
||||
this.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer,
|
||||
mc.renderEngine, renderStack, xPosition + 6, yPosition + 8);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int yTexPos = this.enabled ? 3 : 32;
|
||||
int ySize = this.enabled ? 25 : 32;
|
||||
int xOffset = this.id == 2 ? 0 : 1;
|
||||
int yPos = this.yPosition + (this.enabled ? 3 : 0);
|
||||
mc.renderEngine.bindTexture(this.texture);
|
||||
this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28,
|
||||
yTexPos, 28, ySize);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer,
|
||||
mc.renderEngine, renderStack, xPosition + 6, yPosition + 8);
|
||||
this.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer,
|
||||
mc.renderEngine, renderStack, xPosition + 6, yPosition + 8);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
boolean inWindow = this.enabled && this.visible
|
||||
&& mouseX >= this.xPosition && mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
if (inWindow) {
|
||||
this.onTabClicked();
|
||||
}
|
||||
return inWindow;
|
||||
}
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
boolean inWindow = this.enabled && this.visible
|
||||
&& mouseX >= this.xPosition && mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
if (inWindow) {
|
||||
this.onTabClicked();
|
||||
}
|
||||
return inWindow;
|
||||
}
|
||||
|
||||
public abstract void onTabClicked();
|
||||
public abstract void onTabClicked();
|
||||
|
||||
public abstract boolean shouldAddToList();
|
||||
public abstract boolean shouldAddToList();
|
||||
}
|
||||
@@ -7,50 +7,50 @@ import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.gui.player.inventory.*;
|
||||
|
||||
public class InventoryTabCustomNpc extends AbstractTab {
|
||||
public InventoryTabCustomNpc() {
|
||||
super(0, 0, 0, new ItemStack(CustomItems.letter));
|
||||
public InventoryTabCustomNpc() {
|
||||
super(0, 0, 0, new ItemStack(CustomItems.letter));
|
||||
|
||||
if(CustomItems.letter == null)
|
||||
renderStack = new ItemStack(Items.book);
|
||||
}
|
||||
if (CustomItems.letter == null)
|
||||
renderStack = new ItemStack(Items.book);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
tabHelper();
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAddToList() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldAddToList() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void tabHelper(){
|
||||
public static void tabHelper() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int tab = GuiCNPCInventory.activeTab;
|
||||
if(tab == -100){
|
||||
if (tab == -100) {
|
||||
mc.displayGuiScreen(new GuiQuestLog());
|
||||
}
|
||||
if(tab == -101){
|
||||
if (tab == -101) {
|
||||
mc.displayGuiScreen(new GuiParty());
|
||||
}
|
||||
if(tab == -102){
|
||||
if (tab == -102) {
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
}
|
||||
if(tab == -103){
|
||||
if (tab == -103) {
|
||||
mc.displayGuiScreen(new GuiSettings());
|
||||
}
|
||||
if(tab == -104){
|
||||
if (tab == -104) {
|
||||
mc.displayGuiScreen(new GuiProfiles());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventoryTabVanilla extends AbstractTab {
|
||||
public InventoryTabVanilla() {
|
||||
super(0, 0, 0, new ItemStack(Blocks.crafting_table));
|
||||
}
|
||||
public InventoryTabVanilla() {
|
||||
super(0, 0, 0, new ItemStack(Blocks.crafting_table));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
TabRegistry.openInventoryGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAddToList() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldAddToList() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -14,88 +14,88 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TabRegistry {
|
||||
private static ArrayList<AbstractTab> tabList = new ArrayList<AbstractTab>();
|
||||
private static ArrayList<AbstractTab> tabList = new ArrayList<AbstractTab>();
|
||||
|
||||
public static void registerTab(AbstractTab tab) {
|
||||
tabList.add(tab);
|
||||
}
|
||||
public static void registerTab(AbstractTab tab) {
|
||||
tabList.add(tab);
|
||||
}
|
||||
|
||||
public static ArrayList<AbstractTab> getTabList() {
|
||||
return tabList;
|
||||
}
|
||||
public static ArrayList<AbstractTab> getTabList() {
|
||||
return tabList;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if ((event.gui instanceof GuiInventory)) {
|
||||
int xSize = 176;
|
||||
int ySize = 166;
|
||||
int guiLeft = (event.gui.width - xSize) / 2;
|
||||
int guiTop = (event.gui.height - ySize) / 2;
|
||||
guiLeft += getPotionOffset();
|
||||
updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class);
|
||||
addTabsToList(event.buttonList);
|
||||
}
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if ((event.gui instanceof GuiInventory)) {
|
||||
int xSize = 176;
|
||||
int ySize = 166;
|
||||
int guiLeft = (event.gui.width - xSize) / 2;
|
||||
int guiTop = (event.gui.height - ySize) / 2;
|
||||
guiLeft += getPotionOffset();
|
||||
updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class);
|
||||
addTabsToList(event.buttonList);
|
||||
}
|
||||
}
|
||||
|
||||
private static Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
private static Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
public static void openInventoryGui() {
|
||||
mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(
|
||||
mc.thePlayer.openContainer.windowId));
|
||||
GuiInventory inventory = new GuiInventory(mc.thePlayer);
|
||||
mc.displayGuiScreen(inventory);
|
||||
}
|
||||
public static void openInventoryGui() {
|
||||
mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(
|
||||
mc.thePlayer.openContainer.windowId));
|
||||
GuiInventory inventory = new GuiInventory(mc.thePlayer);
|
||||
mc.displayGuiScreen(inventory);
|
||||
}
|
||||
|
||||
public static void updateTabValues(int cornerX, int cornerY,
|
||||
Class<?> selectedButton) {
|
||||
int count = 2;
|
||||
for (int i = 0; i < tabList.size(); i++) {
|
||||
AbstractTab t = tabList.get(i);
|
||||
if (t.shouldAddToList()) {
|
||||
t.id = count;
|
||||
t.xPosition = cornerX + (count - 2) * 28;
|
||||
t.yPosition = cornerY - 28;
|
||||
t.enabled = !t.getClass().equals(selectedButton);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void updateTabValues(int cornerX, int cornerY,
|
||||
Class<?> selectedButton) {
|
||||
int count = 2;
|
||||
for (int i = 0; i < tabList.size(); i++) {
|
||||
AbstractTab t = tabList.get(i);
|
||||
if (t.shouldAddToList()) {
|
||||
t.id = count;
|
||||
t.xPosition = cornerX + (count - 2) * 28;
|
||||
t.yPosition = cornerY - 28;
|
||||
t.enabled = !t.getClass().equals(selectedButton);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addTabsToList(List buttonList) {
|
||||
for (AbstractTab tab : tabList) {
|
||||
if (tab.shouldAddToList()) {
|
||||
buttonList.add(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void addTabsToList(List buttonList) {
|
||||
for (AbstractTab tab : tabList) {
|
||||
if (tab.shouldAddToList()) {
|
||||
buttonList.add(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPotionOffset() {
|
||||
// If at least one potion is active...
|
||||
if (!mc.thePlayer.getActivePotionEffects().isEmpty()) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
try {
|
||||
// Check whether NEI is hidden and enabled
|
||||
Class<?> c = Class
|
||||
.forName("codechicken.nei.NEIClientConfig");
|
||||
Object hidden = c.getMethod("isHidden").invoke(null);
|
||||
Object enabled = c.getMethod("isEnabled").invoke(null);
|
||||
if (hidden != null && hidden instanceof Boolean
|
||||
&& enabled != null && enabled instanceof Boolean) {
|
||||
if ((Boolean) hidden || !((Boolean) enabled)) {
|
||||
// If NEI is disabled or hidden, offset the tabs by
|
||||
// 60
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else {
|
||||
// If NEI is not installed, offset the tabs
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
// No potions, no offset needed
|
||||
return 0;
|
||||
}
|
||||
public static int getPotionOffset() {
|
||||
// If at least one potion is active...
|
||||
if (!mc.thePlayer.getActivePotionEffects().isEmpty()) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
try {
|
||||
// Check whether NEI is hidden and enabled
|
||||
Class<?> c = Class
|
||||
.forName("codechicken.nei.NEIClientConfig");
|
||||
Object hidden = c.getMethod("isHidden").invoke(null);
|
||||
Object enabled = c.getMethod("isEnabled").invoke(null);
|
||||
if (hidden != null && hidden instanceof Boolean
|
||||
&& enabled != null && enabled instanceof Boolean) {
|
||||
if ((Boolean) hidden || !((Boolean) enabled)) {
|
||||
// If NEI is disabled or hidden, offset the tabs by
|
||||
// 60
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else {
|
||||
// If NEI is not installed, offset the tabs
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
// No potions, no offset needed
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user