Search in sources :

Example 1 with ParticleType

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);
            }
        }
    });
}
Also used : FluidState(net.minecraft.fluid.FluidState) java.util(java.util) IAgriCrop(com.infinityraider.agricraft.api.v1.crop.IAgriCrop) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) BiFunction(java.util.function.BiFunction) AgriSoilCondition(com.agricraft.agricore.plant.AgriSoilCondition) IAgriGrowthStage(com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage) Direction(net.minecraft.util.Direction) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) AgriCore(com.agricraft.agricore.core.AgriCore) ItemStack(net.minecraft.item.ItemStack) ImmutableList(com.google.common.collect.ImmutableList) AgriGrowthRequirement(com.infinityraider.agricraft.impl.v1.requirement.AgriGrowthRequirement) IAgriFertilizer(com.infinityraider.agricraft.api.v1.fertilizer.IAgriFertilizer) com.infinityraider.agricraft.api.v1.requirement(com.infinityraider.agricraft.api.v1.requirement) BlockState(net.minecraft.block.BlockState) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Fluids(net.minecraft.fluid.Fluids) AgriCraft(com.infinityraider.agricraft.AgriCraft) Entity(net.minecraft.entity.Entity) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) IJsonPlantCallback(com.infinityraider.agricraft.api.v1.plant.IJsonPlantCallback) IncrementalGrowthLogic(com.infinityraider.agricraft.impl.v1.crop.IncrementalGrowthLogic) AgriApi(com.infinityraider.agricraft.api.v1.AgriApi) VanillaSeedConversionHandler(com.infinityraider.agricraft.handler.VanillaSeedConversionHandler) LivingEntity(net.minecraft.entity.LivingEntity) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) Collectors(java.util.stream.Collectors) AgriPlantQuadGenerator(com.infinityraider.agricraft.render.plant.AgriPlantQuadGenerator) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) Consumer(java.util.function.Consumer) IParticleData(net.minecraft.particles.IParticleData) IAgriStatsMap(com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap) AgriPlant(com.agricraft.agricore.plant.AgriPlant) ResourceLocation(net.minecraft.util.ResourceLocation) ParticleType(net.minecraft.particles.ParticleType) Fluid(net.minecraft.fluid.Fluid) ActionResultType(net.minecraft.util.ActionResultType) ForgeRegistries(net.minecraftforge.registries.ForgeRegistries) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) IParticleData(net.minecraft.particles.IParticleData) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Aggregations

AgriCore (com.agricraft.agricore.core.AgriCore)1 AgriPlant (com.agricraft.agricore.plant.AgriPlant)1 AgriSoilCondition (com.agricraft.agricore.plant.AgriSoilCondition)1 ImmutableList (com.google.common.collect.ImmutableList)1 AgriCraft (com.infinityraider.agricraft.AgriCraft)1 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)1 IAgriCrop (com.infinityraider.agricraft.api.v1.crop.IAgriCrop)1 IAgriGrowthStage (com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)1 IAgriFertilizer (com.infinityraider.agricraft.api.v1.fertilizer.IAgriFertilizer)1 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)1 IJsonPlantCallback (com.infinityraider.agricraft.api.v1.plant.IJsonPlantCallback)1 com.infinityraider.agricraft.api.v1.requirement (com.infinityraider.agricraft.api.v1.requirement)1 IAgriStatsMap (com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap)1 VanillaSeedConversionHandler (com.infinityraider.agricraft.handler.VanillaSeedConversionHandler)1 IncrementalGrowthLogic (com.infinityraider.agricraft.impl.v1.crop.IncrementalGrowthLogic)1 AgriGrowthRequirement (com.infinityraider.agricraft.impl.v1.requirement.AgriGrowthRequirement)1 AgriPlantQuadGenerator (com.infinityraider.agricraft.render.plant.AgriPlantQuadGenerator)1 java.util (java.util)1 BiFunction (java.util.function.BiFunction)1 Consumer (java.util.function.Consumer)1