Advertisement
jayhillx

StrawberryParticle

Feb 18th, 2021
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. @OnlyIn(Dist.CLIENT)
  2. public class StrawberryParticle extends SpriteTexturedParticle {
  3. private final IAnimatedSprite spriteWithAge;
  4.  
  5. private StrawberryParticle(ClientWorld world, double x, double y, double z, double p_i232429_8_, double motionY, double p_i232429_12_, IAnimatedSprite spriteWithAge) {
  6. super(world, x, y, z, 0.05D, motionY, 0.05D);
  7. this.spriteWithAge = spriteWithAge;
  8. this.motionY *= 0.004D;
  9. if (p_i232429_8_ == 0.0D && p_i232429_12_ == 0.0D) {
  10. this.motionX *= 0.004D;
  11. this.motionZ *= 0.004D;
  12. }
  13. this.particleScale *= 1.0F;
  14. this.maxAge = (int)(6.0D / (Math.random() * 0.4D + 0.2D));
  15. this.canCollide = false;
  16. this.selectSpriteWithAge(spriteWithAge);
  17. }
  18.  
  19. @Override
  20. public IParticleRenderType getRenderType() {
  21. return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
  22. }
  23.  
  24. @Override
  25. public void tick() {
  26. this.prevPosX = this.posX;
  27. this.prevPosY = this.posY;
  28. this.prevPosZ = this.posZ;
  29. if (this.age++ >= this.maxAge) {
  30. this.setExpired();
  31. } else {
  32. this.selectSpriteWithAge(this.spriteWithAge);
  33. this.motionY += 0.004D;
  34. this.move(this.motionX, this.motionY, this.motionZ);
  35. if (this.posY == this.prevPosY) {
  36. this.motionX *= 1.1D;
  37. this.motionZ *= 1.1D;
  38. }
  39. this.motionX *= 0.96F;
  40. this.motionY *= 0.96F;
  41. this.motionZ *= 0.96F;
  42. }
  43. }
  44.  
  45. @OnlyIn(Dist.CLIENT)
  46. public static class AmbientMobFactory implements IParticleFactory<BasicParticleType> {
  47. private final IAnimatedSprite spriteSet;
  48.  
  49. public AmbientMobFactory(IAnimatedSprite spriteSet) {
  50. this.spriteSet = spriteSet;
  51. }
  52.  
  53. public Particle makeParticle(BasicParticleType typeIn, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
  54. Particle particle = new StrawberryParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
  55. particle.setColor((float)xSpeed, (float)ySpeed, (float)zSpeed);
  56. return particle;
  57. }
  58. }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement