Skip to content

Commit

Permalink
1.5.3 - 1.7.10, bug fixes
Browse files Browse the repository at this point in the history
-1.7.10 version is here.
-Bug fixes.
-Code cleanup.
  • Loading branch information
Elix-x committed May 3, 2016
1 parent 999d34a commit 5dd44bd
Show file tree
Hide file tree
Showing 35 changed files with 2,479 additions and 30 deletions.
2 changes: 1 addition & 1 deletion 1.7.10/src/main/java/code/elix_x/excore/EXCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class EXCore {

public static final String MODID = "excore";
public static final String NAME = "EXCore";
public static final String VERSION = "1.4.1";
public static final String VERSION = "1.5.3";

public static final String DEPENDENCY = MODID + "@[" + VERSION + ",)";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package code.elix_x.excore.utils.client.cursor;

import java.awt.image.BufferedImage;
import java.nio.IntBuffer;

import javax.imageio.ImageIO;

import org.lwjgl.LWJGLException;
import org.lwjgl.input.Cursor;
import org.lwjgl.input.Mouse;

import com.google.common.base.Throwables;

import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;

public class CursorHelper {

public static final Cursor defaultCursor = Mouse.getNativeCursor();

public static Cursor createCursor(ResourceLocation texture){
try {
BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(texture).getInputStream());
return new Cursor(image.getWidth(), image.getHeight(), image.getWidth() / 2, image.getHeight() / 2, 1, IntBuffer.wrap(image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth())), null);
} catch(Exception e){
throw Throwables.propagate(e);
}
}

public static Cursor createCursor(ResourceLocation texture, int hotSpotX, int hotSpotY){
try {
BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(texture).getInputStream());
return new Cursor(image.getWidth(), image.getHeight(), hotSpotX, hotSpotY, 1, IntBuffer.wrap(image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth())), null);
} catch(Exception e){
throw Throwables.propagate(e);
}
}

public static void setCursor(Cursor cursor){
try {
Mouse.setNativeCursor(cursor);
} catch(LWJGLException e){
Throwables.propagate(e);
}
}

