Attempt to fix pylon model rendering

This commit is contained in:
Vincent Lee committed 2017-08-19 23:17:59 -05:00
1 parent f3f66401f7
commit 443de41647
6 files changed
+86 -142

No files matched your search

@@ -10,11 +10,9 @@
*/
package vazkii.botania.client.render.tile;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@@ -24,22 +22,25 @@ 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.ModelPylon;
import vazkii.botania.client.model.IPylonModel;
import vazkii.botania.client.model.ModelPylonGaia;
import vazkii.botania.client.model.ModelPylonMana;
import vazkii.botania.client.model.ModelPylonNatura;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TilePylon;
import javax.annotation.Nonnull;
import java.util.EnumMap;
import java.util.Map;
import java.util.Random;
public class RenderTilePylon extends TileEntitySpecialRenderer<TilePylon> {
private static final ResourceLocation MANA_MODEL_PATH = new ResourceLocation("botania:models/block/pylon.obj");
private static final ResourceLocation NATURA_MODEL_PATH = new ResourceLocation("botania:models/block/pylon.obj");
private static final ResourceLocation GAIA_MODEL_PATH = new ResourceLocation("botania:models/block/pylon.obj");
private static final ResourceLocation MANA_TEXTURE = new ResourceLocation(LibResources.MODEL_PYLON_MANA);
private static final ResourceLocation NATURA_TEXTURE = new ResourceLocation(LibResources.MODEL_PYLON_NATURA);
private static final ResourceLocation GAIA_TEXTURE = new ResourceLocation(LibResources.MODEL_PYLON_GAIA);
private Map<PylonVariant, ModelPylon> models = new EnumMap<>(PylonVariant.class);
private final ModelPylonMana manaModel = new ModelPylonMana();
private final ModelPylonNatura naturaModel = new ModelPylonNatura();
private final ModelPylonGaia gaiaModel = new ModelPylonGaia();
@Override
public void render(@Nonnull TilePylon pylon, double d0, double d1, double d2, float pticks, int digProgress, float unused) {
@@ -48,31 +49,25 @@ public class RenderTilePylon extends TileEntitySpecialRenderer<TilePylon> {
return;
PylonVariant type = ModBlocks.pylon.getStateFromMeta(pylon.getBlockMetadata()).getValue(BotaniaStateProps.PYLON_VARIANT);
ModelPylon model = models.computeIfAbsent(type, t -> {
ResourceLocation modelPath;
ImmutableMap<String, String> textures;
switch (t) {
default:
case MANA: {
modelPath = MANA_MODEL_PATH;
textures = ImmutableMap.of("#pylon", "botania:model/pylon_0");
break;
}
case NATURA: {
modelPath = NATURA_MODEL_PATH;
textures = ImmutableMap.of("#pylon", "botania:model/pylon_1");
break;
}
case GAIA: {
modelPath = GAIA_MODEL_PATH;
textures = ImmutableMap.of("#pylon", "botania:model/pylon_2");
break;
}
IPylonModel model;
switch(type) {
default:
case MANA: {
model = manaModel;
Minecraft.getMinecraft().renderEngine.bindTexture(MANA_TEXTURE);
break;
}
return new ModelPylon(modelPath, textures);
});
case NATURA: {
model = naturaModel;
Minecraft.getMinecraft().renderEngine.bindTexture(NATURA_TEXTURE);
break;
}
case GAIA: {
model = gaiaModel;
Minecraft.getMinecraft().renderEngine.bindTexture(GAIA_TEXTURE);
break;
}
}
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
@@ -81,8 +76,6 @@ public class RenderTilePylon extends TileEntitySpecialRenderer<TilePylon> {
float a = MultiblockRenderHandler.rendering ? 0.6F : 1F;
GlStateManager.color(1F, 1F, 1F, a);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
double worldTime = (double) (ClientTickHandler.ticksInGame + pticks);
worldTime += new Random(pylon.getPos().hashCode()).nextInt(360);
@@ -95,11 +88,10 @@ public class RenderTilePylon extends TileEntitySpecialRenderer<TilePylon> {
GlStateManager.pushMatrix();
GlStateManager.translate(0.5F, 0F, -0.5F);
GlStateManager.rotate((float) worldTime * 1.5F, 0F, 1F, 0F);
GlStateManager.translate(-0.5F, 0F, 0.5F);
//GlStateManager.translate(-0.5F, 0F, 0.5F);
model.renderRing();
GlStateManager.translate(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D);
model.renderGems();
GlStateManager.popMatrix();
}
@@ -107,9 +99,8 @@ public class RenderTilePylon extends TileEntitySpecialRenderer<TilePylon> {
GlStateManager.translate(0D, Math.sin(worldTime / 20D) / 17.5, 0D);
GlStateManager.translate(0.5F, 0F, -0.5F);
GlStateManager.rotate((float) -worldTime, 0F, 1F, 0F);
GlStateManager.translate(-0.5F, 0F, 0.5F);
//GlStateManager.translate(-0.5F, 0F, 0.5F);
GlStateManager.disableCull();