22/03/2015

This commit is contained in:
brandon3055 committed 2015-03-22 08:40:44 +11:00
1 parent 8c6b509169
commit 2c0440e6b8
36 files changed
+1717 -157

No files matched your search

@@ -1,8 +1,8 @@
package com.brandon3055.draconicevolution.client.gui;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.network.ParticleGenPacket;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.network.ParticleGenPacket;
import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -13,15 +13,17 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
public class GUIParticleGenerator extends GuiScreen {
private final int xSize = 212;
private final int ySize = 198;
private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/ParticleGenerator.png");
private int page = 1;
private int infoPage = 0;
private boolean hasInitialized = false;
//Particle variables
private boolean particles_enabled = true;
private int red = 0;
private int green = 0;
private int blue = 0;
@@ -50,6 +52,21 @@ public class GUIParticleGenerator extends GuiScreen {
private int selected_particle = 1;
private int selected_max = 3;
private float gravity = 0F;
//Beam variables
private boolean beam_enabled = false;
private boolean render_core = false;
private int beam_red = 0;
private int beam_green = 0;
private int beam_blue = 0;
private float beam_scale = 0F;
private float beam_pitch = 0F;
private float beam_yaw = 0F;
private float beam_length = 0F;
private float beam_rotation = 0F;
//Buttons
//Info Page
@@ -74,13 +91,15 @@ public class GUIParticleGenerator extends GuiScreen {
int posY = (this.height - ySize) / 2;
drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize);
if (page < 3) fontRendererObj.drawStringWithShadow("Particle Generator", posX + 60, posY + 5, 0x00FFFF);
else if (page < 10) fontRendererObj.drawStringWithShadow("Beam Generator", posX + 65, posY + 5, 0x00FFFF);
else fontRendererObj.drawStringWithShadow("Information", posX + 75, posY + 5, 0x00FFFF);
if (page == 1) page1Txt();
else if (page == 2) page2Txt();
else {
fontRendererObj.drawSplitString(InfoText[page - 3], posX + 5, posY + 20, 200, 0x000000);
fontRendererObj.drawSplitString("Page: " + (page - 3), posX + 88, posY + 180, 200, 0xFF0000);
else if (page == 3) page3Txt();
else if (page == 10) {
fontRendererObj.drawSplitString(InfoText[infoPage], posX + 5, posY + 20, 200, 0x000000);
fontRendererObj.drawSplitString("Page: " + (infoPage + 1), posX + 88, posY + 180, 200, 0xFF0000);
}
fontRendererObj.drawStringWithShadow("Hold:", posX + 215, posY + 11, 0xFFFFFF);
@@ -89,13 +108,6 @@ public class GUIParticleGenerator extends GuiScreen {
fontRendererObj.drawStringWithShadow("Shift+Ctrl +- 100", posX + 215, posY + 41, 0xFFFFFF);
super.drawScreen(x, y, f);
ArrayList<String> lines = new ArrayList<String>();
lines.add("test");
//drawHoveringText(lines, x, y, fontRendererObj);
}
//@formatter:on
@@ -111,20 +123,35 @@ public class GUIParticleGenerator extends GuiScreen {
int posY = (this.height - ySize) / 2;
buttonList.clear();
if (page < 10)
{
buttonList.add(new GuiButton(33, posX + 213, posY + 177, 47, 20, "===>"));
buttonList.add(new GuiButton(32, posX - 47, posY + 177, 47, 20, "<==="));
}
if (page == 1) page1Buttons();
else if (page == 2) page2Buttons();
else {
else if (page == 3) page3Buttons();
else if (page == 10){
buttonList.add(new GuiButton(57, posX + 4, posY + 174, 80, 20, "Previous page"));
buttonList.add(new GuiButton(56, posX + 128, posY + 174, 80, 20, "Next page"));
}
if (page < 3) buttonList.add(new GuiButton(54, posX - 21, posY + 3, 20, 20, "i"));
if (page < 10) buttonList.add(new GuiButton(54, posX - 21, posY + 3, 20, 20, "i"));
else buttonList.add(new GuiButton(55, posX - 31, posY + 23, 30, 20, "Back"));
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.id < 100) particleActions(button);
else beamActions(button);
}
private void particleActions(GuiButton button) {
int value = 1;
float value_F;
short packetValue = 0;
@@ -135,7 +162,8 @@ public class GUIParticleGenerator extends GuiScreen {
value_F = (value) / 1000F;
switch (button.id) {
switch (button.id)
{
case 0://Red +
red = (red + value) > 255 ? 255 : red + value;
packetValue = (short) red;
@@ -265,12 +293,12 @@ public class GUIParticleGenerator extends GuiScreen {
packetValue = (short) (random_scale * 100F);
break;
case 32://Page 2
page = 2;
if (page > 1) page--;
packetValue = (short) page;
initGui();
break;
case 33://Page 1
page = 1;
if (page < 3) page++;
initGui();
packetValue = (short) page;
break;
@@ -357,7 +385,7 @@ public class GUIParticleGenerator extends GuiScreen {
packetValue = (short) (gravity * 1000F);
break;
case 54://Info Page
page = 3;
page = 10;
initGui();
packetValue = (short) page;
break;
@@ -367,13 +395,18 @@ public class GUIParticleGenerator extends GuiScreen {
packetValue = (short) page;
break;
case 56://Info Next Page
if (page < 7) page++;
if (infoPage < 4) infoPage++;
else initGui();
break;
case 57://Info Previous Page
if (page > 3) page--;
if (infoPage > 0) infoPage--;
else initGui();
break;
case 58://particles Enabled
particles_enabled = !particles_enabled;
packetValue = particles_enabled ? (byte)1 : (byte)0;
initGui();
break;
}
DraconicEvolution.network.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord));
}
@@ -424,6 +457,18 @@ public class GUIParticleGenerator extends GuiScreen {
fade = tile.fade;
selected_particle = tile.selected_particle;
gravity = tile.gravity;
particles_enabled = tile.particles_enabled;
render_core = tile.render_core;
beam_enabled = tile.beam_enabled;
beam_red = tile.beam_red;
beam_green = tile.beam_green;
beam_blue = tile.beam_blue;
beam_scale = tile.beam_scale;
beam_pitch = tile.beam_pitch;
beam_yaw = tile.beam_yaw;
beam_length = tile.beam_length;
beam_rotation = tile.beam_rotation;
}
//@formatter:off
@@ -529,7 +574,7 @@ public class GUIParticleGenerator extends GuiScreen {
buttonList.add(new GuiButton(27, posX + DX4, posY + y1 + 6 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(31, posX + DX4, posY + y1 + 7 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(32, posX + 213, posY + 177, 47, 20, "Page 2"));
}
private void page2Txt() {
@@ -607,9 +652,172 @@ public class GUIParticleGenerator extends GuiScreen {
buttonList.add(new GuiButton(41, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(45, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(33, posX - 47, posY + 177, 47, 20, "Page 1"));
buttonList.add(new GuiButton(50, posX + DX3 - 11, posY + y1 + 3 * 22, 102, 20, "Block Collision: " + (collide ? "on" : "off")));
buttonList.add(new GuiButton(51, posX + DX3 - 11, posY + y1 + 4 * 22, 102, 20, "Particle Selected: " + selected_particle));
buttonList.add(new GuiButton(58, posX + DX3 - 11, posY + y1 + 5 * 22, 102, 20, "Enabled: " + (particles_enabled ? "on" : "off")));
}
private void page3Txt() {
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
int col1 = posX + 30;
int col2 = posX + 141;
int ln1 = 20;
int ln2 = 30;
String pitch = String.valueOf(Math.round(beam_pitch * 100F) / 100F);
String yaw = String.valueOf(Math.round(beam_yaw * 100F) / 100F);
String length = String.valueOf(Math.round(beam_length * 100F) / 100F);
String rotation = String.valueOf(Math.round(beam_rotation * 100F) / 100F);
String scale = String.valueOf(Math.round(beam_scale * 100F) / 100F);
fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false);
fontRendererObj.drawString(String.valueOf(beam_red), col1, posY + ln2 + 0 * 22, 0x000000, false);
fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false);
fontRendererObj.drawString(String.valueOf(beam_green), col1, posY + ln2 + 1 * 22, 0x000000, false);
fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false);
fontRendererObj.drawString(String.valueOf(beam_blue), col1, posY + ln2 + 2 * 22, 0x000000, false);
fontRendererObj.drawString("Z Rot:", col1, posY + ln1 + 3 * 22, 0x000000, false);
fontRendererObj.drawString(pitch, col1, posY + ln2 + 3 * 22, 0x000000, false);
fontRendererObj.drawString("X Rot:", col1, posY + ln1 + 4 * 22, 0x000000, false);
fontRendererObj.drawString(yaw, col1, posY + ln2 + 4 * 22, 0x000000, false);
fontRendererObj.drawString("Length:", col1, posY + ln1 + 5 * 22, 0x000000, false);
fontRendererObj.drawString(length, col1, posY + ln2 + 5 * 22, 0x000000, false);
fontRendererObj.drawString("Rotation:", col1, posY + ln1 + 6 * 22, 0x000000, false);
fontRendererObj.drawString(rotation, col1, posY + ln2 + 6 * 22, 0x000000, false);
fontRendererObj.drawString("Scale:", col1, posY + ln1 + 7 * 22, 0x000000, false);
fontRendererObj.drawString(scale, col1, posY + ln2 + 7 * 22, 0x000000, false);
}
@SuppressWarnings("unchecked")
private void page3Buttons() {
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
int DX1 = 5;//x pos for row 1,2,3,4
int DX2 = DX1 + 71;
int DX3 = DX2 + 40;
int DX4 = DX3 + 71;
int y1 = 19;
buttonList.add(new GuiButton(100, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(101, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(102, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(103, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(104, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(105, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(106, posX + DX1, posY + y1 + 6 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(107, posX + DX1, posY + y1 + 7 * 22, 20, 20, "+"));
buttonList.add(new GuiButton(108, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(109, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(110, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(111, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(112, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(113, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(114, posX + DX2, posY + y1 + 6 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(115, posX + DX2, posY + y1 + 7 * 22, 20, 20, "-"));
buttonList.add(new GuiButton(116, posX + DX3 - 11, posY + y1 + 0 * 22, 102, 20, "Enabled: " + (beam_enabled ? "on" : "off")));
buttonList.add(new GuiButton(117, posX + DX3 - 11, posY + y1 + 1 * 22, 102, 20, "Render Core: " + (render_core ? "on" : "off")));
buttonList.add(new GuiButton(127, posX + DX3 - 11, posY + y1 + 7 * 22, 102, 20, "Take note of values"));
}
private void beamActions(GuiButton button) {
int value = 1;
float value_F;
short packetValue = 0;
if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) value = 10;
if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) value = 100;
if ((Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)))
value = 1000;
value_F = (value) / 100F;
switch (button.id)
{
case 100: //beam red +
beam_red = (beam_red + value) > 255 ? 255 : beam_red + value;
packetValue = (short) beam_red;
break;
case 101: //beam green +
beam_green = (beam_green + value) > 255 ? 255 : beam_green + value;
packetValue = (short) beam_green;
break;
case 102: //beam blue +
beam_blue = (beam_blue + value) > 255 ? 255 : beam_blue + value;
packetValue = (short) beam_blue;
break;
case 103: //beam pitch +
beam_pitch = (beam_pitch + value_F) > 360F ? 360F : beam_pitch + value_F;
packetValue = (short) (beam_pitch * 100F);
break;
case 104: //beam yaw +
beam_yaw = (beam_yaw + value_F) > 360F ? 360F : beam_yaw + value_F;
packetValue = (short) (beam_yaw * 100F);
break;
case 105: //beam length +
beam_length = (beam_length + value_F) > 30F ? 30F : beam_length + value_F;
packetValue = (short) (beam_length * 100F);
break;
case 106: //beam rotation +
beam_rotation = (beam_rotation + value_F) > 1F ? 1F : beam_rotation + value_F;
packetValue = (short) (beam_rotation * 100F);
break;
case 107: //beam scale +
beam_scale = (beam_scale + value_F) > 5F ? 5F : beam_scale + value_F;
packetValue = (short) (beam_scale * 100F);
break;
case 108: //beam red -
beam_red = (beam_red - value) < 0 ? 0 : beam_red - value;
packetValue = (short) beam_red;
break;
case 109: //beam green -
beam_green = (beam_green - value) < 0 ? 0 : beam_green - value;
packetValue = (short) beam_green;
break;
case 110: //beam blue -
beam_blue = (beam_blue - value) < 0 ? 0 : beam_blue - value;
packetValue = (short) beam_blue;
break;
case 111: //beam pitch -
beam_pitch = (beam_pitch - value_F) < -0F ? -0F : beam_pitch - value_F;
packetValue = (short) (beam_pitch * 100F);
break;
case 112: //beam yaw -
beam_yaw = (beam_yaw - value_F) < -0F ? -0F : beam_yaw - value_F;
packetValue = (short) (beam_yaw * 100F);
break;
case 113: //beam length -
beam_length = (beam_length - value_F) < -0F ? -0F : beam_length - value_F;
packetValue = (short) (beam_length * 100F);
break;
case 114: //beam rotation -
beam_rotation = (beam_rotation - value_F) < -1F ? -1F : beam_rotation - value_F;
packetValue = (short) (beam_rotation * 100F);
break;
case 115: //beam scale -
beam_scale = (beam_scale - value_F) < -0F ? -0F : beam_scale - value_F;
packetValue = (short) (beam_scale * 100F);
break;
case 116: //beam enabled
beam_enabled = !beam_enabled;
packetValue = beam_enabled ? (byte) 1 : (byte) 0;
initGui();
break;
case 117: //beam enabled
render_core = !render_core;
packetValue = render_core ? (byte) 1 : (byte) 0;
initGui();
break;
}
DraconicEvolution.network.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord));
}
//@formatter:on
@@ -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) {
@@ -1,18 +1,18 @@
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.gui.guicomponents.*;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.container.DummyContainer;
import com.brandon3055.draconicevolution.common.lib.References;
import com.google.gson.stream.JsonReader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.apache.commons.io.IOUtils;
import org.lwjgl.opengl.GL11;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
@@ -23,11 +23,18 @@ public class GUIManual extends GUIScrollingBase {
private static List<ManualPage> pageList = new ArrayList<ManualPage>();
public static List<String> imageURLs = new ArrayList<String>();
private static ManualPage currentPage = null;
public GUIManual() {
super(new DummyContainer(), 0, 0);
this.xSize = 255;
this.ySize = 325;
super(new DummyContainer(), 255, 325);
if (currentPage != null)
{
collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE);
collection.addComponent(new ComponentButton(102, 325, 50, 20, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE);
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_PAGE, true);
}
}
@Override
@@ -39,17 +46,19 @@ public class GUIManual extends GUIScrollingBase {
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";
public static final String GR_PAGE = "PAGE";
@Override
protected ComponentCollection assembleComponents() {
loadPages();
collection = new ComponentCollection(0, 0, xSize, ySize, this);
loadPages();//todo remove
collection = new ComponentCollection(0, 0, xSize, ySize + 20, 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);
collection.addComponent(new ComponentTexturedRect(0, 100, 0, 0, 255, 255, ResourceHandler.getResource("textures/gui/manualimages/debanner.png"), true)).setGroup(GR_INTRO);
collection.addComponent(new ComponentTexturedRect(7, 100, 0, 0, 255, 255, ResourceHandler.getResource("textures/gui/images/debanner.png"), true)).setGroup(GR_INTRO).setName("BANNER");
collection.addComponent(new ComponentButton(75, 260, 100, 20, 0, this, StatCollector.translateToLocal("info.de.manual.indexButton.txt"), StatCollector.translateToLocal("info.de.manual.indexButtonTip.txt"))).setGroup(GR_INTRO);
// ITextureObject iTextureObject = mc.getTextureManager().getTexture(ResourceHandler.getResource("textures/gui/manualBottom.png"));
// mc.getResourceManager().getResource(ResourceHandler.getResource("textures/gui/manualBottom.png")).
@@ -57,7 +66,7 @@ public class GUIManual extends GUIScrollingBase {
// if (iTextureObject instanceof TextureMap)
// {
// LogHelper.info(((TextureMap) iTextureObject).getTextureExtry("textures/gui/manualBottom.png"));
// }
// }todo old
for (int i = 0; i < pageList.size(); i++)
{
@@ -65,7 +74,6 @@ public class GUIManual extends GUIScrollingBase {
pageLength += 20;
}
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_INTRO, true);
return collection;
@@ -73,6 +81,7 @@ public class GUIManual extends GUIScrollingBase {
@Override
public void handleScrollInput(int direction) {
if (currentPage != null) return;
scrollOffset += direction * 10;
if (scrollOffset < 0) scrollOffset = 0;
if (scrollOffset > pageLength - ySize + 40) scrollOffset = pageLength - ySize + 40;
@@ -82,7 +91,9 @@ public class GUIManual extends GUIScrollingBase {
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
super.drawScreen(mouseX, mouseY, par3);
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
if (collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled()) fontRendererObj.drawSplitString(StatCollector.translateToLocal("info.de.manual.introTxt.txt"), posX + 20, posY + 190, 150, 0x000000);
}
@Override
@@ -102,15 +113,40 @@ public class GUIManual extends GUIScrollingBase {
}
@Override
public void buttonClicked(int id) {
super.buttonClicked(id);
if (id == 0)
{
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_INDEX, true);
}
else if (id == 1)
{
currentPage = null;
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_INDEX, true);
collection.schedulRemoval(GR_PAGE);
}
}
public static void loadPages()
{
//LogHelper.info("loading pages");
try
{
pageList.clear();
pageList.clear();//todo remove these (only needed for testing)
imageURLs.clear();
File manualJSON = new File(ResourceHandler.getConfigFolder(), "manual.json");
InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(References.RESOURCESPREFIX + "manual.json")).getInputStream();
OutputStream os = new FileOutputStream(manualJSON);
IOUtils.copy(is, os);
is.close();
os.close();
JsonReader reader = new JsonReader(new FileReader(manualJSON));
List<String> images;
List<String> content;
@@ -195,4 +231,23 @@ public class GUIManual extends GUIScrollingBase {
//for (ManualPage p : pageList) LogHelper.info(p.getLocalizedName());
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
if (buttonPressed) return;
for (ComponentBase c : collection.getComponents())
{
if (c instanceof ComponentIndexButton && c.isEnabled() && ((ComponentIndexButton) c).isOnScreen() && c.isMouseOver(x - guiLeft, y - guiTop))
{
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
currentPage = ((ComponentIndexButton) c).getPage();
collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE);
collection.addComponent(new ComponentButton(102, 325, 50, 20, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE);
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_PAGE, true);
break;
}
}
}
}
@@ -2,6 +2,9 @@ package com.brandon3055.draconicevolution.client.gui.componentguis;
import net.minecraft.util.StatCollector;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Created by Brandon on 7/03/2015.
*/
@@ -12,6 +15,7 @@ public class ManualPage {
public int meta;
public String[] imageURLs;
public String[] content;
public int scrollOffset = 0;
public ManualPage(String name, String[] imageURLs, String[] content)
{
@@ -27,6 +31,20 @@ public class ManualPage {
this.meta = meta;
}
public String getImageResourceName(String url)
{
try
{
String fileName = new URL(url).getFile();
return fileName.substring(fileName.indexOf("/") + 1);
}
catch (MalformedURLException e)
{
e.printStackTrace();
return "";
}
}
public String getLocalizedName()
{
if (nameL != null) return nameL;
@@ -11,6 +11,7 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@@ -24,7 +25,7 @@ public abstract class ComponentBase extends Gui {
protected int y;
protected boolean enabled = true;
public static Minecraft mc;
protected FontRenderer fontRendererObj;
public FontRenderer fontRendererObj;
private String group = "";
/** The width of the screen object. */
public int width;
@@ -226,4 +227,7 @@ public abstract class ComponentBase extends Gui {
this.width = width;
this.height = height;
}
/**Translate To Local*/
public String ttl(String unlocalizedName){return StatCollector.translateToLocal(unlocalizedName);}
}
@@ -2,7 +2,7 @@ package com.brandon3055.draconicevolution.client.gui.guicomponents;
import com.brandon3055.draconicevolution.client.gui.componentguis.ManualPage;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import cpw.mods.fml.common.registry.GameData;
import com.brandon3055.draconicevolution.common.utills.Utills;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -19,7 +19,7 @@ public class ComponentIndexButton extends ComponentScrollingBase {
public ComponentIndexButton(int x, int y, GUIScrollingBase gui, ManualPage page) {
super(x, y, gui);
this.page = page;
getStackFromName(page.name);
stack = Utills.getStackFromName(page.name, page.meta);
}
@Override
@@ -39,9 +39,9 @@ public class ComponentIndexButton extends ComponentScrollingBase {
@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())
if (isOnScreen())
{
int sy = y - gui.scrollOffset;
boolean mouseOver = isMouseOver(mouseX, mouseY);
fontRendererObj.drawString(page.getLocalizedName(), x + 19, sy, mouseOver ? 0xdd00ff : 0x000000);
@@ -62,21 +62,17 @@ public class ComponentIndexButton extends ComponentScrollingBase {
}
}
public boolean isOnScreen()
{
int sy = y - gui.scrollOffset;
return sy > 1 && sy + getHeight() < gui.getYSize();
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
private void getStackFromName(String name)
{
if (name.contains("tile."))
{
name = name.replace("draconicevolution", "DraconicEvolution").replace("tile.", "");
stack = new ItemStack(GameData.getBlockRegistry().getObject(name), 1, page.meta);
}
if (name.contains("item."))
{
name = name.replace("draconicevolution", "DraconicEvolution").replace("item.", "");
stack = new ItemStack(GameData.getItemRegistry().getObject(name), 1, page.meta);
}
public ManualPage getPage() {
return page;
}
}
@@ -0,0 +1,380 @@
package com.brandon3055.draconicevolution.client.gui.guicomponents;
import com.brandon3055.draconicevolution.client.gui.componentguis.ManualPage;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.utill.CustomResourceLocation;
import com.brandon3055.draconicevolution.common.utills.GuiHelper;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.utills.Utills;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.*;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.lwjgl.opengl.GL11;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by Brandon on 19/03/2015.
*/
public class ComponentManualPage extends ComponentScrollingBase {
public ManualPage page;
public List<ContentComponent> contentList = new ArrayList<ContentComponent>();
private int pageLength = 0;
public ComponentManualPage(int x, int y, GUIScrollingBase gui, ManualPage page) {
super(x, y, gui);
this.page = page;
pageLength = 25;
for (String s : page.content)
{
ContentComponent c = new ContentComponent(s, pageLength, this);
pageLength += c.getHeight();
contentList.add(c);
}
pageLength += 100;
LogHelper.info(page.scrollOffset);
}
@Override
public void handleScrollInput(int direction) {
page.scrollOffset += direction * 10;
if (page.scrollOffset < 0) page.scrollOffset = 0;
if (page.scrollOffset > pageLength - getHeight() + 40) page.scrollOffset = pageLength - getHeight() + 40;
if (pageLength + 40 <= getHeight()) page.scrollOffset = 0;
}
@Override
public int getWidth() {
return gui.width;
}
@Override
public int getHeight() {
return gui.height;
}
@Override
public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
for (ContentComponent c : contentList)
{
c.render(mouseX, mouseY);
}
}
@Override
public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
private static class ContentComponent {
private String content;
/**0 = text, 1 = image, 2 = crafting*/
private int type;
public int yPos;
private ComponentManualPage page;
private String[] textLines;
private List<IRecipe> recipes = new ArrayList<IRecipe>();
private List<ItemStack> smeltingRecipes = new ArrayList<ItemStack>();
private ItemStack result;
public ContentComponent(String content, int y, ComponentManualPage page)
{
this.content = content;
this.yPos = y;
this.page = page;
init();
}
public void init()
{
type = content.contains("http://") ? 1 : content.contains("[c]") ? 2 : 0;
if (type == 0) {
List<String> l = page.fontRendererObj.listFormattedStringToWidth(content, 220);
textLines = l.toArray(new String[l.size()]);
}
else if (type == 2)
{
String s = content.substring(content.indexOf("[c]") + 3);
LogHelper.info(content + " " + s);
String name = s.substring(0, s.lastIndexOf(":"));
ItemStack stack = Utills.getStackFromName(name, Integer.parseInt(s.substring(s.lastIndexOf(":") + 1)));
result = stack;
if (stack != null)
{
LogHelper.info(stack);
for (IRecipe recipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList())
{
if (recipe == null) continue;
ItemStack result = recipe.getRecipeOutput();
if (result == null || !result.isItemEqual(stack)) continue;
Object[] input = getRecipeInput(recipe);
if (input == null) continue;
recipes.add(recipe);
}
Iterator iterator = FurnaceRecipes.smelting().getSmeltingList().entrySet().iterator();
Map.Entry entry;
while (iterator.hasNext())
{
entry = (Map.Entry) iterator.next();
if (entry.getKey() instanceof ItemStack && ((ItemStack) entry.getValue()).isItemEqual(stack))
{
smeltingRecipes.add((ItemStack) entry.getKey());
}
}
LogHelper.info(recipes);
LogHelper.info(smeltingRecipes);
}
}
else textLines = null;
}
public int getHeight()
{
if (type == 1 && ResourceHandler.downloadedImages.containsKey(content))
{
CustomResourceLocation texture = ResourceHandler.downloadedImages.get(content);
return (int)((double)texture.getHeight() / (double)texture.getWidth() * 220D) + 5;
}
else if (type == 2)
{
return (recipes.size() + smeltingRecipes.size()) * 57;
}
return (textLines != null ? textLines.length * 12 : 12) + 5;
}
public void render(int mouseX, int mouseY)
{
if (type == 1) {
renderImage();
return;
}
else if (type == 2)
{
renderCrafting(mouseX, mouseY);
return;
}
else if (textLines != null)
{
for (int i = 0; i < textLines.length; i++)
{
int y = (yPos + i * 12) - page.page.scrollOffset;
if (y > 310 || y < 5) continue;
page.fontRendererObj.drawString(textLines[i], 20, y, 0x000000);
}
}
}
private void renderImage()
{
if (ResourceHandler.downloadedImages.containsKey(content))
{
CustomResourceLocation texture = ResourceHandler.downloadedImages.get(content);
texture.bind();
Tessellator tess = Tessellator.instance;
double ySize = (double)texture.getHeight() / (double)texture.getWidth() * 220D;
double topS = 0;
if ((yPos - page.page.scrollOffset) < 0) {
topS = (yPos - 5 - page.page.scrollOffset);
}
double btmS = 0;
if ((yPos - page.page.scrollOffset) + ySize > 310) {
btmS = (yPos - 5 - page.page.scrollOffset) - 310 + ySize;
}
double xmin = 17.5D ;
double xmax = 17.5D + 220D ;
double ymin = yPos - page.page.scrollOffset - topS;
double ymax = yPos + ySize - page.page.scrollOffset - btmS;
double vmin = Math.max(0D, topS / -ySize);
double vmax = Math.min(1D, 1D - btmS / ySize);
tess.startDrawingQuads();
tess.setColorRGBA_F(1f, 1f, 1f, 1f);
tess.addVertexWithUV(xmin, ymin, 0, 0, vmin);
tess.addVertexWithUV(xmin, ymax, 0, 0, vmax);
tess.addVertexWithUV(xmax, ymax, 0, 1, vmax);
tess.addVertexWithUV(xmax, ymin, 0, 1, vmin);
tess.draw();
}
}
private void renderCrafting(int mouseX, int mouseY)
{
if (result == null) return;
ResourceHandler.bindResource("textures/gui/Widgets.png");
GL11.glColor4f(1f, 1f, 1f, 1f);
int posX = 70;
int posY = yPos - page.page.scrollOffset;
for (IRecipe recipe : recipes)
{
int index = recipes.indexOf(recipe);
int yDown = index * 57;
for (int i = 0; i < 9; i++)
{
int x = i % 3 * 18;
int y = i / 3 * 18;
if (y + yDown + posY < 0 || y + yDown + posY > 305) continue;
page.drawTexturedModalRect(x + posX, y + yDown + posY, 138, 0, 18, 18);
ItemStack stack = (ItemStack)(getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ItemStack ? getRecipeInput(recipe)[i] : getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ArrayList ? ((ArrayList) getRecipeInput(recipe)[i]).get(0) : null);
if (stack != null)
{
page.drawItemStack(stack, 1 + x + posX, 1 + y + yDown + posY, "");
}
}
if (14 + yDown + posY > 0 && 14 + yDown + posY < 300) page.drawTexturedModalRect(90 + posX, 14 + yDown + posY, 156, 0, 26, 26);
if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) {
page.drawTexturedModalRect(61 + posX, 19 + yDown + posY, 204, 0, 22, 15);
if (recipe.getRecipeOutput() != null) page.drawItemStack(recipe.getRecipeOutput(), 5 + 90 + posX, 5 + 14 + yDown + posY, "");
}
}
for (IRecipe recipe : recipes)
{
int index = recipes.indexOf(recipe);
int yDown = index * 57;
if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) {
if (GuiHelper.isInRect(5 + 90 + posX, 5 + 14 + yDown + posY, 18, 18, mouseX, mouseY))
{
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
if (recipe.getRecipeOutput() != null) page.renderToolTip(recipe.getRecipeOutput(), mouseX, mouseY);
ResourceHandler.bindResource("textures/gui/Widgets.png");
GL11.glColor4f(1f, 1f, 1f, 1f);
GL11.glPopAttrib();
}
}
for (int i = 0; i < 9; i++)
{
int x = i % 3 * 18;
int y = i / 3 * 18;
if (y + yDown + posY < 0 || y + yDown + posY > 305) continue;
ItemStack stack = (ItemStack)(getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ItemStack ? getRecipeInput(recipe)[i] : getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ArrayList ? ((ArrayList) getRecipeInput(recipe)[i]).get(0) : null);
if (stack != null)
{
if (GuiHelper.isInRect(1 + x + posX, 1 + y + yDown + posY, 18, 18, mouseX, mouseY))
{
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
page.renderToolTip(stack, mouseX, mouseY);
ResourceHandler.bindResource("textures/gui/Widgets.png");
GL11.glColor4f(1f, 1f, 1f, 1f);
GL11.glPopAttrib();
}
}
}
}
for (ItemStack recipe : smeltingRecipes)
{
int index = smeltingRecipes.indexOf(recipe);
int yDown = (recipes.size() + index) * 57;
if (yDown + posY > 0 && yDown + posY < 305) {
page.drawTexturedModalRect(posX + 18, yDown + posY, 138, 0, 18, 18);
page.drawItemStack(recipe, posX + 19, yDown + posY + 1, "");
}
if (21 + yDown + posY > 0 && 21 + yDown + posY < 305) page.drawTexturedModalRect(posX + 18, yDown + posY + 21, 238, 0, 18, 15);
if (36 + yDown + posY > 0 && 36 + yDown + posY < 305) page.drawTexturedModalRect(posX + 18, yDown + posY + 36, 238, 15, 18, 33);
if (14 + yDown + posY > 0 && 14 + yDown + posY < 300) {
page.drawTexturedModalRect(90 + posX, 14 + yDown + posY, 156, 0, 26, 26);
page.drawItemStack(result, 95 + posX, 19 + yDown + posY, "");
}
if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) page.drawTexturedModalRect(50 + posX, 19 + yDown + posY, 204, 0, 22, 15);
if (yDown + posY > 0 && yDown + posY < 305) {
if (GuiHelper.isInRect(posX + 19, yDown + posY + 1, 18, 18, mouseX, mouseY))
{
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
page.renderToolTip(recipe, mouseX, mouseY);
ResourceHandler.bindResource("textures/gui/Widgets.png");
GL11.glColor4f(1f, 1f, 1f, 1f);
GL11.glPopAttrib();
}
}
if (14 + yDown + posY > 0 && 14 + yDown + posY < 305) {
if (GuiHelper.isInRect(95 + posX, 19 + yDown + posY, 18, 18, mouseX, mouseY))
{
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
page.renderToolTip(result, mouseX, mouseY);
ResourceHandler.bindResource("textures/gui/Widgets.png");
GL11.glColor4f(1f, 1f, 1f, 1f);
GL11.glPopAttrib();
}
}
}
}
@SuppressWarnings("unchecked")
private Object[] getRecipeInput(IRecipe recipe) {
if (recipe instanceof ShapelessOreRecipe) return ((ShapelessOreRecipe)recipe).getInput().toArray();
else if (recipe instanceof ShapedOreRecipe) return getShapedOreRecipe((ShapedOreRecipe)recipe);
else if (recipe instanceof ShapedRecipes) return ((ShapedRecipes)recipe).recipeItems;
else if (recipe instanceof ShapelessRecipes) return ((ShapelessRecipes)recipe).recipeItems.toArray(new ItemStack[0]);
return null;
}
private Object[] getShapedOreRecipe(ShapedOreRecipe recipe) {
try {
Field field = ShapedOreRecipe.class.getDeclaredField("width");
if (field != null) {
field.setAccessible(true);
int width = field.getInt(recipe);
Object[] input = recipe.getInput();
Object[] grid = new Object[9];
for (int i = 0, offset = 0, y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++, i++) {
if (x < width && offset < input.length) {
grid[i] = input[offset];
offset++;
} else {
grid[i] = null;
}
}
}
return grid;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
}
@@ -48,21 +48,22 @@ public class ComponentTexturedRect extends ComponentBase {
{
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glScalef(1f, 0.33f, 1f);
GL11.glScalef(0.5f, 0.5f, 0.5f);
//GL11.glScalef(1f, 0.33f, 1f);
//GL11.glScalef(0.5f, 0.5f, 0.5f);
}
GL11.glColor4f(1f, 1f, 1f, 1f);
drawTexturedModalRect(x, y, texX, texY, width, height);
if (transparent)
{
GL11.glScalef(2f, 2f, 2f);
//GL11.glScalef(2f, 2f, 2f);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
}
}
}
@@ -16,6 +16,7 @@ public abstract class GUIScrollingBase extends GUIBase {
@Override
public void handleMouseInput() {
super.handleMouseInput();
int i = org.lwjgl.input.Mouse.getEventDWheel();
if (i != 0) {
handleScrollInput(i > 0 ? -1 : 1);
@@ -1,10 +1,15 @@
package com.brandon3055.draconicevolution.client.handler;
import com.brandon3055.draconicevolution.client.gui.componentguis.GUIManual;
import com.brandon3055.draconicevolution.client.utill.CustomResourceLocation;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.google.common.collect.Lists;
import com.google.common.io.ByteStreams;
import com.google.gson.stream.JsonWriter;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
@@ -12,8 +17,13 @@ import net.minecraft.client.resources.FolderResourcePack;
import net.minecraft.util.ResourceLocation;
import scala.actors.threadpool.Arrays;
import java.io.File;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -22,27 +32,184 @@ import java.util.Map;
* Created by Brandon on 8/02/2015.
*/
public class ResourceHandler {
private static ResourceHandler instance = new 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>();
public static Map<String, CustomResourceLocation> downloadedImages = new HashMap<String, CustomResourceLocation>();
private static String savePath;
private static File saveFolder;
private static File imagesFolder;
private static DownloadThread downloadThread;
public static int downloadStatus = 0;
//-------------------- File Handling -----------------------//
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent event)
{
if (downloadThread != null && downloadThread.isFinished)
{
LogHelper.info("Image Download Finished");
downloadStatus = downloadThread.wasSuccessful ? 1 : 2;
FMLCommonHandler.instance().bus().unregister(this);
addRSPack();
}
}
public static void init(FMLPreInitializationEvent event)
{
if (event != null)savePath = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/config/draconicevolution";
FMLCommonHandler.instance().bus().register(instance);
if (event != null) savePath = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/config/draconicevolution";
GUIManual.loadPages();
for (String s : GUIManual.imageURLs)
downloadThread = new DownloadThread(GUIManual.imageURLs);
downloadThread.start();
}
public static class DownloadThread extends Thread
{
private List<String> imageURLs;
private boolean isFinished = false;
private boolean wasSuccessful = true;
public DownloadThread(List<String> imageURLs)
{
LogHelper.info(s + " " + checkExistence(s));
this.imageURLs = new ArrayList<String>(imageURLs);
}
addRSPack();
@Override
public void run() {
for (String s : imageURLs)
{
boolean success = true;
if (!checkExistence(s)) downloadImage(s);
if (checkExistence(s))
{
try
{
URL url = new URL(s);
String fileName = url.getFile();
BufferedImage bi = ImageIO.read(new File(getImagesFolder(), fileName));
downloadedImages.put(s, new CustomResourceLocation(fileName.substring(fileName.indexOf("/") + 1), bi.getWidth(), bi.getHeight()));
}
catch (MalformedURLException e)
{
success = false;
LogHelper.error("Image Read Failed");
e.printStackTrace();
}
catch (IOException e)
{
success = false;
LogHelper.error("Image Read Failed");
e.printStackTrace();
}
}
else success = false;
}
isFinished = true;
}
private static boolean downloadImage(String urlString)
{
try {
URL url = new URL(urlString);
String fileName = url.getFile();
LogHelper.info("Downloading Image " + fileName);
File dll = new File(getImagesFolder(), fileName);
InputStream is = url.openStream();
OutputStream os = new FileOutputStream(dll);
ByteStreams.copy(is, os);
is.close();
os.close();
}catch (IOException e){
LogHelper.error("Download Failed");
e.printStackTrace();
return false;
}
return true;
}
private static boolean checkExistence(String urlS)
{
try
{
URL url = new URL(urlS);
String fileName = url.getFile();
return Arrays.asList(getImagesFolder().list()).contains(fileName.substring(fileName.indexOf("/") + 1));
}
catch (MalformedURLException e)
{
LogHelper.error("Unable to check files existence. Invalid URL: " + urlS);
e.printStackTrace();
return false;
}
}
public boolean isFinished() {
return isFinished;
}
public boolean wasSuccessful() {
return wasSuccessful;
}
}
private static void addRSPack()
{
File rspack = new File(getConfigFolder(), "/resources");
if (!rspack.exists()) return;
if (!Arrays.asList(rspack.list()).contains("pack.mcmeta"))
{
try
{
JsonWriter writer = new JsonWriter(new FileWriter(new File(rspack, "pack.mcmeta")));
writer.beginObject();
writer.name("pack");
writer.beginObject();
writer.name("pack_format").value(1);
writer.name("description").value("Draconic Evolution GUI Images");
writer.endObject();
writer.endObject();
writer.close();
}
catch (IOException e)
{
LogHelper.error("Error creating pack.mcmeta");
e.printStackTrace();
}
}
Field f = ReflectionHelper.findField(Minecraft.class, "defaultResourcePacks", "field_110449_ao");
f.setAccessible(true);
try {
List defaultResourcePacks = (List)f.get(Minecraft.getMinecraft());
defaultResourcePacks.add(new FolderResourcePack(rspack));
f.set(Minecraft.getMinecraft(), defaultResourcePacks);
LogHelper.info("RS Added");
Minecraft.getMinecraft().refreshResources();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
}
public static File getConfigFolder()
@@ -61,44 +228,6 @@ public class ResourceHandler {
return imagesFolder;
}
private static void downloadImages()
{
}
private static boolean checkExistence(String url)
{
LogHelper.info("checkExistence " + Arrays.asList(getImagesFolder().list()) + " " + Arrays.asList(getImagesFolder().list()).contains(url) + " " + url);
return true;
}
private static void addRSPack()
{
File rspack = new File(getConfigFolder(), "/resources");
if (!rspack.exists()) return;
List defaultResourcePacks = Lists.newArrayList();
Field f = ReflectionHelper.findField(Minecraft.class, "defaultResourcePacks", "field_110449_ao");
f.setAccessible(true);
try {
defaultResourcePacks = (List)f.get(Minecraft.getMinecraft());
defaultResourcePacks.add(new FolderResourcePack(rspack));
// for (Object o : defaultResourcePacks){
// if (o instanceof FolderResourcePack) LogHelper.info(((FolderResourcePack) o).getPackName());
// if (o instanceof FileResourcePack) LogHelper.info(((FileResourcePack)o).getPackName());
// }
f.set(Minecraft.getMinecraft(), defaultResourcePacks);
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
}//http://i.imgur.com/zYLHSxW.png
//----------------------------------------------------------//
@@ -42,6 +42,7 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
renderBlock(tileEntityGen, f);
GL11.glPopMatrix();
}
@@ -98,6 +99,8 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
{
drawEnergyBeam(tessellator, tl, f3);
}
if (tl.beam_enabled) preRenderBeam(tessellator, tl, f3);
}
@@ -141,6 +144,13 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
GL11.glColor4f(0.0F, 2.0F, 0.0F, 1F);
GL11.glTranslated(0.5, 0, 0.5);
GL11.glScalef(0.4F, 0.4F, 0.4F);
if (!tile.stabalizerMode) {
float red = (float)tile.beam_red / 255F;
float green = (float)tile.beam_green / 255F;
float blue = (float)tile.beam_blue / 255F;
GL11.glColor4f(red, green, blue, 1F);
GL11.glScalef(tile.beam_scale, tile.beam_scale, tile.beam_scale);
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200, 200);
GL11.glDisable(GL11.GL_LIGHTING);
@@ -156,6 +166,12 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glColor4f(0.0F, 1.0F, 1.0F, 0.5F);
if (!tile.stabalizerMode) {
float red = (float)tile.beam_red / 255F;
float green = (float)tile.beam_green / 255F;
float blue = (float)tile.beam_blue / 255F;
GL11.glColor4f(red, green, blue, 0.5F);
}
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glScalef(1.3F, 1.3F, 1.3F);
@@ -473,4 +489,188 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
tess.addVertexWithUV(FN + x, FN + y, XX, srcXMax, srcYMax);
}
private void preRenderBeam(Tessellator tess, TileParticleGenerator gen, float f)
{
GL11.glPushMatrix();
GL11.glTranslated(0, 0.5, 0.5);
GL11.glRotatef(90F + gen.beam_pitch, 1F, 0F, 0F);
GL11.glTranslated(0, 0, -0.5);
GL11.glTranslated(0.5, 0, 0);
GL11.glRotatef(gen.beam_yaw, 0F, 0F, 1F);
GL11.glTranslated(-0.5, 0, 0);
renderBeam(tess, gen, f);
GL11.glPopMatrix();
if (gen.render_core) {
GL11.glPushMatrix();
GL11.glTranslated(0, 0.5, 0);
renderStabilizerSphere(gen);
GL11.glPopMatrix();
}
}
private void renderBeam(Tessellator tess, TileParticleGenerator tile, float f){
int x = 0;
int y = 0;
int z = 0;
double length = tile.beam_length;
float red = (float)tile.beam_red / 255F;
float green = (float)tile.beam_green / 255F;
float blue = (float)tile.beam_blue / 255F;
GL11.glPushMatrix();
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
bindTexture(beamTexture);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
OpenGlHelper.glBlendFunc(770, 1, 1, 0);
//float time = (float)tile.getWorldObj().getTotalWorldTime() + f;
float time = tile.rotation + f;
float upMot = -time * 0.2F - (float) MathHelper.floor_float(-time * 0.1F);
float rotValue = tile.beam_rotation * (tile.rotation + f * 0.5F);
double rotation = rotValue ;
tess.startDrawingQuads();
tess.setBrightness(200);
tess.setColorRGBA(tile.beam_red, tile.beam_green, tile.beam_blue, 32);
double scale = (double)tile.beam_scale * 0.2D;
double d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; //x point 1
double d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; //z point 1
double d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; //x point 2
double d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; //z point 2
double d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale;//Dist from x-3
double d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale;
double d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale;
double d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale;
double height = (double)(length);
double texXMin = 0.0D;
double texXMax = 1.0D;
double d28 = (double)(-1.0F + upMot);
double texHeight = (double)(length) * (0.5D / scale) + d28;
tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight);
tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28);
tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28);
tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight);
tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight);
tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28);
tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28);
tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight);
tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight);
tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28);
tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28);
tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight);
tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight);
tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28);
tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28);
tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight);
rotation += 0.77f;
d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale;
d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale;
d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale;
d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale;
d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale;
d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale;
d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale;
d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale;
d28 = (-1F + (upMot*1));
texHeight = (double)(length) * (0.5D / scale) + d28;
tess.setColorRGBA_F(red, green, blue, 1f);
tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight);
tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28);
tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28);
tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight);
tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight);
tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28);
tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28);
tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight);
tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight);
tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28);
tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28);
tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight);
tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight);
tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28);
tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28);
tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight);
tess.draw();
GL11.glPushMatrix();
//GL11.glTranslated(0, 0.4, 0);
//length -= 0.5F;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glDepthMask(false);
GL11.glTranslated(0.5, 0, 0.5);
GL11.glScalef(tile.beam_scale, 1f, tile.beam_scale);
GL11.glTranslated(-0.5, -0, -0.5);
tess.startDrawingQuads();
tess.setColorRGBA(tile.beam_red, tile.beam_green, tile.beam_blue, 32);
double d30 = 0.2D;
double d4 = 0.2D;
double d6 = 0.8D;
double d8 = 0.2D;
double d10 = 0.2D;
double d12 = 0.8D;
double d14 = 0.8D;
double d16 = 0.8D;
double d18 = (double)(length);
double d20 = 0.0D;
double d22 = 1D;
double d24 = (double)(-1.0F + upMot);
double d26 = (double)(length) + d24;
tess.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26);
tess.addVertexWithUV(x + d30, y, z + d4, d22, d24);
tess.addVertexWithUV(x + d6, y, z + d8, d20, d24);
tess.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26);
tess.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26);
tess.addVertexWithUV(x + d14, y, z + d16, d22, d24);
tess.addVertexWithUV(x + d10, y, z + d12, d20, d24);
tess.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26);
tess.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26);
tess.addVertexWithUV(x + d6, y, z + d8, d22, d24);
tess.addVertexWithUV(x + d14, y, z + d16, d20, d24);
tess.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26);
tess.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26);
tess.addVertexWithUV(x + d10, y, z + d12, d22, d24);
tess.addVertexWithUV(x + d30, y, z + d4, d20, d24);
tess.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26);
tess.draw();
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
}
@@ -1,6 +1,7 @@
package com.brandon3055.draconicevolution.client.utill;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import net.minecraft.util.ResourceLocation;
/**
@@ -12,7 +13,7 @@ public class CustomResourceLocation extends ResourceLocation {
private int height;
public CustomResourceLocation(String texturePath, int width, int height) {
super(texturePath);
super(References.MODID.toLowerCase() , "textures/gui/manualimages/" + texturePath);
this.width = width;
this.height = height;
}
@@ -74,7 +74,7 @@ public class CommonProxy {
}
catch (Exception e) {
LogHelper.error("Severe error, please report this to the mod author:");
LogHelper.error(e);
e.printStackTrace();
}
}
@@ -15,6 +15,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.IBlockAccess;
@@ -45,6 +47,19 @@ public class ParticleGenerator extends BlockDE
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
if (world.getBlockMetadata(x, y, z) == 1) return false;
if (player.getHeldItem() != null && player.getHeldItem().getItem() == Items.paper)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null;
ItemStack stack = player.getHeldItem();
if (gen != null && stack.hasTagCompound() && stack.getTagCompound().hasKey("particles_enabled"))
{
gen.setBlockNBT(stack.getTagCompound());
return true;
}
}
if (player.isSneaking())
{
if (activateEnergyStorageCore(world, x, y, z, player)) return true;
@@ -146,4 +146,16 @@ public class EnergyPylon extends BlockDE {//todo fix sphere renderer
}
if (world.getBlockMetadata(x, y, z) == 0 && world.getTileEntity(x, y, z) != null) world.removeTileEntity(x, y, z);
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta) {
TileEnergyPylon tile = world.getTileEntity(x, y, z) instanceof TileEnergyPylon ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null;
if (tile != null) return (int)(tile.getEnergyStored() / tile.getMaxEnergyStored() * 15D);
return 0;
}
}
@@ -1,6 +1,8 @@
package com.brandon3055.draconicevolution.common.entity;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
import com.brandon3055.draconicevolution.common.utills.DamageSourceChaos;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEndPortal;
import net.minecraft.entity.Entity;
@@ -315,6 +317,12 @@ public class EntityCustomDragon extends EntityDragon {
}
}
}
if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0) {
createPortal = false;
portalX = ConfigHandler.dragonEggSpawnLocation[0];
portalY = ConfigHandler.dragonEggSpawnLocation[1];
portalZ = ConfigHandler.dragonEggSpawnLocation[2];
}
}
++this.deathTicks;
@@ -345,14 +353,6 @@ public class EntityCustomDragon extends EntityDragon {
i -= j;
this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
}
/*
float mm = 0.3F;
EntityItem item = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(ModItems.draconiumDust, 3 + worldObj.rand.nextInt(3)));
item.motionX = mm * ((((float)worldObj.rand.nextInt(100))/100F) - 0.5F);
item.motionY = mm * ((((float)worldObj.rand.nextInt(100))/100F) - 0.5F);
item.motionZ = mm * ((((float)worldObj.rand.nextInt(100))/100F) - 0.5F);
worldObj.spawnEntityInWorld(item);
*/
}
if (this.deathTicks == 1) {
@@ -479,6 +479,8 @@ public class EntityCustomDragon extends EntityDragon {
}
private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) {
if (!ConfigHandler.dragonBreaksBlocks) return false;
int i = MathHelper.floor_double(par1AxisAlignedBB.minX);
int j = MathHelper.floor_double(par1AxisAlignedBB.minY);
int k = MathHelper.floor_double(par1AxisAlignedBB.minZ);
@@ -516,17 +518,26 @@ public class EntityCustomDragon extends EntityDragon {
private void spawnEgg()
{
if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 && !isUber) {
portalX = ConfigHandler.dragonEggSpawnLocation[0];
portalY = ConfigHandler.dragonEggSpawnLocation[1];
portalZ = ConfigHandler.dragonEggSpawnLocation[2];
}
BlockEndPortal.field_149948_a = true;
if (createPortal || isUber) {
createEnderPortal(portalX, portalZ);
}
LogHelper.info("spawn egg");
if (worldObj.getBlock(portalX, portalY + 1, portalZ) == Blocks.air) {
worldObj.setBlock(portalX, portalY + 1, portalZ, Blocks.dragon_egg);
LogHelper.info("spawn egg2 " + portalX + " " + portalY + " " + portalZ);
}else {
for (int i = portalY + 1; i < 250; i++) {
if (worldObj.getBlock(portalX, i, portalZ) == Blocks.air) {
worldObj.setBlock(portalX, i, portalZ, Blocks.dragon_egg);
LogHelper.info("spawn egg3");
break;
}
}
@@ -603,9 +614,14 @@ public class EntityCustomDragon extends EntityDragon {
compound.setFloat("AttackDamage", attackDamage);
compound.setBoolean("IsUber", isUber);
compound.setBoolean("Initialized", initialized);
compound.setInteger("PortalX", portalX);
compound.setInteger("PortalY", portalY);
compound.setInteger("PortalZ", portalZ);
if (isUber)
{
compound.setInteger("PortalX", portalX);
compound.setInteger("PortalY", portalY);
compound.setInteger("PortalZ", portalZ);
}
LogHelper.info(portalY + " write");
}
@Override
@@ -615,9 +631,14 @@ public class EntityCustomDragon extends EntityDragon {
isUber = compound.getBoolean("IsUber");
initialized = compound.getBoolean("Initialized");
this.dataWatcher.updateObject(12, isUber ? (byte)1: (byte)0);
portalX = compound.getInteger("PortalX");
portalY = compound.getInteger("PortalY");
portalZ = compound.getInteger("PortalZ");
if (isUber)
{
portalX = compound.getInteger("PortalX");
portalY = compound.getInteger("PortalY");
portalZ = compound.getInteger("PortalZ");
}
LogHelper.info(portalY + " read");
}
@Override
@@ -30,6 +30,8 @@ public class ConfigHandler {
public static boolean disableOreSpawnNether;
public static boolean enableHudDisplay;
public static boolean enableVersionChecker;
public static boolean dragonBreaksBlocks;
public static int[] dragonEggSpawnLocation;
//spawner
public static String[] spawnerList;
@@ -83,6 +85,8 @@ public class ConfigHandler {
disableOreSpawnOverworld = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Overworld)", false, "Set to true to prevent draconium ore from spawning in the overworld").getBoolean(false);
enableHudDisplay = config.get(Configuration.CATEGORY_GENERAL, "Enable HUD info", true, "Set to false to disable the HUD info for tools and blocks").getBoolean(true);
enableVersionChecker = config.get(Configuration.CATEGORY_GENERAL, "Enable version checker", true, "Set to false to disable the version checker").getBoolean(true);
dragonBreaksBlocks = config.get(Configuration.CATEGORY_GENERAL, "Can dragon break blocks", true, "Set to false to disable the DE dragons ability to break blocks (dose not effect vanilla dragon)").getBoolean(true);
dragonEggSpawnLocation = config.get(Configuration.CATEGORY_GENERAL, "Dragon egg spawn location", new int[] {0, 0, 0}, "Sets the exact location to spawn the dragon egg and disables the portal spawn (dose not effect vanilla dragon)").getIntList();
//Spawner
spawnerListType = config.get("spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false);
@@ -1,11 +1,18 @@
package com.brandon3055.draconicevolution.common.network;
import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
public class ParticleGenPacket implements IMessage
{
@@ -221,10 +228,94 @@ public class ParticleGenPacket implements IMessage
case 55://Back
gen.page = (int) message.value;
break;
case 58://Back
LogHelper.info(message.value);
gen.particles_enabled = message.value == 1;
break;
case 100: //beam red +
gen.beam_red = message.value;
break;
case 101: //beam green +
gen.beam_green = message.value;
break;
case 102: //beam blue +
gen.beam_blue = message.value;
break;
case 103: //beam pitch +
gen.beam_pitch = (float) message.value / 100F;
break;
case 104: //beam yaw +
gen.beam_yaw = (float) message.value / 100F;
break;
case 105: //beam length +
gen.beam_length = (float) message.value / 100F;
break;
case 106: //beam rotation +
gen.beam_rotation = (float) message.value / 100F;
break;
case 107: //beam scale +
gen.beam_scale = (float) message.value / 100F;
break;
case 108: //beam red -
gen.beam_red = message.value;
break;
case 109: //beam green -
gen.beam_green = message.value;
break;
case 110: //beam blue -
gen.beam_blue = message.value;
break;
case 111: //beam pitch -
gen.beam_pitch = (float) message.value / 100F;
break;
case 112: //beam yaw -
gen.beam_yaw = (float) message.value / 100F;
break;
case 113: //beam length -
gen.beam_length = (float) message.value / 100F;
break;
case 114: //beam rotation -
gen.beam_rotation = (float) message.value / 100F;
break;
case 115: //beam scale -
gen.beam_scale = (float) message.value / 100F;
break;
case 116: //beam enabled
gen.beam_enabled = message.value == 1;
break;
case 117: //beam enabled
gen.render_core = message.value == 1;
break;
}
if (message.buttonId == 127)
{
if (ctx.getServerHandler().playerEntity.capabilities.isCreativeMode || ctx.getServerHandler().playerEntity.inventory.hasItem(Items.paper)) {
giveNote(message, ctx);
}
else ctx.getServerHandler().playerEntity.addChatComponentMessage(new ChatComponentText("You need paper in your inventory to do that"));
}
ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(message.tileX, message.tileY, message.tileZ);
}
return null;
}
private void giveNote(ParticleGenPacket message, MessageContext ctx)
{
EntityPlayer player = ctx.getServerHandler().playerEntity;
if (!player.capabilities.isCreativeMode) player.inventory.consumeInventoryItem(Items.paper);
ItemStack stack = new ItemStack(Items.paper);
stack.setTagCompound(new NBTTagCompound());
TileEntity tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.tileX, message.tileY, message.tileZ);
TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator)tile : null;
if (gen != null)
{
gen.getBlockNBT(stack.getTagCompound());
stack.setStackDisplayName("Saved Particle Gen Settings");
player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, stack));
}
}
}
}
@@ -17,6 +17,8 @@ import net.minecraft.util.AxisAlignedBB;
import java.util.Random;
public class TileParticleGenerator extends TileEntity {
public boolean particles_enabled = true;
public int red = 0;
public int green = 0;
public int blue = 0;
@@ -52,15 +54,28 @@ public class TileParticleGenerator extends TileEntity {
public float rotation = 0;
public boolean stabalizerMode = false;
//beam
public boolean beam_enabled = false;
public boolean render_core = false;
public int beam_red = 0;
public int beam_green = 0;
public int beam_blue = 0;
public float beam_scale = 1F;
public float beam_pitch = 0F;
public float beam_yaw = 0F;
public float beam_length = 0F;
public float beam_rotation = 0F;
private int tick = 0;
@SideOnly(Side.CLIENT)
@Override
public void updateEntity() {
if (!worldObj.isRemote) return;
rotation += 0.5F;
if (stabalizerMode) {
rotation += 0.5F;
spawnStabilizerParticle();
}
if (stabalizerMode) return;
@@ -69,7 +84,7 @@ public class TileParticleGenerator extends TileEntity {
else if (!signal && inverted) active = true;
else active = false;
if (tick >= spawn_rate && active) {
if (tick >= spawn_rate && active && particles_enabled) {
tick = 0;
Random rand = worldObj.rand;
@@ -141,6 +156,36 @@ public class TileParticleGenerator extends TileEntity {
public void writeToNBT(NBTTagCompound compound) {
master.writeToNBT(compound, "Key");
compound.setBoolean("StabalizerMode", stabalizerMode);
getBlockNBT(compound);
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
master.readFromNBT(compound, "Key");
stabalizerMode = compound.getBoolean("StabalizerMode");
setBlockNBT(compound);
super.readFromNBT(compound);
}
public TileEnergyStorageCore getMaster() {
if (master == null) return null;
TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null;
return tile;
}
public void setMaster(TileLocation master) {
this.master = master;
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB;
}
public void getBlockNBT(NBTTagCompound compound)
{
compound.setInteger("Red", red);
compound.setInteger("Green", green);
compound.setInteger("Blue", blue);
@@ -172,14 +217,22 @@ public class TileParticleGenerator extends TileEntity {
compound.setBoolean("Active", active);
compound.setBoolean("Signal", signal);
compound.setBoolean("Inverted", inverted);
compound.setBoolean("particles_enabled", particles_enabled);
super.writeToNBT(compound);
compound.setBoolean("beam_enabled", beam_enabled);
compound.setBoolean("render_core", render_core);
compound.setInteger("beam_red", beam_red);
compound.setInteger("beam_green", beam_green);
compound.setInteger("beam_blue", beam_blue);
compound.setFloat("beam_scale", beam_scale);
compound.setFloat("beam_pitch", beam_pitch);
compound.setFloat("beam_yaw", beam_yaw);
compound.setFloat("beam_length", beam_length);
compound.setFloat("beam_rotation", beam_rotation);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
master.readFromNBT(compound, "Key");
stabalizerMode = compound.getBoolean("StabalizerMode");
public void setBlockNBT(NBTTagCompound compound)
{
red = compound.getInteger("Red");
green = compound.getInteger("Green");
blue = compound.getInteger("Blue");
@@ -211,22 +264,17 @@ public class TileParticleGenerator extends TileEntity {
active = compound.getBoolean("Active");
signal = compound.getBoolean("Signal");
inverted = compound.getBoolean("Inverted");
particles_enabled = compound.getBoolean("particles_enabled");
super.readFromNBT(compound);
}
public TileEnergyStorageCore getMaster() {
if (master == null) return null;
TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null;
return tile;
}
public void setMaster(TileLocation master) {
this.master = master;
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB;
beam_enabled = compound.getBoolean("beam_enabled");
render_core = compound.getBoolean("render_core");
beam_red = compound.getInteger("beam_red");
beam_green = compound.getInteger("beam_green");
beam_blue = compound.getInteger("beam_blue");
beam_scale = compound.getFloat("beam_scale");
beam_pitch = compound.getFloat("beam_pitch");
beam_yaw = compound.getFloat("beam_yaw");
beam_length = compound.getFloat("beam_length");
beam_rotation = compound.getFloat("beam_rotation");
}
}
@@ -194,8 +194,11 @@ public class TileEnderResurrection extends TileEntity{
public boolean onActivated(EntityPlayer player){
boolean flag = true;
if (player.dimension != 1) return true;
if (xCoord > 80 || zCoord > 80 || xCoord < -80 || zCoord < -80){
if (worldObj.provider.dimensionId != 1) {
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.SpawnDragonMustBeInTheEnd.txt"));
return true;
}
if (xCoord > 100 || zCoord > 100 || xCoord < -100 || zCoord < -100){
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.SpawnDragonToFarFrom00.txt"));
return false;
}
@@ -38,6 +38,8 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I
private int selectedCore = 0;
private byte particleRate = 0;
private byte lastTickParticleRate = 0;
private int lastCheckCompOverride = 0;
private int tick = 0;
@Override
@@ -52,6 +54,23 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I
if (worldObj.isRemote) return;
tick++;
if (tick % 20 == 0)
{
int cOut = (int)(getEnergyStored() / getMaxEnergyStored() * 15D);
if (cOut != lastCheckCompOverride)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord));
lastCheckCompOverride = cOut;
}
}
if (active && !reciveEnergy){
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ);
@@ -81,11 +100,11 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I
}
private void findCores(){
int yMod = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? 3 : -3;
int yMod = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? 16 : -16;
int range = 15;
List<TileLocation> locations = new ArrayList<TileLocation>();
for (int x = xCoord-range; x <= xCoord+range; x++){
for (int y = yCoord+yMod-(range/4); y <= yCoord+yMod+(range/4); y++){
for (int y = yCoord+yMod-range; y <= yCoord+yMod+range; y++){
for (int z = zCoord-range; z <= zCoord+range; z++){
if (worldObj.getBlock(x, y, z) == ModBlocks.energyStorageCore){
locations.add(new TileLocation(x, y, z));
@@ -1,6 +1,8 @@
package com.brandon3055.draconicevolution.common.utills;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.item.ItemStack;
/**
* Created by Brandon on 25/07/2014.
@@ -60,4 +62,19 @@ public class Utills {
{
return FMLCommonHandler.instance().getMinecraftServerInstance() == null;
}
public static ItemStack getStackFromName(String name, int meta)
{
if (name.contains("tile."))
{
name = name.replace("draconicevolution", "DraconicEvolution").replace("tile.", "");
if (GameData.getBlockRegistry().getObject(name) != null) return new ItemStack(GameData.getBlockRegistry().getObject(name), 1, meta);
}
if (name.contains("item."))
{
name = name.replace("draconicevolution", "DraconicEvolution").replace("item.", "");
if (GameData.getItemRegistry().getObject(name) != null) return new ItemStack(GameData.getItemRegistry().getObject(name), 1, meta);
}
return null;
}
}