forked from micdoodle8/Galacticraft
-
Notifications
You must be signed in to change notification settings - Fork 48
Removal of TConstruct dependency #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akirapriva
wants to merge
16
commits into
GTNewHorizons:master
Choose a base branch
from
akirapriva:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b6ffe49
removal of tconstruct dep
akirapriva c700b56
Update ClientProxyCore.java
akirapriva 21f80c7
cache PacketSimple$EnumSimplePacket.values()
Alexdoru b9c3f17
cache GCPlayerHandler$EnumModelPacket.values()
Alexdoru 9a3c264
cache PacketSimpleAsteroids$EnumSimplePacketAsteroids.values()
Alexdoru 45131c9
cache PacketSimpleMars$EnumSimplePacketMars.values()
Alexdoru 8181082
cache IRocketType$EnumRocketType.values()
Alexdoru 92a21b8
cache EntitySpaceshipBase$EnumLaunchPhase.values()
Alexdoru f38f257
cache EnumEnclosedBlock.values()
Alexdoru 2fd53d9
op & wf
UltraProdigy e15081b
Merge branch 'master' into master
Dream-Master bdba100
Merge branch 'pr-123'
akirapriva 5718467
Merge branch 'pr-124'
akirapriva aa26af5
Merge branch 'master' into master
Dream-Master e038f92
Merge branch 'master' into master
Dream-Master 601cad5
Merge branch 'master' into master
Dream-Master File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/main/java/micdoodle8/mods/galacticraft/api/client/tabs/AbstractTab.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package micdoodle8.mods.galacticraft.api.client.tabs; | ||
|
|
||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.client.gui.GuiButton; | ||
| import net.minecraft.client.renderer.RenderHelper; | ||
| import net.minecraft.client.renderer.entity.RenderItem; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.util.ResourceLocation; | ||
|
|
||
| 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(); | ||
|
|
||
| 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) { | ||
| drawButton(mc, this.renderStack, false); | ||
| } | ||
|
|
||
| /** | ||
| * Draws inventory tab | ||
| * | ||
| * @param mc | ||
| * @param tabIcon Item to use as tab icon | ||
| * @param enableItemIconDepthTest whether to enable GL_DEPTH_TEST for rendering the item icon | ||
| */ | ||
|
|
||
| protected void drawButton(Minecraft mc, ItemStack tabIcon, boolean enableItemIconDepthTest) { | ||
| if (this.visible) { | ||
| GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); | ||
|
|
||
| int yTexPos = this.enabled ? 2 : 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); | ||
| if (enableItemIconDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST); | ||
| this.itemRenderer.renderItemAndEffectIntoGUI( | ||
| mc.fontRenderer, | ||
| mc.renderEngine, | ||
| tabIcon, | ||
| xPosition + 6, | ||
| yPosition + 8); | ||
| this.itemRenderer | ||
| .renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, tabIcon, xPosition + 6, yPosition + 8); | ||
| if (enableItemIconDepthTest) GL11.glDisable(GL11.GL_DEPTH_TEST); | ||
| 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; | ||
| } | ||
|
|
||
| public abstract void onTabClicked(); | ||
|
|
||
| public abstract boolean shouldAddToList(); | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/micdoodle8/mods/galacticraft/api/client/tabs/InventoryTabVanilla.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package micdoodle8.mods.galacticraft.api.client.tabs; | ||
|
|
||
| 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)); | ||
| } | ||
|
|
||
| @Override | ||
| public void onTabClicked() { | ||
| TabRegistry.openInventoryGui(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean shouldAddToList() { | ||
| return true; | ||
| } | ||
| } |
92 changes: 92 additions & 0 deletions
92
src/main/java/micdoodle8/mods/galacticraft/api/client/tabs/TabRegistry.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package micdoodle8.mods.galacticraft.api.client.tabs; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.client.gui.inventory.GuiInventory; | ||
| import net.minecraft.network.play.client.C0DPacketCloseWindow; | ||
| import net.minecraftforge.client.event.GuiScreenEvent; | ||
|
|
||
| import codechicken.nei.NEIClientConfig; | ||
| import cpw.mods.fml.client.FMLClientHandler; | ||
| import cpw.mods.fml.common.Loader; | ||
| import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
| import cpw.mods.fml.relauncher.Side; | ||
| import cpw.mods.fml.relauncher.SideOnly; | ||
|
|
||
| public class TabRegistry { | ||
|
|
||
| private static final ArrayList<AbstractTab> tabList = new ArrayList<>(); | ||
|
|
||
| public static void registerTab(AbstractTab tab) { | ||
| tabList.add(tab); | ||
| } | ||
|
|
||
| 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.gui.buttonList); | ||
| } | ||
| } | ||
|
|
||
| private static final 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 updateTabValues(int cornerX, int cornerY, Class<?> selectedButton) { | ||
| int count = 2; | ||
| for (AbstractTab t : tabList) { | ||
| 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 int getPotionOffset() { | ||
| // If at least one potion is active... | ||
| if (!mc.thePlayer.getActivePotionEffects().isEmpty()) { | ||
| if (Loader.isModLoaded("NotEnoughItems")) { | ||
| try { | ||
| if (NEIClientConfig.isHidden() || !NEIClientConfig.isEnabled()) { | ||
| // If NEI is disabled or hidden, offset the tabs by 60 | ||
| return 60; | ||
| } | ||
| } catch (Exception ignored) {} | ||
| } else { | ||
| // If NEI is not installed, offset the tabs | ||
| return 60; | ||
| } | ||
| } | ||
| // No potions, no offset needed | ||
| return 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this ever be false? Also, this won't work when having TConstruct installed - having two tabregistries is not really feasible, they'd compete for the same rendering space. Possibly an option to pull those tabs into GTNHLib? Either that or fall back to tconstruct dynamically. Architecturally cleaner is to avoid that code duplication though.