mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Functional visualize button and transparent blocks.
This commit is contained in:
1 parent
bf1230e84b
commit
2247a1eace
6 files changed
+45
-26
No files matched your search
@@ -33,12 +33,21 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public final class MultiblockRenderHandler {
|
||||
|
||||
RenderBlocks blockRender = new RenderBlocks();
|
||||
MultiblockSet currentMultiblock;
|
||||
ChunkCoordinates anchor;
|
||||
int angle;
|
||||
int blocksPlaced;
|
||||
public static boolean rendering = false;
|
||||
|
||||
private static RenderBlocks blockRender = RenderBlocks.getInstance();
|
||||
public static MultiblockSet currentMultiblock;
|
||||
public static ChunkCoordinates anchor;
|
||||
public static int angle;
|
||||
public static int blocksPlaced;
|
||||
|
||||
public static void setMultiblock(MultiblockSet set) {
|
||||
currentMultiblock = set;
|
||||
anchor = null;
|
||||
angle = 0;
|
||||
blocksPlaced = 0;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldRenderLast(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -50,9 +59,11 @@ public final class MultiblockRenderHandler {
|
||||
|
||||
private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) {
|
||||
if(currentMultiblock != null) {
|
||||
rendering = true;
|
||||
Multiblock mb = currentMultiblock.getForEntity(player);
|
||||
for(MultiblockComponent comp : mb.getComponents())
|
||||
renderComponent(player.worldObj, mb, comp, src);
|
||||
rendering = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.api.mana.IPoolOverlayProvider;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.MultiblockRenderHandler;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.model.ModelPool;
|
||||
@@ -50,8 +51,10 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
TilePool pool = (TilePool) tileentity;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
float a = MultiblockRenderHandler.rendering ? 0.6F : 1F;
|
||||
GL11.glColor4f(1F, 1F, 1F, a);
|
||||
GL11.glTranslated(d0, d1, d2);
|
||||
boolean inf = tileentity.getWorldObj() == null ? forceMeta == 1 : tileentity.getBlockMetadata() == 1;
|
||||
boolean dil = tileentity.getWorldObj() == null ? forceMeta == 2 : tileentity.getBlockMetadata() == 2;
|
||||
@@ -62,9 +65,9 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
int color = pool.color;
|
||||
float[] acolor = EntitySheep.fleeceColorTable[color];
|
||||
GL11.glColor3f(acolor[0], acolor[1], acolor[2]);
|
||||
GL11.glColor4f(acolor[0], acolor[1], acolor[2], a);
|
||||
model.render();
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
GL11.glColor4f(1F, 1F, 1F, a);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
@@ -94,7 +97,7 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glColor4f(1F, 1F, 1F, (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2));
|
||||
GL11.glColor4f(1F, 1F, 1F, a * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2));
|
||||
GL11.glTranslatef(-0.5F, -1F - 0.43F, -0.5F);
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glScalef(s, s, s);
|
||||
@@ -114,7 +117,7 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glColor4f(1F, 1F, 1F, a);
|
||||
GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w);
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glScalef(s, s, s);
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.MultiblockRenderHandler;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.model.IPylonModel;
|
||||
@@ -53,7 +54,8 @@ public class RenderTilePylon extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
float a = MultiblockRenderHandler.rendering ? 0.6F : 1F;
|
||||
GL11.glColor4f(1F, 1F, 1F, a);
|
||||
if(tileentity.getWorldObj() != null) {
|
||||
green = tileentity.getBlockMetadata() == 1;
|
||||
pink = tileentity.getBlockMetadata() == 2;
|
||||
@@ -105,14 +107,14 @@ public class RenderTilePylon extends TileEntitySpecialRenderer {
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
model.renderCrystal();
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glColor4f(1F, 1F, 1F, a);
|
||||
if(!ShaderHelper.useShaders()) {
|
||||
int light = 15728880;
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
||||
float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D));
|
||||
GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F);
|
||||
GL11.glColor4f(1F, 1F, 1F, a * (alpha + 0.183F));
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
@@ -16,11 +16,8 @@ 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.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -33,7 +30,7 @@ import vazkii.botania.api.lexicon.LexiconPage;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.core.handler.MultiblockRenderHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -43,16 +40,14 @@ public class PageMultiblock extends LexiconPage {
|
||||
private static final ResourceLocation multiblockOverlay = new ResourceLocation(LibResources.GUI_MULTIBLOCK_OVERLAY);
|
||||
|
||||
GuiButton button;
|
||||
MultiblockSet set;
|
||||
Multiblock mb;
|
||||
int ticksElapsed;
|
||||
|
||||
public PageMultiblock(String unlocalizedName, Multiblock mb) {
|
||||
public PageMultiblock(String unlocalizedName, MultiblockSet set) {
|
||||
super(unlocalizedName);
|
||||
this.mb = mb;
|
||||
}
|
||||
|
||||
public PageMultiblock(String unlocalizedName, MultiblockSet mb) {
|
||||
this(unlocalizedName, mb.getForIndex(0));
|
||||
this.mb = set.getForIndex(0);
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,9 +105,13 @@ public class PageMultiblock extends LexiconPage {
|
||||
|
||||
@Override
|
||||
public void onOpened(IGuiLexiconEntry gui) {
|
||||
button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, StatCollector.translateToLocal("botaniamisc.visualize"));
|
||||
button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr());
|
||||
gui.getButtonList().add(button);
|
||||
}
|
||||
|
||||
String getButtonStr() {
|
||||
return StatCollector.translateToLocal(MultiblockRenderHandler.currentMultiblock == set ? "botaniamisc.unvisualize" : "botaniamisc.visualize");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(IGuiLexiconEntry gui) {
|
||||
@@ -123,7 +122,10 @@ public class PageMultiblock extends LexiconPage {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) {
|
||||
if(button == this.button) {
|
||||
// TODO
|
||||
if(MultiblockRenderHandler.currentMultiblock == set)
|
||||
MultiblockRenderHandler.setMultiblock(null);
|
||||
else MultiblockRenderHandler.setMultiblock(set);
|
||||
button.displayString = getButtonStr();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user