use of net.minecraft.block.SoulFireBlock in project relics by SSKirillSS.
the class BlazingFlaskItem method collectFire.
protected void collectFire(PlayerEntity player, ItemStack stack) {
World world = player.getCommandSenderWorld();
int fire = NBTUtils.getInt(stack, TAG_FIRE_AMOUNT, 0);
if (player.isSpectator() || fire >= stats.capacity)
return;
List<BlockPos> positions = WorldUtils.getBlockSphere(player.blockPosition(), stats.consumptionRadius).stream().filter(pos -> (world.getBlockState(pos).getBlock() instanceof AbstractFireBlock)).collect(Collectors.toList());
for (BlockPos pos : positions) {
Vector3d blockVec = new Vector3d(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D);
double distance = player.position().add(0, 1, 0).distanceTo(blockVec);
Vector3d direction = player.position().add(0, 1, 0).subtract(blockVec).normalize();
world.addParticle(new CircleTintData((world.getBlockState(pos).getBlock() instanceof SoulFireBlock) ? new Color(0, 200, 255) : new Color(255, 122, 0), (float) (distance * 0.075F), (int) distance * 5, 0.95F, false), blockVec.x(), blockVec.y(), blockVec.z(), direction.x * 0.2F, direction.y * 0.2F, direction.z * 0.2F);
if (player.tickCount % stats.consumptionCooldown == 0) {
world.playSound(null, pos, SoundEvents.FURNACE_FIRE_CRACKLE, SoundCategory.PLAYERS, 1.0F, 1.0F);
NBTUtils.setInt(stack, TAG_FIRE_AMOUNT, Math.min(stats.capacity, fire + positions.size()));
}
}
}
Aggregations