Little work on multiblock page
This commit is contained in:
parent
14b387dd56
commit
90f0b0ae5b
6 changed files with 67 additions and 129 deletions
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
package techreborn.client.render;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -26,6 +25,8 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import techreborn.client.multiblock.IMultiblockRenderHook;
|
||||
import techreborn.client.multiblock.Multiblock;
|
||||
|
@ -37,9 +38,13 @@ public class MultiblockRenderEvent {
|
|||
|
||||
private static RenderBlocks blockRender = RenderBlocks.getInstance();
|
||||
public MultiblockSet currentMultiblock;
|
||||
public static ChunkCoordinates anchor;
|
||||
public static int angle;
|
||||
|
||||
public void setMultiblock(MultiblockSet set) {
|
||||
currentMultiblock = set;
|
||||
anchor = null;
|
||||
angle = 0;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -50,12 +55,21 @@ public class MultiblockRenderEvent {
|
|||
renderPlayerLook(mc.thePlayer, mc.objectMouseOver);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if(currentMultiblock != null && anchor == null && event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer == Minecraft.getMinecraft().thePlayer) {
|
||||
anchor = new ChunkCoordinates(event.x, event.y, event.z);
|
||||
angle = MathHelper.floor_double(event.entityPlayer.rotationYaw * 4.0 / 360.0 + 0.5) & 3;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) {
|
||||
if(currentMultiblock != null) {
|
||||
int anchorX = src.blockX;
|
||||
int anchorY = src.blockY + 1;
|
||||
int anchorZ = src.blockZ;
|
||||
int anchorX = anchor != null ? anchor.posX : src.blockX;
|
||||
int anchorY = anchor != null ? anchor.posY +1 : src.blockY + 1;
|
||||
int anchorZ = anchor != null ? anchor.posZ : src.blockZ;
|
||||
|
||||
rendering = true;
|
||||
Multiblock mb =currentMultiblock.getForEntity(player);
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.pda.pages.ConfigPage;
|
||||
import techreborn.pda.pages.ContentsPage;
|
||||
import techreborn.pda.pages.CraftingInfoPage;
|
||||
import techreborn.pda.pages.IndexPage;
|
||||
|
@ -54,7 +53,6 @@ public class GuiManual extends GuiScreen{
|
|||
pageCollection.addPage(new ItemsPage("POWER_STORAGE", pageCollection, "POWER_STORAGE_PAGE"));
|
||||
pageCollection.addPage(new VersionPage("VERSION", pageCollection, "VERSION PAGE", 777777));
|
||||
pageCollection.addPage(new MultiBlockPage("MULTIBLOCKS", pageCollection, "MULTIBLOCK_PAGE"));
|
||||
pageCollection.addPage(new ConfigPage("CONFIG", pageCollection, "PDA_CONFIG"));
|
||||
|
||||
pageCollection.addPage(new CraftingInfoPage("POWER_STORAGE_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Aesu), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AlloyFurnace), ""));
|
||||
|
@ -178,7 +176,6 @@ public class GuiManual extends GuiScreen{
|
|||
super.initGui();
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.guiTop = (this.height - this.ySize) / 2;
|
||||
ConfigPage.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
package techreborn.pda.pages;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.config.TechRebornConfigGui;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.pda.PageCollection;
|
||||
import techreborn.pda.util.GuiButtonCustomTexture;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ConfigPage extends TitledPage {
|
||||
public static PDASettings pdaSettings;
|
||||
private GuiButton plusOneButton;
|
||||
private GuiButton minusOneButton;
|
||||
private GuiButton plusOneButtonScale;
|
||||
private GuiButton minusOneButtonScale;
|
||||
|
||||
private static File pdaSettingsFile = new File(Minecraft.getMinecraft().mcDataDir, "TechRebornPDASettings.pda");
|
||||
|
||||
public ConfigPage(String name, PageCollection collection, String unlocalizedTitle) {
|
||||
super(name, true, collection, "techreborn.pda.pdaconfig", 518915);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
buttonList.clear();
|
||||
plusOneButton = new GuiButton(0, getXMin() + 85, getYMin() + 19, 10, 10, "+");
|
||||
minusOneButton = new GuiButton(1, getXMin() + 110, getYMin() + 19, 10, 10, "-");
|
||||
plusOneButtonScale = new GuiButton(2, getXMin() + 85, getYMin() + 39, 10, 10, "+");
|
||||
minusOneButtonScale = new GuiButton(3, getXMin() + 110, getYMin() + 39, 10, 10, "-");
|
||||
|
||||
buttonList.add(plusOneButton);
|
||||
buttonList.add(minusOneButton);
|
||||
buttonList.add(plusOneButtonScale);
|
||||
buttonList.add(minusOneButtonScale);
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.fontRendererObj.drawString("GUI_ID", getXMin() + 20, getYMin() + 20, 518915);
|
||||
this.fontRendererObj.drawString(pdaSettings.GUI_ID + "", getXMin() + 100, getYMin() + 20, 518915);
|
||||
this.fontRendererObj.drawString("GUI_SCALE", getXMin() + 20, getYMin() + 40, 518915);
|
||||
this.fontRendererObj.drawString(pdaSettings.scale + "", getXMin() + 100, getYMin() + 40, 518915);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button) {
|
||||
if (button.id == 0) pdaSettings.GUI_ID++;
|
||||
if (button.id == 1 && pdaSettings.GUI_ID != 0) pdaSettings.GUI_ID--;
|
||||
if (button.id == 2) pdaSettings.scale++;
|
||||
if (button.id == 3 && pdaSettings.scale != 0) pdaSettings.scale--;
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
save();
|
||||
}
|
||||
|
||||
//To add new settings just make a new variable in here, the default value will be the value that you set it.
|
||||
|
||||
public static class PDASettings{
|
||||
public int GUI_ID = 0;
|
||||
public float scale = 0F;
|
||||
}
|
||||
|
||||
public static void load(){
|
||||
if(!pdaSettingsFile.exists()){
|
||||
pdaSettings = new PDASettings();
|
||||
} else {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
BufferedReader reader = new BufferedReader(new FileReader(pdaSettingsFile));
|
||||
pdaSettings = gson.fromJson(reader, PDASettings.class);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
pdaSettings = new PDASettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void save(){
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(pdaSettings);
|
||||
try {
|
||||
FileWriter writer = new FileWriter(pdaSettingsFile);
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package techreborn.pda.pages;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -11,10 +13,10 @@ import techreborn.pda.PageCollection;
|
|||
import techreborn.pda.util.GuiButtonCustomTexture;
|
||||
import techreborn.pda.util.GuiButtonTextOnly;
|
||||
|
||||
public class ContentsPage extends TitledPage{
|
||||
public class ContentsPage extends TitledPage {
|
||||
|
||||
public ContentsPage(String name, PageCollection collection) {
|
||||
super(name, false, collection, "techreborn.pda.contents", 518915);
|
||||
super(name, false, collection, "techreborn.pda.contents", Color.white.getRGB());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -31,8 +33,6 @@ public class ContentsPage extends TitledPage{
|
|||
|
||||
buttonList.add(new GuiButtonCustomTexture(7, getXMin() + 160, getYMin() + 180, 0, 46, 80, 20, new ItemStack(ModItems.lapotronicOrb), "INDEX", "Changelog"));
|
||||
buttonList.add(new GuiButtonCustomTexture(8, getXMin() + 25, getYMin() + 180, 0, 46, 80, 20, new ItemStack(ModItems.lapotronicOrb), "INDEX", "Configs"));
|
||||
buttonList.add(new GuiButtonCustomTexture(9, getXMin() + 95, getYMin() + 180, 0, 46, 80, 20, new ItemStack(ModItems.lapotronicOrb), "INDEX", "CONFIG"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,9 @@ package techreborn.pda.pages;
|
|||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -19,13 +22,13 @@ public class MultiBlockPage extends TitledPage{
|
|||
public static ResourceLocation test = new ResourceLocation("techreborn:textures/pda/multiblocks/base.png");
|
||||
|
||||
public MultiBlockPage(String name, PageCollection collection, String unlocalizedTitle) {
|
||||
super(name, false, collection, unlocalizedTitle, 777777);
|
||||
super(name, false, collection, unlocalizedTitle, Color.white.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
GuiButton button = new GuiButton(212, 10, 10, "Show multiblock in world");
|
||||
GuiButton button = new GuiButton(212, getXMin() + 30, getYMin() + 140, "Show multiblock in world");
|
||||
buttonList.add(button);
|
||||
if(ClientProxy.multiblockRenderEvent.currentMultiblock != null){
|
||||
button.displayString = "Hide multiblock in world";
|
||||
|
@ -40,7 +43,6 @@ public class MultiBlockPage extends TitledPage{
|
|||
@Override
|
||||
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.renderOverlayComponents(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
this.drawCenteredString(fontRendererObj, "TODO", offsetX + 120, offsetY + 130, 777777);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,14 +52,43 @@ public class MultiBlockPage extends TitledPage{
|
|||
if(ClientProxy.multiblockRenderEvent.currentMultiblock == null){
|
||||
{//This code here makes a basic multiblock and then sets to the selected one.
|
||||
Multiblock multiblock = new Multiblock();
|
||||
multiblock.addComponent(0, 0, 0, Blocks.brick_block, 0);
|
||||
multiblock.addComponent(1, 0, 0, Blocks.cobblestone, 0);
|
||||
multiblock.addComponent(0, 0, 1, Blocks.cobblestone, 0);
|
||||
multiblock.addComponent(-1, 0, 0, Blocks.cobblestone, 0);
|
||||
multiblock.addComponent(0, 0, -1, Blocks.cobblestone, 0);
|
||||
multiblock.addComponent(-1, 0, -1, Blocks.cobblestone, 0);
|
||||
multiblock.addComponent(1, 0, 1, Blocks.cobblestone, 0);
|
||||
multiblock.addComponent(0, 1, 0, Blocks.diamond_block, 0);
|
||||
multiblock.addComponent(0, 0, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 0, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 0, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 0, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 0, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 0, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 0, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 0, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 0, 1, ModBlocks.MachineCasing, 0);
|
||||
|
||||
multiblock.addComponent(1, 1, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 1, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 1, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 1, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 1, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 1, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 1, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 1, 1, ModBlocks.MachineCasing, 0);
|
||||
|
||||
multiblock.addComponent(1, 2, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 2, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 2, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 2, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 2, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 2, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 2, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 2, 1, ModBlocks.MachineCasing, 0);
|
||||
|
||||
multiblock.addComponent(1, 3, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 3, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 3, 0, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(0, 3, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 3, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(-1, 3, 1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 3, -1, ModBlocks.MachineCasing, 0);
|
||||
multiblock.addComponent(1, 3, 1, ModBlocks.MachineCasing, 0);
|
||||
|
||||
MultiblockSet set = new MultiblockSet(multiblock);
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package techreborn.pda.util;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.config.GuiButtonExt;
|
||||
|
@ -48,7 +50,7 @@ public class GuiButtonCustomTexture extends GuiButtonExt {
|
|||
RenderHelper.enableStandardItemLighting();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, itemstack, this.xPosition, this.yPosition);
|
||||
this.drawString(mc.fontRenderer, this.NAME, this.xPosition + 20, this.yPosition + 3, 777777);
|
||||
this.drawString(mc.fontRenderer, this.NAME, this.xPosition + 20, this.yPosition + 3, Color.white.getRGB());
|
||||
}
|
||||
}
|
||||
public boolean getIsHovering(){return field_146123_n;}
|
||||
|
|
Loading…
Reference in a new issue