Unicopia/src/main/java/com/minelittlepony/unicopia/render/RenderCloud.java

81 lines
2.3 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia.render;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.minelittlepony.unicopia.entity.EntityCloud;
import com.minelittlepony.unicopia.model.ModelCloud;
public class RenderCloud extends RenderLiving<EntityCloud> {
private static final ResourceLocation cloud = new ResourceLocation("unicopia", "textures/entity/clouds.png");
private static final ResourceLocation rainCloud = new ResourceLocation("unicopia", "textures/entity/clouds_storm.png");
public RenderCloud(RenderManager rendermanagerIn) {
super(rendermanagerIn, new ModelCloud(), 1f);
}
2019-01-30 14:49:30 +01:00
@Override
public float prepareScale(EntityCloud entity, float par2) {
2019-01-30 14:50:24 +01:00
float scale = entity.getCloudSize();
2019-01-30 14:50:24 +01:00
GL11.glScalef(scale, scale, scale);
return 0.0625F;
}
2019-01-30 14:49:30 +01:00
@Override
protected void renderModel(EntityCloud entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {
if (!entity.isDead) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, -entity.height/entity.getCloudSize() + 0.3F, 0);
GlStateManager.disableLighting();
GlStateManager.enableBlend();
2019-01-30 14:50:24 +01:00
GlStateManager.color(1, 1, 1, entity.getOpaque() ? 1 : 0.8F);
2019-01-30 14:50:24 +01:00
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
2019-01-30 14:50:24 +01:00
super.renderModel(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor);
2019-01-30 14:50:24 +01:00
GlStateManager.disableBlend();
GlStateManager.enableLighting();
GlStateManager.color(1, 1, 1, 1);
2019-01-30 14:50:24 +01:00
GlStateManager.popMatrix();
}
}
2019-01-30 14:49:30 +01:00
@Override
protected ResourceLocation getEntityTexture(EntityCloud entity) {
2019-01-30 14:50:24 +01:00
if (entity.getIsRaining() && entity.getIsThundering()) {
return rainCloud;
}
return cloud;
}
2019-01-30 14:49:30 +01:00
@Override
protected int getColorMultiplier(EntityCloud par1EntityLivingBase, float yaw, float pitch) {
return 0;
}
2019-01-30 14:49:30 +01:00
@Override
protected float getDeathMaxRotation(EntityCloud par1EntityLivingBase) {
return 0;
}
}