use of net.minecraft.particles.ParticleType in project AgriCraft by AgriCraft.
the class JsonPlant method spawnParticles.
@Override
public void spawnParticles(@Nonnull IAgriCrop crop, Random rand) {
final int index = IncrementalGrowthLogic.getGrowthIndex(crop.getGrowthStage());
final World world = crop.world();
if (index == -1 || world == null) {
return;
}
this.plant.getParticleEffects().stream().filter(effect -> effect.allowParticles(index)).forEach(effect -> {
ParticleType<?> particle = ForgeRegistries.PARTICLE_TYPES.getValue(new ResourceLocation(effect.getParticle()));
if (!(particle instanceof IParticleData)) {
return;
}
for (int amount = 0; amount < 3; ++amount) {
if (rand.nextDouble() < effect.getProbability()) {
BlockPos pos = crop.getPosition();
double x = pos.getX() + 0.5D + (rand.nextBoolean() ? 1 : -1) * effect.getDeltaX() * rand.nextDouble();
double y = pos.getY() + 0.5D + effect.getDeltaY() * rand.nextDouble();
double z = pos.getZ() + 0.5D + (rand.nextBoolean() ? 1 : -1) * effect.getDeltaZ() * rand.nextDouble();
world.addParticle((IParticleData) particle, x, y, z, 0.0D, 0.0D, 0.0D);
}
}
});
}
Aggregations