Skip to content

Commit

Permalink
Spawn flame particles overtime, complete an item on Ferdzz#72
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSilvaFreire committed Oct 21, 2020
1 parent 2e5af70 commit f863347
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package me.ferdz.placeableitems.block.component.impl;

import me.ferdz.placeableitems.block.component.AbstractBlockComponent;
import net.minecraft.block.BlockState;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Random;

public class BlazePowderBlockComponent extends AbstractBlockComponent {
@Override
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random random) {
final double xSpreadRadius = 0.15, ySpreadRadius = 0.05;
worldIn.addParticle(
ParticleTypes.FLAME,
pos.getX() + 0.5 + randomFireSpread(xSpreadRadius, random),
pos.getY() + 0.2 + randomFireSpread(ySpreadRadius, random),
pos.getZ() + 0.5 + randomFireSpread(xSpreadRadius, random),
0,
0,
0
);
}

private double randomFireSpread(double spreadRadius, Random random) {
return (-spreadRadius + (2 * spreadRadius * random.nextGaussian()));
}

private double randomFireSpeed(Random random) {
return random.nextGaussian() * 0.03;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ public static void onBlocksRegistry(final RegistryEvent.Register<Block> event) {
.build()
.setShape(VoxelShapesUtil.create(14, 4, 14))
.register("beetroot_soup_block", Items.BEETROOT_SOUP, registry);
// TODO: Add animated particles
BLAZE_POWDER = new PlaceableItemsBlockBuilder()
.addComponent(new BlazePowderBlockComponent())
.build()
.setShape(VoxelShapesUtil.create(14, 6, 14))
.register("blaze_powder_block", Items.BLAZE_POWDER, registry);
Expand Down

0 comments on commit f863347

Please sign in to comment.