Simplify texture loading for pixie trail particle

This commit is contained in:
Cheeserolls 2015-04-30 18:53:18 +01:00
parent e52abcf704
commit 8a499bccd0
2 changed files with 6 additions and 13 deletions

View File

@ -11,17 +11,16 @@ package biomesoplenty.client.particle;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.client.FMLClientHandler;
public class EntityPixieTrailFX extends EntityFX public class EntityPixieTrailFX extends EntityFX
{ {
public static ResourceLocation textureLocation = new ResourceLocation("biomesoplenty:textures/particles/pixietrail.png"); public static ResourceLocation textureLocation = new ResourceLocation("biomesoplenty:textures/particles/pixietrail.png");
public static SimpleTexture texture;
float pixieTrailParticleScale; float pixieTrailParticleScale;
public EntityPixieTrailFX(World world, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) public EntityPixieTrailFX(World world, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn)
@ -52,9 +51,8 @@ public class EntityPixieTrailFX extends EntityFX
@Override @Override
public void renderParticle(WorldRenderer worldRendererIn, Entity entity, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) public void renderParticle(WorldRenderer worldRendererIn, Entity entity, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{ {
// EffectRenderer will by default bind the vanilla particles texture, override with our own (this is loaded and initialized in ClientProxy) // EffectRenderer will by default bind the vanilla particles texture, override with our own (this is loaded and initialized in ClientProxy)
GlStateManager.bindTexture(texture.getGlTextureId()); FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureLocation);
float scaleMultiplier = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F; float scaleMultiplier = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
scaleMultiplier = MathHelper.clamp_float(scaleMultiplier, 0.0F, 1.0F); scaleMultiplier = MathHelper.clamp_float(scaleMultiplier, 0.0F, 1.0F);

View File

@ -15,8 +15,6 @@ import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -26,7 +24,7 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry;
import biomesoplenty.api.block.IBOPBlock; import biomesoplenty.api.block.IBOPBlock;
import biomesoplenty.api.particle.BOPParticleTypes; import biomesoplenty.api.particle.BOPParticleTypes;
import biomesoplenty.client.particle.EntityPixieTrailFX; import biomesoplenty.client.particle.*;
import biomesoplenty.common.config.MiscConfigurationHandler; import biomesoplenty.common.config.MiscConfigurationHandler;
import biomesoplenty.common.entities.EntityPixie; import biomesoplenty.common.entities.EntityPixie;
import biomesoplenty.common.entities.EntityWasp; import biomesoplenty.common.entities.EntityWasp;
@ -43,7 +41,6 @@ public class ClientProxy extends CommonProxy
public void registerRenderers() public void registerRenderers()
{ {
Minecraft minecraft = Minecraft.getMinecraft(); Minecraft minecraft = Minecraft.getMinecraft();
TextureManager textureManager = minecraft.renderEngine;
if (MiscConfigurationHandler.overrideTitlePanorama) if (MiscConfigurationHandler.overrideTitlePanorama)
GuiMainMenu.titlePanoramaPaths = bopTitlePanoramaPaths; GuiMainMenu.titlePanoramaPaths = bopTitlePanoramaPaths;
@ -52,11 +49,6 @@ public class ClientProxy extends CommonProxy
RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart(minecraft.getRenderManager())); RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart(minecraft.getRenderManager()));
RenderingRegistry.registerEntityRenderingHandler(EntityWasp.class, new RenderWasp(minecraft.getRenderManager())); RenderingRegistry.registerEntityRenderingHandler(EntityWasp.class, new RenderWasp(minecraft.getRenderManager()));
RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie(minecraft.getRenderManager())); RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie(minecraft.getRenderManager()));
// load the texture for EntityPixieTrailFX
EntityPixieTrailFX.texture = new SimpleTexture(EntityPixieTrailFX.textureLocation);
textureManager.loadTexture(EntityPixieTrailFX.textureLocation, EntityPixieTrailFX.texture);
} }
@ -96,6 +88,9 @@ public class ClientProxy extends CommonProxy
{ {
case PIXIETRAIL: case PIXIETRAIL:
entityFx = new EntityPixieTrailFX(minecraft.theWorld, x, y, z, MathHelper.getRandomDoubleInRange(minecraft.theWorld.rand, -0.03, 0.03), -0.02D, MathHelper.getRandomDoubleInRange(minecraft.theWorld.rand, -0.03, 0.03)); entityFx = new EntityPixieTrailFX(minecraft.theWorld, x, y, z, MathHelper.getRandomDoubleInRange(minecraft.theWorld.rand, -0.03, 0.03), -0.02D, MathHelper.getRandomDoubleInRange(minecraft.theWorld.rand, -0.03, 0.03));
break;
default:
break;
} }
if (entityFx != null) {minecraft.effectRenderer.addEffect(entityFx);} if (entityFx != null) {minecraft.effectRenderer.addEffect(entityFx);}