Add pixie trail particle
This commit is contained in:
parent
aa96726ee9
commit
e52abcf704
|
@ -0,0 +1,6 @@
|
|||
package biomesoplenty.api.particle;
|
||||
|
||||
public enum BOPParticleTypes
|
||||
{
|
||||
PIXIETRAIL;
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
******************************************************************************/
|
||||
|
||||
package biomesoplenty.client.particle;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityPixieTrailFX extends EntityFX
|
||||
{
|
||||
|
||||
public static ResourceLocation textureLocation = new ResourceLocation("biomesoplenty:textures/particles/pixietrail.png");
|
||||
public static SimpleTexture texture;
|
||||
float pixieTrailParticleScale;
|
||||
|
||||
public EntityPixieTrailFX(World world, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn)
|
||||
{
|
||||
this(world, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, 1.0F);
|
||||
}
|
||||
|
||||
public EntityPixieTrailFX(World world, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, float par14)
|
||||
{
|
||||
super(world, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
this.motionX *= 0.10000000149011612D;
|
||||
this.motionY *= 0.10000000149011612D;
|
||||
this.motionZ *= 0.10000000149011612D;
|
||||
this.motionX += xSpeedIn;
|
||||
this.motionY += ySpeedIn;
|
||||
this.motionZ += zSpeedIn;
|
||||
this.particleScale *= 0.75F;
|
||||
this.particleScale *= par14;
|
||||
this.pixieTrailParticleScale = this.particleScale;
|
||||
this.particleMaxAge = (int)((8.0D / (Math.random() * 0.8D + 0.2D)) * 8);
|
||||
this.particleMaxAge = (int)((float)this.particleMaxAge * par14);
|
||||
this.particleAge = (particleMaxAge / 2) + (int)((particleMaxAge / 2) * world.rand.nextInt(7));
|
||||
this.particleAlpha = 1.0F;
|
||||
this.noClip = false;
|
||||
}
|
||||
|
||||
@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_)
|
||||
{
|
||||
|
||||
// EffectRenderer will by default bind the vanilla particles texture, override with our own (this is loaded and initialized in ClientProxy)
|
||||
GlStateManager.bindTexture(texture.getGlTextureId());
|
||||
|
||||
float scaleMultiplier = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
|
||||
scaleMultiplier = MathHelper.clamp_float(scaleMultiplier, 0.0F, 1.0F);
|
||||
this.particleScale = this.particleScale * scaleMultiplier;
|
||||
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
|
||||
super.renderParticle(worldRendererIn, entity, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.depthMask(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
if (particleAge++ >= particleMaxAge)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
this.setParticleTextureIndex(7 - particleAge * 8 / particleMaxAge);
|
||||
this.moveEntity(motionX, motionY, motionZ);
|
||||
|
||||
if (posY == prevPosY)
|
||||
{
|
||||
motionX *= 1.1D;
|
||||
motionZ *= 1.1D;
|
||||
}
|
||||
|
||||
motionX *= 0.9599999785423279D;
|
||||
motionY *= 0.9599999785423279D;
|
||||
motionZ *= 0.9599999785423279D;
|
||||
|
||||
if (onGround)
|
||||
{
|
||||
motionX *= 0.699999988079071D;
|
||||
motionZ *= 0.699999988079071D;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -14,6 +14,8 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import biomesoplenty.api.item.BOPItems;
|
||||
import biomesoplenty.api.particle.BOPParticleTypes;
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import net.minecraft.entity.EntityFlying;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.EntityMoveHelper;
|
||||
|
@ -22,7 +24,6 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -60,8 +61,7 @@ public class EntityPixie extends EntityFlying implements IMob {
|
|||
{
|
||||
if (this.rand.nextInt(2)==0)
|
||||
{
|
||||
// TODO: add pixie particle BiomesOPlenty.proxy.spawnParticle("pixietrail", this.posX + (this.rand.nextDouble()) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - (double)this.yOffset, this.posZ + (this.rand.nextDouble()) * (double)this.width);
|
||||
this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D, new int[0]);
|
||||
BiomesOPlenty.proxy.spawnParticle(BOPParticleTypes.PIXIETRAIL, this.posX + (this.rand.nextDouble()) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - 0.25D, this.posZ + (this.rand.nextDouble()) * (double)this.width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,21 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
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.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import biomesoplenty.api.block.IBOPBlock;
|
||||
import biomesoplenty.api.particle.BOPParticleTypes;
|
||||
import biomesoplenty.client.particle.EntityPixieTrailFX;
|
||||
import biomesoplenty.common.config.MiscConfigurationHandler;
|
||||
import biomesoplenty.common.entities.EntityPixie;
|
||||
import biomesoplenty.common.entities.EntityWasp;
|
||||
|
@ -29,7 +35,6 @@ import biomesoplenty.common.entities.RenderWasp;
|
|||
import biomesoplenty.common.entities.projectiles.EntityDart;
|
||||
import biomesoplenty.common.entities.projectiles.RenderDart;
|
||||
|
||||
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
public static ResourceLocation[] bopTitlePanoramaPaths = new ResourceLocation[] {new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_0.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_1.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_2.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_3.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_4.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_5.png")};
|
||||
|
@ -38,6 +43,7 @@ public class ClientProxy extends CommonProxy
|
|||
public void registerRenderers()
|
||||
{
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
TextureManager textureManager = minecraft.renderEngine;
|
||||
|
||||
if (MiscConfigurationHandler.overrideTitlePanorama)
|
||||
GuiMainMenu.titlePanoramaPaths = bopTitlePanoramaPaths;
|
||||
|
@ -47,6 +53,11 @@ public class ClientProxy extends CommonProxy
|
|||
RenderingRegistry.registerEntityRenderingHandler(EntityWasp.class, new RenderWasp(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);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,4 +86,19 @@ public class ClientProxy extends CommonProxy
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(BOPParticleTypes type, double x, double y, double z)
|
||||
{
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
EntityFX entityFx = null;
|
||||
switch (type)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
if (entityFx != null) {minecraft.effectRenderer.addEffect(entityFx);}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
package biomesoplenty.core;
|
||||
|
||||
import biomesoplenty.api.particle.BOPParticleTypes;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
|
@ -15,7 +16,7 @@ import net.minecraft.item.Item;
|
|||
public class CommonProxy
|
||||
{
|
||||
public void registerRenderers() {}
|
||||
|
||||
public void registerItemVariantModel(Item item, String name, int metadata) {}
|
||||
public void registerNonRenderingProperties(Block block) {}
|
||||
public void spawnParticle(BOPParticleTypes type, double x, double y, double z) {}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 756 B |
Loading…
Reference in New Issue