-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduced tool upgrades (renamed from "temporal tool modules" and …
…the "pocket watch" before that).
- Loading branch information
Showing
35 changed files
with
506 additions
and
306 deletions.
There are no files selected for viewing
This file contains 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
12 changes: 12 additions & 0 deletions
12
src/main/java/lumaceon/mods/clockworkphase2/api/item/IKeybindActivation.java
This file contains 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,12 @@ | ||
package lumaceon.mods.clockworkphase2.api.item; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public interface IKeybindActivation | ||
{ | ||
/** | ||
* Called CLIENT-SIDE when the activate keybind is pressed with this itemstack in hand. | ||
*/ | ||
public void onKeyPressed(ItemStack item, EntityPlayer player); | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/lumaceon/mods/clockworkphase2/api/item/ITemporalToolModule.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/main/java/lumaceon/mods/clockworkphase2/api/item/IToolUpgrade.java
This file contains 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,22 @@ | ||
package lumaceon.mods.clockworkphase2.api.item; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
public interface IToolUpgrade | ||
{ | ||
/** | ||
* Called to activate or deactivate this tool upgrade | ||
* @param item A stack representing the tool upgrade. | ||
* @param active True to set this to active, false to turn it off. | ||
*/ | ||
public void setActive(ItemStack item, boolean active); | ||
|
||
/** | ||
* @param item The tool upgrade stack. | ||
* @return Whether or not this itemstack is active. | ||
*/ | ||
public boolean getActive(ItemStack item); | ||
|
||
public float getQualityMultiplier(ItemStack item); | ||
public float getSpeedMultiplier(ItemStack item); | ||
} |
This file contains 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
66 changes: 66 additions & 0 deletions
66
src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiClockworkTool.java
This file contains 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,66 @@ | ||
package lumaceon.mods.clockworkphase2.client.gui; | ||
|
||
import lumaceon.mods.clockworkphase2.api.util.internal.NBTHelper; | ||
import lumaceon.mods.clockworkphase2.api.util.internal.NBTTags; | ||
import lumaceon.mods.clockworkphase2.client.gui.components.GuiButtonItem; | ||
import lumaceon.mods.clockworkphase2.network.PacketHandler; | ||
import lumaceon.mods.clockworkphase2.network.message.MessageToolUpgradeActivate; | ||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.client.renderer.entity.RenderItem; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class GuiClockworkTool extends GuiScreen | ||
{ | ||
public ItemStack[] items; | ||
public RenderItem itemRenders; | ||
public int guiLeft, guiTop, xSize, ySize; | ||
|
||
public GuiClockworkTool(ItemStack[] itemStacks) { | ||
super(); | ||
itemRenders = new RenderItem(); | ||
if(itemStacks == null) | ||
itemStacks = new ItemStack[0]; | ||
this.items = itemStacks; | ||
this.xSize = 300; | ||
this.ySize = 60; | ||
} | ||
|
||
@Override | ||
public void initGui() | ||
{ | ||
super.initGui(); | ||
this.guiLeft = (this.width - this.xSize) / 2; | ||
this.guiTop = (this.height - this.ySize) / 2; | ||
buttonList.clear(); | ||
int index = 0; | ||
for(int x = 0; x < 10; x++) | ||
{ | ||
for(int y = 0; y < 2; y++) | ||
{ | ||
if(items.length > index && items[index] != null) | ||
buttonList.add(new GuiButtonItem(items[index], index, guiLeft + (x % 10) * 30, guiTop + y * 30, "", itemRenders, fontRendererObj, NBTHelper.BOOLEAN.get(items[index], NBTTags.ACTIVE))); | ||
else | ||
buttonList.add(new GuiButtonItem(null, index, guiLeft + (x % 10) * 30, guiTop + y * 30, "", itemRenders, fontRendererObj, false)); | ||
index++; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void actionPerformed(GuiButton button) { | ||
PacketHandler.INSTANCE.sendToServer(new MessageToolUpgradeActivate(button.id)); | ||
((GuiButtonItem) buttonList.get(button.id)).active = !((GuiButtonItem) buttonList.get(button.id)).active; | ||
} | ||
|
||
@Override | ||
protected void keyTyped(char p_73869_1_, int p_73869_2_) { | ||
if(p_73869_2_ == 1 || p_73869_2_ == this.mc.gameSettings.keyBindInventory.getKeyCode()) | ||
this.mc.thePlayer.closeScreen(); | ||
} | ||
|
||
@Override | ||
public boolean doesGuiPauseGame() { | ||
return false; | ||
} | ||
} |
This file contains 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
78 changes: 78 additions & 0 deletions
78
src/main/java/lumaceon/mods/clockworkphase2/client/gui/components/GuiButtonItem.java
This file contains 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,78 @@ | ||
package lumaceon.mods.clockworkphase2.client.gui.components; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.FontRenderer; | ||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.renderer.OpenGlHelper; | ||
import net.minecraft.client.renderer.entity.RenderItem; | ||
import net.minecraft.item.ItemStack; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
public class GuiButtonItem extends GuiButton | ||
{ | ||
public boolean active; | ||
public ItemStack item; | ||
public RenderItem itemRender; | ||
public FontRenderer fontRenderer; | ||
public Minecraft mc; | ||
|
||
public GuiButtonItem(ItemStack is, int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_, RenderItem renderItem, FontRenderer fontRenderer, boolean active) { | ||
super(p_i1020_1_, p_i1020_2_, p_i1020_3_, 20, 20, p_i1020_4_); | ||
this.item = is; | ||
this.itemRender = renderItem; | ||
this.itemRender.renderWithColor = false; | ||
this.mc = Minecraft.getMinecraft(); | ||
this.active = active; | ||
} | ||
|
||
@Override | ||
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) | ||
{ | ||
if(this.visible) | ||
{ | ||
FontRenderer fontrenderer = p_146112_1_.fontRenderer; | ||
p_146112_1_.getTextureManager().bindTexture(buttonTextures); | ||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); | ||
GL11.glDisable(GL11.GL_LIGHTING); | ||
this.field_146123_n = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; | ||
int k = this.getHoverState(this.field_146123_n); | ||
GL11.glEnable(GL11.GL_BLEND); | ||
OpenGlHelper.glBlendFunc(770, 771, 1, 0); | ||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | ||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height); | ||
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); | ||
this.mouseDragged(p_146112_1_, p_146112_2_, p_146112_3_); | ||
int l = 14737632; | ||
|
||
if(packedFGColour != 0) | ||
l = packedFGColour; | ||
else if(!this.enabled) | ||
l = 10526880; | ||
else if(this.field_146123_n) | ||
l = 16777120; | ||
|
||
if(item != null) | ||
{ | ||
if(!active) | ||
GL11.glColor4f(0.5F, 0.5F, 0.5F, 1.0F); | ||
else | ||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); | ||
this.drawItemStack(item, this.xPosition + 2, this.yPosition + 2, this.displayString); | ||
} | ||
} | ||
} | ||
|
||
private void drawItemStack(ItemStack is, int x, int y, String name) | ||
{ | ||
GL11.glTranslatef(0.0F, 0.0F, 32.0F); | ||
float zLevelOrigin = this.zLevel; | ||
this.zLevel = 200.0F; | ||
itemRender.zLevel = 200.0F; | ||
FontRenderer font = null; | ||
if (is != null) font = is.getItem().getFontRenderer(is); | ||
if (font == null) font = fontRenderer; | ||
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), is, x, y); | ||
this.zLevel = zLevelOrigin; | ||
itemRender.zLevel = 0.0F; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/lumaceon/mods/clockworkphase2/client/keybind/KeyHandler.java
This file contains 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 |
---|---|---|
@@ -1,6 +1,33 @@ | ||
package lumaceon.mods.clockworkphase2.client.keybind; | ||
|
||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import cpw.mods.fml.common.gameevent.InputEvent; | ||
import lumaceon.mods.clockworkphase2.api.item.IKeybindActivation; | ||
import lumaceon.mods.clockworkphase2.lib.KeyLib; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class KeyHandler | ||
{ | ||
public static KeyLib.Keys getKeyPressed() | ||
{ | ||
if(Keybindings.activate.isPressed()) | ||
return KeyLib.Keys.ACTIVATE; | ||
else | ||
return KeyLib.Keys.IRRELEVANT; | ||
} | ||
|
||
@SubscribeEvent | ||
public void handleKeyPress(InputEvent.KeyInputEvent event) | ||
{ | ||
EntityPlayer player = Minecraft.getMinecraft().thePlayer; | ||
KeyLib.Keys keyPressed = getKeyPressed(); | ||
if(keyPressed.equals(KeyLib.Keys.ACTIVATE)) | ||
{ | ||
ItemStack item = player.inventory.getCurrentItem(); | ||
if(item != null && item.getItem() instanceof IKeybindActivation) | ||
((IKeybindActivation) item.getItem()).onKeyPressed(item, player); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/lumaceon/mods/clockworkphase2/client/keybind/Keybindings.java
This file contains 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,10 @@ | ||
package lumaceon.mods.clockworkphase2.client.keybind; | ||
|
||
import lumaceon.mods.clockworkphase2.lib.KeyLib; | ||
import net.minecraft.client.settings.KeyBinding; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
public class Keybindings | ||
{ | ||
public static KeyBinding activate = new KeyBinding(KeyLib.ACTIVATE, Keyboard.KEY_R, KeyLib.CATEGORY); | ||
} |
Oops, something went wrong.