mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 04:32:23 +00:00
Fix more stuff
This commit is contained in:
1 parent
80d9d106c1
commit
f8d1b5aff0
8 files changed
+154
-184
No files matched your search
@@ -8,10 +8,12 @@
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
@@ -34,6 +36,7 @@ import vazkii.botania.client.render.entity.RenderPixie;
|
||||
import vazkii.botania.client.render.entity.RenderPoolMinecart;
|
||||
import vazkii.botania.client.render.entity.RenderSpark;
|
||||
import vazkii.botania.client.render.tile.*;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TileAnimatedTorch;
|
||||
@@ -94,7 +97,6 @@ public final class ModelHandler {
|
||||
ModelLoader.addSpecialModel(prefix("block/mana_pump_head"));
|
||||
registerSubtiles();
|
||||
|
||||
RenderTileFloatingFlower renderTileFloatingFlower = new RenderTileFloatingFlower();
|
||||
ClientRegistry.bindTileEntityRenderer(TileAltar.TYPE, RenderTileAltar::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileSpreader.TYPE, RenderTileSpreader::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TilePool.TYPE, RenderTilePool::new);
|
||||
@@ -102,9 +104,12 @@ public final class ModelHandler {
|
||||
ClientRegistry.bindTileEntityRenderer(TilePylon.TYPE, RenderTilePylon::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileEnchanter.TYPE, RenderTileEnchanter::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileAlfPortal.TYPE, RenderTileAlfPortal::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileFloatingFlower.TYPE, renderTileFloatingFlower);
|
||||
ClientRegistry.bindTileEntityRenderer(TileFloatingFlower.TYPE, RenderTileFloatingFlower::new);
|
||||
// TODO 1.14 this seems highly questionable.
|
||||
ClientRegistry.bindTileEntityRenderer(TileEntitySpecialFlower.class, renderTileFloatingFlower);
|
||||
ModSubtiles.TYPES.stream()
|
||||
.map(Pair::getSecond)
|
||||
.map(rl -> Registry.BLOCK_ENTITY_TYPE.getValue(rl).get())
|
||||
.forEach(typ -> ClientRegistry.bindTileEntityRenderer(typ, RenderTileFloatingFlower::new));
|
||||
ClientRegistry.bindTileEntityRenderer(TileTinyPotato.TYPE, new RenderTileTinyPotato());
|
||||
ClientRegistry.bindTileEntityRenderer(TileStarfield.TYPE, new RenderTileStarfield());
|
||||
ClientRegistry.bindTileEntityRenderer(TileBrewery.TYPE, RenderTileBrewery::new);
|
||||
@@ -123,7 +128,7 @@ public final class ModelHandler {
|
||||
ClientRegistry.bindTileEntityRenderer(TileHourglass.TYPE, RenderTileHourglass::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileSparkChanger.TYPE, RenderTileSparkChanger::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileCocoon.TYPE, RenderTileCocoon::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileLightRelay.TYPE, new RenderTileLightRelay());
|
||||
ClientRegistry.bindTileEntityRenderer(TileLightRelay.TYPE, RenderTileLightRelay::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileBellows.TYPE, RenderTileBellows::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileGaiaHead.TYPE, new RenderTileGaiaHead());
|
||||
ClientRegistry.bindTileEntityRenderer(TileTeruTeruBozu.TYPE, RenderTileTeruTeruBozu::new);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
package vazkii.botania.client.core.helper;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -36,13 +36,16 @@ import java.util.OptionalDouble;
|
||||
import java.util.Random;
|
||||
|
||||
public final class RenderHelper {
|
||||
private static final RenderType STAR_LAYER;
|
||||
private static final RenderType STAR;
|
||||
public static final RenderType RECTANGLE;
|
||||
public static final RenderType CIRCLE;
|
||||
public static final RenderType LINE_1;
|
||||
public static final RenderType LINE_4;
|
||||
public static final RenderType LINE_5;
|
||||
public static final RenderType LINE_8;
|
||||
public static final RenderType LIGHT_RELAY;
|
||||
public static final RenderType SPINNING_CUBE;
|
||||
public static final RenderType SPINNING_CUBE_GHOST;
|
||||
public static final RenderType ICON_OVERLAY;
|
||||
public static final RenderType BABYLON_ICON;
|
||||
public static final RenderType MANA_POOL_WATER;
|
||||
@@ -64,7 +67,7 @@ public final class RenderHelper {
|
||||
.writeMaskState(colorMask)
|
||||
.transparency(lightningTransparency)
|
||||
.build(false);
|
||||
STAR_LAYER = RenderType.of(LibResources.PREFIX_MOD + "star", DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLES, 256, false, true, glState);
|
||||
STAR = RenderType.of(LibResources.PREFIX_MOD + "star", DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLES, 256, false, true, glState);
|
||||
|
||||
glState = RenderType.State.builder().transparency(translucentTransparency).cull(disableCull).build(false);
|
||||
RECTANGLE = RenderType.of(LibResources.PREFIX_MOD + "rectangle_highlight", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, false, true, glState);
|
||||
@@ -79,6 +82,16 @@ public final class RenderHelper {
|
||||
glState = RenderType.State.builder().lineWidth(new RenderState.LineState(OptionalDouble.of(8))).layering(projectionLayering).transparency(translucentTransparency).writeMaskState(colorMask).build(false);
|
||||
LINE_8 = RenderType.of(LibResources.PREFIX_MOD + "line_8", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 64, glState);
|
||||
|
||||
glState = RenderType.State.builder().texture(mipmapBlockAtlasTexture).transparency(translucentTransparency).alpha(new RenderState.AlphaState(0.05F)).build(true);
|
||||
// todo 1.15: need normals?
|
||||
LIGHT_RELAY = new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.HALO, null, RenderType.of(LibResources.PREFIX_MOD + "light_relay", DefaultVertexFormats.POSITION_COLOR_TEXTURE_LIGHT, GL11.GL_QUADS, 64, glState));
|
||||
|
||||
glState = RenderType.State.builder().texture(new RenderState.TextureState()).build(false);
|
||||
SPINNING_CUBE = RenderType.of(LibResources.PREFIX_MOD + "spinning_cube", DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 64, glState);
|
||||
|
||||
glState = RenderType.State.builder().texture(new RenderState.TextureState()).transparency(translucentTransparency).build(false);
|
||||
SPINNING_CUBE_GHOST = RenderType.of(LibResources.PREFIX_MOD + "spinning_cube_ghost", DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 64, glState);
|
||||
|
||||
glState = RenderType.State.builder().texture(mipmapBlockAtlasTexture).transparency(translucentTransparency).lightmap(enableLightmap).build(true);
|
||||
ICON_OVERLAY = RenderType.of(LibResources.PREFIX_MOD + "icon_overlay", DefaultVertexFormats.POSITION_COLOR_TEXTURE_LIGHT, GL11.GL_QUADS, 128, glState);
|
||||
|
||||
@@ -106,7 +119,7 @@ public final class RenderHelper {
|
||||
}
|
||||
|
||||
public static void renderStar(MatrixStack ms, IRenderTypeBuffer buffers, int color, float xScale, float yScale, float zScale, long seed) {
|
||||
IVertexBuilder buffer = buffers.getBuffer(STAR_LAYER);
|
||||
IVertexBuilder buffer = buffers.getBuffer(STAR);
|
||||
|
||||
float ticks = (ClientTickHandler.ticksInGame % 200) + ClientTickHandler.partialTicks;
|
||||
if (ticks >= 100)
|
||||
@@ -167,13 +180,13 @@ public final class RenderHelper {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT, true);
|
||||
RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, true);
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
GlStateManager.colorMask(false, false, false, false);
|
||||
GlStateManager.depthMask(false);
|
||||
GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
||||
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
GL11.glStencilMask(0xFF);
|
||||
RenderSystem.colorMask(false, false, false, false);
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.stencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
||||
RenderSystem.stencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
RenderSystem.stencilMask(0xFF);
|
||||
mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
mc.textureManager.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD));
|
||||
@@ -183,15 +196,15 @@ public final class RenderHelper {
|
||||
int degs = (int) (360 * progress);
|
||||
float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableTexture();
|
||||
GlStateManager.shadeModel(GL11.GL_SMOOTH);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.colorMask(true, true, true, true);
|
||||
GlStateManager.depthMask(true);
|
||||
GL11.glStencilMask(0x00);
|
||||
GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.shadeModel(GL11.GL_SMOOTH);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.stencilMask(0x00);
|
||||
RenderSystem.stencilFunc(GL11.GL_EQUAL, 1, 0xFF);
|
||||
|
||||
BufferBuilder buf = Tessellator.getInstance().getBuffer();
|
||||
buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
|
||||
@@ -205,9 +218,9 @@ public final class RenderHelper {
|
||||
buf.vertex(centerX, centerY, 0).color(0F, 1F, 0.5F, a).endVertex();
|
||||
Tessellator.getInstance().draw();
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableTexture();
|
||||
GlStateManager.shadeModel(GL11.GL_FLAT);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.shadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.client.fx;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
@@ -70,7 +71,8 @@ public class FXSparkle extends Particle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
|
||||
public void buildGeometry(IVertexBuilder buffer, ActiveRenderInfo info, float partialTicks) {
|
||||
/* todo 1.15 redo this in a modern way (using TexturedParticle)
|
||||
int part = particle + age/multiplier;
|
||||
|
||||
float var8 = part % 8 / 8.0F;
|
||||
@@ -89,6 +91,7 @@ public class FXSparkle extends Particle {
|
||||
buffer.pos(var13 - rotationX * var12 + rotationXY * var12, var14 + rotationZ * var12, var15 - rotationYZ * var12 + rotationXZ * var12).tex(var9, var10).color(particleRed * var16, particleGreen * var16, particleBlue * var16, 1).endVertex();
|
||||
buffer.pos(var13 + rotationX * var12 + rotationXY * var12, var14 + rotationZ * var12, var15 + rotationYZ * var12 + rotationXZ * var12).tex(var8, var10).color(particleRed * var16, particleGreen * var16, particleBlue * var16, 1).endVertex();
|
||||
buffer.pos(var13 + rotationX * var12 - rotationXY * var12, var14 - rotationZ * var12, var15 + rotationYZ * var12 - rotationXZ * var12).tex(var8, var11).color(particleRed * var16, particleGreen * var16, particleBlue * var16, 1).endVertex();
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,13 +140,13 @@ public class FXSparkle extends Particle {
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(x, y, z);
|
||||
Vec3d vec3d = new Vec3d(x - (double)blockpos.getX(), y - (double)blockpos.getY(), z - (double)blockpos.getZ());
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable();
|
||||
Direction direction = Direction.UP;
|
||||
double d0 = Double.MAX_VALUE;
|
||||
|
||||
for(Direction direction1 : new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, Direction.UP}) {
|
||||
blockpos$mutableblockpos.setPos(blockpos).move(direction1);
|
||||
if (!Block.isOpaque(this.world.getBlockState(blockpos$mutableblockpos).getCollisionShape(this.world, blockpos$mutableblockpos))) {
|
||||
blockpos$mutable.setPos(blockpos).move(direction1);
|
||||
if (!this.world.getBlockState(blockpos$mutable).isFullCube(this.world, blockpos$mutable)) {
|
||||
double d1 = vec3d.getCoordinate(direction1.getAxis());
|
||||
double d2 = direction1.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 1.0D - d1 : d1;
|
||||
if (d2 < d0) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.client.fx;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
@@ -62,7 +63,8 @@ public class FXWisp extends Particle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
|
||||
public void buildGeometry(IVertexBuilder buffer, ActiveRenderInfo info, float partialTicks) {
|
||||
/* todo 1.15 redo in modern way (TexturedParticle)
|
||||
float agescale = (float)age / (float) moteHalfLife;
|
||||
if (agescale > 1F)
|
||||
agescale = 2 - agescale;
|
||||
@@ -80,6 +82,7 @@ public class FXWisp extends Particle {
|
||||
buffer.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(1, 1).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
|
||||
buffer.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(1, 0).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
|
||||
buffer.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(0, 0).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
|
||||
*/
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -120,7 +123,7 @@ public class FXWisp extends Particle {
|
||||
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 0.75F);
|
||||
textureManager.bindTexture(ConfigHandler.CLIENT.matrixMode.get() ? vanillaParticles : particles);
|
||||
bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
|
||||
bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
||||
}
|
||||
|
||||
private static void endRenderCommon() {
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Feb 2, 2014, 6:37:00 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.model;
|
||||
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.model.Model;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
|
||||
public class ModelSpinningCubes extends Model {
|
||||
|
||||
private final ModelRenderer spinningCube;
|
||||
|
||||
public ModelSpinningCubes() {
|
||||
spinningCube = new ModelRenderer(this, 42, 0);
|
||||
spinningCube.addCuboid(0F, 0F, 0F, 1, 1, 1);
|
||||
spinningCube.setRotationPoint(0F, 0F, 0F);
|
||||
spinningCube.setTextureSize(64, 64);
|
||||
}
|
||||
|
||||
public void renderSpinningCubes(int cubes, int repeat, int origRepeat) {
|
||||
GlStateManager.disableTexture();
|
||||
|
||||
final float modifier = 6F;
|
||||
final float rotationModifier = 0.2F;
|
||||
final float radiusBase = 0.35F;
|
||||
final float radiusMod = 0.05F;
|
||||
|
||||
double ticks = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks - 1.3 * (origRepeat - repeat);
|
||||
float offsetPerCube = 360 / cubes;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translatef(-0.025F, 0.85F, -0.025F);
|
||||
for(int i = 0; i < cubes; i++) {
|
||||
float offset = offsetPerCube * i;
|
||||
float deg = (int) (ticks / rotationModifier % 360F + offset);
|
||||
float rad = deg * (float) Math.PI / 180F;
|
||||
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
|
||||
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
|
||||
float x = (float) (radiusX * Math.cos(rad));
|
||||
float z = (float) (radiusZ * Math.sin(rad));
|
||||
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translatef(x, y, z);
|
||||
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
|
||||
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
|
||||
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
|
||||
|
||||
GlStateManager.rotatef(deg, xRotate, yRotate, zRotate);
|
||||
if(repeat < origRepeat) {
|
||||
GlStateManager.color4f(1F, 1F, 1F, (float) repeat / (float) origRepeat * 0.4F);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.disableAlphaTest();
|
||||
} else GlStateManager.color4f(1F, 1F, 1F, 1F);
|
||||
|
||||
int light = 15728880;
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
|
||||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
|
||||
spinningCube.render(1F / 16F);
|
||||
|
||||
if(repeat < origRepeat) {
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlphaTest();
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.enableTexture();
|
||||
|
||||
if(repeat != 0)
|
||||
renderSpinningCubes(cubes, repeat - 1, origRepeat);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,17 +10,24 @@
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.state.enums.LuminizerVariant;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.core.proxy.ClientProxy;
|
||||
import vazkii.botania.common.block.BlockLightRelay;
|
||||
@@ -34,12 +41,13 @@ public class RenderTileLightRelay extends TileEntityRenderer<TileLightRelay> {
|
||||
|
||||
private static Map<LuminizerVariant, TextureAtlasSprite> sprites = new EnumMap<>(LuminizerVariant.class);
|
||||
|
||||
@Override
|
||||
public void render(@Nonnull TileLightRelay tile, double x, double y, double z, float pticks, int digProgress) {
|
||||
if(!tile.getWorld().isBlockLoaded(tile.getPos()))
|
||||
return;
|
||||
public RenderTileLightRelay(TileEntityRendererDispatcher manager) {
|
||||
super(manager);
|
||||
}
|
||||
|
||||
BlockState state = tile.getWorld().getBlockState(tile.getPos());
|
||||
@Override
|
||||
public void render(@Nonnull TileLightRelay tile, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) {
|
||||
BlockState state = tile.getBlockState();
|
||||
if(!(state.getBlock() instanceof BlockLightRelay))
|
||||
return;
|
||||
|
||||
@@ -53,64 +61,46 @@ public class RenderTileLightRelay extends TileEntityRenderer<TileLightRelay> {
|
||||
|
||||
TextureAtlasSprite iicon = sprites.get(((BlockLightRelay) state.getBlock()).variant);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translated(x + 0.5, y + 0.3, z + 0.5);
|
||||
GlStateManager.enableRescaleNormal();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.05F);
|
||||
ms.push();
|
||||
ms.translate(0.5, 0.3, 0.5);
|
||||
|
||||
double time = ClientTickHandler.ticksInGame + pticks;
|
||||
GlStateManager.color4f(1F, 1F, 1F, 1F);
|
||||
|
||||
float scale = 0.75F;
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
ms.scale(scale, scale, scale);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
float r = 180.0F - mc.getRenderManager().playerViewY;
|
||||
GlStateManager.rotatef(r, 0F, 1F, 0F);
|
||||
GlStateManager.rotatef(-mc.getRenderManager().playerViewX, 1F, 0F, 0F);
|
||||
ms.multiply(mc.getRenderManager().getRotation());
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180.0F));
|
||||
|
||||
float off = 0.25F;
|
||||
GlStateManager.translatef(0F, off, 0F);
|
||||
GlStateManager.rotatef((float) time, 0F, 0F, 1F);
|
||||
GlStateManager.translatef(0F, -off, 0F);
|
||||
ms.translate(0F, off, 0F);
|
||||
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion((float) time));
|
||||
ms.translate(0F, -off, 0F);
|
||||
|
||||
mc.textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
ShaderHelper.useShader(ShaderHelper.BotaniaShader.HALO);
|
||||
renderIcon(tessellator, iicon);
|
||||
ShaderHelper.releaseShader();
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderHelper.LIGHT_RELAY);
|
||||
renderIcon(ms, buffer, iicon);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.color4f(1F, 1F, 1F, 1F);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.popMatrix();
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
private void renderIcon(Tessellator tess, TextureAtlasSprite icon) {
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
float size = f1 - f;
|
||||
private void renderIcon(MatrixStack ms, IVertexBuilder buffer, TextureAtlasSprite icon) {
|
||||
float size = icon.getMaxU() - icon.getMinU();
|
||||
float pad = size / 8F;
|
||||
f += pad;
|
||||
f1 -= pad;
|
||||
f2 += pad;
|
||||
f3 -= pad;
|
||||
float f = icon.getMinU() + pad;
|
||||
float f1 = icon.getMaxU() - pad;
|
||||
float f2 = icon.getMinV() + pad;
|
||||
float f3 = icon.getMaxV() - pad;
|
||||
|
||||
float f4 = 1.0F;
|
||||
float f5 = 0.5F;
|
||||
float f6 = 0.25F;
|
||||
|
||||
tess.getBuffer().begin(GL11.GL_QUADS, ClientProxy.POSITION_TEX_LMAP_NORMAL);
|
||||
tess.getBuffer().pos(0.0F - f5, 0.0F - f6, 0.0D).tex(f, f3).lightmap(240, 240).normal(0, 1, 0).endVertex();
|
||||
tess.getBuffer().pos(f4 - f5, 0.0F - f6, 0.0D).tex(f1, f3).lightmap(240, 240).normal(0, 1, 0).endVertex();
|
||||
tess.getBuffer().pos(f4 - f5, f4 - f6, 0.0D).tex(f1, f2).lightmap(240, 240).normal(0, 1, 0).endVertex();
|
||||
tess.getBuffer().pos(0.0F - f5, f4 - f6, 0.0D).tex(f, f2).lightmap(240, 240).normal(0, 1, 0).endVertex();
|
||||
tess.draw();
|
||||
Matrix4f mat = ms.peek().getModel();
|
||||
int fullbright = 0xF000F0;
|
||||
buffer.vertex(mat, 0.0F - f5, 0.0F - f6, 0.0F).color(1F, 1F, 1F, 1F).texture(f, f3).light(fullbright).endVertex();
|
||||
buffer.vertex(mat, f4 - f5, 0.0F - f6, 0.0F).color(1F, 1F, 1F, 1F).texture(f1, f3).light(fullbright).endVertex();
|
||||
buffer.vertex(mat, f4 - f5, f4 - f6, 0.0F).color(1F, 1F, 1F, 1F).texture(f1, f2).light(fullbright).endVertex();
|
||||
buffer.vertex(mat, 0.0F - f5, f4 - f6, 0.0F).color(1F, 1F, 1F, 1F).texture(f, f2).light(fullbright).endVertex();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,27 +12,30 @@ package vazkii.botania.client.render.tile;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.model.ModelSpinningCubes;
|
||||
import vazkii.botania.common.block.tile.TileRuneAltar;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RenderTileRuneAltar extends TileEntityRenderer<TileRuneAltar> {
|
||||
|
||||
private final ModelSpinningCubes cubes = new ModelSpinningCubes();
|
||||
private final ModelRenderer spinningCube = new ModelRenderer(64, 32, 42, 0);
|
||||
|
||||
public RenderTileRuneAltar(TileEntityRendererDispatcher manager) {
|
||||
super(manager);
|
||||
spinningCube.addCuboid(0F, 0F, 0F, 1, 1, 1);
|
||||
spinningCube.setRotationPoint(0F, 0F, 0F);
|
||||
spinningCube.setTextureSize(64, 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,8 +74,7 @@ public class RenderTileRuneAltar extends TileEntityRenderer<TileRuneAltar> {
|
||||
ms.push();
|
||||
ms.translate(0.5F, 1.8F, 0.5F);
|
||||
ms.multiply(new Vector3f(1, 0, 1).getDegreesQuaternion(180F));
|
||||
int repeat = 15;
|
||||
cubes.renderSpinningCubes(2, repeat, repeat);
|
||||
renderSpinningCubes(ms, buffers, overlay, 2, 15);
|
||||
ms.pop();
|
||||
|
||||
ms.translate(0F, 0.2F, 0F);
|
||||
@@ -86,4 +88,47 @@ public class RenderTileRuneAltar extends TileEntityRenderer<TileRuneAltar> {
|
||||
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
private void renderSpinningCubes(MatrixStack ms, IRenderTypeBuffer buffers, int overlay, int cubes, int iters) {
|
||||
for (int curIter = iters; curIter > 0; curIter--) {
|
||||
final float modifier = 6F;
|
||||
final float rotationModifier = 0.2F;
|
||||
final float radiusBase = 0.35F;
|
||||
final float radiusMod = 0.05F;
|
||||
|
||||
double ticks = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks - 1.3 * (iters - curIter);
|
||||
float offsetPerCube = 360 / cubes;
|
||||
|
||||
ms.push();
|
||||
ms.translate(-0.025F, 0.85F, -0.025F);
|
||||
for(int i = 0; i < cubes; i++) {
|
||||
float offset = offsetPerCube * i;
|
||||
float deg = (int) (ticks / rotationModifier % 360F + offset);
|
||||
float rad = deg * (float) Math.PI / 180F;
|
||||
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
|
||||
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
|
||||
float x = (float) (radiusX * Math.cos(rad));
|
||||
float z = (float) (radiusZ * Math.sin(rad));
|
||||
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
|
||||
|
||||
ms.push();
|
||||
ms.translate(x, y, z);
|
||||
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
|
||||
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
|
||||
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
|
||||
|
||||
ms.multiply(new Vector3f(xRotate, yRotate, zRotate).getDegreesQuaternion(deg));
|
||||
float alpha = 1;
|
||||
if(curIter < iters) {
|
||||
alpha = (float) curIter / (float) iters * 0.4F;
|
||||
}
|
||||
|
||||
IVertexBuilder buffer = buffers.getBuffer(curIter < iters ? RenderHelper.SPINNING_CUBE_GHOST : RenderHelper.SPINNING_CUBE);
|
||||
spinningCube.render(ms, buffer, 0xF000F0, overlay, 1, 1, 1, alpha);
|
||||
|
||||
ms.pop();
|
||||
}
|
||||
ms.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.SoundType;
|
||||
@@ -14,7 +15,6 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
|
||||
import vazkii.botania.common.block.subtile.SubTileManastar;
|
||||
import vazkii.botania.common.block.subtile.SubTilePureDaisy;
|
||||
@@ -153,7 +153,7 @@ public class ModSubtiles {
|
||||
return new ResourceLocation(orig.getNamespace(), orig.getPath() + "_chibi");
|
||||
}
|
||||
|
||||
private static final List<Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation>> TYPES = ImmutableList.<Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation>>of(
|
||||
public static final List<Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation>> TYPES = ImmutableList.<Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation>>of(
|
||||
Pair.of(SubTilePureDaisy::new, LibBlockNames.SUBTILE_PUREDAISY),
|
||||
Pair.of(SubTileManastar::new, LibBlockNames.SUBTILE_MANASTAR),
|
||||
Pair.of(SubTileEndoflame::new, LibBlockNames.SUBTILE_ENDOFLAME),
|
||||
@@ -212,8 +212,8 @@ public class ModSubtiles {
|
||||
Block.Properties floatProps = Block.Properties.create(Material.EARTH).hardnessAndResistance(0.5F).sound(SoundType.GROUND).lightValue(15);
|
||||
|
||||
for (Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation> type : TYPES) {
|
||||
register(r, new BlockSpecialFlower(props, type.getLeft()), type.getValue());
|
||||
register(r, new BlockFloatingSpecialFlower(floatProps, type.getLeft()), floating(type.getValue()));
|
||||
register(r, new BlockSpecialFlower(props, type.getFirst()), type.getSecond());
|
||||
register(r, new BlockFloatingSpecialFlower(floatProps, type.getFirst()), floating(type.getSecond()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,11 +224,11 @@ public class ModSubtiles {
|
||||
Item.Properties props = ModItems.defaultBuilder();
|
||||
|
||||
for (Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation> type : TYPES) {
|
||||
Block block = b.getValue(type.getRight());
|
||||
Block floating = b.getValue(floating(type.getRight()));
|
||||
Block block = b.getValue(type.getSecond());
|
||||
Block floating = b.getValue(floating(type.getSecond()));
|
||||
|
||||
register(r, new ItemBlockSpecialFlower(block, props), type.getRight());
|
||||
register(r, new ItemBlockSpecialFlower(floating, props), floating(type.getRight()));
|
||||
register(r, new ItemBlockSpecialFlower(block, props), type.getSecond());
|
||||
register(r, new ItemBlockSpecialFlower(floating, props), floating(type.getSecond()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,9 +238,9 @@ public class ModSubtiles {
|
||||
IForgeRegistry<TileEntityType<?>> r = evt.getRegistry();
|
||||
|
||||
for (Pair<Supplier<? extends TileEntitySpecialFlower>, ResourceLocation> type : TYPES) {
|
||||
Block block = b.getValue(type.getRight());
|
||||
Block floating = b.getValue(floating(type.getRight()));
|
||||
register(r, TileEntityType.Builder.create(type.getLeft(), block, floating).build(null), type.getRight());
|
||||
Block block = b.getValue(type.getSecond());
|
||||
Block floating = b.getValue(floating(type.getSecond()));
|
||||
register(r, TileEntityType.Builder.create(type.getFirst(), block, floating).build(null), type.getSecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user