Skip to content

Commit

Permalink
💫 brick kiln particle
Browse files Browse the repository at this point in the history
  • Loading branch information
LocusAzzurro committed Jan 25, 2024
1 parent c5a154e commit 143bd3d
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.*;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
Expand All @@ -32,6 +35,8 @@
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.Nullable;

import java.util.Random;

public class BrickKiln extends DecorativeBlock implements EntityBlock, BaseBlockPropertyHolder {

public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
Expand Down Expand Up @@ -88,6 +93,27 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState
}
}

public void animateTick(BlockState pState, Level pLevel, BlockPos pPos, Random pRand) {
if (pState.getValue(LIT)) {
double d0 = (double)pPos.getX() + 0.5D;
double d1 = pPos.getY();
double d2 = (double)pPos.getZ() + 0.5D;
if (pRand.nextDouble() < 0.1D) {
pLevel.playLocalSound(d0, d1, d2, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false); //todo custom sound event
}

Direction direction = pState.getValue(FACING);
Direction.Axis direction$axis = direction.getAxis();
double d3 = 0.52D;
double d4 = pRand.nextDouble() * 0.6D - 0.3D;
double d5 = direction$axis == Direction.Axis.X ? (double)direction.getStepX() * d3 : d4;
double d6 = pRand.nextDouble() * 6.0D / 16.0D;
double d7 = direction$axis == Direction.Axis.Z ? (double)direction.getStepZ() * d3 : d4;
pLevel.addParticle(ParticleTypes.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
pLevel.addParticle(ParticleTypes.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
}
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
super.createBlockStateDefinition(pBuilder);
Expand Down

0 comments on commit 143bd3d

Please sign in to comment.