mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Added a structure cost preview.
This commit is contained in:
1 parent
e9f99e972d
commit
80235194b6
4 files changed
+63
-7
No files matched your search
@@ -13,12 +13,10 @@ package vazkii.botania.api.lexicon.multiblock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Mult;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
|
||||
/**
|
||||
* This class describes a Mutiblock object. It's used to display a
|
||||
@@ -28,6 +26,7 @@ import net.minecraft.util.ChunkCoordinates;
|
||||
public class Multiblock {
|
||||
|
||||
public List<MultiblockComponent> components = new ArrayList();
|
||||
public List<ItemStack> materials = new ArrayList();
|
||||
|
||||
public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ;
|
||||
|
||||
@@ -38,6 +37,7 @@ public class Multiblock {
|
||||
public void addComponent(MultiblockComponent component) {
|
||||
components.add(component);
|
||||
changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ);
|
||||
calculateCostForNewComponent(component);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +65,26 @@ public class Multiblock {
|
||||
maxZ = z;
|
||||
}
|
||||
|
||||
private void calculateCostForNewComponent(MultiblockComponent comp) {
|
||||
ItemStack[] materials = comp.getMaterials();
|
||||
if(materials != null)
|
||||
for(ItemStack stack : materials)
|
||||
addStack(stack);
|
||||
}
|
||||
|
||||
private void addStack(ItemStack stack) {
|
||||
if(stack == null)
|
||||
return;
|
||||
|
||||
for(ItemStack oStack : materials)
|
||||
if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) {
|
||||
oStack.stackSize += stack.stackSize;
|
||||
return;
|
||||
}
|
||||
|
||||
materials.add(stack);
|
||||
}
|
||||
|
||||
public void setRenderOffset(int x, int y, int z) {
|
||||
offX = x;
|
||||
offY = y;
|
||||
|
||||
+5
-2
@@ -11,10 +11,9 @@
|
||||
package vazkii.botania.api.lexicon.multiblock.component;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A component of a multiblock, the normal one
|
||||
@@ -48,6 +47,10 @@ public class MultiblockComponent {
|
||||
return world.getBlock(x, y, z) == getBlock() && (meta == -1 || world.getBlockMetadata(x, y, z) == meta);
|
||||
}
|
||||
|
||||
public ItemStack[] getMaterials() {
|
||||
return new ItemStack[] { new ItemStack(block, 1, meta) };
|
||||
}
|
||||
|
||||
public void rotate(double angle) {
|
||||
double x = relPos.posX;
|
||||
double z = relPos.posZ;
|
||||
|
||||
@@ -10,20 +10,28 @@
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.lexicon.LexiconPage;
|
||||
@@ -67,7 +75,7 @@ public class PageMultiblock extends LexiconPage {
|
||||
|
||||
final float maxX = 90, maxY = 60;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(gui.getLeft() + gui.getWidth() / 2, gui.getTop() + 90, gui.getZLevel() + 500F);
|
||||
GL11.glTranslatef(gui.getLeft() + gui.getWidth() / 2, gui.getTop() + 90, gui.getZLevel() + 100F);
|
||||
|
||||
float diag = (float) Math.sqrt(mb.getXSize() * mb.getXSize() + mb.getZSize() * mb.getZSize());
|
||||
float height = mb.getYSize();
|
||||
@@ -91,6 +99,30 @@ public class PageMultiblock extends LexiconPage {
|
||||
font.setUnicodeFlag(true);
|
||||
font.drawString(s, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(s) / 2, gui.getTop() + 16, 0x000000);
|
||||
font.setUnicodeFlag(unicode);
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
int x = gui.getLeft() + 15;
|
||||
int y = gui.getTop() + 25;
|
||||
RenderItem.getInstance().renderItemIntoGUI(font, render, new ItemStack(Blocks.stonebrick), x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0F, 0F, 200F);
|
||||
if(mx >= x && mx < x + 16 && my >= y && my < y + 16) {
|
||||
List<String> mats = new ArrayList();
|
||||
mats.add(StatCollector.translateToLocal("botaniamisc.materialsRequired"));
|
||||
for(ItemStack stack : mb.materials) {
|
||||
String size = "" + stack.stackSize;
|
||||
if(size.length() < 2)
|
||||
size = "0" + size;
|
||||
mats.add(" " + EnumChatFormatting.AQUA + size + " " + EnumChatFormatting.GRAY + stack.getDisplayName());
|
||||
}
|
||||
|
||||
vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, mats);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderBlock(Block block, int meta, int x, int y, int z) {
|
||||
|
||||
Reference in new issue
Block a user