Files
Applied-Energistics-2/src/main/java/appeng/client/render/effects/EnergyFx.java
T
2020-06-16 21:45:35 +02:00

186 lines
7.0 KiB
Java

/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
@OnlyIn(Dist.CLIENT)
public class EnergyFx extends BreakingParticle {
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx");
}
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
public EnergyFx(final World par1World, final double par2, final double par4, final double par6,
final IAnimatedSprite sprite) {
super(par1World, par2, par4, par6, new ItemStack(Items.DIAMOND));
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 1;
this.particleRed = 1;
this.particleAlpha = 1.4f;
this.particleScale = 3.5f;
this.selectSpriteRandomly(sprite);
this.startBlkX = MathHelper.floor(this.posX);
this.startBlkY = MathHelper.floor(this.posY);
this.startBlkZ = MathHelper.floor(this.posZ);
}
// FIXME @Override
// FIXME public int getFXLayer()
// FIXME {
// FIXME return 1;
// FIXME }
// FIXME
// FIXME @Override
// FIXME public IParticleRenderType getRenderType() {
// FIXME // TODO: FIXME
// FIXME return IParticleRenderType.NO_RENDER;
// FIXME }
// FIXME
// FIXME @Override
// FIXME public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float partialTicks, final float par3, final float par4, final float par5, final float par6, final float par7 )
// FIXME {
// FIXME final float f6 = this.particleTextureIndex.getMinU();
// FIXME final float f7 = this.particleTextureIndex.getMaxU();
// FIXME final float f8 = this.particleTextureIndex.getMinV();
// FIXME final float f9 = this.particleTextureIndex.getMaxV();
// FIXME final float f10 = 0.1F * this.particleScale;
// FIXME
// FIXME final float f11 = (float) ( this.prevPosX + ( this.getPosX() - this.prevPosX ) * partialTicks - interpPosX );
// FIXME final float f12 = (float) ( this.prevPosY + ( this.getPosY() - this.prevPosY ) * partialTicks - interpPosY );
// FIXME final float f13 = (float) ( this.prevPosZ + ( this.getPosZ() - this.prevPosZ ) * partialTicks - interpPosZ );
// FIXME
// FIXME final int blkX = MathHelper.floor( this.getPosX() );
// FIXME final int blkY = MathHelper.floor( this.getPosY() );
// FIXME final int blkZ = MathHelper.floor( this.getPosZ() );
// FIXME
// FIXME if( blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ )
// FIXME {
// FIXME int i = this.getBrightnessForRender( partialTicks );
// FIXME int j = i >> 16 & 65535;
// FIXME int k = i & 65535;
// FIXME
// FIXME final float f14 = 1.0F;
// FIXME par1Tessellator.pos( f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10 )
// FIXME .tex( f7, f9 )
// FIXME .color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
// FIXME .lightmap( j, k )
// FIXME .endVertex();
// FIXME par1Tessellator.pos( f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10 )
// FIXME .tex( f7, f8 )
// FIXME .color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
// FIXME .lightmap( j, k )
// FIXME .endVertex();
// FIXME par1Tessellator.pos( f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10 )
// FIXME .tex( f6, f8 )
// FIXME .color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
// FIXME .lightmap( j, k )
// FIXME .endVertex();
// FIXME par1Tessellator.pos( f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10 )
// FIXME .tex( f6, f9 )
// FIXME .color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
// FIXME .lightmap( j, k )
// FIXME .endVertex();
// FIXME }
// FIXME }
// FIXME
public void fromItem(final AEPartLocation d) {
this.posX += 0.2 * d.xOffset;
this.posY += 0.2 * d.yOffset;
this.posZ += 0.2 * d.zOffset;
this.particleScale *= 0.8f;
}
// FIXME
// FIXME @Override
// FIXME public void tick()
// FIXME {
// FIXME this.prevPosX = this.getPosX();
// FIXME this.prevPosY = this.getPosY();
// FIXME this.prevPosZ = this.getPosZ();
// FIXME
// FIXME if( this.age++ >= this.maxAge )
// FIXME {
// FIXME this.setExpired();
// FIXME }
// FIXME
// FIXME this.motionY -= 0.04D * this.particleGravity;
// FIXME this.move( this.motionX, this.motionY, this.motionZ );
// FIXME this.motionX *= 0.9800000190734863D;
// FIXME this.motionY *= 0.9800000190734863D;
// FIXME this.motionZ *= 0.9800000190734863D;
// FIXME
// FIXME this.particleScale *= 0.89f;
// FIXME this.particleAlpha *= 0.89f;
// FIXME }
// FIXME
public void setMotionX(float motionX) {
this.motionX = motionX;
}
public void setMotionY(float motionY) {
this.motionY = motionY;
}
public void setMotionZ(float motionZ) {
this.motionZ = motionZ;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet);
result.setMotionX((float) xSpeed);
result.setMotionY((float) ySpeed);
result.setMotionZ((float) zSpeed);
return result;
}
}
}