Vibrant Quartz Glass + Particles

This commit is contained in:
Sebastian Hartte
2020-06-01 15:12:02 +02:00
parent dffea9a167
commit 260b2d1c92
8 changed files with 69 additions and 30 deletions
+2
View File
@@ -124,6 +124,8 @@ sourceSets {
include 'appeng/helpers/AEGlassMaterial.java' include 'appeng/helpers/AEGlassMaterial.java'
include 'appeng/block/spatial/BlockMatrixFrame.java' include 'appeng/block/spatial/BlockMatrixFrame.java'
include 'appeng/util/LookDirection.java' include 'appeng/util/LookDirection.java'
include 'appeng/decorative/solid/BlockQuartzLamp.java'
include 'appeng/client/render/effects/VibrantFX.java'
include 'appeng/core/sync/AppEngPacket.java' include 'appeng/core/sync/AppEngPacket.java'
include 'appeng/core/sync/network/INetworkInfo.java' include 'appeng/core/sync/network/INetworkInfo.java'
@@ -19,35 +19,49 @@
package appeng.client.render.effects; package appeng.client.render.effects;
import net.minecraft.client.particle.Particle; import appeng.core.AppEng;
import net.minecraft.client.particle.*;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
public class VibrantFX extends Particle public class VibrantFX extends SpriteTexturedParticle
{ {
public VibrantFX( final World par1World, final double x, final double y, final double z, final double par8, final double par10, final double par12 ) public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "vibrant_fx");
}
public VibrantFX( final World par1World, final double x, final double y, final double z, final double par8, final double par10, final double par12, IAnimatedSprite sprite)
{ {
super( par1World, x, y, z, par8, par10, par12 ); super( par1World, x, y, z, par8, par10, par12 );
final float f = this.rand.nextFloat() * 0.1F + 0.8F; final float f = this.rand.nextFloat() * 0.1F + 0.8F;
this.particleRed = f * 0.7f; this.particleRed = f * 0.7f;
this.particleGreen = f * 0.89f; this.particleGreen = f * 0.89f;
this.particleBlue = f * 0.9f; this.particleBlue = f * 0.9f;
this.setParticleTextureIndex( 0 ); this.selectSpriteRandomly(sprite);
this.setSize( 0.04F, 0.04F ); this.setSize( 0.04F, 0.04F );
this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F; this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F;
this.motionX = 0.0D; this.motionX = 0.0D;
this.motionY = 0.0D; this.motionY = 0.0D;
this.motionZ = 0.0D; this.motionZ = 0.0D;
this.prevPosX = this.getPosX(); this.prevPosX = this.posX;
this.prevPosY = this.getPosY(); this.prevPosY = this.posY;
this.prevPosZ = this.getPosZ(); this.prevPosZ = this.posZ;
this.maxAge = (int) ( 20.0D / ( Math.random() * 0.8D + 0.1D ) ); this.maxAge = (int) ( 20.0D / ( Math.random() * 0.8D + 0.1D ) );
} }
@Override
public IParticleRenderType getRenderType() {
// FIXME Might be PARTICLE_SHEET_LIT
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
@Override @Override
public int getBrightnessForRender( final float par1 ) public int getBrightnessForRender( final float par1 )
{ {
@@ -61,9 +75,9 @@ public class VibrantFX extends Particle
@Override @Override
public void tick() public void tick()
{ {
this.prevPosX = this.getPosX(); this.prevPosX = this.posX;
this.prevPosY = this.getPosY(); this.prevPosY = this.posY;
this.prevPosZ = this.getPosZ(); this.prevPosZ = this.posZ;
// this.moveEntity(this.motionX, this.motionY, this.motionZ); // this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.particleScale *= 0.95; this.particleScale *= 0.95;
@@ -73,4 +87,18 @@ public class VibrantFX extends Particle
} }
this.maxAge--; this.maxAge--;
} }
@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) {
return new VibrantFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet);
}
}
} }
@@ -25,6 +25,7 @@ import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent; import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IModelRegistrationComponent; import appeng.bootstrap.components.IModelRegistrationComponent;
import appeng.client.render.effects.ChargedOreFX; import appeng.client.render.effects.ChargedOreFX;
import appeng.client.render.effects.VibrantFX;
import appeng.client.render.model.GlassModelLoader; import appeng.client.render.model.GlassModelLoader;
import appeng.core.stats.AeStats; import appeng.core.stats.AeStats;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@@ -265,10 +266,12 @@ final class Registration
{ {
final IForgeRegistry<ParticleType<?>> registry = event.getRegistry(); final IForgeRegistry<ParticleType<?>> registry = event.getRegistry();
registry.register(ChargedOreFX.TYPE); registry.register(ChargedOreFX.TYPE);
registry.register(VibrantFX.TYPE);
} }
public void registerParticleFactories(ParticleFactoryRegisterEvent event) { public void registerParticleFactories(ParticleFactoryRegisterEvent event) {
Minecraft.getInstance().particles.registerFactory(ChargedOreFX.TYPE, ChargedOreFX.Factory::new); Minecraft.getInstance().particles.registerFactory(ChargedOreFX.TYPE, ChargedOreFX.Factory::new);
Minecraft.getInstance().particles.registerFactory(VibrantFX.TYPE, VibrantFX.Factory::new);
} }
// //
@@ -30,11 +30,9 @@ import appeng.bootstrap.IItemRendering;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import appeng.decorative.AEDecorativeBlock; import appeng.decorative.AEDecorativeBlock;
import appeng.decorative.solid.BlockChargedQuartzOre; import appeng.decorative.solid.*;
import appeng.decorative.solid.BlockQuartzGlass;
import appeng.decorative.solid.BlockQuartzOre;
import appeng.decorative.solid.BlockQuartzPillar;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -145,7 +143,7 @@ public final class ApiBlocks implements IBlocks
this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build(); this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build();
this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS ) this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS )
.block( "quartz_glass", BlockQuartzGlass::new ) .block( "quartz_glass", () -> new BlockQuartzGlass(Block.Properties.create(Material.GLASS).hardnessAndResistance(2.2F).sound(SoundType.GLASS).notSolid()) )
.rendering(new BlockRenderingCustomizer() { .rendering(new BlockRenderingCustomizer() {
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -154,15 +152,22 @@ public final class ApiBlocks implements IBlocks
} }
}) })
.build(); .build();
// this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", BlockQuartzLamp::new ) this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", () -> new BlockQuartzLamp(Block.Properties.create(Material.GLASS).hardnessAndResistance(2.2F).sound(SoundType.GLASS).lightValue(15).notSolid()) )
// .addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS ) .addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS )
// .useCustomItemModel() .rendering(new BlockRenderingCustomizer() {
// .build(); @Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
}
})
.build();
// this.quartzFixture = registry.block( "quartz_fixture", BlockQuartzFixture::new ) // this.quartzFixture = registry.block( "quartz_fixture", BlockQuartzFixture::new )
// .features( AEFeature.DECORATIVE_LIGHTS ) // .features( AEFeature.DECORATIVE_LIGHTS )
// .useCustomItemModel() // .useCustomItemModel()
// .build(); // .build();
//
// this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", BlockFluix::new ).build(); // this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", BlockFluix::new ).build();
// //
// this.skyStoneBlock = registry.features( AEFeature.SKY_STONE ) // this.skyStoneBlock = registry.features( AEFeature.SKY_STONE )
@@ -29,8 +29,8 @@ import net.minecraft.util.Direction;
public class BlockQuartzGlass extends AbstractGlassBlock { public class BlockQuartzGlass extends AbstractGlassBlock {
public BlockQuartzGlass() { public BlockQuartzGlass(Properties props) {
super(Block.Properties.create(Material.GLASS).hardnessAndResistance(2.2F).sound(SoundType.GLASS).notSolid()); super(props);
} }
@Override @Override
@@ -22,7 +22,6 @@ package appeng.decorative.solid;
import java.util.Random; import java.util.Random;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -36,9 +35,8 @@ import appeng.core.AppEng;
public class BlockQuartzLamp extends BlockQuartzGlass public class BlockQuartzLamp extends BlockQuartzGlass
{ {
public BlockQuartzLamp() public BlockQuartzLamp(Properties props) {
{ super(props);
this.setLightLevel( 1.0f );
} }
@Override @Override
@@ -56,9 +54,7 @@ public class BlockQuartzLamp extends BlockQuartzGlass
final double d1 = ( r.nextFloat() - 0.5F ) * 0.96D; final double d1 = ( r.nextFloat() - 0.5F ) * 0.96D;
final double d2 = ( r.nextFloat() - 0.5F ) * 0.96D; final double d2 = ( r.nextFloat() - 0.5F ) * 0.96D;
final VibrantFX fx = new VibrantFX( w, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D ); w.addParticle(VibrantFX.TYPE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0, 0, 0);
Minecraft.getInstance().effectRenderer.addEffect( fx );
} }
} }
} }
@@ -1,7 +1,7 @@
{ {
"variants": { "variants": {
"": { "": {
"model": "appliedenergistics2:block/builtin/quartz_glass" "model": "appliedenergistics2:block/quartz_glass"
} }
} }
} }
@@ -0,0 +1,5 @@
{
"textures": [
"minecraft:generic_0"
]
}