07/03/2015

This commit is contained in:
brandon3055 committed 2015-03-07 17:48:24 +11:00
1 parent e1e7994171
commit fa5621e00b
21 files changed
+374 -125

No files matched your search

@@ -4,6 +4,7 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
import com.brandon3055.draconicevolution.client.handler.HudHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.keybinding.KeyBindings;
import com.brandon3055.draconicevolution.client.keybinding.KeyInputHandler;
import com.brandon3055.draconicevolution.client.render.block.*;
@@ -49,7 +50,7 @@ public class ClientProxy extends CommonProxy {
System.out.println("on Client side");
super.preInit(event);
ResourceHandler.init(event);
// downloadLocation = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/mods/derspack";
// downloadLocation = downloadLocation.replaceAll("\\\\", "/");
@@ -1,8 +1,8 @@
package com.brandon3055.draconicevolution.client.gui;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.gui.componentguis.GUIManual;
import com.brandon3055.draconicevolution.client.gui.componentguis.GUIToolConfig;
import com.brandon3055.draconicevolution.client.gui.manual.GuiManual;
import com.brandon3055.draconicevolution.common.container.*;
import com.brandon3055.draconicevolution.common.inventory.InventoryTool;
import com.brandon3055.draconicevolution.common.tileentities.*;
@@ -144,7 +144,7 @@ public class GuiHandler implements IGuiHandler {
}
break;
case GUIID_MANUAL:
return new GuiManual();
return new GUIManual();
case GUIID_DISSENCHANTER:
TileEntity dissenchanter = world.getTileEntity(x, y, z);
if (dissenchanter != null && dissenchanter instanceof TileDissEnchanter) {
@@ -0,0 +1,169 @@
package com.brandon3055.draconicevolution.client.gui.componentguis;
import com.brandon3055.draconicevolution.client.gui.guicomponents.ComponentCollection;
import com.brandon3055.draconicevolution.client.gui.guicomponents.ComponentIndexButton;
import com.brandon3055.draconicevolution.client.gui.guicomponents.ComponentTexturedRect;
import com.brandon3055.draconicevolution.client.gui.guicomponents.GUIScrollingBase;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.container.DummyContainer;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.google.gson.stream.JsonReader;
import org.lwjgl.opengl.GL11;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Brandon on 6/03/2015.
*/
public class GUIManual extends GUIScrollingBase {
private static List<ManualPage> pageList = new ArrayList<ManualPage>();
public GUIManual() {
super(new DummyContainer(), 0, 0);
this.xSize = 255;
this.ySize = 325;
}
@Override
public void initGui() {
super.initGui();
loadPages();
}
public static final String GR_BACKGROUND = "BACKGROUND";
public static final String GR_INTRO = "INTRO";
public static final String GR_INDEX = "INDEX";
public static final String GR_4 = "BACKGROUND";
@Override
protected ComponentCollection assembleComponents() {
collection = new ComponentCollection(0, 0, xSize, ySize, this);
collection.addComponent(new ComponentTexturedRect(0, 0, 255, 255, ResourceHandler.getResource("textures/gui/manualTop.png"))).setGroup(GR_BACKGROUND);
collection.addComponent(new ComponentTexturedRect(0, 255, 255, 69, ResourceHandler.getResource("textures/gui/manualBottom.png"))).setGroup(GR_BACKGROUND);
for (int i = 0; i < 35; i ++)
{
collection.addComponent(new ComponentIndexButton(20, 20 + i * 12, this)).setGroup(GR_INDEX);
pageLength += 12;
}
return collection;
}
@Override
public void handleScrollInput(int direction) {
scrollOffset += direction * 5;
if (scrollOffset < 0) scrollOffset = 0;
if (scrollOffset > pageLength - ySize + 40) scrollOffset = pageLength - ySize + 40;
if (pageLength + 40 <= ySize) scrollOffset = 0;
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
super.drawScreen(mouseX, mouseY, par3);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
ResourceHandler.bindResource("textures/gui/manualBottom.png");
GL11.glColor4f(1f, 1f, 1f, 1f);
drawTexturedModalRect(0, ySize - 34, 0, 69, 256, 34);
drawTexturedModalRect(0, 0, 0, 103, 256, 34);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
public static void loadPages()
{
LogHelper.info("loading pages");
try
{
pageList.clear();
File manualJSON = new File(ResourceHandler.getSaveFolder(), "manual.json");
JsonReader reader = new JsonReader(new FileReader(manualJSON));
List<String> images;
List<String> content;
reader.beginArray();
//Read next page
while (reader.hasNext())
{
String name;
images = new ArrayList<String>();
content = new ArrayList<String>();
reader.beginObject();
//Read page name
String s = reader.nextName();
if (s.equals("name"))
{
name = reader.nextString();
}
else throw new IOException("Error reading manual.json (invalid name in place of \"name\" [Found:\"" + s + "\"])");
//Read page images
s = reader.nextName();
if (s.equals("images"))
{
reader.beginArray();
while (reader.hasNext())
{
images.add(reader.nextString());
}
reader.endArray();
}
else throw new IOException("Error reading manual.json (invalid name in place of \"images\" [Found:\"" + s + "\"])");
//Read page content
s = reader.nextName();
if (s.equals("content"))
{
reader.beginArray();
while (reader.hasNext())
{
content.add(reader.nextString());
}
reader.endArray();
}
else throw new IOException("Error reading manual.json (invalid name in place of \"content\" [Found:\"" + s + "\"])");
reader.endObject();
pageList.add(new ManualPage(name, images.toArray(new String[images.size()]), content.toArray(new String[content.size()])));
}
reader.endArray();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
for (ManualPage p : pageList) LogHelper.info(p.getLocalizedName());
}
}
@@ -0,0 +1,27 @@
package com.brandon3055.draconicevolution.client.gui.componentguis;
import net.minecraft.util.StatCollector;
/**
* Created by Brandon on 7/03/2015.
*/
public class ManualPage {
public String name;
public String[] imageURLs;
public String[] content;
public ManualPage(String name, String[] imageURLs, String[] content)
{
this.name = name;
this.imageURLs = imageURLs;
this.content = content;
}
public String getLocalizedName()
{
return (name.contains("item.") || name.contains("tile.")) ? StatCollector.translateToLocal(name) : name.contains("info.") ? name.substring(name.indexOf("info.") + 5) : "Invalid Name Data";
}
}
@@ -0,0 +1,41 @@
package com.brandon3055.draconicevolution.client.gui.guicomponents;
import net.minecraft.client.Minecraft;
/**
* Created by Brandon on 7/03/2015.
*/
public class ComponentIndexButton extends ComponentScrollingBase {
public ComponentIndexButton(int x, int y, GUIScrollingBase gui) {
super(x, y, gui);
}
@Override
public void handleScrollInput(int direction) {
//this.y += direction * 10;
}
@Override
public int getWidth() {
return 200;
}
@Override
public int getHeight() {
return 12;
}
@Override
public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
int sy = y - gui.scrollOffset;
if (sy > 1 && sy + getHeight() < gui.getYSize())
{
fontRendererObj.drawString("!!!!!!!!!!! Test !!!!!!!!!! " + y/12, x, sy, 0xffffff);
}
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
}
@@ -4,8 +4,14 @@ package com.brandon3055.draconicevolution.client.gui.guicomponents;
* Created by Brandon on 6/03/2015.
*/
public abstract class ComponentScrollingBase extends ComponentBase {
public ComponentScrollingBase(int x, int y) {
protected GUIScrollingBase gui;
public int scrollOffset;
public int componentLength;
public ComponentScrollingBase(int x, int y, GUIScrollingBase gui) {
super(x, y);
this.gui = gui;
}
public abstract void handleScrollInput(int direction);
@@ -121,4 +121,8 @@ public abstract class GUIBase extends GuiContainer {
}
public void buttonClicked(int id){buttonPressed = true;}
public int getXSize() { return xSize; }
public int getYSize() { return ySize; }
}
@@ -7,6 +7,9 @@ import net.minecraft.inventory.Container;
*/
public abstract class GUIScrollingBase extends GUIBase {
public int scrollOffset;
public int pageLength;
public GUIScrollingBase(Container container, int xSize, int ySize) {
super(container, xSize, ySize);
}
@@ -15,11 +18,11 @@ public abstract class GUIScrollingBase extends GUIBase {
public void handleMouseInput() {
int i = org.lwjgl.input.Mouse.getEventDWheel();
if (i != 0) {
handleScrollInput(i > 0 ? 1 : -1);
handleScrollInput(i > 0 ? -1 : 1);
for (ComponentBase c : collection.getComponents())
{
if (c instanceof ComponentScrollingBase) ((ComponentScrollingBase) c).handleScrollInput(i > 0 ? 1 : -1);
if (c instanceof ComponentScrollingBase) ((ComponentScrollingBase) c).handleScrollInput(i > 0 ? -1 : 1);
}
}
}
@@ -0,0 +1,87 @@
package com.brandon3055.draconicevolution.client.handler;
import com.brandon3055.draconicevolution.common.lib.References;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.ResourceLocation;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Brandon on 8/02/2015.
*/
public class ResourceHandler {
private static ResourceLocation defaultParticles;
private static ResourceLocation particles = new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png");
private static Map<String, ResourceLocation> cachedResources = new HashMap<String, ResourceLocation>();
private static String savePath;
private static File saveFolder;
//-------------------- File Handling -----------------------//
public static void init(FMLPreInitializationEvent event)
{
savePath = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/mods/draconicevolution";
}
public static File getSaveFolder()
{
if (saveFolder == null) { saveFolder = new File(savePath); }
if (!saveFolder.exists()) saveFolder.mkdir();
return saveFolder;
}
//----------------------------------------------------------//
public static void bindTexture(ResourceLocation texture)
{
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
}
/**Binds the vanilla particle sheet*/
public static void bindDefaultParticles()
{
if (defaultParticles == null)
{
try
{
defaultParticles = (ResourceLocation) ReflectionHelper.getPrivateValue(EffectRenderer.class, null, "particleTextures", "field_110737_b");
}
catch (Exception e) {}
}
if (defaultParticles != null) bindTexture(defaultParticles);
}
public static void bindParticles()
{
bindTexture(particles);
}
public static ResourceLocation getResource(String rs)
{
if (!cachedResources.containsKey(rs)) cachedResources.put(rs, new ResourceLocation(References.RESOURCESPREFIX + rs));
return cachedResources.get(rs);
}
public static void bindResource(String rs)
{
bindTexture(ResourceHandler.getResource(rs));
}
}
@@ -1,39 +0,0 @@
package com.brandon3055.draconicevolution.client.handler;
import com.brandon3055.draconicevolution.common.lib.References;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.ResourceLocation;
/**
* Created by Brandon on 8/02/2015.
*/
public class ResourceHelper {
private static ResourceLocation defaultParticles;
private static ResourceLocation particles = new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png");
public static void bindTexture(ResourceLocation texture)
{
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
}
/**Binds the vanilla particle sheet*/
public static void bindDefaultParticles()
{
if (defaultParticles == null)
{
try
{
defaultParticles = (ResourceLocation) ReflectionHelper.getPrivateValue(EffectRenderer.class, null, "particleTextures", "field_110737_b");
}
catch (Exception e) {}
}
if (defaultParticles != null) bindTexture(defaultParticles);
}
public static void bindParticles()
{
bindTexture(particles);
}
}
@@ -1,6 +1,6 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
@@ -61,7 +61,7 @@ public class ParticleCustom extends EntityFX
{//Note U=X V=Y
tesselator.draw();
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -92,7 +92,7 @@ public class ParticleCustom extends EntityFX
tesselator.addVertexWithUV((double)(drawX + par3 * drawScale - par6 * drawScale), (double)(drawY - par4 * drawScale), (double)(drawZ + par5 * drawScale - par7 * drawScale), (double)minU, (double)maxV);
tesselator.draw();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -1,6 +1,6 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
@@ -63,7 +63,7 @@ public class ParticleDistortion extends EntityFX {
public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tessellator.draw();
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
tessellator.startDrawingQuads();
tessellator.setBrightness(200);//make sure you have this!!
@@ -94,7 +94,7 @@ public class ParticleDistortion extends EntityFX {
tessellator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tessellator.draw();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tessellator.startDrawingQuads();
}
@@ -1,6 +1,6 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
@@ -97,7 +97,7 @@ public class ParticleEnergy extends EntityFX {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -128,7 +128,7 @@ public class ParticleEnergy extends EntityFX {
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -1,7 +1,7 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.Utills;
import net.minecraft.client.Minecraft;
@@ -218,7 +218,7 @@ public class ParticleEnergyBeam extends EntityFX {
GL11.glPopMatrix();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tessellator.startDrawingQuads();
}
@@ -1,6 +1,6 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
@@ -60,7 +60,7 @@ public class ParticleEnergyField extends EntityFX {//todo Fancy Animated Particl
GL11.glPushMatrix();
//GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
GL11.glDepthMask(false);
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
float minU = 0.0F + 0.125F * (advanced ? 4 : 3);
float maxU = 0.0F + 0.125F * (advanced ? 5 : 4);//minU + 0.124F;
@@ -126,7 +126,7 @@ public class ParticleEnergyField extends EntityFX {//todo Fancy Animated Particl
//GL11.glPopAttrib();
GL11.glPopMatrix();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tessellator.startDrawingQuads();
}
}
@@ -1,6 +1,6 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
@@ -121,7 +121,7 @@ public final class Particles {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -172,7 +172,7 @@ public final class Particles {
}
tesselator.draw();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -225,7 +225,7 @@ public final class Particles {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -260,7 +260,7 @@ public final class Particles {
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -421,7 +421,7 @@ public final class Particles {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
ResourceHelper.bindParticles();
ResourceHandler.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);
@@ -453,7 +453,7 @@ public final class Particles {
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
ResourceHelper.bindDefaultParticles();
ResourceHandler.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -49,7 +49,8 @@ public class DraconiumItemBlock extends ItemBlock implements IEnergyContainerIte
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if(container.getItemDamage() != 0) return 0;
if(container.getItemDamage() != 0 || container.stackSize <= 0) return 0;
maxReceive /= container.stackSize;
if (container.stackTagCompound == null) {
container.stackTagCompound = new NBTTagCompound();
}
@@ -64,7 +65,7 @@ public class DraconiumItemBlock extends ItemBlock implements IEnergyContainerIte
container.setItemDamage(2);
container.setTagCompound(null);
}
return energyReceived;
return energyReceived * container.stackSize;
}
@Override
@@ -6,6 +6,7 @@ import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
@@ -75,6 +76,7 @@ public class Tclogo extends ItemDE {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (world.isRemote)
{
String str = "A String";
@@ -88,6 +90,10 @@ public class Tclogo extends ItemDE {
//player.addChatMessage(localIChatComponent);
}
else
{
for (Object o : EntityList.classToStringMapping.values()) LogHelper.info(o);
}
if (!player.isSneaking())