@SideOnly(Side.CLIENT)
public class ParticleFX extends EntityFX
{
public static final String NAME = MainClass.MODID + "snow";
private static final ResourceLocation snowTextures = new ResourceLocation("текстура");
public ParticleFX(World world, double x, double y, double z, double velX, double velY, double velZ)
{
super(world, x, y, z, velX, velY, velZ);
this.particleRed = 1.0F;
this.particleGreen = 1.0F;
this.particleBlue = 1.0F;
this.setParticleTextureIndex(rand.nextInt(8));
this.setSize(0.02F, 0.02F);
this.particleScale *= 0.6f;
this.motionX = velX;
this.motionY = velY;
this.motionZ =...
@SideOnly(Side.CLIENT)
public class ParticleFX extends EntityFX
{
public static final String NAME = MainClass.MODID + "snow";
private static final ResourceLocation snowTextures = new ResourceLocation("текстура");
public ParticleFX(World world, double x, double y, double z, double velX, double velY, double velZ)
{
super(world, x, y, z, velX, velY, velZ);
this.particleRed = 1.0F;
this.particleGreen = 1.0F;
this.particleBlue = 1.0F;
this.setParticleTextureIndex(rand.nextInt(8));
this.setSize(0.02F, 0.02F);
this.particleScale *= 0.6f;
this.motionX = velX;
this.motionY = velY;
this.motionZ = velZ;
this.particleMaxAge = 40 + rand.nextInt(10);
}
public ParticleFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, int maxAge){
this(par1World, par2, par4, par6, par8, par10, par12);
this.particleMaxAge = maxAge;
}
/**
* обновление для позиции частицы
*/
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleMaxAge-- <= 1)
{
this.setDead();
}
}
/**
* установление индекса текстуры
*/
public void setParticleTextureIndex(int par1)
{
this.particleTextureIndexX = par1 % 4;
this.particleTextureIndexY = par1 / 4;
}
@Override
public int getFXLayer() {
return 3;
}
// новый индекс текстуры (для разнообразия частицы)
@Override
public void renderParticle(Tessellator tessellator, float partialTicks, float par3, float par4, float par5, float par6, float par7)
{
GL11.glPushMatrix();
// Эта штука делает затенение. Параметр, ничего не делает.
int j = this.getBrightnessForRender(0);
int k = j % 65536;
int l = j / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F);
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().renderEngine.bindTexture(snowTextures);
tessellator.startDrawingQuads();
float f6 = (float)this.particleTextureIndexX / 4.0F;
float f7 = f6 + 0.0624375F*4;
float f8 = (float)this.particleTextureIndexY / 4.0F;
float f9 = f8 + 0.0624375F*4;
float f10 = 0.1F * this.particleScale;
if (this.particleIcon != null)
{
f6 = this.particleIcon.getMinU();
f7 = this.particleIcon.getMaxU();
f8 = this.particleIcon.getMinV();
f9 = this.particleIcon.getMaxV();
}
Entity player = Minecraft.getMinecraft().thePlayer;
this.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
this.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
this.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX);
float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY);
float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ);
float f14 = 1.0F;
tessellator.setColorRGBA_F(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha);
tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9);
tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8);
tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8);
tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9);
tessellator.draw();
GL11.glPopMatrix();
}
}
public void spawnParticle(EnumParticleType type, World world, double x, double y, double z, double velX, double velY, double velZ, int maxAge, float r, float g, float b, boolean doGravity, double radius) {
switch (type) {
case Particle: //из EnumParticle
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityParticleFX(world, x, y, z, velX, velY, velZ));
break;
}
}
}
public void spawnParticle(EnumParticleType type, World world, double x, double y, double z, double velX, double velY, double velZ, int maxAge, float r, float g, float b, boolean doGravity, double radius){
}
@Deprecated
public class PacketParticleSpawn implements IMessageHandler<Message, IMessage> {
@Override
public IMessage onMessage(Message message, MessageContext messagecontext) {
if (messagecontext.side.isClient()) {
World world = Minecraft.getMinecraft().theWorld;
if (message.name == EntityParticleFX.NAME) {
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityParticleFX(world, message.x, message.y, message.z, message.velX, message.velY, message.velZ, message.maxAge));
} else {
world.spawnParticle(message.name, message.x, message.y, message.z, message.velX, message.velY, message.velZ);
}
}
return null;
}
public static class Message implements IMessage {
/**
* Название частицы. Либо ванильное имя (cм. RenderGlobal),или одно из
*имени своих частиц.
*/
private String name;
private double x;
private double y;
private double z;
private double velX;
private double velY;
private double velZ;
private int maxAge;
private float r;
private float g;
private float b;
// Этот конструктор нада или будут ошибки (используется где-то в fml)
public Message() {
}
public Message(String name, double x, double y, double z, double velX, double velY, double velZ, int maxAge, float r, float g, float b) {
this.name = name;
this.x = x;
this.y = y;
this.z = z;
this.velX = velX;
this.velY = velY;
this.velZ = velZ;
this.maxAge = maxAge;
this.r = r;
this.g = g;
this.b = b;
}
@Override
public void fromBytes(ByteBuf buf) {
this.name = ByteBufUtils.readUTF8String(buf);
this.x = buf.readDouble();
this.y = buf.readDouble();
this.z = buf.readDouble();
this.velX = buf.readDouble();
this.velY = buf.readDouble();
this.velZ = buf.readDouble();
this.maxAge = buf.readInt();
this.r = buf.readFloat();
this.g = buf.readFloat();
this.b = buf.readFloat();
}
@Override
public void toBytes(ByteBuf buf) {
ByteBufUtils.writeUTF8String(buf, name);
buf.writeDouble(x);
buf.writeDouble(y);
buf.writeDouble(z);
buf.writeDouble(velX);
buf.writeDouble(velY);
buf.writeDouble(velZ);
buf.writeInt(maxAge);
buf.writeFloat(r);
buf.writeFloat(g);
buf.writeFloat(b);
}
}
}