public static void resetCursor(){
setCursor(defaultCursor);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package code.elix_x.excore.utils.client.gui;

import net.minecraft.client.gui.GuiScreen;

public class BasicGuiScreen extends GuiScreen {

public final GuiScreen parent;

protected int guiWidth;
protected int guiHeight;

protected int xPos;
protected int yPos;

public BasicGuiScreen(GuiScreen parent, int guiWidth, int guiHeight){
this.parent = parent;
this.guiWidth = guiWidth;
this.guiHeight = guiHeight;
}

@Override
public void initGui(){
xPos = (width - guiWidth) / 2;
yPos = (height - guiHeight) / 2;
}

@Override
protected void keyTyped(char c, int key){
if(key == 1){
onClose();
this.mc.displayGuiScreen(parent);
return;
}
}

protected void onClose(){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package code.elix_x.excore.utils.client.gui;

import code.elix_x.excore.utils.client.gui.elements.ColoredRectangleGuiElement;
import code.elix_x.excore.utils.client.gui.elements.IntegralSliderGuiElement;
import code.elix_x.excore.utils.color.RGBA;
import net.minecraft.client.gui.GuiScreen;

public class ColorSelectorGuiScreen extends ElementalGuiScreen {

protected RGBA color;

public ColorSelectorGuiScreen(GuiScreen parent, RGBA color){
super(parent, 256, 104);
this.color = color;
}

@Override
protected void addElements(){
add(new ColoredRectangleGuiElement("Color Display", xPos + (guiWidth - 20) / 2, yPos, 20, 20, 0, 2, color));

nextY += 2 + 20 + 2;

add(new ColoredRectangleGuiElement("Red Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(255, 0, 0, 255), new RGBA(0, 0, 0, 0), new RGBA(255, 0, 0, 255)));
add(new IntegralSliderGuiElement("Red Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.r, true){

@Override
protected void checkSliderValue(){
super.checkSliderValue();
color.r = getValue();
}

});

nextY += 2 + 16 + 2;

add(new ColoredRectangleGuiElement("Green Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(0, 255, 0, 255), new RGBA(0, 0, 0, 0), new RGBA(0, 255, 0, 255)));
add(new IntegralSliderGuiElement("Green Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.g, true){

@Override
protected void checkSliderValue(){
super.checkSliderValue();
color.g = getValue();
}

});

nextY += 2 + 16 + 2;

add(new ColoredRectangleGuiElement("Blue Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(0, 0, 255, 255), new RGBA(0, 0, 0, 0), new RGBA(0, 0, 255, 255)));
add(new IntegralSliderGuiElement("Blue Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.b, true){

@Override
protected void checkSliderValue(){
super.checkSliderValue();
color.b = getValue();
}

});

nextY += 2 + 16 + 2;

add(new ColoredRectangleGuiElement("Alpha Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(0, 0, 0, 255), new RGBA(0, 0, 0, 0), new RGBA(0, 0, 0, 255)));
add(new IntegralSliderGuiElement("Alpha Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.a, true){

@Override
protected void checkSliderValue(){
super.checkSliderValue();
color.a = getValue();
}

});

nextY += 2 + 16 + 2;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package code.elix_x.excore.utils.client.gui;

import java.util.ArrayList;
import java.util.List;

import org.lwjgl.input.Mouse;

import code.elix_x.excore.utils.client.gui.elements.IGuiElement;
import code.elix_x.excore.utils.client.gui.elements.IGuiElementsHandler;
import net.minecraft.client.gui.GuiScreen;

public class ElementalGuiScreen extends BasicGuiScreen implements IGuiElementsHandler<IGuiElement<ElementalGuiScreen>> {

protected List<IGuiElement<ElementalGuiScreen>> elements = new ArrayList<IGuiElement<ElementalGuiScreen>>();

protected IGuiElement<ElementalGuiScreen> focused;

protected int nextY;

public ElementalGuiScreen(GuiScreen parent, int guiWidth, int guiHeight){
super(parent, guiWidth, guiHeight);
}

@Override
public void add(IGuiElement<ElementalGuiScreen> element){
elements.add(element);
}

@Override
public IGuiElement<ElementalGuiScreen> getFocused(){
return focused;
}

@Override
public void setFocused(IGuiElement element){
focused = element;
}

@Override
public void looseFocus(){
setFocused(null);
}

@Override
public void initGui(){
super.initGui();
elements.clear();
nextY = yPos;
addElements();
for(IGuiElement<ElementalGuiScreen> element : elements) element.initGui(this, parent);
}

protected void addElements(){

}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks){
for(IGuiElement<ElementalGuiScreen> element : elements){
element.drawGuiPre(this, this, mouseX, mouseY);
}
for(IGuiElement<ElementalGuiScreen> element : elements){
element.drawBackground(this, this, mouseX, mouseY);
}
for(IGuiElement<ElementalGuiScreen> element : elements){
element.drawGuiPost(this, this, mouseX, mouseY);
}
}

@Override
protected void keyTyped(char c, int key){
super.keyTyped(c, key);
if(focused != null && focused.handleKeyboardEvent(this, this, true, key, c)) return;
for(IGuiElement<ElementalGuiScreen> element : elements){
if(element != focused && element.handleKeyboardEvent(this, this, true, key, c)) return;
}
}

@Override
public void handleMouseInput(){
super.handleMouseInput();
int dWheel = Mouse.getEventDWheel();
if(dWheel != 0){
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
if(focused != null && focused.handleMouseEvent(this, this, mouseX, mouseY, dWheel)) return;
for(IGuiElement<ElementalGuiScreen> element : elements){
if(element != focused && element.handleMouseEvent(this, this, mouseX, mouseY, dWheel)) return;
}
}
}

@Override
protected void mouseClicked(int mouseX, int mouseY, int key){
if(focused != null && focused.handleMouseEvent(this, this, mouseX, mouseY, true, key)) return;
for(IGuiElement<ElementalGuiScreen> element : elements){
if(element != focused && element.handleMouseEvent(this, this, mouseX, mouseY, true, key)) return;
}
super.mouseClicked(mouseX, mouseY, key);
}

@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int key){
if(focused != null && focused.handleMouseEvent(this, this, mouseX, mouseY, false, key)) return;
for(IGuiElement<ElementalGuiScreen> element : elements){
if(element != focused && element.handleMouseEvent(this, this, mouseX, mouseY, false, key)) return;
}
super.mouseMovedOrUp(mouseX, mouseY, key);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package code.elix_x.excore.utils.client.gui.elements;

import cpw.mods.fml.client.config.GuiButtonExt;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;

public class ButtonGuiElement<H extends IGuiElementsHandler<? extends IGuiElement<H>>> extends RectangularGuiElement<H> {

protected GuiButtonExt button;

public ButtonGuiElement(String name, int xPos, int yPos, int width, int height, int borderX, int borderY, String buttonText){
super(name, xPos, yPos, width, height, borderX, borderY);
this.button = new GuiButtonExt(0, xPos + borderX, yPos + borderY, width, height, buttonText);
}

@Override
public void openGui(H handler, GuiScreen gui){

}

@Override
public void initGui(H handler, GuiScreen gui){

}

@Override
public void drawGuiPre(H handler, GuiScreen gui, int mouseX, int mouseY){

}

@Override
public void drawBackground(H handler, GuiScreen gui, int mouseX, int mouseY){

}

@Override
public void drawGuiPost(H handler, GuiScreen gui, int mouseX, int mouseY){
button.drawButton(gui.mc, mouseX, mouseY);
}

@Override
public void drawGuiPostPost(H handler, GuiScreen gui, int mouseX, int mouseY){

}

@Override
public boolean handleKeyboardEvent(H handler, GuiScreen gui, boolean down, int key, char c){
return false;
}

@Override
public boolean handleMouseEvent(H handler, GuiScreen gui, int mouseX, int mouseY, boolean down, int key){
if(down && key == 0 && button.mousePressed(gui.mc, mouseX, mouseY)){
onButtonPressed();
return true;
}
return false;
}

public void onButtonPressed(){
button.func_146113_a(Minecraft.getMinecraft().getSoundHandler());
}

@Override
public boolean handleMouseEvent(H handler, GuiScreen gui, int mouseX, int mouseY, int dWheel){
return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package code.elix_x.excore.utils.client.gui.elements;

import code.elix_x.excore.utils.color.RGBA;
import net.minecraft.client.gui.FontRenderer;

public class CenteredStringGuiElement<H extends IGuiElementsHandler<? extends IGuiElement<H>>> extends StringGuiElement<H> {

public CenteredStringGuiElement(String name, int xPos, int yPos, int borderX, int borderY, String text, FontRenderer fontRenderer, RGBA color){
super(name, xPos - fontRenderer.getStringWidth(text) / 2, yPos, borderX, borderY, text, fontRenderer, color);
}

}
Loading

0 comments on commit 5dd44bd

Please sign in to comment.