All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.
This commit is contained in:
@@ -20,12 +20,24 @@ package appeng.client.render.effects;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.command.arguments.ItemInput;
|
||||
import net.minecraft.command.arguments.ItemParser;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -33,23 +45,32 @@ import appeng.client.EffectType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.entity.EntityFloatingItem;
|
||||
import appeng.entity.ICanDie;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class AssemblerFX extends Particle implements ICanDie
|
||||
{
|
||||
|
||||
public static final ParticleType<AssemblerParticleData> TYPE = new ParticleType<>(false, new AssemblerParticleData.Deserializer());
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx");
|
||||
}
|
||||
|
||||
private final EntityFloatingItem fi;
|
||||
private final float speed;
|
||||
private float time = 0;
|
||||
|
||||
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final IAEItemStack is )
|
||||
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final ItemStack displayItem )
|
||||
{
|
||||
super( w, x, y, z, r, g, b );
|
||||
this.motionX = 0;
|
||||
this.motionY = 0;
|
||||
this.motionZ = 0;
|
||||
this.speed = speed;
|
||||
final ItemStack displayItem = is.asItemStackRepresentation();
|
||||
this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem );
|
||||
w.addEntity( this.fi );
|
||||
this.maxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
|
||||
@@ -99,7 +120,6 @@ public class AssemblerFX extends Particle implements ICanDie
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
// TODO: FIXME
|
||||
return IParticleRenderType.NO_RENDER;
|
||||
}
|
||||
|
||||
@@ -117,4 +137,102 @@ public class AssemblerFX extends Particle implements ICanDie
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class AssemblerParticleData implements IParticleData {
|
||||
|
||||
private final float r;
|
||||
private final float g;
|
||||
private final float b;
|
||||
private final float speed;
|
||||
private final ItemStack itemStack;
|
||||
|
||||
public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.speed = speed;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeFloat(r);
|
||||
buffer.writeFloat(g);
|
||||
buffer.writeFloat(b);
|
||||
buffer.writeFloat(speed);
|
||||
buffer.writeItemStack(itemStack);
|
||||
}
|
||||
|
||||
public static class Deserializer implements IDeserializer<AssemblerParticleData> {
|
||||
|
||||
@Override
|
||||
public AssemblerParticleData deserialize(ParticleType<AssemblerParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
|
||||
reader.expect(' ');
|
||||
float r = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float g = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float b = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float speed = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
ItemParser itemparser = (new ItemParser(reader, false)).parse();
|
||||
ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false);
|
||||
return new AssemblerParticleData(r, g, b, speed, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssemblerParticleData read(ParticleType<AssemblerParticleData> particleTypeIn, PacketBuffer buffer) {
|
||||
float r = buffer.readFloat();
|
||||
float g = buffer.readFloat();
|
||||
float b = buffer.readFloat();
|
||||
float speed = buffer.readFloat();
|
||||
ItemStack itemStack = buffer.readItemStack();
|
||||
return new AssemblerParticleData(r, g, b, speed, itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameters() {
|
||||
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()), this.r, this.g, this.b, this.speed)
|
||||
+ (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize();
|
||||
}
|
||||
|
||||
public float getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public float getG() {
|
||||
return g;
|
||||
}
|
||||
|
||||
public float getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<AssemblerParticleData> {
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
}
|
||||
|
||||
public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,130 +19,120 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
|
||||
import net.minecraft.client.particle.BreakingParticle;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
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.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.textures.ParticleTextures;
|
||||
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class CraftingFx extends BreakingParticle
|
||||
{
|
||||
|
||||
private final TextureAtlasSprite particleTextureIndex;
|
||||
public static final BasicParticleType TYPE = new BasicParticleType(false);
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx");
|
||||
}
|
||||
|
||||
private final int startBlkX;
|
||||
private final int startBlkY;
|
||||
private final int startBlkZ;
|
||||
|
||||
public CraftingFx( final World par1World, final double par2, final double par4, final double par6, final Item par8Item )
|
||||
public CraftingFx( final World par1World, final double x, final double y, final double z, final IAnimatedSprite sprite )
|
||||
{
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 0.9f;
|
||||
this.particleRed = 1;
|
||||
this.particleAlpha = 1.3f;
|
||||
this.particleScale = 1.5f;
|
||||
this.particleTextureIndex = ParticleTextures.BlockEnergyParticle;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
this.maxAge /= 1.2;
|
||||
|
||||
this.startBlkX = MathHelper.floor( this.getPosX() );
|
||||
this.startBlkY = MathHelper.floor( this.getPosY() );
|
||||
this.startBlkZ = MathHelper.floor( this.getPosZ() );
|
||||
this.startBlkX = MathHelper.floor( this.posX );
|
||||
this.startBlkY = MathHelper.floor( this.posY );
|
||||
this.startBlkZ = MathHelper.floor( this.posZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
// TODO: FIXME
|
||||
return IParticleRenderType.NO_RENDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float partialTick, final float x, final float y, final float z, final float rx, final float rz )
|
||||
{
|
||||
if( partialTick < 0 || partialTick > 1 )
|
||||
if( partialTicks < 0 || partialTicks > 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final float f6 = this.particleTextureIndex.getMinU();
|
||||
final float f7 = this.particleTextureIndex.getMaxU();
|
||||
final float f8 = this.particleTextureIndex.getMinV();
|
||||
final float f9 = this.particleTextureIndex.getMaxV();
|
||||
final float scale = 0.1F * this.particleScale;
|
||||
|
||||
float offX = (float) ( this.prevPosX + ( this.getPosX() - this.prevPosX ) * partialTick );
|
||||
float offY = (float) ( this.prevPosY + ( this.getPosY() - this.prevPosY ) * partialTick );
|
||||
float offZ = (float) ( this.prevPosZ + ( this.getPosZ() - this.prevPosZ ) * partialTick );
|
||||
float offX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX));
|
||||
float offY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY));
|
||||
float offZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ));
|
||||
|
||||
final int blkX = MathHelper.floor( offX );
|
||||
final int blkY = MathHelper.floor( offY );
|
||||
final int blkZ = MathHelper.floor( offZ );
|
||||
// I believe this particle is same as breaking particle, but should not exit the original block it was
|
||||
// spawned in (which is encased in glass)
|
||||
if( blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ )
|
||||
{
|
||||
offX -= interpPosX;
|
||||
offY -= interpPosY;
|
||||
offZ -= interpPosZ;
|
||||
Vec3d vec3d = renderInfo.getProjectedView();
|
||||
offX -= vec3d.x;
|
||||
offY -= vec3d.y;
|
||||
offZ -= vec3d.z;
|
||||
|
||||
int i = this.getBrightnessForRender( partialTick );
|
||||
int j = i >> 16 & 65535;
|
||||
int k = i & 65535;
|
||||
Vector3f[] avector3f = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)};
|
||||
float scale = this.getScale(partialTicks);
|
||||
|
||||
// AELog.info( "" + partialTick );
|
||||
final float f14 = 1.0F;
|
||||
par1Tessellator.pos( offX - x * scale - rx * scale, offY - y * scale, offZ - z * scale - rz * scale )
|
||||
.tex( f7, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( offX - x * scale + rx * scale, offY + y * scale, offZ - z * scale + rz * scale )
|
||||
.tex( f7, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( offX + x * scale + rx * scale, offY + y * scale, offZ + z * scale + rz * scale )
|
||||
.tex( f6, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( offX + x * scale - rx * scale, offY - y * scale, offZ + z * scale - rz * scale )
|
||||
.tex( f6, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
Vector3f vector3f = avector3f[i];
|
||||
vector3f.transform(renderInfo.getRotation());
|
||||
vector3f.mul(scale);
|
||||
vector3f.add(offX, offY, offZ);
|
||||
}
|
||||
|
||||
float minU = this.getMinU();
|
||||
float maxU = this.getMaxU();
|
||||
float minV = this.getMinV();
|
||||
float maxV = this.getMaxV();
|
||||
int j = this.getBrightnessForRender(partialTicks);
|
||||
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
public void fromItem( final AEPartLocation d )
|
||||
{
|
||||
this.getPosX() += 0.2 * d.xOffset;
|
||||
this.getPosY() += 0.2 * d.yOffset;
|
||||
this.getPosZ() += 0.2 * d.zOffset;
|
||||
this.posX += 0.2 * d.xOffset;
|
||||
this.posY += 0.2 * d.yOffset;
|
||||
this.posZ += 0.2 * d.zOffset;
|
||||
this.particleScale *= 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
this.prevPosX = this.getPosX();
|
||||
this.prevPosY = this.getPosY();
|
||||
this.prevPosZ = this.getPosZ();
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
if( this.age++ >= this.maxAge )
|
||||
{
|
||||
@@ -172,4 +162,18 @@ public class CraftingFx extends BreakingParticle
|
||||
{
|
||||
this.motionZ = motionZ;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<BasicParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite p_i50477_1_) {
|
||||
this.spriteSet = p_i50477_1_;
|
||||
}
|
||||
|
||||
public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new CraftingFx(worldIn, x, y, z, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
|
||||
import net.minecraft.client.particle.BreakingParticle;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import appeng.core.AppEng;
|
||||
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;
|
||||
@@ -38,22 +40,26 @@ import appeng.api.util.AEPartLocation;
|
||||
public class EnergyFx extends BreakingParticle
|
||||
{
|
||||
|
||||
// FIXME private final TextureAtlasSprite particleTextureIndex;
|
||||
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 ItemStack par8Item )
|
||||
public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final IAnimatedSprite sprite )
|
||||
{
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
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;
|
||||
// FIXME this.particleTextureIndex = ParticleTextures.BlockEnergyParticle;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
|
||||
this.startBlkX = MathHelper.floor( this.posX );
|
||||
this.startBlkY = MathHelper.floor( this.posY );
|
||||
@@ -163,4 +169,22 @@ public class EnergyFx extends BreakingParticle
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,23 @@ package appeng.client.render.effects;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
public class LightningArcFX extends LightningFX
|
||||
{
|
||||
public static final ParticleType<LightningArcParticleData> TYPE = new ParticleType<>(false, LightningArcParticleData.DESERIALIZER);
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
|
||||
}
|
||||
|
||||
private static final Random RANDOM_GENERATOR = new Random();
|
||||
|
||||
private final double rx;
|
||||
@@ -61,4 +73,20 @@ public class LightningArcFX extends LightningFX
|
||||
localSteps[s][2] = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<LightningArcParticleData> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
SpriteTexturedParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y, data.target.z, 0, 0, 0);
|
||||
lightningFX.selectSpriteRandomly(this.spriteSet);
|
||||
return lightningFX;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.sun.javafx.geom.Vec3f;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Contains the target point of the lightning arc (the source point is infered from the particle starting position).
|
||||
*/
|
||||
public class LightningArcParticleData implements IParticleData {
|
||||
|
||||
public final Vec3f target;
|
||||
|
||||
public LightningArcParticleData(Vec3f target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public static final IDeserializer<LightningArcParticleData> DESERIALIZER = new IDeserializer<LightningArcParticleData>() {
|
||||
@Override
|
||||
public LightningArcParticleData deserialize(ParticleType<LightningArcParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
|
||||
reader.expect(' ');
|
||||
float x = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float y = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float z = reader.readFloat();
|
||||
return new LightningArcParticleData(new Vec3f(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn, PacketBuffer buffer) {
|
||||
float x = buffer.readFloat();
|
||||
float y = buffer.readFloat();
|
||||
float z = buffer.readFloat();
|
||||
return new LightningArcParticleData(new Vec3f(x, y, z));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return LightningArcFX.TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeFloat(target.x);
|
||||
buffer.writeFloat(target.y);
|
||||
buffer.writeFloat(target.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameters() {
|
||||
return String.format(Locale.ROOT, "%.2f %.2f %.2f", target.x, target.y, target.z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class LightningFX extends SpriteTexturedParticle
|
||||
this.regen();
|
||||
}
|
||||
|
||||
private LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge )
|
||||
protected LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge )
|
||||
{
|
||||
super( w, x, y, z, r, g, b );
|
||||
this.precomputedSteps = new double[LightningFX.STEPS][3];
|
||||
|
||||
@@ -19,26 +19,37 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.particle.BreakingParticle;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
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.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.textures.ParticleTextures;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
public class MatterCannonFX extends BreakingParticle
|
||||
{
|
||||
|
||||
private final TextureAtlasSprite particleTextureIndex;
|
||||
public static final BasicParticleType TYPE = new BasicParticleType(false);
|
||||
|
||||
public MatterCannonFX( final World par1World, final double par2, final double par4, final double par6, final ItemStack par8Item )
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
|
||||
}
|
||||
|
||||
public MatterCannonFX( final World par1World, final double x, final double y, final double z, IAnimatedSprite sprite )
|
||||
{
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 1;
|
||||
@@ -48,7 +59,7 @@ public class MatterCannonFX extends BreakingParticle
|
||||
this.motionX = 0.0f;
|
||||
this.motionY = 0.0f;
|
||||
this.motionZ = 0.0f;
|
||||
this.particleTextureIndex = ParticleTextures.BlockMatterCannonParticle;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
}
|
||||
|
||||
public void fromItem( final AEPartLocation d )
|
||||
@@ -78,49 +89,17 @@ public class MatterCannonFX extends BreakingParticle
|
||||
this.particleAlpha *= 0.59f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
@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 data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new MatterCannonFX(world, x, y, z, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float par2, final float par3, final float par4, final float par5, final float par6, final float par7 )
|
||||
{
|
||||
final float f6 = this.particleTextureIndex.getMinU();
|
||||
final float f7 = this.particleTextureIndex.getMaxU();
|
||||
final float f8 = this.particleTextureIndex.getMinV();
|
||||
final float f9 = this.particleTextureIndex.getMaxV();
|
||||
final float f10 = 0.05F * this.particleScale;
|
||||
|
||||
final float f11 = (float) ( this.prevPosX + ( this.posX - this.prevPosX ) * par2 - interpPosX );
|
||||
final float f12 = (float) ( this.prevPosY + ( this.posY - this.prevPosY ) * par2 - interpPosY );
|
||||
final float f13 = (float) ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * par2 - interpPosZ );
|
||||
final float f14 = 1.0F;
|
||||
|
||||
int i = this.getBrightnessForRender( par2 );
|
||||
int j = i >> 16 & 65535;
|
||||
int k = i & 65535;
|
||||
|
||||
par1Tessellator.pos( f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10 )
|
||||
.tex( f7, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10 )
|
||||
.tex( f7, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10 )
|
||||
.tex( f6, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10 )
|
||||
.tex( f6, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user